Treat map setup commands like trade script commands

Fixes #736
This commit is contained in:
Rangi 2020-07-22 13:37:43 -04:00
parent b17255fe3f
commit 212846af57
5 changed files with 199 additions and 247 deletions

View File

@ -1,48 +1,52 @@
add_mapsetup: MACRO
\1_MapSetupCmd:
dba \1
ENDM
MapSetupCommands: MapSetupCommands:
; entries correspond to map_*_command constants (see macros/scripts/map_setup.asm) add_mapsetup EnableLCD ; 00
dba EnableLCD ; 00 add_mapsetup DisableLCD ; 01
dba DisableLCD ; 01 add_mapsetup InitSound ; 02
dba InitSound ; 02 add_mapsetup PlayMapMusic ; 03
dba PlayMapMusic ; 03 add_mapsetup RestartMapMusic ; 04
dba RestartMapMusic ; 04 add_mapsetup FadeToMapMusic ; 05
dba FadeToMapMusic ; 05 add_mapsetup FadeMapMusicAndPalettes ; 06
dba FadeMapMusicAndPalettes ; 06 add_mapsetup PlayMapMusicBike ; 07
dba PlayMapMusicBike ; 07 add_mapsetup ForceMapMusic ; 08
dba ForceMapMusic ; 08 add_mapsetup FadeInToMusic ; 09
dba FadeInToMusic ; 09 add_mapsetup LoadBlockData ; 0a (callback 1)
dba LoadBlockData ; 0a (callback 1) add_mapsetup LoadConnectionBlockData ; 0b
dba LoadConnectionBlockData ; 0b add_mapsetup SaveScreen ; 0c
dba SaveScreen ; 0c add_mapsetup BufferScreen ; 0d
dba BufferScreen ; 0d add_mapsetup LoadMapGraphics ; 0e
dba LoadMapGraphics ; 0e add_mapsetup LoadMapTileset ; 0f
dba LoadMapTileset ; 0f add_mapsetup LoadMapTimeOfDay ; 10
dba LoadMapTimeOfDay ; 10 add_mapsetup LoadMapPalettes ; 11
dba LoadMapPalettes ; 11 add_mapsetup LoadWildMonData ; 12
dba LoadWildMonData ; 12 add_mapsetup RefreshMapSprites ; 13
dba RefreshMapSprites ; 13 add_mapsetup HandleNewMap ; 14
dba HandleNewMap ; 14 add_mapsetup HandleContinueMap ; 15
dba HandleContinueMap ; 15 add_mapsetup LoadMapObjects ; 16
dba LoadMapObjects ; 16 add_mapsetup EnterMapSpawnPoint ; 17
dba EnterMapSpawnPoint ; 17 add_mapsetup EnterMapConnection ; 18
dba EnterMapConnection ; 18 add_mapsetup EnterMapWarp ; 19
dba EnterMapWarp ; 19 add_mapsetup LoadMapAttributes ; 1a
dba LoadMapAttributes ; 1a add_mapsetup LoadMapAttributes_SkipObjects ; 1b
dba LoadMapAttributes_SkipObjects ; 1b add_mapsetup ClearBGPalettes ; 1c
dba ClearBGPalettes ; 1c add_mapsetup FadeOutPalettes ; 1d
dba FadeOutPalettes ; 1d add_mapsetup FadeInPalettes ; 1e
dba FadeInPalettes ; 1e add_mapsetup GetMapScreenCoords ; 1f
dba GetMapScreenCoords ; 1f add_mapsetup GetWarpDestCoords ; 20
dba GetWarpDestCoords ; 20 add_mapsetup SpawnInFacingDown ; 21
dba SpawnInFacingDown ; 21 add_mapsetup SpawnPlayer ; 22
dba SpawnPlayer ; 22 add_mapsetup RefreshPlayerCoords ; 23
dba RefreshPlayerCoords ; 23 add_mapsetup ResetPlayerObjectAction ; 24
dba ResetPlayerObjectAction ; 24 add_mapsetup SkipUpdateMapSprites ; 25
dba SkipUpdateMapSprites ; 25 add_mapsetup UpdateRoamMons ; 26
dba UpdateRoamMons ; 26 add_mapsetup JumpRoamMons ; 27
dba JumpRoamMons ; 27 add_mapsetup FadeOutMapMusic ; 28
dba FadeOutMapMusic ; 28 add_mapsetup ActivateMapAnims ; 29
dba ActivateMapAnims ; 29 add_mapsetup SuspendMapAnims ; 2a
dba SuspendMapAnims ; 2a add_mapsetup ApplyMapPalettes ; 2b
dba ApplyMapPalettes ; 2b add_mapsetup EnableTextAcceleration ; 2c
dba EnableTextAcceleration ; 2c add_mapsetup InitMapNameSign ; 2d
dba InitMapNameSign ; 2d

