Add new map setup script MAPSETUP_ENTERLEVEL (#4), and integrate overworld HUD setup in the corresponding setup scripts (#15)

This commit is contained in:
xCrystal 2023-08-31 19:27:39 +02:00
parent 7bd940aeac
commit 74f2a55332
8 changed files with 44 additions and 8 deletions

View File

@ -13,6 +13,7 @@
const MAPSETUP_SUBMENU ; fa
const MAPSETUP_BADWARP ; fb
const MAPSETUP_FLY ; fc
const MAPSETUP_ENTERLEVEL ; fd
DEF NUM_MAPSETUP_SCRIPTS EQU const_value - $f1
; callback types

View File

@ -49,3 +49,5 @@ MapSetupCommands:
add_mapsetup SuspendMapAnims ; 2a
add_mapsetup ApplyMapPalettes ; 2b
add_mapsetup EnableTextAcceleration ; 2c
add_mapsetup ConstructAndEnableOverworldHUD ; 2d
add_mapsetup EnableOverworldHUD ; 2e

View File

@ -13,6 +13,7 @@ MapSetupScripts:
dw MapSetupScript_Submenu
dw MapSetupScript_BadWarp
dw MapSetupScript_Fly
dw MapSetupScript_EnterLevel
assert_table_length NUM_MAPSETUP_SCRIPTS
; valid commands are listed in MapSetupCommands (see data/maps/setup_script_pointers.asm)
@ -20,6 +21,33 @@ MACRO mapsetup
db (\1_MapSetupCmd - MapSetupCommands) / 3
ENDM
MapSetupScript_EnterLevel:
; same as MapSetupScript_Warp, but includes ConstructAndEnableOverworldHUD
mapsetup DisableLCD
mapsetup InitSound
mapsetup EnterMapSpawnPoint
mapsetup LoadMapAttributes
mapsetup HandleNewMap
mapsetup SpawnPlayer
mapsetup RefreshPlayerCoords
mapsetup GetMapScreenCoords
mapsetup LoadBlockData
mapsetup BufferScreen
mapsetup LoadMapGraphics
mapsetup LoadMapTimeOfDay
mapsetup ConstructAndEnableOverworldHUD
mapsetup LoadMapObjects
mapsetup EnableLCD
mapsetup LoadMapPalettes
mapsetup SpawnInFacingDown
mapsetup RefreshMapSprites
mapsetup PlayMapMusicBike
mapsetup FadeInToMusic
mapsetup FadeInPalettesFromWhite
mapsetup ActivateMapAnims
mapsetup LoadWildMonData
db -1 ; end
MapSetupScript_Teleport:
mapsetup ResetPlayerObjectAction
MapSetupScript_Fly:
@ -128,6 +156,7 @@ MapSetupScript_ReloadMap:
mapsetup LoadConnectionBlockData
mapsetup LoadMapGraphics
mapsetup LoadMapTimeOfDay
mapsetup EnableOverworldHUD
mapsetup EnableLCD
mapsetup LoadMapPalettes
mapsetup RefreshMapSprites
@ -167,6 +196,7 @@ MapSetupScript_Continue:
mapsetup BufferScreen
mapsetup LoadMapGraphics
mapsetup LoadMapTimeOfDay
mapsetup ConstructAndEnableOverworldHUD
mapsetup EnableLCD
mapsetup LoadMapPalettes
mapsetup RefreshMapSprites

View File

@ -327,7 +327,7 @@ Continue:
call DelayFrames
farcall JumpRoamMons
ld a, [wSpawnAfterChampion]
cp SPAWN_LEVEL_1
cp SPAWN_N_A
jr z, .SpawnAfterE4
ld a, MAPSETUP_CONTINUE
ldh [hMapEntryMethod], a
@ -378,7 +378,7 @@ FinishContinueFunction:
res GAME_TIMER_MOBILE_F, [hl]
farcall OverworldLoop
ld a, [wSpawnAfterChampion]
cp SPAWN_LEVEL_1
cp SPAWN_N_A
jr z, .AfterRed
jp Reset

View File

@ -141,7 +141,7 @@ LevelSelectionMenu::
ld a, [wLevelSelectionMenuCurrentLandmark]
call LevelSelectionMenu_GetLandmarkSpawnPoint
ld [wDefaultSpawnpoint], a
ld a, MAPSETUP_WARP
ld a, MAPSETUP_ENTERLEVEL
ld [hMapEntryMethod], a
xor a
ld [wDontPlayMapMusicOnReload], a ; play map music

View File

@ -110,8 +110,6 @@ EnterMap:
ld [wXYComparePointer], a
ld [wXYComparePointer + 1], a
call SetUpFiveStepWildEncounterCooldown
ld hl, wTextboxFlags
set TEXT_2BPP_F, [hl]
farcall RunMapSetupScript
call DisableEvents
@ -128,9 +126,6 @@ EnterMap:
ld [wPoisonStepCount], a
.dontresetpoison
call ConstructOverworldHUDTilemap
call EnableOverworldHUD
xor a ; end map entry
ldh [hMapEntryMethod], a
ld a, MAPSTATUS_HANDLE

View File

@ -117,3 +117,10 @@ endr
pop af
ld [rVBK], a
ret
ConstructAndEnableOverworldHUD::
; map setup command used by MAPSETUP_ENTERLEVEL and MAPSETUP_CONTINUE
ld hl, wTextboxFlags
set TEXT_2BPP_F, [hl]
call ConstructOverworldHUDTilemap
jp EnableOverworldHUD

View File

@ -67,6 +67,7 @@ OpenText1bpp::
ld a, BANK(ReanchorBGMap_NoOAMUpdate) ; aka BANK(LoadFont_NoOAMUpdate)
rst Bankswitch
; note: 1bpp text is NOT compatible with the overworld HUD enabled because it uses 2bpp font tiles.
ld hl, wTextboxFlags
res TEXT_2BPP_F, [hl]