Implement Flash technique through a map callback of type MAPCALLBACK_ENDMAPSETUP (#34)

This callback type is executed in a new map setup command at the very end of every map setup script. Maps that should trigger the use of Flash automatically should use an instance of this callback with fixed functionality
This commit is contained in:
xCrystal 2023-12-31 15:05:07 +01:00
parent c5e3179059
commit ce4ca85494
7 changed files with 38 additions and 2 deletions

View File

@ -24,3 +24,4 @@ DEF NUM_MAPSETUP_SCRIPTS EQU const_value - $f1
const MAPCALLBACK_CMDQUEUE const MAPCALLBACK_CMDQUEUE
const MAPCALLBACK_SPRITES const MAPCALLBACK_SPRITES
const MAPCALLBACK_NEWMAP const MAPCALLBACK_NEWMAP
const MAPCALLBACK_ENDMAPSETUP

View File

@ -49,8 +49,8 @@ MapGroup_DebugLevel1:
MapGroup_DebugLevel2: MapGroup_DebugLevel2:
table_width MAP_LENGTH, MapGroup_DebugLevel2 table_width MAP_LENGTH, MapGroup_DebugLevel2
map DebugLevel2_Map1, TILESET_BOARD_DEBUG_2, INDOOR_CAVE, LANDMARK_DEBUGLEVEL_2, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_NITE, FISHGROUP_SHORE, 2 map DebugLevel2_Map1, TILESET_BOARD_DEBUG_2, INDOOR_CAVE, LANDMARK_DEBUGLEVEL_2, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_NITE | IN_DARKNESS, FISHGROUP_SHORE, 2
map DebugLevel2_Map2, TILESET_BOARD_DEBUG_2, INDOOR_CAVE, LANDMARK_DEBUGLEVEL_2, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_NITE, FISHGROUP_SHORE, 2 map DebugLevel2_Map2, TILESET_BOARD_DEBUG_2, INDOOR_CAVE, LANDMARK_DEBUGLEVEL_2, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_NITE | IN_DARKNESS, FISHGROUP_SHORE, 2
assert_table_length NUM_DEBUGLEVEL_2_MAPS assert_table_length NUM_DEBUGLEVEL_2_MAPS
MapGroup_DebugLevel3: MapGroup_DebugLevel3:

View File

@ -56,3 +56,4 @@ MapSetupCommands:
add_mapsetup AnchorPointAfterWarp ; 31 add_mapsetup AnchorPointAfterWarp ; 31
add_mapsetup BackupMapObjects ; 32 add_mapsetup BackupMapObjects ; 32
add_mapsetup LoadDisabledSpaces ; 33 add_mapsetup LoadDisabledSpaces ; 33
add_mapsetup MapCallbackAtEndMapSetup ; 34

View File

@ -48,6 +48,7 @@ MapSetupScript_EnterLevel:
mapsetup FadeInPalettesFromWhite mapsetup FadeInPalettesFromWhite
mapsetup ActivateMapAnims mapsetup ActivateMapAnims
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_Teleport: MapSetupScript_Teleport:
@ -81,6 +82,7 @@ MapSetupScript_Warp:
mapsetup ActivateMapAnims mapsetup ActivateMapAnims
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup AnchorPointAfterWarp mapsetup AnchorPointAfterWarp
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_BadWarp: MapSetupScript_BadWarp:
@ -108,6 +110,7 @@ MapSetupScript_BadWarp:
mapsetup ActivateMapAnims mapsetup ActivateMapAnims
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup AnchorPointAfterWarp mapsetup AnchorPointAfterWarp
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_Connection: MapSetupScript_Connection:
@ -128,6 +131,7 @@ MapSetupScript_Connection:
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup UpdateRoamMons mapsetup UpdateRoamMons
mapsetup ActivateMapAnims mapsetup ActivateMapAnims
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_Fall: MapSetupScript_Fall:
@ -158,6 +162,7 @@ MapSetupScript_Train:
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup UpdateRoamMons mapsetup UpdateRoamMons
mapsetup AnchorPointAfterWarp mapsetup AnchorPointAfterWarp
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_ReloadMap: MapSetupScript_ReloadMap:
@ -178,6 +183,7 @@ MapSetupScript_ReloadMap:
mapsetup FadeInPalettesFromWhite mapsetup FadeInPalettesFromWhite
mapsetup ActivateMapAnims mapsetup ActivateMapAnims
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_ExitViewMap: MapSetupScript_ExitViewMap:
@ -202,6 +208,7 @@ MapSetupScript_ExitViewMap:
mapsetup FadeInPalettesFromWhite mapsetup FadeInPalettesFromWhite
mapsetup ActivateMapAnims mapsetup ActivateMapAnims
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_LinkReturn: MapSetupScript_LinkReturn:
@ -222,6 +229,7 @@ MapSetupScript_LinkReturn:
mapsetup ActivateMapAnims mapsetup ActivateMapAnims
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup EnableTextAcceleration mapsetup EnableTextAcceleration
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_Continue: MapSetupScript_Continue:
@ -244,6 +252,7 @@ MapSetupScript_Continue:
mapsetup FadeInPalettesFromWhite mapsetup FadeInPalettesFromWhite
mapsetup ActivateMapAnims mapsetup ActivateMapAnims
mapsetup LoadWildMonData mapsetup LoadWildMonData
mapsetup MapCallbackAtEndMapSetup
db -1 ; end db -1 ; end
MapSetupScript_Submenu: MapSetupScript_Submenu:

View File

@ -9,6 +9,23 @@ PlayWhirlpoolSound:
call WaitSFX call WaitSFX
ret ret
UseFlashAuto::
; ReplaceTimeOfDayPals in map setup command LoadMapTimeOfDay sets wTimeOfDayPalset to DARKNESS_PALSET
; only if wStatusFlags[STATUSFLAGS_FLASH_F] has not been set.
ld a, [wTimeOfDayPalset]
cp DARKNESS_PALSET
ret nz
ld c, 30 ; 500 ms
call DelayFrames
call WaitSFX
ld de, SFX_FLASH
call PlaySFX
call BlindingFlash
ld c, 30 ; 500 ms
call DelayFrames
call WaitSFX
ret
BlindingFlash: BlindingFlash:
farcall FadeOutPalettesToWhite farcall FadeOutPalettesToWhite
ld hl, wStatusFlags ld hl, wStatusFlags

View File

@ -202,3 +202,6 @@ ResetLevelScopedEventFlags:
jr nz, .loop jr nz, .loop
ret ret
MapCallbackAtEndMapSetup:
ld a, MAPCALLBACK_ENDMAPSETUP
jp RunMapCallback

View File

@ -4,6 +4,11 @@ DebugLevel2_Map1_MapScripts:
def_scene_scripts def_scene_scripts
def_callbacks def_callbacks
callback MAPCALLBACK_ENDMAPSETUP, .FlashAutoScript
.FlashAutoScript:
callasm UseFlashAuto
endcallback
DebugLevel2_Map1_MapEvents: DebugLevel2_Map1_MapEvents:
db 0, 0 ; filler db 0, 0 ; filler