2023-10-14 10:28:35 -07:00
|
|
|
BoardSpaceScripts:: ; used only for BANK(BoardSpaceScripts)
|
|
|
|
|
|
|
|
BlueSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
2023-10-14 12:45:48 -07:00
|
|
|
iftrue .not_landed
|
2023-10-24 11:36:23 -07:00
|
|
|
wait 400
|
2023-10-14 12:45:48 -07:00
|
|
|
scall LandedInRegularSpaceScript
|
|
|
|
.not_landed
|
2023-10-14 10:28:35 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
RedSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
2023-10-14 12:45:48 -07:00
|
|
|
iftrue .not_landed
|
2023-10-24 11:36:23 -07:00
|
|
|
wait 400
|
2023-10-14 12:45:48 -07:00
|
|
|
scall LandedInRegularSpaceScript
|
|
|
|
.not_landed
|
2023-10-14 10:28:35 -07:00
|
|
|
end
|
|
|
|
|
2023-10-19 11:38:54 -07:00
|
|
|
GreenSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
|
|
|
iftrue .not_landed
|
2023-10-24 11:36:23 -07:00
|
|
|
wait 400
|
2023-10-19 11:38:54 -07:00
|
|
|
scall LandedInRegularSpaceScript
|
|
|
|
.not_landed
|
|
|
|
end
|
|
|
|
|
|
|
|
ItemSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
|
|
|
iftrue .not_landed
|
2023-10-24 11:36:23 -07:00
|
|
|
wait 400
|
2023-10-19 11:38:54 -07:00
|
|
|
scall LandedInRegularSpaceScript
|
|
|
|
.not_landed
|
|
|
|
end
|
|
|
|
|
|
|
|
PokemonSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
|
|
|
iftrue .not_landed
|
2023-10-24 11:36:23 -07:00
|
|
|
wait 600
|
2023-10-23 08:04:59 -07:00
|
|
|
loadpikachudata
|
|
|
|
startbattle
|
|
|
|
reloadmapafterbattle
|
|
|
|
wait 100
|
2023-10-19 11:38:54 -07:00
|
|
|
scall LandedInRegularSpaceScript
|
|
|
|
.not_landed
|
|
|
|
end
|
|
|
|
|
|
|
|
MinigameSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
|
|
|
iftrue .not_landed
|
2023-10-24 11:36:23 -07:00
|
|
|
wait 600
|
2023-10-19 11:38:54 -07:00
|
|
|
scall LandedInRegularSpaceScript
|
|
|
|
.not_landed
|
|
|
|
end
|
|
|
|
|
|
|
|
EndSpaceScript::
|
2023-10-21 09:00:59 -07:00
|
|
|
; fading out will kick before reaching HandleMapBackground, so update sprites after any change
|
|
|
|
scall ArriveToRegularSpaceScript
|
|
|
|
wait 400
|
|
|
|
playmusic MUSIC_TRAINER_VICTORY
|
|
|
|
wait 600
|
|
|
|
callasm .FadeOutSlow ; 800 ms
|
|
|
|
wait 400
|
|
|
|
exitoverworld CLEARED_LEVEL
|
2023-10-23 09:40:08 -07:00
|
|
|
endall
|
2023-10-19 11:38:54 -07:00
|
|
|
|
2023-10-21 09:00:59 -07:00
|
|
|
.FadeOutSlow:
|
|
|
|
; clear spaces left sprites
|
|
|
|
ld hl, wDisplaySecondarySprites
|
|
|
|
res SECONDARYSPRITES_SPACES_LEFT_F, [hl]
|
2023-10-21 09:46:56 -07:00
|
|
|
call UpdateActiveSprites
|
2023-10-21 09:00:59 -07:00
|
|
|
; fade out slow to white
|
|
|
|
ld b, RGBFADE_TO_WHITE_8BGP_8OBP
|
|
|
|
jp DoRGBFadeEffect
|
|
|
|
|
2023-10-14 10:28:35 -07:00
|
|
|
GreySpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
2023-10-14 12:45:48 -07:00
|
|
|
iftrue .not_landed
|
|
|
|
scall LandedInRegularSpaceScript
|
|
|
|
.not_landed
|
2023-10-14 10:28:35 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
ArriveToRegularSpaceScript:
|
|
|
|
playsound SFX_PRESENT
|
|
|
|
callasm ArriveToRegularSpace
|
|
|
|
end
|
|
|
|
|
|
|
|
ArriveToRegularSpace:
|
2023-10-18 08:46:57 -07:00
|
|
|
; load new space
|
|
|
|
ld a, [wCurSpaceNextSpace]
|
|
|
|
ld [wCurSpace], a
|
|
|
|
call LoadCurSpaceData
|
|
|
|
; decrease wSpacesLeft and copy to hScriptVar
|
2023-10-14 10:28:35 -07:00
|
|
|
ld hl, wSpacesLeft
|
|
|
|
dec [hl]
|
|
|
|
ld a, [hl]
|
|
|
|
ld [hScriptVar], a
|
2023-10-18 08:46:57 -07:00
|
|
|
; if landed, clear spaces left sprites
|
2023-10-14 10:28:35 -07:00
|
|
|
and a
|
2023-10-21 09:00:59 -07:00
|
|
|
jr nz, .not_landed
|
2023-10-14 10:28:35 -07:00
|
|
|
ld hl, wDisplaySecondarySprites
|
2023-10-14 11:41:18 -07:00
|
|
|
res SECONDARYSPRITES_SPACES_LEFT_F, [hl]
|
2023-10-21 09:00:59 -07:00
|
|
|
.not_landed
|
2023-10-23 08:04:59 -07:00
|
|
|
; update sprites
|
2023-10-21 09:46:56 -07:00
|
|
|
jp UpdateActiveSprites
|
2023-10-14 12:45:48 -07:00
|
|
|
|
|
|
|
LandedInRegularSpaceScript:
|
|
|
|
callasm LandedInRegularSpace
|
|
|
|
end
|
|
|
|
|
|
|
|
LandedInRegularSpace:
|
2023-10-20 11:07:56 -07:00
|
|
|
; disable the space effect (turn the space into a grey space)
|
|
|
|
ld a, [wCurSpaceXCoord]
|
|
|
|
add 4
|
|
|
|
ld d, a
|
|
|
|
ld a, [wCurSpaceYCoord]
|
|
|
|
add 4
|
|
|
|
ld e, a
|
|
|
|
call GetBlockLocation
|
|
|
|
ld a, [hl]
|
|
|
|
and UNIQUE_SPACE_METATILES_MASK
|
|
|
|
add FIRST_GREY_SPACE_METATILE
|
|
|
|
ld [hl], a
|
|
|
|
; trigger end of turn
|
2023-10-14 12:45:48 -07:00
|
|
|
ld a, BOARDEVENT_END_TURN
|
|
|
|
ldh [hCurBoardEvent], a
|
|
|
|
ret
|
2023-10-24 11:36:23 -07:00
|
|
|
|
|
|
|
BranchSpaceScript::
|
|
|
|
scall .ArriveToBranchSpaceScript
|
2023-10-28 10:09:58 -07:00
|
|
|
callasm .PromptPlayerToChooseDirection
|
|
|
|
wait 200
|
2023-10-24 11:36:23 -07:00
|
|
|
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
|
2023-10-28 10:09:58 -07:00
|
|
|
|
|
|
|
.PromptPlayerToChooseDirection:
|
|
|
|
; compute available directions in b as joypad dpad flags
|
|
|
|
ld hl, wTempSpaceBranchStruct
|
|
|
|
ld b, 0
|
|
|
|
ld a, [hli]
|
|
|
|
cp -1
|
|
|
|
jr z, .not_right
|
|
|
|
set D_RIGHT_F, b
|
|
|
|
.not_right
|
|
|
|
ld a, [hli]
|
|
|
|
cp -1
|
|
|
|
jr z, .not_left
|
|
|
|
set D_LEFT_F, b
|
|
|
|
.not_left
|
|
|
|
ld a, [hli]
|
|
|
|
cp -1
|
|
|
|
jr z, .not_up
|
|
|
|
set D_UP_F, b
|
|
|
|
.not_up
|
|
|
|
ld a, [hli]
|
|
|
|
cp -1
|
|
|
|
jr z, .joypad_loop
|
|
|
|
set D_DOWN_F, b
|
|
|
|
|
|
|
|
; sample input of an available direction
|
|
|
|
.joypad_loop
|
|
|
|
call GetJoypad
|
|
|
|
ldh a, [hJoyPressed]
|
|
|
|
and b
|
|
|
|
jr z, .joypad_loop
|
|
|
|
|
|
|
|
; load the next space for the chosen direction
|
|
|
|
ld hl, wTempSpaceBranchStruct
|
|
|
|
bit D_RIGHT_F, a
|
|
|
|
jr nz, .ok
|
|
|
|
inc hl
|
|
|
|
bit D_LEFT_F, a
|
|
|
|
jr nz, .ok
|
|
|
|
inc hl
|
|
|
|
bit D_UP_F, a
|
|
|
|
jr nz, .ok
|
|
|
|
inc hl
|
|
|
|
.ok
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wCurSpaceNextSpace], a
|
|
|
|
ld hl, wDisplaySecondarySprites
|
|
|
|
res SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
|
|
|
|
jp PlayClickSFX
|
|
|
|
|
|
|
|
UnionSpaceScript::
|
|
|
|
callasm .ArriveToUnionSpace
|
|
|
|
end
|
|
|
|
|
|
|
|
.ArriveToUnionSpace:
|
|
|
|
; these are just transition spaces, so simply load the next space
|
|
|
|
ld a, [wCurSpaceNextSpace]
|
|
|
|
ld [wCurSpace], a
|
|
|
|
call LoadCurSpaceData
|
|
|
|
end
|