ref: 739a60b33c54021c975f22d627e4b5e40206fe37
parent: 1c41b2e579315ca582157fb3c824bda8ce4ecbbe
author: mid-kid <esteve.varela@gmail.com>
date: Mon Nov 18 13:16:50 EST 2019
Make the map setup commands match the actual function names better These functions used as map setup commands are used in other places, too, so I can't prefix them under the same. The names should match except I won't repeat "map" in a map setup command name.
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -6,7 +6,7 @@
; FadeMusic
; PlayStereoSFX
-_MapSetup_Sound_Off::
+_InitSound::
; restart sound operation
; clear all relevant hardware registers & wram
push hl
@@ -62,7 +62,7 @@
push af
ld a, [wMusicFadeID]
push af
- call _MapSetup_Sound_Off
+ call _InitSound
pop af
ld [wMusicFadeID], a
pop af
@@ -2797,7 +2797,7 @@
ClearChannels::
; runs ClearChannel for all 4 channels
-; doesn't seem to be used, but functionally identical to MapSetup_Sound_Off
+; doesn't seem to be used, but functionally identical to InitSound
ld hl, rNR50
xor a
ld [hli], a
--- a/constants/map_setup_constants.asm
+++ b/constants/map_setup_constants.asm
@@ -15,55 +15,53 @@
const MAPSETUP_FLY ; fc
; MapSetupCommands indexes (see engine/overworld/map_setup.asm)
-; Names taken from Condensation water's scripting compendium
-; https://hax.iimarck.us/files/scriptingcodes_eng.htm
const_def
- const map_lcd_on ; 00
- const map_lcd_off ; 01
- const map_sound_off ; 02
- const map_music ; 03
- const map_start_music ; 04
- const map_fade_music ; 05
- const map_fade ; 06
- const map_bike_music ; 07
- const map_music_force ; 08
- const map_max_volume ; 09
- const map_load_blocks ; 0a
- const map_connection_blocks ; 0b
- const map_save_screen ; 0c
- const map_buffer_screen ; 0d
- const map_load_graphics ; 0e
- const map_load_tileset ; 0f
- const map_time_of_day ; 10
- const map_palettes ; 11
- const map_wildmons ; 12
- const map_sprites ; 13
- const map_change_callback ; 14
- const map_start_callback ; 15
- const map_load_objects ; 16
- const map_load_spawn ; 17
- const map_load_connection ; 18
- const map_load_warp ; 19
- const map_load_attributes ; 1a
- const map_load_attributes_2 ; 1b
- const map_clear_bg_palettes ; 1c
- const map_fade_out_palettes ; 1d
- const map_fade_in_palettes ; 1e
- const map_anchor_screen ; 1f
- const map_warp_face ; 20
- const map_face_down ; 21
- const map_spawn_coord ; 22
- const map_player_coord ; 23
- const map_prolong_sprites ; 24
- const map_delay_sprites ; 25
- const map_update_roam ; 26
- const map_keep_roam ; 27
- const map_fade_out_music ; 28
- const map_animations_on ; 29
- const map_animations_off ; 2a
- const map_keep_palettes ; 2b
- const map_text_scroll_off ; 2c
- const map_stop_script ; 2d
+ 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_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
--- a/data/maps/setup_scripts.asm
+++ b/data/maps/setup_scripts.asm
@@ -14,163 +14,163 @@
dw MapSetupScript_Fly
MapSetupScript_Teleport:
- db map_prolong_sprites
+ db map_reset_player_object_action
MapSetupScript_Fly:
db map_fade_out_palettes
- db map_keep_roam
+ db map_jump_roam_mons
MapSetupScript_Warp:
- db map_lcd_off
- db map_sound_off
- db map_load_spawn
+ db map_disable_lcd
+ db map_init_sound
+ db map_enter_spawn_point
db map_load_attributes
- db map_change_callback
- db map_spawn_coord
- db map_player_coord
- db map_anchor_screen
- db map_load_blocks
+ 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_time_of_day
+ db map_load_time_of_day
db map_load_objects
- db map_lcd_on
- db map_palettes
- db map_face_down
- db map_sprites
- db map_bike_music
- db map_max_volume
+ 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_music
db map_fade_in_palettes
- db map_animations_on
- db map_wildmons
+ db map_activate_anims
+ db map_load_wild_mon_data
db map_end
MapSetupScript_BadWarp:
- db map_load_spawn
+ db map_enter_spawn_point
db map_load_attributes
- db map_change_callback
- db map_spawn_coord
- db map_player_coord
- db map_anchor_screen
- db map_load_blocks
+ 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_lcd_off
+ db map_disable_lcd
db map_load_graphics
- db map_time_of_day
+ db map_load_time_of_day
db map_fade_out_music
- db map_lcd_on
+ db map_enable_lcd
db map_load_objects
- db map_palettes
- db map_face_down
- db map_sprites
- db map_fade_music
+ 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_animations_on
- db map_wildmons
+ db map_activate_anims
+ db map_load_wild_mon_data
db map_end
MapSetupScript_Connection:
- db map_animations_off
- db map_load_connection
+ db map_suspend_anims
+ db map_enter_connection
db map_load_attributes
- db map_change_callback
- db map_player_coord
- db map_load_blocks
+ 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_music
- db map_palettes
- db map_stop_script
- db map_keep_palettes
- db map_wildmons
- db map_update_roam
- db map_animations_on
+ 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
MapSetupScript_Fall:
- db map_prolong_sprites
+ db map_reset_player_object_action
MapSetupScript_Door:
db map_fade_out_palettes
MapSetupScript_Train:
- db map_load_warp
+ db map_enter_warp
db map_load_attributes
- db map_warp_face
- db map_change_callback
- db map_player_coord
- db map_load_blocks
+ 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_lcd_off
+ db map_disable_lcd
db map_load_graphics
- db map_time_of_day
+ db map_load_time_of_day
db map_fade_out_music
- db map_lcd_on
+ db map_enable_lcd
db map_load_objects
- db map_palettes
- db map_sprites
- db map_fade_music
+ db map_load_palettes
+ db map_refresh_sprites
+ db map_fade_to_music
db map_fade_in_palettes
- db map_animations_on
- db map_wildmons
- db map_update_roam
+ db map_activate_anims
+ db map_load_wild_mon_data
+ db map_update_roam_mons
db map_end
MapSetupScript_ReloadMap:
- db map_fade
+ db map_fade_music_and_palettes
db map_clear_bg_palettes
- db map_lcd_off
- db map_sound_off
- db map_load_blocks
- db map_connection_blocks
+ 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_time_of_day
- db map_lcd_on
- db map_palettes
- db map_sprites
- db map_music_force
+ 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_animations_on
- db map_wildmons
+ db map_activate_anims
+ db map_load_wild_mon_data
db map_end
MapSetupScript_LinkReturn:
- db map_fade
- db map_lcd_off
- db map_sound_off
- db map_change_callback
- db map_load_blocks
+ 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_time_of_day
- db map_lcd_on
- db map_palettes
- db map_sprites
- db map_bike_music
+ 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_animations_on
- db map_wildmons
- db map_text_scroll_off
+ db map_activate_anims
+ db map_load_wild_mon_data
+ db map_enable_text_acceleration
db map_end
MapSetupScript_Continue:
- db map_lcd_off
- db map_sound_off
- db map_load_attributes_2
- db map_anchor_screen
- db map_start_callback
- db map_load_blocks
- db map_connection_blocks
+ 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_time_of_day
- db map_lcd_on
- db map_palettes
- db map_sprites
- db map_bike_music
+ 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_animations_on
- db map_wildmons
+ db map_activate_anims
+ db map_load_wild_mon_data
db map_end
MapSetupScript_Submenu:
- db map_load_blocks
- db map_connection_blocks
+ db map_load_block_data
+ db map_load_connection_block_data
db map_end
--- a/engine/events/map_name_sign.asm
+++ b/engine/events/map_name_sign.asm
@@ -1,6 +1,6 @@
MAP_NAME_SIGN_START EQU $60
-ReturnFromMapSetupScript::
+InitMapNameSign::
xor a
ldh [hBGMapMode], a
farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -617,7 +617,7 @@
callasm FlyFromAnim
farscall Script_AbortBugContest
special WarpToSpawnPoint
- callasm DelayLoadingNewSprites
+ callasm SkipUpdateMapSprites
loadvar VAR_MOVEMENT, PLAYER_NORMAL
newloadmap MAPSETUP_FLY
callasm FlyToAnim
--- a/engine/overworld/map_setup.asm
+++ b/engine/overworld/map_setup.asm
@@ -18,7 +18,7 @@
ReadMapSetupScript:
.loop
ld a, [hli]
- cp -1
+ cp map_end
ret z
push hl
@@ -62,52 +62,52 @@
; entries correspond to command indexes in constants/map_setup_constants.asm
dba EnableLCD ; 00
dba DisableLCD ; 01
- dba MapSetup_Sound_Off ; 02
+ dba InitSound ; 02
dba PlayMapMusic ; 03
dba RestartMapMusic ; 04
dba FadeToMapMusic ; 05
- dba RotatePalettesRightMapAndMusic ; 06
- dba EnterMapMusic ; 07
+ dba FadeMapMusicAndPalettes ; 06
+ dba PlayMapMusicBike ; 07
dba ForceMapMusic ; 08
dba FadeInMusic ; 09
dba LoadBlockData ; 0a (callback 1)
- dba LoadNeighboringBlockData ; 0b
+ dba LoadConnectionBlockData ; 0b
dba SaveScreen ; 0c
dba BufferScreen ; 0d
- dba LoadGraphics ; 0e
- dba LoadTileset ; 0f
+ dba LoadMapGraphics ; 0e
+ dba LoadMapTileset ; 0f
dba LoadMapTimeOfDay ; 10
dba LoadMapPalettes ; 11
dba LoadWildMonData ; 12
dba RefreshMapSprites ; 13
dba HandleNewMap ; 14
- dba InitCommandQueue ; 15
- dba LoadObjectsRunCallback_02 ; 16
- dba LoadSpawnPoint ; 17
+ dba HandleContinueMap ; 15
+ dba LoadMapObjects ; 16
+ dba EnterMapSpawnPoint ; 17
dba EnterMapConnection ; 18
- dba LoadWarpData ; 19
+ dba EnterMapWarp ; 19
dba LoadMapAttributes ; 1a
- dba LoadMapAttributes_SkipPeople ; 1b
+ dba LoadMapAttributes_SkipObjects ; 1b
dba ClearBGPalettes ; 1c
dba FadeOutPalettes ; 1d
dba FadeInPalettes ; 1e
- dba GetCoordOfUpperLeftCorner ; 1f
- dba RestoreFacingAfterWarp ; 20
+ dba GetMapScreenCoords ; 1f
+ dba GetWarpDestCoords ; 20
dba SpawnInFacingDown ; 21
dba SpawnPlayer ; 22
dba RefreshPlayerCoords ; 23
- dba DelayClearingOldSprites ; 24
- dba DelayLoadingNewSprites ; 25
+ dba ResetPlayerObjectAction ; 24
+ dba SkipUpdateMapSprites ; 25
dba UpdateRoamMons ; 26
dba JumpRoamMons ; 27
- dba FadeOldMapMusic ; 28
+ dba FadeOutMapMusic ; 28
dba ActivateMapAnims ; 29
dba SuspendMapAnims ; 2a
- dba RetainOldPalettes ; 2b
- dba DontScrollText ; 2c
- dba ReturnFromMapSetupScript ; 2d
+ dba ApplyMapPalettes ; 2b
+ dba EnableTextAcceleration ; 2c
+ dba InitMapNameSign ; 2d
-DontScrollText:
+EnableTextAcceleration:
xor a
ld [wDisableTextAcceleration], a
ret
@@ -122,7 +122,7 @@
ldh [hMapAnims], a
ret
-LoadObjectsRunCallback_02:
+LoadMapObjects:
ld a, MAPCALLBACK_OBJECTS
call RunMapCallback
farcall LoadObjectMasks
@@ -132,12 +132,12 @@
; unused
ret
-DelayClearingOldSprites:
+ResetPlayerObjectAction:
ld hl, wPlayerSpriteSetupFlags
set PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
ret
-DelayLoadingNewSprites:
+SkipUpdateMapSprites:
ld hl, wPlayerSpriteSetupFlags
set PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
ret
@@ -215,16 +215,16 @@
and a
ret
-FadeOldMapMusic:
+FadeOutMapMusic:
ld a, 6
call SkipMusic
ret
-RetainOldPalettes:
+ApplyMapPalettes:
farcall _UpdateTimePals
ret
-RotatePalettesRightMapAndMusic:
+FadeMapMusicAndPalettes:
ld e, 0
ld a, [wMusicFadeID]
ld d, 0
--- a/engine/overworld/spawn_points.asm
+++ b/engine/overworld/spawn_points.asm
@@ -1,6 +1,6 @@
INCLUDE "data/maps/spawn_points.asm"
-LoadSpawnPoint:
+EnterMapSpawnPoint:
; loads the spawn point in wDefaultSpawnpoint
push hl
push de
--- a/engine/overworld/warp_connection.asm
+++ b/engine/overworld/warp_connection.asm
@@ -6,7 +6,7 @@
call ResetBikeFlags
ld a, MAPCALLBACK_NEWMAP
call RunMapCallback
-InitCommandQueue:
+HandleContinueMap:
farcall ClearCmdQueue
ld a, MAPCALLBACK_CMDQUEUE
call RunMapCallback
@@ -149,7 +149,7 @@
scf
ret
-LoadWarpData:
+EnterMapWarp:
call .SaveDigWarp
call .SetSpawn
ld a, [wNextWarp]
@@ -295,8 +295,8 @@
ldh [rVBK], a
ret
-LoadGraphics:
- call LoadTileset
+LoadMapGraphics:
+ call LoadMapTileset
call LoadTilesetGFX
xor a
ldh [hMapAnims], a
@@ -313,7 +313,7 @@
RefreshMapSprites:
call ClearSprites
- farcall ReturnFromMapSetupScript
+ farcall InitMapNameSign
call GetMovementPermissions
farcall RefreshPlayerSprite
farcall CheckReplaceKrisSprite
@@ -325,7 +325,7 @@
call SafeUpdateSprites
.skip
ld a, [wPlayerSpriteSetupFlags]
- and %00011100
+ and (1 << PLAYERSPRITESETUP_FEMALE_TO_MALE_F) | (1 << 3) | (1 << 4)
ld [wPlayerSpriteSetupFlags], a
ret
@@ -386,7 +386,7 @@
scf
ret
-GetCoordOfUpperLeftCorner::
+GetMapScreenCoords::
ld hl, wOverworldMapBlocks
ld a, [wXCoord]
bit 0, a
--- a/engine/pokegear/pokegear.asm
+++ b/engine/pokegear/pokegear.asm
@@ -1309,7 +1309,7 @@
cp RESTART_MAP_MUSIC
jr z, .restart_map_music
cp ENTER_MAP_MUSIC
- call z, EnterMapMusic
+ call z, PlayMapMusicBike
xor a
ld [wPokegearRadioMusicPlaying], a
ret
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -1,6 +1,6 @@
; Audio interfaces.
-MapSetup_Sound_Off::
+InitSound::
push hl
push de
push bc
@@ -8,11 +8,11 @@
ldh a, [hROMBank]
push af
- ld a, BANK(_MapSetup_Sound_Off)
+ ld a, BANK(_InitSound)
ldh [hROMBank], a
ld [MBC3RomBank], a
- call _MapSetup_Sound_Off
+ call _InitSound
pop af
ldh [hROMBank], a
@@ -71,7 +71,7 @@
ldh a, [hROMBank]
push af
- ld a, BANK(_PlayMusic) ; aka BANK(_MapSetup_Sound_Off)
+ ld a, BANK(_PlayMusic) ; aka BANK(_InitSound)
ldh [hROMBank], a
ld [MBC3RomBank], a
@@ -83,7 +83,7 @@
jr .end
.nomusic
- call _MapSetup_Sound_Off
+ call _InitSound
.end
pop af
@@ -359,7 +359,8 @@
pop hl
ret
-EnterMapMusic::
+PlayMapMusicBike::
+; If the player's on a bike, play the bike music instead of the map music
push hl
push de
push bc
--- a/home/init.asm
+++ b/home/init.asm
@@ -1,6 +1,6 @@
Reset::
di
- call MapSetup_Sound_Off
+ call InitSound
xor a
ldh [hMapAnims], a
call ClearPalettes
@@ -162,7 +162,7 @@
predef InitSGBBorder ; SGB init
- call MapSetup_Sound_Off
+ call InitSound
xor a
ld [wMapMusic], a
jp GameInit
--- a/home/map.asm
+++ b/home/map.asm
@@ -380,11 +380,11 @@
call CopyMapPartialAndAttributes
call SwitchToMapScriptsBank
call ReadMapScripts
- xor a ; do not skip object_events
+ xor a ; do not skip object events
call ReadMapEvents
ret
-LoadMapAttributes_SkipPeople::
+LoadMapAttributes_SkipObjects::
call CopyMapPartialAndAttributes
call SwitchToMapScriptsBank
call ReadMapScripts
@@ -656,7 +656,7 @@
jr nz, .loop
ret
-RestoreFacingAfterWarp::
+GetWarpDestCoords::
call GetMapScriptsBank
rst Bankswitch
@@ -684,7 +684,7 @@
call .backup
.skip
- farcall GetCoordOfUpperLeftCorner
+ farcall GetMapScreenCoords
ret
.backup
@@ -1437,7 +1437,7 @@
.vertical
ld b, SCREEN_META_WIDTH
ld c, SCREEN_META_HEIGHT - 1
- jr SaveScreen_LoadNeighbor
+ jr SaveScreen_LoadConnection
.left
ld de, wScreenSave + 1
@@ -1449,9 +1449,9 @@
.horizontal
ld b, SCREEN_META_WIDTH - 1
ld c, SCREEN_META_HEIGHT
- jr SaveScreen_LoadNeighbor
+ jr SaveScreen_LoadConnection
-LoadNeighboringBlockData::
+LoadConnectionBlockData::
ld hl, wOverworldMapAnchor
ld a, [hli]
ld h, [hl]
@@ -1463,7 +1463,7 @@
ld b, SCREEN_META_WIDTH
ld c, SCREEN_META_HEIGHT
-SaveScreen_LoadNeighbor::
+SaveScreen_LoadConnection::
.row
push bc
push hl
@@ -1480,7 +1480,6 @@
ld e, a
jr nc, .okay
inc d
-
.okay
pop hl
ldh a, [hConnectionStripLength]
@@ -2259,7 +2258,7 @@
pop de
ret
-LoadTileset::
+LoadMapTileset::
push hl
push bc
--- a/home/window.asm
+++ b/home/window.asm
@@ -39,7 +39,7 @@
ld a, $90
ldh [hWY], a
call ReplaceKrisSprite
- farcall ReturnFromMapSetupScript
+ farcall InitMapNameSign
farcall LoadOverworldFont
ret