View File

@ -13,164 +13,169 @@ MapSetupScripts:
dw MapSetupScript_BadWarp dw MapSetupScript_BadWarp
dw MapSetupScript_Fly dw MapSetupScript_Fly
; valid commands are listed in MapSetupCommands (see data/maps/setup_script_pointers.asm)
mapsetup: MACRO
db (\1_MapSetupCmd - MapSetupCommands) / 3
ENDM
MapSetupScript_Teleport: MapSetupScript_Teleport:
map_reset_player_object_action mapsetup ResetPlayerObjectAction
MapSetupScript_Fly: MapSetupScript_Fly:
map_fade_out_palettes mapsetup FadeOutPalettes
map_jump_roam_mons mapsetup JumpRoamMons
MapSetupScript_Warp: MapSetupScript_Warp:
map_disable_lcd mapsetup DisableLCD
map_init_sound mapsetup InitSound
map_enter_spawn_point mapsetup EnterMapSpawnPoint
map_load_attributes mapsetup LoadMapAttributes
map_handle_new mapsetup HandleNewMap
map_spawn_player mapsetup SpawnPlayer
map_refresh_player_coords mapsetup RefreshPlayerCoords
map_get_screen_coords mapsetup GetMapScreenCoords
map_load_block_data mapsetup LoadBlockData
map_buffer_screen mapsetup BufferScreen
map_load_graphics mapsetup LoadMapGraphics
map_load_time_of_day mapsetup LoadMapTimeOfDay
map_load_objects mapsetup LoadMapObjects
map_enable_lcd mapsetup EnableLCD
map_load_palettes mapsetup LoadMapPalettes
map_spawn_in_facing_down mapsetup SpawnInFacingDown
map_refresh_sprites mapsetup RefreshMapSprites
map_play_music_bike mapsetup PlayMapMusicBike
map_fade_in_to_music mapsetup FadeInToMusic
map_fade_in_palettes mapsetup FadeInPalettes
map_activate_anims mapsetup ActivateMapAnims
map_load_wild_mon_data mapsetup LoadWildMonData
map_end db -1 ; end
MapSetupScript_BadWarp: MapSetupScript_BadWarp:
map_enter_spawn_point mapsetup EnterMapSpawnPoint
map_load_attributes mapsetup LoadMapAttributes
map_handle_new mapsetup HandleNewMap
map_spawn_player mapsetup SpawnPlayer
map_refresh_player_coords mapsetup RefreshPlayerCoords
map_get_screen_coords mapsetup GetMapScreenCoords
map_load_block_data mapsetup LoadBlockData
map_buffer_screen mapsetup BufferScreen
map_disable_lcd mapsetup DisableLCD
map_load_graphics mapsetup LoadMapGraphics
map_load_time_of_day mapsetup LoadMapTimeOfDay
map_fade_out_music mapsetup FadeOutMapMusic
map_enable_lcd mapsetup EnableLCD
map_load_objects mapsetup LoadMapObjects
map_load_palettes mapsetup LoadMapPalettes
map_spawn_in_facing_down mapsetup SpawnInFacingDown
map_refresh_sprites mapsetup RefreshMapSprites
map_fade_to_music mapsetup FadeToMapMusic
map_fade_in_palettes mapsetup FadeInPalettes
map_activate_anims mapsetup ActivateMapAnims
map_load_wild_mon_data mapsetup LoadWildMonData
map_end db -1 ; end
MapSetupScript_Connection: MapSetupScript_Connection:
map_suspend_anims mapsetup SuspendMapAnims
map_enter_connection mapsetup EnterMapConnection
map_load_attributes mapsetup LoadMapAttributes
map_handle_new mapsetup HandleNewMap
map_refresh_player_coords mapsetup RefreshPlayerCoords
map_load_block_data mapsetup LoadBlockData
map_load_tileset mapsetup LoadMapTileset
map_save_screen mapsetup SaveScreen
map_load_objects mapsetup LoadMapObjects
map_fade_to_music mapsetup FadeToMapMusic
map_load_palettes mapsetup LoadMapPalettes
map_init_name_sign mapsetup InitMapNameSign
map_apply_palettes mapsetup ApplyMapPalettes
map_load_wild_mon_data mapsetup LoadWildMonData
map_update_roam_mons mapsetup UpdateRoamMons
map_activate_anims mapsetup ActivateMapAnims
map_end db -1 ; end
MapSetupScript_Fall: MapSetupScript_Fall:
map_reset_player_object_action mapsetup ResetPlayerObjectAction
MapSetupScript_Door: MapSetupScript_Door:
map_fade_out_palettes mapsetup FadeOutPalettes
MapSetupScript_Train: MapSetupScript_Train:
map_enter_warp mapsetup EnterMapWarp
map_load_attributes mapsetup LoadMapAttributes
map_get_warp_dest_coords mapsetup GetWarpDestCoords
map_handle_new mapsetup HandleNewMap
map_refresh_player_coords mapsetup RefreshPlayerCoords
map_load_block_data mapsetup LoadBlockData
map_buffer_screen mapsetup BufferScreen
map_disable_lcd mapsetup DisableLCD
map_load_graphics mapsetup LoadMapGraphics
map_load_time_of_day mapsetup LoadMapTimeOfDay
map_fade_out_music mapsetup FadeOutMapMusic
map_enable_lcd mapsetup EnableLCD
map_load_objects mapsetup LoadMapObjects
map_load_palettes mapsetup LoadMapPalettes
map_refresh_sprites mapsetup RefreshMapSprites
map_fade_to_music mapsetup FadeToMapMusic
map_fade_in_palettes mapsetup FadeInPalettes
map_activate_anims mapsetup ActivateMapAnims
map_load_wild_mon_data mapsetup LoadWildMonData
map_update_roam_mons mapsetup UpdateRoamMons
map_end db -1 ; end
MapSetupScript_ReloadMap: MapSetupScript_ReloadMap:
map_fade_music_and_palettes mapsetup FadeMapMusicAndPalettes
map_clear_bg_palettes mapsetup ClearBGPalettes
map_disable_lcd mapsetup DisableLCD
map_init_sound mapsetup InitSound
map_load_block_data mapsetup LoadBlockData
map_load_connection_block_data mapsetup LoadConnectionBlockData
map_load_graphics mapsetup LoadMapGraphics
map_load_time_of_day mapsetup LoadMapTimeOfDay
map_enable_lcd mapsetup EnableLCD
map_load_palettes mapsetup LoadMapPalettes
map_refresh_sprites mapsetup RefreshMapSprites
map_force_music mapsetup ForceMapMusic
map_fade_in_palettes mapsetup FadeInPalettes
map_activate_anims mapsetup ActivateMapAnims
map_load_wild_mon_data mapsetup LoadWildMonData
map_end db -1 ; end
MapSetupScript_LinkReturn: MapSetupScript_LinkReturn:
map_fade_music_and_palettes mapsetup FadeMapMusicAndPalettes
map_disable_lcd mapsetup DisableLCD
map_init_sound mapsetup InitSound
map_handle_new mapsetup HandleNewMap
map_load_block_data mapsetup LoadBlockData
map_buffer_screen mapsetup BufferScreen
map_load_graphics mapsetup LoadMapGraphics
map_load_time_of_day mapsetup LoadMapTimeOfDay
map_enable_lcd mapsetup EnableLCD
map_load_palettes mapsetup LoadMapPalettes
map_refresh_sprites mapsetup RefreshMapSprites
map_play_music_bike mapsetup PlayMapMusicBike
map_fade_in_palettes mapsetup FadeInPalettes
map_activate_anims mapsetup ActivateMapAnims
map_load_wild_mon_data mapsetup LoadWildMonData
map_enable_text_acceleration mapsetup EnableTextAcceleration
map_end db -1 ; end
MapSetupScript_Continue: MapSetupScript_Continue:
map_disable_lcd mapsetup DisableLCD
map_init_sound mapsetup InitSound
map_load_attributes_no_objects mapsetup LoadMapAttributes_SkipObjects
map_get_screen_coords mapsetup GetMapScreenCoords
map_handle_continue mapsetup HandleContinueMap
map_load_block_data mapsetup LoadBlockData
map_load_connection_block_data mapsetup LoadConnectionBlockData
map_buffer_screen mapsetup BufferScreen
map_load_graphics mapsetup LoadMapGraphics
map_load_time_of_day mapsetup LoadMapTimeOfDay
map_enable_lcd mapsetup EnableLCD
map_load_palettes mapsetup LoadMapPalettes
map_refresh_sprites mapsetup RefreshMapSprites
map_play_music_bike mapsetup PlayMapMusicBike
map_fade_in_palettes mapsetup FadeInPalettes
map_activate_anims mapsetup ActivateMapAnims
map_load_wild_mon_data mapsetup LoadWildMonData
map_end db -1 ; end
MapSetupScript_Submenu: MapSetupScript_Submenu:
map_load_block_data mapsetup LoadBlockData
map_load_connection_block_data mapsetup LoadConnectionBlockData
map_end db -1 ; end

