diff --git a/charmap.asm b/charmap.asm index 9f78eea89..c487c8886 100644 --- a/charmap.asm +++ b/charmap.asm @@ -186,7 +186,8 @@ DEF OVERWORLD_FRAME_FIRST_TILE EQU "┌" DEF BOARD_MENU_BG_FIRST_TILE EQU "A" ; Object tile locations (vTiles0) -DEF SECONDARY_SPRITES_FIRST_TILE EQU $20 -DEF BOARD_MENU_OAM_FIRST_TILE EQU SECONDARY_SPRITES_FIRST_TILE -DEF DIE_ROLL_OAM_FIRST_TILE EQU BOARD_MENU_OAM_FIRST_TILE + 45 ; max(BOARD_MENU_ITEM_SIZE * NUM_BOARD_MENU_ITEMS, DIE_SIZE * 10) -DEF DIE_NUMBERS_OAM_FIRST_TILE EQU BOARD_MENU_OAM_FIRST_TILE +DEF SECONDARY_SPRITES_FIRST_TILE EQU $20 +DEF BOARD_MENU_OAM_FIRST_TILE EQU SECONDARY_SPRITES_FIRST_TILE +DEF DIE_ROLL_OAM_FIRST_TILE EQU BOARD_MENU_OAM_FIRST_TILE + 45 ; max(BOARD_MENU_ITEM_SIZE * NUM_BOARD_MENU_ITEMS, DIE_SIZE * 10) +DEF DIE_NUMBERS_OAM_FIRST_TILE EQU BOARD_MENU_OAM_FIRST_TILE +DEF BRANCH_ARROWS_OAM_FIRST_TILE EQU DIE_NUMBERS_OAM_FIRST_TILE + 40 ; DIE_NUMBER_SIZE * 10 diff --git a/constants/collision_constants.asm b/constants/collision_constants.asm index 8bc69733c..30b54204f 100644 --- a/constants/collision_constants.asm +++ b/constants/collision_constants.asm @@ -123,6 +123,7 @@ DEF COLL_UP_LEFT_BUOY EQU $c7 ; unused const COLL_MINIGAME_SPACE ; $d5 const COLL_END_SPACE ; $d6 const COLL_GREY_SPACE ; $d7 + const COLL_BRANCH_SPACE ; $d8 DEF NUM_COLL_SPACES EQU const_value - $d0 DEF COLL_FF EQU $ff ; garbage diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index ea60b641e..2a4267c71 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -8,9 +8,10 @@ DEF AUTO_INPUT EQU $ff ; wDisplaySecondarySprites const_def - const SECONDARYSPRITES_BOARD_MENU_F ; 0 - const SECONDARYSPRITES_DIE_ROLL_F ; 1 - const SECONDARYSPRITES_SPACES_LEFT_F ; 2 + const SECONDARYSPRITES_BOARD_MENU_F ; 0 + const SECONDARYSPRITES_DIE_ROLL_F ; 1 + const SECONDARYSPRITES_SPACES_LEFT_F ; 2 + const SECONDARYSPRITES_BRANCH_ARROWS_F ; 3 ; wCurDexMode:: const_def diff --git a/data/sprites/secondary_sprites.asm b/data/sprites/secondary_sprites.asm index d7d8f0fe7..4c97144b6 100644 --- a/data/sprites/secondary_sprites.asm +++ b/data/sprites/secondary_sprites.asm @@ -113,3 +113,10 @@ SpacesLeftNumberOAM: dbsprite 2, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 11, PAL_OW_MISC dbsprite 1, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 30, PAL_OW_MISC dbsprite 2, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 31, PAL_OW_MISC + +BranchArrowsOAM: +; the PAL_ argument is unused (actual palette comes from the player gender) + dbsprite 10, 7, 4, 0, BRANCH_ARROWS_OAM_FIRST_TILE, PAL_OW_RED ; right + dbsprite 8, 7, 4, 0, BRANCH_ARROWS_OAM_FIRST_TILE + 1, PAL_OW_RED ; left + dbsprite 9, 6, 4, 0, BRANCH_ARROWS_OAM_FIRST_TILE + 2, PAL_OW_RED ; up + dbsprite 9, 8, 4, 0, BRANCH_ARROWS_OAM_FIRST_TILE + 3, PAL_OW_RED ; down diff --git a/docs/develop/index.md b/docs/develop/index.md index efcc6ade2..71922ba18 100755 --- a/docs/develop/index.md +++ b/docs/develop/index.md @@ -341,11 +341,11 @@ $~~~~$then always returns PLAYERMOVEMENT_FINISH but often is overwritten by c - **hCurBoardEvent**: holds a *BOARDEVENT_* value. -- **wTurnData** ~ **wTurnDataEnd**: not preserved on save, and cleared at the beginning of BoardMenuScript (i.e. on turn begin). It's part of *wMapStatus* ~ *wMapStatusEnd*, so it's also cleared by *StartMap*. +- **wTurnData** ~ **wTurnDataEnd**: not preserved on save, and cleared at the beginning of BoardMenuScript (i.e. on turn begin). It's part of *wMapStatus* ~ *wMapStatusEnd*, so it's also cleared by *StartMap*. Includes: - **wDieRoll** - **wSpacesLeft** -- Addresses within *wCurMapData* ~ *wCurMapDataEnd*: preserved on save. +- Addresses within *wCurMapData* ~ *wCurMapDataEnd*: preserved on save. Includes: - **wCurTurn** - **wCurSpace** - **wCurSpaceStruct**: diff --git a/engine/board/spaces.asm b/engine/board/spaces.asm index 31f36a74d..f338cc9d2 100755 --- a/engine/board/spaces.asm +++ b/engine/board/spaces.asm @@ -3,6 +3,7 @@ BoardSpaceScripts:: ; used only for BANK(BoardSpaceScripts) BlueSpaceScript:: scall ArriveToRegularSpaceScript iftrue .not_landed + wait 400 scall LandedInRegularSpaceScript .not_landed end @@ -10,6 +11,7 @@ BlueSpaceScript:: RedSpaceScript:: scall ArriveToRegularSpaceScript iftrue .not_landed + wait 400 scall LandedInRegularSpaceScript .not_landed end @@ -17,6 +19,7 @@ RedSpaceScript:: GreenSpaceScript:: scall ArriveToRegularSpaceScript iftrue .not_landed + wait 400 scall LandedInRegularSpaceScript .not_landed end @@ -24,6 +27,7 @@ GreenSpaceScript:: ItemSpaceScript:: scall ArriveToRegularSpaceScript iftrue .not_landed + wait 400 scall LandedInRegularSpaceScript .not_landed end @@ -31,6 +35,7 @@ ItemSpaceScript:: PokemonSpaceScript:: scall ArriveToRegularSpaceScript iftrue .not_landed + wait 600 loadpikachudata startbattle reloadmapafterbattle @@ -42,6 +47,7 @@ PokemonSpaceScript:: MinigameSpaceScript:: scall ArriveToRegularSpaceScript iftrue .not_landed + wait 600 scall LandedInRegularSpaceScript .not_landed end @@ -76,9 +82,6 @@ GreySpaceScript:: ArriveToRegularSpaceScript: playsound SFX_PRESENT callasm ArriveToRegularSpace - iftrue .not_landed - wait 600 -.not_landed end ArriveToRegularSpace: @@ -121,3 +124,31 @@ LandedInRegularSpace: ld a, BOARDEVENT_END_TURN ldh [hCurBoardEvent], a ret + +BranchSpaceScript:: + scall .ArriveToBranchSpaceScript + end + +.ArriveToBranchSpaceScript: + playsound SFX_TWINKLE + wait 400 + callasm .ArriveToBranchSpace + end + +.ArriveToBranchSpace: +; load new space + ld a, [wCurSpaceNextSpace] + ld [wCurSpace], a + call LoadCurSpaceData +; load its branch data + call LoadTempSpaceBranchData + call .DisableDirectionsRequiringLockedTechniques +; draw arrows for valid directions + farcall LoadBranchArrowsGFX + ld hl, wDisplaySecondarySprites + set SECONDARYSPRITES_BRANCH_ARROWS_F, [hl] +; update sprites + jp UpdateActiveSprites + +.DisableDirectionsRequiringLockedTechniques: + ret diff --git a/engine/gfx/load_board_gfx.asm b/engine/gfx/load_board_gfx.asm index 8af37c8fd..9a03f9a25 100755 --- a/engine/gfx/load_board_gfx.asm +++ b/engine/gfx/load_board_gfx.asm @@ -38,3 +38,13 @@ LoadBoardMenuDieNumbersGFX:: .DieNumbersOAMGFX: INCBIN "gfx/board/die_numbers.2bpp" + +LoadBranchArrowsGFX:: + ld de, .BranchArrowsOAMGFX + ld hl, vTiles0 + BRANCH_ARROWS_OAM_FIRST_TILE * LEN_2BPP_TILE + lb bc, BANK(.BranchArrowsOAMGFX), NUM_DIRECTIONS + call Get2bppViaHDMA + ret + +.BranchArrowsOAMGFX: +INCBIN "gfx/board/branch_arrows.2bpp" diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 10c622f4f..89107d76e 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -384,6 +384,7 @@ CheckBoardEvent: dw MinigameSpaceScript ; COLL_MINIGAME_SPACE dw EndSpaceScript ; COLL_END_SPACE dw GreySpaceScript ; COLL_GREY_SPACE + dw BranchSpaceScript ; COLL_BRANCH_SPACE assert_table_length NUM_COLL_SPACES CheckTrainerEvent: diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 8e2e2cb37..5e208d3a6 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -3113,9 +3113,11 @@ InitSecondarySprites: bit SECONDARYSPRITES_BOARD_MENU_F, a call nz, InitBoardMenuSprites bit SECONDARYSPRITES_DIE_ROLL_F, a - call nz, InitRollDieSprites + call nz, InitDieRollSprites bit SECONDARYSPRITES_SPACES_LEFT_F, a call nz, InitSpacesLeftNumberSprites + bit SECONDARYSPRITES_BRANCH_ARROWS_F, a + call nz, InitBranchArrowsSprites ret InitBoardMenuSprites: @@ -3143,7 +3145,7 @@ InitBoardMenuSprites: pop af ret -InitRollDieSprites: +InitDieRollSprites: push af ld a, [wDieRoll] @@ -3197,4 +3199,55 @@ InitSpacesLeftNumberSprites: pop af ret +InitBranchArrowsSprites: + push af + +; find the beginning of free space in OAM, and assure there's space for 4 objects + ldh a, [hUsedSpriteIndex] + cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (NUM_DIRECTIONS * SPRITEOAMSTRUCT_LENGTH) + 1 + jr nc, .oam_full + + ld hl, BranchArrowsOAM + ld de, wTempSpaceBranchStruct + ld c, NUM_DIRECTIONS +.loop + ld a, [de] + cp -1 ; + jr z, .next1 ; skip this arrow if this direction is not valid + +; draw this arrow and advance hUsedSpriteIndex +; preserve loop variables d, e, c + push de + push bc + ldh a, [hUsedSpriteIndex] + ld e, a + ld d, HIGH(wShadowOAM) +; copy all bytes minus the attributes one +; the palette matches the player's color palette + ld bc, SPRITEOAMSTRUCT_LENGTH - 1 + call CopyBytes + gender_to_pal + ld [de], a + inc de + ld a, e + ldh [hUsedSpriteIndex], a + pop bc + pop de + jr .next2 + +.next1 + inc hl ; + inc hl ; + inc hl ; + +.next2 + inc hl ; next object in BranchArrowsOAM + inc de + dec c + jr nz, .loop + +.oam_full + pop af + ret + INCLUDE "data/sprites/secondary_sprites.asm" diff --git a/gfx/board/branch_arrows.png b/gfx/board/branch_arrows.png new file mode 100755 index 000000000..b272c15e1 Binary files /dev/null and b/gfx/board/branch_arrows.png differ diff --git a/home/map.asm b/home/map.asm index 0ed187d26..c4138e2b6 100644 --- a/home/map.asm +++ b/home/map.asm @@ -2318,3 +2318,14 @@ LoadSpaceData:: pop de ld a, [wMapScriptsBank] jp FarCopyBytes + +; load the branch data of the space at wCurSpaceStruct to wTempSpaceBranchStruct +LoadTempSpaceBranchData:: + ld hl, wCurSpaceBranchStructPtr + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wTempSpaceBranchStruct + ld bc, wTempSpaceBranchStructEnd - wTempSpaceBranchStruct + ld a, [wMapScriptsBank] + jp FarCopyBytes diff --git a/macros/ram.asm b/macros/ram.asm index 2495ab148..40ba19a9c 100644 --- a/macros/ram.asm +++ b/macros/ram.asm @@ -410,6 +410,7 @@ ENDM MACRO space_struct \1XCoord:: db \1YCoord:: db +\1BranchStructPtr:: ; dw \1Effect:: db \1NextSpace:: db ENDM diff --git a/ram/wram.asm b/ram/wram.asm index 3c220ddfe..70aa47cc8 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -1680,6 +1680,8 @@ wStringBuffer5:: ds STRING_BUFFER_LENGTH NEXTU wTempSpaceStruct:: space_struct wTempSpace wTempSpaceStructEnd:: +wTempSpaceBranchStruct:: ds NUM_DIRECTIONS * 2 +wTempSpaceBranchStructEnd:: ENDU wBattleMenuCursorPosition::