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

@@ -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

View File

@@ -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"

View File

@@ -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:

View File

@@ -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"