View File

@ -18,7 +18,7 @@ INCLUDE "data/maps/setup_scripts.asm"
ReadMapSetupScript: ReadMapSetupScript:
.loop .loop
ld a, [hli] ld a, [hli]
cp map_end_command cp -1 ; end?
ret z ret z
push hl push hl

View File

@ -11,7 +11,6 @@ INCLUDE "macros/scripts/maps.asm"
INCLUDE "macros/scripts/events.asm" INCLUDE "macros/scripts/events.asm"
INCLUDE "macros/scripts/text.asm" INCLUDE "macros/scripts/text.asm"
INCLUDE "macros/scripts/movement.asm" INCLUDE "macros/scripts/movement.asm"
INCLUDE "macros/scripts/map_setup.asm"
INCLUDE "macros/scripts/battle_commands.asm" INCLUDE "macros/scripts/battle_commands.asm"
INCLUDE "macros/scripts/battle_anims.asm" INCLUDE "macros/scripts/battle_anims.asm"
INCLUDE "macros/scripts/gfx_anims.asm" INCLUDE "macros/scripts/gfx_anims.asm"

View File

@ -1,56 +0,0 @@
setup_command: MACRO
const \1_command
\1 EQUS "db \1_command"
ENDM
; MapSetupCommands indexes (see data/maps/setup_script_pointers.asm)
const_def
setup_command map_enable_lcd ; 00
setup_command map_disable_lcd ; 01
setup_command map_init_sound ; 02
setup_command map_play_music ; 03
setup_command map_restart_music ; 04
setup_command map_fade_to_music ; 05
setup_command map_fade_music_and_palettes ; 06
setup_command map_play_music_bike ; 07
setup_command map_force_music ; 08
setup_command map_fade_in_to_music ; 09
setup_command map_load_block_data ; 0a
setup_command map_load_connection_block_data ; 0b
setup_command map_save_screen ; 0c
setup_command map_buffer_screen ; 0d
setup_command map_load_graphics ; 0e
setup_command map_load_tileset ; 0f
setup_command map_load_time_of_day ; 10
setup_command map_load_palettes ; 11
setup_command map_load_wild_mon_data ; 12
setup_command map_refresh_sprites ; 13
setup_command map_handle_new ; 14
setup_command map_handle_continue ; 15
setup_command map_load_objects ; 16
setup_command map_enter_spawn_point ; 17
setup_command map_enter_connection ; 18
setup_command map_enter_warp ; 19
setup_command map_load_attributes ; 1a
setup_command map_load_attributes_no_objects ; 1b
setup_command map_clear_bg_palettes ; 1c
setup_command map_fade_out_palettes ; 1d
setup_command map_fade_in_palettes ; 1e
setup_command map_get_screen_coords ; 1f
setup_command map_get_warp_dest_coords ; 20
setup_command map_spawn_in_facing_down ; 21
setup_command map_spawn_player ; 22
setup_command map_refresh_player_coords ; 23
setup_command map_reset_player_object_action ; 24
setup_command map_skip_update_sprites ; 25
setup_command map_update_roam_mons ; 26
setup_command map_jump_roam_mons ; 27
setup_command map_fade_out_music ; 28
setup_command map_activate_anims ; 29
setup_command map_suspend_anims ; 2a
setup_command map_apply_palettes ; 2b
setup_command map_enable_text_acceleration ; 2c
setup_command map_init_name_sign ; 2d
const_def -1, -1
setup_command map_end ; ff