ref: eca33ef190d3dfcb15e24f1e7e9dac4de9ac3437
parent: d626a0dc3b0ba5d3c4f9984321a5a26941e8ec61
author: Rangi <[email protected]>
date: Mon Jul 13 16:44:16 EDT 2020
Define map setup commands as macros like other script commands
--- a/constants/map_setup_constants.asm
+++ b/constants/map_setup_constants.asm
@@ -14,56 +14,6 @@
const MAPSETUP_BADWARP ; fb
const MAPSETUP_FLY ; fc
-; MapSetupCommands indexes (see engine/overworld/map_setup.asm)
- const_def
- const map_enable_lcd ; 00
- const map_disable_lcd ; 01
- const map_init_sound ; 02
- const map_play_music ; 03
- const map_restart_music ; 04
- const map_fade_to_music ; 05
- const map_fade_music_and_palettes ; 06
- const map_play_music_bike ; 07
- const map_force_music ; 08
- const map_fade_in_to_music ; 09
- const map_load_block_data ; 0a
- const map_load_connection_block_data ; 0b
- const map_save_screen ; 0c
- const map_buffer_screen ; 0d
- const map_load_graphics ; 0e
- const map_load_tileset ; 0f
- const map_load_time_of_day ; 10
- const map_load_palettes ; 11
- const map_load_wild_mon_data ; 12
- const map_refresh_sprites ; 13
- const map_handle_new ; 14
- const map_handle_continue ; 15
- const map_load_objects ; 16
- const map_enter_spawn_point ; 17
- const map_enter_connection ; 18
- const map_enter_warp ; 19
- const map_load_attributes ; 1a
- const map_load_attributes_no_objects ; 1b
- const map_clear_bg_palettes ; 1c
- const map_fade_out_palettes ; 1d
- const map_fade_in_palettes ; 1e
- const map_get_screen_coords ; 1f
- const map_get_warp_dest_coords ; 20
- const map_spawn_in_facing_down ; 21
- const map_spawn_player ; 22
- const map_refresh_player_coords ; 23
- const map_reset_player_object_action ; 24
- const map_skip_update_sprites ; 25
- const map_update_roam_mons ; 26
- const map_jump_roam_mons ; 27
- const map_fade_out_music ; 28
- const map_activate_anims ; 29
- const map_suspend_anims ; 2a
- const map_apply_palettes ; 2b
- const map_enable_text_acceleration ; 2c
- const map_init_name_sign ; 2d
-map_end EQU -1
-
; callback types
const_def 1
const MAPCALLBACK_TILES
--- /dev/null
+++ b/data/maps/setup_script_pointers.asm
@@ -1,0 +1,48 @@
+MapSetupCommands:
+; entries correspond to map_*_command constants (see macros/scripts/map_setup.asm)
+ dba EnableLCD ; 00
+ dba DisableLCD ; 01
+ dba InitSound ; 02
+ dba PlayMapMusic ; 03
+ dba RestartMapMusic ; 04
+ dba FadeToMapMusic ; 05
+ dba FadeMapMusicAndPalettes ; 06
+ dba PlayMapMusicBike ; 07
+ dba ForceMapMusic ; 08
+ dba FadeInToMusic ; 09
+ dba LoadBlockData ; 0a (callback 1)
+ dba LoadConnectionBlockData ; 0b
+ dba SaveScreen ; 0c
+ dba BufferScreen ; 0d
+ dba LoadMapGraphics ; 0e
+ dba LoadMapTileset ; 0f
+ dba LoadMapTimeOfDay ; 10
+ dba LoadMapPalettes ; 11
+ dba LoadWildMonData ; 12
+ dba RefreshMapSprites ; 13
+ dba HandleNewMap ; 14
+ dba HandleContinueMap ; 15
+ dba LoadMapObjects ; 16
+ dba EnterMapSpawnPoint ; 17
+ dba EnterMapConnection ; 18
+ dba EnterMapWarp ; 19
+ dba LoadMapAttributes ; 1a
+ dba LoadMapAttributes_SkipObjects ; 1b
+ dba ClearBGPalettes ; 1c
+ dba FadeOutPalettes ; 1d
+ dba FadeInPalettes ; 1e
+ dba GetMapScreenCoords ; 1f
+ dba GetWarpDestCoords ; 20
+ dba SpawnInFacingDown ; 21
+ dba SpawnPlayer ; 22
+ dba RefreshPlayerCoords ; 23
+ dba ResetPlayerObjectAction ; 24
+ dba SkipUpdateMapSprites ; 25
+ dba UpdateRoamMons ; 26
+ dba JumpRoamMons ; 27
+ dba FadeOutMapMusic ; 28
+ dba ActivateMapAnims ; 29
+ dba SuspendMapAnims ; 2a
+ dba ApplyMapPalettes ; 2b
+ dba EnableTextAcceleration ; 2c
+ dba InitMapNameSign ; 2d
--- a/data/maps/setup_scripts.asm
+++ b/data/maps/setup_scripts.asm
@@ -14,163 +14,163 @@
dw MapSetupScript_Fly
MapSetupScript_Teleport:
- db map_reset_player_object_action
+ map_reset_player_object_action
MapSetupScript_Fly:
- db map_fade_out_palettes
- db map_jump_roam_mons
+ map_fade_out_palettes
+ map_jump_roam_mons
MapSetupScript_Warp:
- db map_disable_lcd
- db map_init_sound
- db map_enter_spawn_point
- db map_load_attributes
- db map_handle_new
- db map_spawn_player
- db map_refresh_player_coords
- db map_get_screen_coords
- db map_load_block_data
- db map_buffer_screen
- db map_load_graphics
- db map_load_time_of_day
- db map_load_objects
- db map_enable_lcd
- db map_load_palettes
- db map_spawn_in_facing_down
- db map_refresh_sprites
- db map_play_music_bike
- db map_fade_in_to_music
- db map_fade_in_palettes
- db map_activate_anims
- db map_load_wild_mon_data
- db map_end
+ map_disable_lcd
+ map_init_sound
+ map_enter_spawn_point
+ map_load_attributes
+ map_handle_new
+ map_spawn_player
+ map_refresh_player_coords
+ map_get_screen_coords
+ map_load_block_data
+ map_buffer_screen
+ map_load_graphics
+ map_load_time_of_day
+ map_load_objects
+ map_enable_lcd
+ map_load_palettes
+ map_spawn_in_facing_down
+ map_refresh_sprites
+ map_play_music_bike
+ map_fade_in_to_music
+ map_fade_in_palettes
+ map_activate_anims
+ map_load_wild_mon_data
+ map_end
MapSetupScript_BadWarp:
- db map_enter_spawn_point
- db map_load_attributes
- db map_handle_new
- db map_spawn_player
- db map_refresh_player_coords
- db map_get_screen_coords
- db map_load_block_data
- db map_buffer_screen
- db map_disable_lcd
- db map_load_graphics
- db map_load_time_of_day
- db map_fade_out_music
- db map_enable_lcd
- db map_load_objects
- db map_load_palettes
- db map_spawn_in_facing_down
- db map_refresh_sprites
- db map_fade_to_music
- db map_fade_in_palettes
- db map_activate_anims
- db map_load_wild_mon_data
- db map_end
+ map_enter_spawn_point
+ map_load_attributes
+ map_handle_new
+ map_spawn_player
+ map_refresh_player_coords
+ map_get_screen_coords
+ map_load_block_data
+ map_buffer_screen
+ map_disable_lcd
+ map_load_graphics
+ map_load_time_of_day
+ map_fade_out_music
+ map_enable_lcd
+ map_load_objects
+ map_load_palettes
+ map_spawn_in_facing_down
+ map_refresh_sprites
+ map_fade_to_music
+ map_fade_in_palettes
+ map_activate_anims
+ map_load_wild_mon_data
+ map_end
MapSetupScript_Connection:
- db map_suspend_anims
- db map_enter_connection
- db map_load_attributes
- db map_handle_new
- db map_refresh_player_coords
- db map_load_block_data
- db map_load_tileset
- db map_save_screen
- db map_load_objects
- db map_fade_to_music
- db map_load_palettes
- db map_init_name_sign
- db map_apply_palettes
- db map_load_wild_mon_data
- db map_update_roam_mons
- db map_activate_anims
- db map_end
+ map_suspend_anims
+ map_enter_connection
+ map_load_attributes
+ map_handle_new
+ map_refresh_player_coords
+ map_load_block_data
+ map_load_tileset
+ map_save_screen
+ map_load_objects
+ map_fade_to_music
+ map_load_palettes
+ map_init_name_sign
+ map_apply_palettes
+ map_load_wild_mon_data
+ map_update_roam_mons
+ map_activate_anims
+ map_end
MapSetupScript_Fall:
- db map_reset_player_object_action
+ map_reset_player_object_action
MapSetupScript_Door:
- db map_fade_out_palettes
+ map_fade_out_palettes
MapSetupScript_Train:
- db map_enter_warp
- db map_load_attributes
- db map_get_warp_dest_coords
- db map_handle_new
- db map_refresh_player_coords
- db map_load_block_data
- db map_buffer_screen
- db map_disable_lcd
- db map_load_graphics
- db map_load_time_of_day
- db map_fade_out_music
- db map_enable_lcd
- db map_load_objects
- db map_load_palettes
- db map_refresh_sprites
- db map_fade_to_music
- db map_fade_in_palettes
- db map_activate_anims
- db map_load_wild_mon_data
- db map_update_roam_mons
- db map_end
+ map_enter_warp
+ map_load_attributes
+ map_get_warp_dest_coords
+ map_handle_new
+ map_refresh_player_coords
+ map_load_block_data
+ map_buffer_screen
+ map_disable_lcd
+ map_load_graphics
+ map_load_time_of_day
+ map_fade_out_music
+ map_enable_lcd
+ map_load_objects
+ map_load_palettes
+ map_refresh_sprites
+ map_fade_to_music
+ map_fade_in_palettes
+ map_activate_anims
+ map_load_wild_mon_data
+ map_update_roam_mons
+ map_end
MapSetupScript_ReloadMap:
- db map_fade_music_and_palettes
- db map_clear_bg_palettes
- db map_disable_lcd
- db map_init_sound
- db map_load_block_data
- db map_load_connection_block_data
- db map_load_graphics
- db map_load_time_of_day
- db map_enable_lcd
- db map_load_palettes
- db map_refresh_sprites
- db map_force_music
- db map_fade_in_palettes
- db map_activate_anims
- db map_load_wild_mon_data
- db map_end
+ map_fade_music_and_palettes
+ map_clear_bg_palettes
+ map_disable_lcd
+ map_init_sound
+ map_load_block_data
+ map_load_connection_block_data
+ map_load_graphics
+ map_load_time_of_day
+ map_enable_lcd
+ map_load_palettes
+ map_refresh_sprites
+ map_force_music
+ map_fade_in_palettes
+ map_activate_anims
+ map_load_wild_mon_data
+ map_end
MapSetupScript_LinkReturn:
- db map_fade_music_and_palettes
- db map_disable_lcd
- db map_init_sound
- db map_handle_new
- db map_load_block_data
- db map_buffer_screen
- db map_load_graphics
- db map_load_time_of_day
- db map_enable_lcd
- db map_load_palettes
- db map_refresh_sprites
- db map_play_music_bike
- db map_fade_in_palettes
- db map_activate_anims
- db map_load_wild_mon_data
- db map_enable_text_acceleration
- db map_end
+ map_fade_music_and_palettes
+ map_disable_lcd
+ map_init_sound
+ map_handle_new
+ map_load_block_data
+ map_buffer_screen
+ map_load_graphics
+ map_load_time_of_day
+ map_enable_lcd
+ map_load_palettes
+ map_refresh_sprites
+ map_play_music_bike
+ map_fade_in_palettes
+ map_activate_anims
+ map_load_wild_mon_data
+ map_enable_text_acceleration
+ map_end
MapSetupScript_Continue:
- db map_disable_lcd
- db map_init_sound
- db map_load_attributes_no_objects
- db map_get_screen_coords
- db map_handle_continue
- db map_load_block_data
- db map_load_connection_block_data
- db map_buffer_screen
- db map_load_graphics
- db map_load_time_of_day
- db map_enable_lcd
- db map_load_palettes
- db map_refresh_sprites
- db map_play_music_bike
- db map_fade_in_palettes
- db map_activate_anims
- db map_load_wild_mon_data
- db map_end
+ map_disable_lcd
+ map_init_sound
+ map_load_attributes_no_objects
+ map_get_screen_coords
+ map_handle_continue
+ map_load_block_data
+ map_load_connection_block_data
+ map_buffer_screen
+ map_load_graphics
+ map_load_time_of_day
+ map_enable_lcd
+ map_load_palettes
+ map_refresh_sprites
+ map_play_music_bike
+ map_fade_in_palettes
+ map_activate_anims
+ map_load_wild_mon_data
+ map_end
MapSetupScript_Submenu:
- db map_load_block_data
- db map_load_connection_block_data
- db map_end
+ map_load_block_data
+ map_load_connection_block_data
+ map_end
--- a/docs/index.md
+++ b/docs/index.md
@@ -13,6 +13,7 @@
- [event_commands.md](event_commands.md)
- [movement_commands.md](movement_commands.md)
- [text_commands.md](text_commands.md)
+- [map_setup_scripts.md](map_setup_scripts.md)
## Other types of scripts
--- /dev/null
+++ b/docs/map_setup_scripts.md
@@ -1,0 +1,144 @@
+# Map Setup Commands
+
+Defined in [macros/scripts/map_setup.asm](https://github.com/pret/pokecrystal/blob/master/macros/scripts/map_setup.asm) and [data/maps/setup_script_pointers.asm:MapSetupCommands](https://github.com/pret/pokecrystal/blob/master/data/maps/setup_script_pointers.asm).
+
+
+## `$00`: `map_enable_lcd`
+
+
+## `$01`: `map_disable_lcd`
+
+
+## `$02`: `map_init_sound`
+
+
+## `$03`: `map_play_music`
+
+
+## `$04`: `map_restart_music`
+
+
+## `$05`: `map_fade_to_music`
+
+
+## `$06`: `map_fade_music_and_palettes`
+
+
+## `$07`: `map_play_music_bike`
+
+
+## `$08`: `map_force_music`
+
+
+## `$09`: `map_fade_in_to_music`
+
+
+## `$0A`: `map_load_block_data`
+
+
+## `$0B`: `map_load_connection_block_data`
+
+
+## `$0C`: `map_save_screen`
+
+
+## `$0D`: `map_buffer_screen`
+
+
+## `$0E`: `map_load_graphics`
+
+
+## `$0F`: `map_load_tileset`
+
+
+## `$10`: `map_load_time_of_day`
+
+
+## `$11`: `map_load_palettes`
+
+
+## `$12`: `map_load_wild_mon_data`
+
+
+## `$13`: `map_refresh_sprites`
+
+
+## `$14`: `map_handle_new`
+
+
+## `$15`: `map_handle_continue`
+
+
+## `$16`: `map_load_objects`
+
+
+## `$17`: `map_enter_spawn_point`
+
+
+## `$18`: `map_enter_connection`
+
+
+## `$19`: `map_enter_warp`
+
+
+## `$1A`: `map_load_attributes`
+
+
+## `$1B`: `map_load_attributes_no_objects`
+
+
+## `$1C`: `map_clear_bg_palettes`
+
+
+## `$1D`: `map_fade_out_palettes`
+
+
+## `$1E`: `map_fade_in_palettes`
+
+
+## `$1F`: `map_get_screen_coords`
+
+
+## `$20`: `map_get_warp_dest_coords`
+
+
+## `$21`: `map_spawn_in_facing_down`
+
+
+## `$22`: `map_spawn_player`
+
+
+## `$23`: `map_refresh_player_coords`
+
+
+## `$24`: `map_reset_player_object_action`
+
+
+## `$25`: `map_skip_update_sprites`
+
+
+## `$26`: `map_update_roam_mons`
+
+
+## `$27`: `map_jump_roam_mons`
+
+
+## `$28`: `map_fade_out_music`
+
+
+## `$29`: `map_activate_anims`
+
+
+## `$2A`: `map_suspend_anims`
+
+
+## `$2B`: `map_apply_palettes`
+
+
+## `$2C`: `map_enable_text_acceleration`
+
+
+## `$2D`: `map_init_name_sign`
+
+
+## `$FF`: `map_end`
--- a/engine/overworld/map_setup.asm
+++ b/engine/overworld/map_setup.asm
@@ -18,7 +18,7 @@
ReadMapSetupScript:
.loop
ld a, [hli]
- cp map_end
+ cp map_end_command
ret z
push hl
@@ -58,54 +58,7 @@
pop hl
jr .loop
-MapSetupCommands:
-; entries correspond to command indexes in constants/map_setup_constants.asm
- dba EnableLCD ; 00
- dba DisableLCD ; 01
- dba InitSound ; 02
- dba PlayMapMusic ; 03
- dba RestartMapMusic ; 04
- dba FadeToMapMusic ; 05
- dba FadeMapMusicAndPalettes ; 06
- dba PlayMapMusicBike ; 07
- dba ForceMapMusic ; 08
- dba FadeInToMusic ; 09
- dba LoadBlockData ; 0a (callback 1)
- dba LoadConnectionBlockData ; 0b
- dba SaveScreen ; 0c
- dba BufferScreen ; 0d
- dba LoadMapGraphics ; 0e
- dba LoadMapTileset ; 0f
- dba LoadMapTimeOfDay ; 10
- dba LoadMapPalettes ; 11
- dba LoadWildMonData ; 12
- dba RefreshMapSprites ; 13
- dba HandleNewMap ; 14
- dba HandleContinueMap ; 15
- dba LoadMapObjects ; 16
- dba EnterMapSpawnPoint ; 17
- dba EnterMapConnection ; 18
- dba EnterMapWarp ; 19
- dba LoadMapAttributes ; 1a
- dba LoadMapAttributes_SkipObjects ; 1b
- dba ClearBGPalettes ; 1c
- dba FadeOutPalettes ; 1d
- dba FadeInPalettes ; 1e
- dba GetMapScreenCoords ; 1f
- dba GetWarpDestCoords ; 20
- dba SpawnInFacingDown ; 21
- dba SpawnPlayer ; 22
- dba RefreshPlayerCoords ; 23
- dba ResetPlayerObjectAction ; 24
- dba SkipUpdateMapSprites ; 25
- dba UpdateRoamMons ; 26
- dba JumpRoamMons ; 27
- dba FadeOutMapMusic ; 28
- dba ActivateMapAnims ; 29
- dba SuspendMapAnims ; 2a
- dba ApplyMapPalettes ; 2b
- dba EnableTextAcceleration ; 2c
- dba InitMapNameSign ; 2d
+INCLUDE "data/maps/setup_script_pointers.asm"
EnableTextAcceleration:
xor a
--- a/macros.asm
+++ b/macros.asm
@@ -11,6 +11,7 @@
INCLUDE "macros/scripts/events.asm"
INCLUDE "macros/scripts/text.asm"
INCLUDE "macros/scripts/movement.asm"
+INCLUDE "macros/scripts/map_setup.asm"
INCLUDE "macros/scripts/battle_commands.asm"
INCLUDE "macros/scripts/battle_anims.asm"
INCLUDE "macros/scripts/trade_anims.asm"
--- /dev/null
+++ b/macros/scripts/map_setup.asm
@@ -1,0 +1,56 @@
+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