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-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
2023-12-24 09:42:07 -08:00
|
|
|
givecoins CUR_LEVEL_COINS, BLUE_RED_SPACE_COINS
|
|
|
|
playsound SFX_TRANSACTION
|
2023-12-26 12:04:20 -08:00
|
|
|
special PrintGainCoins
|
2023-10-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
2023-10-14 12:45:48 -07:00
|
|
|
.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-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
2023-12-24 09:42:07 -08:00
|
|
|
takecoins CUR_LEVEL_COINS, BLUE_RED_SPACE_COINS
|
|
|
|
playsound SFX_TRANSACTION
|
2023-12-26 12:04:20 -08:00
|
|
|
special PrintLoseCoins
|
2023-10-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
2023-10-14 12:45:48 -07:00
|
|
|
.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-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
|
|
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
2023-10-19 11:38:54 -07:00
|
|
|
.not_landed
|
|
|
|
end
|
|
|
|
|
|
|
|
ItemSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
|
|
|
iftrue .not_landed
|
2023-10-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
|
|
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
2023-10-19 11:38:54 -07:00
|
|
|
.not_landed
|
|
|
|
end
|
|
|
|
|
|
|
|
PokemonSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
|
|
|
iftrue .not_landed
|
2023-10-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
|
|
|
wait 200
|
2023-10-23 08:04:59 -07:00
|
|
|
loadpikachudata
|
|
|
|
startbattle
|
|
|
|
reloadmapafterbattle
|
|
|
|
wait 100
|
2023-10-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
2023-10-19 11:38:54 -07:00
|
|
|
.not_landed
|
|
|
|
end
|
|
|
|
|
|
|
|
MinigameSpaceScript::
|
|
|
|
scall ArriveToRegularSpaceScript
|
|
|
|
iftrue .not_landed
|
2023-10-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
|
|
|
wait 200
|
|
|
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
2023-10-19 11:38:54 -07:00
|
|
|
.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
|
2023-10-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
2023-10-21 09:00:59 -07:00
|
|
|
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
|
2023-12-24 09:42:07 -08:00
|
|
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
2023-10-30 11:27:19 -07:00
|
|
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
2023-10-14 12:45:48 -07:00
|
|
|
.not_landed
|
2023-10-14 10:28:35 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
ArriveToRegularSpaceScript:
|
|
|
|
playsound SFX_PRESENT
|
2023-10-30 11:27:19 -07:00
|
|
|
callasm .ArriveToRegularSpace
|
2023-10-14 10:28:35 -07:00
|
|
|
end
|
|
|
|
|
2023-10-30 11:27:19 -07:00
|
|
|
.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
|
|
|
|
2023-10-30 11:27:19 -07:00
|
|
|
LandedInRegularSpaceScript_BeforeSpaceEffect:
|
|
|
|
wait 300
|
|
|
|
turnobject PLAYER, DOWN
|
|
|
|
wait 100
|
|
|
|
end
|
|
|
|
|
|
|
|
LandedInRegularSpaceScript_AfterSpaceEffect:
|
|
|
|
callasm .LandedInRegularSpace
|
2023-10-14 12:45:48 -07:00
|
|
|
end
|
|
|
|
|
2023-10-30 11:27:19 -07:00
|
|
|
.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
|
2023-12-20 10:14:28 -08:00
|
|
|
; backup the disabled space to preserve it on map reload
|
|
|
|
call BackupDisabledSpace
|
2023-10-20 11:07:56 -07:00
|
|
|
; 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::
|
2023-11-04 09:17:08 -07:00
|
|
|
scall ArriveToBranchSpaceScript
|
|
|
|
BranchSpaceScript_PromptPlayer::
|
|
|
|
callasm PromptPlayerToChooseBranchDirection
|
2023-10-29 04:03:23 -07:00
|
|
|
iffalse .print_technique_required
|
2023-10-28 10:09:58 -07:00
|
|
|
wait 200
|
2023-10-24 11:36:23 -07:00
|
|
|
end
|
|
|
|
|
2023-10-29 04:03:23 -07:00
|
|
|
.print_technique_required
|
|
|
|
opentext
|
|
|
|
writetext .TechniqueRequiredText
|
|
|
|
waitbutton
|
|
|
|
closetext
|
2023-11-04 09:17:08 -07:00
|
|
|
sjump BranchSpaceScript_PromptPlayer
|
2023-10-29 04:03:23 -07:00
|
|
|
|
|
|
|
.TechniqueRequiredText:
|
|
|
|
text "A new TECHNIQUE is"
|
|
|
|
line "required!"
|
|
|
|
done
|
|
|
|
|
2023-11-04 09:17:08 -07:00
|
|
|
ArriveToBranchSpaceScript:
|
2023-10-24 11:36:23 -07:00
|
|
|
playsound SFX_TWINKLE
|
|
|
|
wait 400
|
|
|
|
callasm .ArriveToBranchSpace
|
|
|
|
end
|
|
|
|
|
|
|
|
.ArriveToBranchSpace:
|
|
|
|
; load new space
|
|
|
|
ld a, [wCurSpaceNextSpace]
|
|
|
|
ld [wCurSpace], a
|
2023-10-29 04:03:23 -07:00
|
|
|
; unlike in other cases, wCurSpaceNextSpace will not yet
|
|
|
|
; contain the next space after calling LoadCurSpaceData.
|
|
|
|
; it will be defined after the player has chosen which direction to take.
|
2023-10-24 11:36:23 -07:00
|
|
|
call LoadCurSpaceData
|
2023-10-29 04:03:23 -07:00
|
|
|
; load the space's branch data
|
2023-10-24 11:36:23 -07:00
|
|
|
call LoadTempSpaceBranchData
|
|
|
|
call .DisableDirectionsRequiringLockedTechniques
|
|
|
|
; draw arrows for valid directions
|
2023-12-23 05:44:36 -08:00
|
|
|
farcall LoadBranchSpaceGFX
|
2023-10-24 11:36:23 -07:00
|
|
|
ld hl, wDisplaySecondarySprites
|
2023-12-23 05:44:36 -08:00
|
|
|
set SECONDARYSPRITES_BRANCH_SPACE_F, [hl]
|
2023-10-24 11:36:23 -07:00
|
|
|
; update sprites
|
|
|
|
jp UpdateActiveSprites
|
|
|
|
|
|
|
|
.DisableDirectionsRequiringLockedTechniques:
|
2023-10-29 04:03:23 -07:00
|
|
|
; set to BRANCH_DIRECTION_UNAVAILABLE each next space byte of the branch struct
|
|
|
|
; that has an unavailable direction due to required techniques not yet unlocked.
|
|
|
|
ld hl, wTempSpaceBranchStruct + NUM_DIRECTIONS
|
|
|
|
ld de, wTempSpaceBranchStruct
|
|
|
|
ld bc, wUnlockedTechniques
|
|
|
|
rept NUM_DIRECTIONS
|
|
|
|
ld a, [bc]
|
|
|
|
and [hl]
|
|
|
|
cp [hl]
|
|
|
|
jr z, .next\@
|
|
|
|
ld a, BRANCH_DIRECTION_UNAVAILABLE
|
|
|
|
ld [de], a
|
|
|
|
.next\@
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
endr
|
2023-10-24 11:36:23 -07:00
|
|
|
ret
|
2023-10-28 10:09:58 -07:00
|
|
|
|
2023-11-04 09:17:08 -07:00
|
|
|
PromptPlayerToChooseBranchDirection:
|
|
|
|
; sample a dpad press or SELECT button
|
2023-10-28 10:09:58 -07:00
|
|
|
ld hl, wTempSpaceBranchStruct
|
|
|
|
call GetJoypad
|
|
|
|
ldh a, [hJoyPressed]
|
2023-11-04 09:17:08 -07:00
|
|
|
and D_PAD | SELECT
|
|
|
|
jr z, PromptPlayerToChooseBranchDirection
|
2023-10-28 10:09:58 -07:00
|
|
|
|
2023-11-04 09:17:08 -07:00
|
|
|
cp SELECT ; check if SELECT pressed along with no dpad key
|
|
|
|
jr nz, .not_select
|
|
|
|
jp .EnterViewMapMode
|
|
|
|
|
|
|
|
.not_select
|
2023-10-29 04:03:23 -07:00
|
|
|
; determine the status (ok/invalid/unavailable) of the chosen direction
|
2023-10-28 10:09:58 -07:00
|
|
|
bit D_RIGHT_F, a
|
2023-10-29 04:03:23 -07:00
|
|
|
jr z, .not_right
|
|
|
|
ld a, [hl]
|
|
|
|
inc a ; cp BRANCH_DIRECTION_INVALID
|
2023-11-04 09:17:08 -07:00
|
|
|
jr z, PromptPlayerToChooseBranchDirection
|
2023-10-29 04:03:23 -07:00
|
|
|
inc a ; cp BRANCH_DIRECTION_UNAVAILABLE
|
|
|
|
jr z, .technique_required
|
|
|
|
jr .direction_chosen
|
|
|
|
.not_right
|
|
|
|
|
2023-10-28 10:09:58 -07:00
|
|
|
inc hl
|
|
|
|
bit D_LEFT_F, a
|
2023-10-29 04:03:23 -07:00
|
|
|
jr z, .not_left
|
|
|
|
ld a, [hl]
|
|
|
|
inc a ; cp BRANCH_DIRECTION_INVALID
|
2023-11-04 09:17:08 -07:00
|
|
|
jr z, PromptPlayerToChooseBranchDirection
|
2023-10-29 04:03:23 -07:00
|
|
|
inc a ; cp BRANCH_DIRECTION_UNAVAILABLE
|
|
|
|
jr z, .technique_required
|
|
|
|
jr .direction_chosen
|
|
|
|
.not_left
|
|
|
|
|
2023-10-28 10:09:58 -07:00
|
|
|
inc hl
|
|
|
|
bit D_UP_F, a
|
2023-10-29 04:03:23 -07:00
|
|
|
jr z, .not_up
|
|
|
|
ld a, [hl]
|
|
|
|
inc a ; cp BRANCH_DIRECTION_INVALID
|
2023-11-04 09:17:08 -07:00
|
|
|
jr z, PromptPlayerToChooseBranchDirection
|
2023-10-29 04:03:23 -07:00
|
|
|
inc a ; cp BRANCH_DIRECTION_UNAVAILABLE
|
|
|
|
jr z, .technique_required
|
|
|
|
jr .direction_chosen
|
|
|
|
.not_up
|
|
|
|
|
2023-10-28 10:09:58 -07:00
|
|
|
inc hl
|
2023-10-29 04:03:23 -07:00
|
|
|
ld a, [hl]
|
|
|
|
inc a ; cp BRANCH_DIRECTION_INVALID
|
2023-11-04 09:17:08 -07:00
|
|
|
jr z, PromptPlayerToChooseBranchDirection
|
2023-10-29 04:03:23 -07:00
|
|
|
inc a ; cp BRANCH_DIRECTION_UNAVAILABLE
|
|
|
|
jr z, .technique_required
|
|
|
|
; fallthrough
|
|
|
|
|
|
|
|
.direction_chosen
|
|
|
|
; save the next space of the chosen direction to wCurSpaceNextSpace
|
2023-10-28 10:09:58 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld [wCurSpaceNextSpace], a
|
|
|
|
ld hl, wDisplaySecondarySprites
|
2023-12-23 05:44:36 -08:00
|
|
|
res SECONDARYSPRITES_BRANCH_SPACE_F, [hl]
|
2023-10-29 04:03:23 -07:00
|
|
|
ld a, TRUE
|
|
|
|
ldh [hScriptVar], a
|
|
|
|
jp PlayClickSFX
|
|
|
|
|
|
|
|
.technique_required
|
|
|
|
xor a ; FALSE
|
|
|
|
ldh [hScriptVar], a
|
2023-10-28 10:09:58 -07:00
|
|
|
jp PlayClickSFX
|
|
|
|
|
2023-11-04 09:17:08 -07:00
|
|
|
.EnterViewMapMode:
|
2023-12-15 10:10:47 -08:00
|
|
|
call BackupMapObjectsOnEnterViewMapMode
|
2023-11-04 09:17:08 -07:00
|
|
|
ld a, BOARDEVENT_VIEW_MAP_MODE
|
|
|
|
ldh [hCurBoardEvent], a
|
2023-12-14 08:11:15 -08:00
|
|
|
ld a, 100
|
2023-11-04 09:17:08 -07:00
|
|
|
ld [wViewMapModeRange], a
|
|
|
|
ld a, [wMapGroup]
|
|
|
|
ld [wBeforeViewMapMapGroup], a
|
|
|
|
ld a, [wMapNumber]
|
|
|
|
ld [wBeforeViewMapMapNumber], a
|
|
|
|
ld a, [wXCoord]
|
|
|
|
ld [wBeforeViewMapXCoord], a
|
|
|
|
ld a, [wYCoord]
|
|
|
|
ld [wBeforeViewMapYCoord], a
|
|
|
|
xor a
|
|
|
|
ld [wViewMapModeDisplacementY], a
|
|
|
|
ld [wViewMapModeDisplacementX], a
|
|
|
|
call DisableOverworldHUD
|
|
|
|
ld hl, wPlayerFlags
|
|
|
|
set INVISIBLE_F, [hl]
|
|
|
|
ld hl, wDisplaySecondarySprites
|
|
|
|
res SECONDARYSPRITES_SPACES_LEFT_F, [hl]
|
2023-12-23 05:44:36 -08:00
|
|
|
res SECONDARYSPRITES_BRANCH_SPACE_F, [hl]
|
2023-11-04 09:17:08 -07:00
|
|
|
farcall MockPlayerObject
|
|
|
|
call UpdateSprites
|
|
|
|
farcall LoadViewMapModeGFX
|
|
|
|
ld hl, wDisplaySecondarySprites
|
|
|
|
set SECONDARYSPRITES_VIEW_MAP_MODE_F, [hl]
|
|
|
|
ld a, TRUE
|
|
|
|
ldh [hScriptVar], a
|
|
|
|
jp PlayClickSFX
|
|
|
|
|
2023-10-28 10:09:58 -07:00
|
|
|
UnionSpaceScript::
|
|
|
|
callasm .ArriveToUnionSpace
|
|
|
|
end
|
|
|
|
|
|
|
|
.ArriveToUnionSpace:
|
|
|
|
; these are just transition spaces, so simply load the next space
|
|
|
|
ld a, [wCurSpaceNextSpace]
|
|
|
|
ld [wCurSpace], a
|
|
|
|
call LoadCurSpaceData
|
2023-12-20 10:14:28 -08:00
|
|
|
ret
|
|
|
|
|
2023-12-26 12:04:20 -08:00
|
|
|
PrintGainCoins:
|
|
|
|
ld hl, wStringBuffer1
|
|
|
|
ld a, "<COIN>"
|
|
|
|
ld [hli], a
|
|
|
|
ld a, "<PLUS>"
|
|
|
|
ld [hli], a
|
|
|
|
jr PrintGainOrLoseCoins
|
|
|
|
|
|
|
|
PrintLoseCoins:
|
|
|
|
ld hl, wStringBuffer1
|
|
|
|
ld a, "<COIN>"
|
|
|
|
ld [hli], a
|
|
|
|
ld a, "<MINUS>"
|
|
|
|
ld [hli], a
|
|
|
|
; fallthrough
|
|
|
|
|
|
|
|
PrintGainOrLoseCoins:
|
|
|
|
push hl
|
|
|
|
; fill string space with "@" to ensure that it is terminated with at least one "@"
|
|
|
|
ld a, "@"
|
|
|
|
ld c, MAX_DELTA_COINS_DIGITS + 1
|
|
|
|
.loop
|
|
|
|
ld [hli], a
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
pop hl
|
|
|
|
; copy coins amount string to wStringBuffer1 + $2
|
|
|
|
ld de, hCoinsTemp
|
|
|
|
lb bc, 3 | 1 << 6, MAX_DELTA_COINS_DIGITS ; 3 bytes, left aligned, no leading zeros, 5 digits
|
|
|
|
call PrintNum
|
|
|
|
ld hl, wDisplaySecondarySprites
|
|
|
|
set SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, [hl]
|
2023-12-27 08:42:46 -08:00
|
|
|
; refresh overworld HUD, and show coins string 750 ms
|
2023-12-26 12:04:20 -08:00
|
|
|
call UpdateActiveSprites
|
2023-12-27 08:42:46 -08:00
|
|
|
call RefreshOverworldHUD
|
2023-12-26 12:04:20 -08:00
|
|
|
ld c, 45 ; 750 ms
|
|
|
|
call DelayFrames
|
|
|
|
ld hl, wDisplaySecondarySprites
|
|
|
|
res SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, [hl]
|
|
|
|
ret
|
|
|
|
|
2023-12-21 11:04:30 -08:00
|
|
|
INCLUDE "engine/board/disabled_spaces.asm"
|