ref: d132a20b7aa5e0e411683e792d90947ab195e1d4
parent: dbabd8b4a94014749a9c2a6f36ed524947c4403e
author: Rangi <[email protected]>
date: Thu Mar 11 11:28:52 EST 2021
Verify script command table sizes
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -1365,6 +1365,7 @@
MusicCommands:
; entries correspond to audio constants (see macros/scripts/audio.asm)
+ table_width 2, MusicCommands
dw Music_Octave8
dw Music_Octave7
dw Music_Octave6
@@ -1413,6 +1414,7 @@
dw Music_Loop
dw Music_Call
dw Music_Ret
+ assert_table_length $100 - FIRST_MUSIC_CMD
MusicF1:
MusicF2:
--- a/engine/battle_anims/anim_commands.asm
+++ b/engine/battle_anims/anim_commands.asm
@@ -329,6 +329,7 @@
BattleAnimCommands::
; entries correspond to anim_* constants (see macros/scripts/battle_anims.asm)
+ table_width 2, BattleAnimCommands
dw BattleAnimCmd_Obj
dw BattleAnimCmd_1GFX
dw BattleAnimCmd_2GFX
@@ -377,6 +378,7 @@
dw BattleAnimCmd_Loop
dw BattleAnimCmd_Call
dw BattleAnimCmd_Ret
+ assert_table_length $100 - FIRST_BATTLE_ANIM_CMD
BattleAnimCmd_EA:
BattleAnimCmd_EB:
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -1,5 +1,6 @@
MovementPointers:
; entries correspond to movement_* constants (see macros/scripts/movement.asm)
+ table_width 2, MovementPointers
dw Movement_turn_head_down ; 00
dw Movement_turn_head_up ; 01
dw Movement_turn_head_left ; 02
@@ -90,6 +91,7 @@
dw Movement_rock_smash ; 57
dw Movement_return_dig ; 58
dw Movement_skyfall_top ; 59
+ assert_table_length NUM_MOVEMENT_CMDS
Movement_teleport_from:
ld hl, OBJECT_STEP_TYPE
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -63,6 +63,7 @@
ScriptCommandTable:
; entries correspond to *_command constants (see macros/scripts/events.asm)
+ table_width 2, ScriptCommandTable
dw Script_scall ; 00
dw Script_farscall ; 01
dw Script_memcall ; 02
@@ -233,6 +234,7 @@
dw Script_getname ; a7
dw Script_wait ; a8
dw Script_checksave ; a9
+ assert_table_length NUM_EVENT_COMMANDS
StartScript:
ld hl, wScriptFlags
--- a/home/text.asm
+++ b/home/text.asm
@@ -699,6 +699,7 @@
TextCommands::
; entries correspond to TX_* constants (see macros/scripts/text.asm)
+ table_width 2, TextCommands
dw TextCommand_START ; TX_START
dw TextCommand_RAM ; TX_RAM
dw TextCommand_BCD ; TX_BCD
@@ -722,6 +723,7 @@
dw TextCommand_STRINGBUFFER ; TX_STRINGBUFFER
dw TextCommand_DAY ; TX_DAY
dw TextCommand_FAR ; TX_FAR
+ assert_table_length NUM_TEXT_CMDS
TextCommand_START::
; write text until "@"
--- a/macros/scripts/battle_anims.asm
+++ b/macros/scripts/battle_anims.asm
@@ -5,6 +5,7 @@
; BattleAnimCommands indexes (see engine/battle_anims/anim_commands.asm)
const_def $d0
+FIRST_BATTLE_ANIM_CMD EQU const_value
const anim_obj_command ; $d0
anim_obj: MACRO
--- a/macros/scripts/events.asm
+++ b/macros/scripts/events.asm
@@ -1062,3 +1062,5 @@
checksave: MACRO
db checksave_command
ENDM
+
+NUM_EVENT_COMMANDS EQU const_value
--- a/macros/scripts/movement.asm
+++ b/macros/scripts/movement.asm
@@ -218,3 +218,5 @@
skyfall_top: MACRO
db movement_skyfall_top
ENDM
+
+NUM_MOVEMENT_CMDS EQU const_value
--- a/macros/scripts/text.asm
+++ b/macros/scripts/text.asm
@@ -137,6 +137,8 @@
db BANK(\1)
ENDM
+NUM_TEXT_CMDS EQU const_value
+
const_next $50
const TX_END ; $50