Effects of branch space [Commit 1] (#28)

This commit is contained in:
xCrystal 2023-10-24 20:36:23 +02:00
parent 884e4bdc63
commit a52e7f4df5
13 changed files with 133 additions and 14 deletions

View File

@ -186,7 +186,8 @@ DEF OVERWORLD_FRAME_FIRST_TILE EQU "┌"
DEF BOARD_MENU_BG_FIRST_TILE EQU "A" DEF BOARD_MENU_BG_FIRST_TILE EQU "A"
; Object tile locations (vTiles0) ; Object tile locations (vTiles0)
DEF SECONDARY_SPRITES_FIRST_TILE EQU $20 DEF SECONDARY_SPRITES_FIRST_TILE EQU $20
DEF BOARD_MENU_OAM_FIRST_TILE EQU SECONDARY_SPRITES_FIRST_TILE 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_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 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

View File

@ -123,6 +123,7 @@ DEF COLL_UP_LEFT_BUOY EQU $c7 ; unused
const COLL_MINIGAME_SPACE ; $d5 const COLL_MINIGAME_SPACE ; $d5
const COLL_END_SPACE ; $d6 const COLL_END_SPACE ; $d6
const COLL_GREY_SPACE ; $d7 const COLL_GREY_SPACE ; $d7
const COLL_BRANCH_SPACE ; $d8
DEF NUM_COLL_SPACES EQU const_value - $d0 DEF NUM_COLL_SPACES EQU const_value - $d0
DEF COLL_FF EQU $ff ; garbage DEF COLL_FF EQU $ff ; garbage

View File

@ -8,9 +8,10 @@ DEF AUTO_INPUT EQU $ff
; wDisplaySecondarySprites ; wDisplaySecondarySprites
const_def const_def
const SECONDARYSPRITES_BOARD_MENU_F ; 0 const SECONDARYSPRITES_BOARD_MENU_F ; 0
const SECONDARYSPRITES_DIE_ROLL_F ; 1 const SECONDARYSPRITES_DIE_ROLL_F ; 1
const SECONDARYSPRITES_SPACES_LEFT_F ; 2 const SECONDARYSPRITES_SPACES_LEFT_F ; 2
const SECONDARYSPRITES_BRANCH_ARROWS_F ; 3
; wCurDexMode:: ; wCurDexMode::
const_def const_def

View File

@ -113,3 +113,10 @@ SpacesLeftNumberOAM:
dbsprite 2, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 11, PAL_OW_MISC 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 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 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

View File

@ -341,11 +341,11 @@ $~~~~$<c>then always returns PLAYERMOVEMENT_FINISH but often is overwritten by c
- **hCurBoardEvent**: holds a *BOARDEVENT_* value. - **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** - **wDieRoll**
- **wSpacesLeft** - **wSpacesLeft**
- Addresses within *wCurMapData* ~ *wCurMapDataEnd*: preserved on save. - Addresses within *wCurMapData* ~ *wCurMapDataEnd*: preserved on save. Includes:
- **wCurTurn** - **wCurTurn**
- **wCurSpace** - **wCurSpace**
- **wCurSpaceStruct**: - **wCurSpaceStruct**:

View File

@ -3,6 +3,7 @@ BoardSpaceScripts:: ; used only for BANK(BoardSpaceScripts)
BlueSpaceScript:: BlueSpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .not_landed iftrue .not_landed
wait 400
scall LandedInRegularSpaceScript scall LandedInRegularSpaceScript
.not_landed .not_landed
end end
@ -10,6 +11,7 @@ BlueSpaceScript::
RedSpaceScript:: RedSpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .not_landed iftrue .not_landed
wait 400
scall LandedInRegularSpaceScript scall LandedInRegularSpaceScript
.not_landed .not_landed
end end
@ -17,6 +19,7 @@ RedSpaceScript::
GreenSpaceScript:: GreenSpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .not_landed iftrue .not_landed
wait 400
scall LandedInRegularSpaceScript scall LandedInRegularSpaceScript
.not_landed .not_landed
end end
@ -24,6 +27,7 @@ GreenSpaceScript::
ItemSpaceScript:: ItemSpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .not_landed iftrue .not_landed
wait 400
scall LandedInRegularSpaceScript scall LandedInRegularSpaceScript
.not_landed .not_landed
end end
@ -31,6 +35,7 @@ ItemSpaceScript::
PokemonSpaceScript:: PokemonSpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .not_landed iftrue .not_landed
wait 600
loadpikachudata loadpikachudata
startbattle startbattle
reloadmapafterbattle reloadmapafterbattle
@ -42,6 +47,7 @@ PokemonSpaceScript::
MinigameSpaceScript:: MinigameSpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .not_landed iftrue .not_landed
wait 600
scall LandedInRegularSpaceScript scall LandedInRegularSpaceScript
.not_landed .not_landed
end end
@ -76,9 +82,6 @@ GreySpaceScript::
ArriveToRegularSpaceScript: ArriveToRegularSpaceScript:
playsound SFX_PRESENT playsound SFX_PRESENT
callasm ArriveToRegularSpace callasm ArriveToRegularSpace
iftrue .not_landed
wait 600
.not_landed
end end
ArriveToRegularSpace: ArriveToRegularSpace:
@ -121,3 +124,31 @@ LandedInRegularSpace:
ld a, BOARDEVENT_END_TURN ld a, BOARDEVENT_END_TURN
ldh [hCurBoardEvent], a ldh [hCurBoardEvent], a
ret 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

View File

@ -38,3 +38,13 @@ LoadBoardMenuDieNumbersGFX::
.DieNumbersOAMGFX: .DieNumbersOAMGFX:
INCBIN "gfx/board/die_numbers.2bpp" 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"

View File

@ -384,6 +384,7 @@ CheckBoardEvent:
dw MinigameSpaceScript ; COLL_MINIGAME_SPACE dw MinigameSpaceScript ; COLL_MINIGAME_SPACE
dw EndSpaceScript ; COLL_END_SPACE dw EndSpaceScript ; COLL_END_SPACE
dw GreySpaceScript ; COLL_GREY_SPACE dw GreySpaceScript ; COLL_GREY_SPACE
dw BranchSpaceScript ; COLL_BRANCH_SPACE
assert_table_length NUM_COLL_SPACES assert_table_length NUM_COLL_SPACES
CheckTrainerEvent: CheckTrainerEvent:

View File

@ -3113,9 +3113,11 @@ InitSecondarySprites:
bit SECONDARYSPRITES_BOARD_MENU_F, a bit SECONDARYSPRITES_BOARD_MENU_F, a
call nz, InitBoardMenuSprites call nz, InitBoardMenuSprites
bit SECONDARYSPRITES_DIE_ROLL_F, a bit SECONDARYSPRITES_DIE_ROLL_F, a
call nz, InitRollDieSprites call nz, InitDieRollSprites
bit SECONDARYSPRITES_SPACES_LEFT_F, a bit SECONDARYSPRITES_SPACES_LEFT_F, a
call nz, InitSpacesLeftNumberSprites call nz, InitSpacesLeftNumberSprites
bit SECONDARYSPRITES_BRANCH_ARROWS_F, a
call nz, InitBranchArrowsSprites
ret ret
InitBoardMenuSprites: InitBoardMenuSprites:
@ -3143,7 +3145,7 @@ InitBoardMenuSprites:
pop af pop af
ret ret
InitRollDieSprites: InitDieRollSprites:
push af push af
ld a, [wDieRoll] ld a, [wDieRoll]
@ -3197,4 +3199,55 @@ InitSpacesLeftNumberSprites:
pop af pop af
ret 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" INCLUDE "data/sprites/secondary_sprites.asm"

BIN
gfx/board/branch_arrows.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@ -2318,3 +2318,14 @@ LoadSpaceData::
pop de pop de
ld a, [wMapScriptsBank] ld a, [wMapScriptsBank]
jp FarCopyBytes 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

View File

@ -410,6 +410,7 @@ ENDM
MACRO space_struct MACRO space_struct
\1XCoord:: db \1XCoord:: db
\1YCoord:: db \1YCoord:: db
\1BranchStructPtr:: ; dw
\1Effect:: db \1Effect:: db
\1NextSpace:: db \1NextSpace:: db
ENDM ENDM

View File

@ -1680,6 +1680,8 @@ wStringBuffer5:: ds STRING_BUFFER_LENGTH
NEXTU NEXTU
wTempSpaceStruct:: space_struct wTempSpace wTempSpaceStruct:: space_struct wTempSpace
wTempSpaceStructEnd:: wTempSpaceStructEnd::
wTempSpaceBranchStruct:: ds NUM_DIRECTIONS * 2
wTempSpaceBranchStructEnd::
ENDU ENDU
wBattleMenuCursorPosition:: wBattleMenuCursorPosition::