From 88a0dd0c249d3e0db4d45906f94c6986edf4f020 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Mon, 19 Feb 2024 08:43:59 -0800 Subject: [PATCH] Add table asserts --- src/audio/level_music.asm | 2 + src/audio/sound_headers.asm | 3 + src/audio/transformation_music.asm | 22 +-- src/audio/waves.asm | 4 + src/constants/audio_constants.asm | 2 + src/constants/cutscene_constants.asm | 4 +- src/constants/level_constants.asm | 4 + src/constants/object_constants.asm | 181 +++++++++++----------- src/constants/particle_constants.asm | 11 +- src/constants/room_constants.asm | 9 ++ src/constants/sound_constants.asm | 1 + src/constants/treasure_constants.asm | 2 +- src/constants/wario_constants.asm | 14 +- src/data/levels/function_tables1.asm | 126 +++++++++++++++ src/data/levels/function_tables2.asm | 52 +++++++ src/engine/action_help/main_power_ups.asm | 3 + src/engine/bank18.asm | 3 + src/engine/bank19.asm | 2 + src/engine/bank20.asm | 6 +- src/engine/bank26.asm | 6 +- src/engine/bank27.asm | 8 +- src/engine/bank2b.asm | 5 +- src/engine/bank30.asm | 18 ++- src/engine/bank35.asm | 2 +- src/engine/bank8.asm | 3 + src/engine/golf/level.asm | 6 +- src/engine/level/particles.asm | 15 +- src/home/home1.asm | 2 +- src/includes.asm | 1 + src/macros/asserts.asm | 17 ++ 30 files changed, 403 insertions(+), 131 deletions(-) create mode 100644 src/macros/asserts.asm diff --git a/src/audio/level_music.asm b/src/audio/level_music.asm index fdb62ab..092e681 100644 --- a/src/audio/level_music.asm +++ b/src/audio/level_music.asm @@ -8,6 +8,7 @@ ENDR ENDM LevelMusic:: + table_width 8 * 2, LevelMusic ; day night level_music MUSIC_OUT_OF_THE_WOODS_DAY, MUSIC_OUT_OF_THE_WOODS_NIGHT ; OUT_OF_THE_WOODS level_music MUSIC_THE_PEACEFUL_VILLAGE_DAY, MUSIC_THE_PEACEFUL_VILLAGE_NIGHT ; THE_PEACEFUL_VILLAGE @@ -34,3 +35,4 @@ LevelMusic:: level_music MUSIC_THE_WARPED_VOID, MUSIC_THE_WARPED_VOID ; THE_WARPED_VOID level_music MUSIC_THE_WEST_CRATER, MUSIC_THE_WEST_CRATER ; THE_EAST_CRATER level_music MUSIC_FOREST_OF_FEAR, MUSIC_FOREST_OF_FEAR ; FOREST_OF_FEAR + assert_table_length NUM_LEVELS diff --git a/src/audio/sound_headers.asm b/src/audio/sound_headers.asm index 675b1c5..31c5338 100644 --- a/src/audio/sound_headers.asm +++ b/src/audio/sound_headers.asm @@ -27,6 +27,7 @@ ENDR ENDM SoundHeaders: + table_width 8, SoundHeaders music Music_OutOfTheWoodsDay, $00, 100, CHAN1_F, 4 ; MUSIC_OUT_OF_THE_WOODS_DAY music Music_OutOfTheWoodsNight, $00, 100, CHAN1_F, 3 ; MUSIC_OUT_OF_THE_WOODS_NIGHT music Music_ForestOfFear, $00, 100, CHAN1_F, 2 ; MUSIC_FOREST_OF_FEAR @@ -85,6 +86,8 @@ SoundHeaders: music Music_Epilogue, $00, 100, CHAN1_F, 3 ; MUSIC_EPILOGUE music Music_HiddenFigureReveal, $00, 100, CHAN1_F, 3 ; MUSIC_HIDDEN_FIGURE_REVEAL music Music_HiddenFigureBattle2, $00, 100, CHAN1_F, 4 ; MUSIC_HIDDEN_FIGURE_BATTLE_2 + assert_table_length NUM_MUSICS + filler_sounds 198 sfx Sfx_Jump, $00, 220, CHAN5_F, 1 ; SFX_JUMP diff --git a/src/audio/transformation_music.asm b/src/audio/transformation_music.asm index 304f82e..91b813d 100644 --- a/src/audio/transformation_music.asm +++ b/src/audio/transformation_music.asm @@ -1,5 +1,6 @@ TransformationMusicIDs:: - dw NULL + table_width 2, TransformationMusicIDs + dw NULL ; TRANSFORMATION_NONE_ID dw MUSIC_HOT_WARIO ; TRANSFORMATION_HOT_WARIO_ID dw MUSIC_FLAT_WARIO ; TRANSFORMATION_FLAT_WARIO_ID dw MUSIC_BALL_O_STRING_WARIO ; TRANSFORMATION_BALL_O_STRING_WARIO_ID @@ -22,12 +23,13 @@ TransformationMusicIDs:: dw NULL ; TRANSFORMATION_LAUNCHED_ID dw NULL ; TRANSFORMATION_MAGIC_ID dw NULL ; TRANSFORMATION_BALL_ID - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL + dw NULL ; TRANSFORMATION_UNUSED_17_ID + dw NULL ; TRANSFORMATION_UNUSED_18_ID + dw NULL ; TRANSFORMATION_UNUSED_19_ID + dw NULL ; TRANSFORMATION_UNUSED_1A_ID + dw NULL ; TRANSFORMATION_UNUSED_1B_ID + dw NULL ; TRANSFORMATION_UNUSED_1C_ID + dw NULL ; TRANSFORMATION_UNUSED_1D_ID + dw NULL ; TRANSFORMATION_UNUSED_1E_ID + dw NULL ; TRANSFORMATION_UNUSED_1F_ID + assert_table_length NUM_TRANSFORMATIONS diff --git a/src/audio/waves.asm b/src/audio/waves.asm index 4c463c7..b604a57 100644 --- a/src/audio/waves.asm +++ b/src/audio/waves.asm @@ -1,4 +1,5 @@ Waves: + table_width 6, Waves db WAVEFORM_SQUARE_1_2_SAWTOOTH, 0, NO_SWEEP, $ff, $ff, $3c ; WAVE_00 db RECT_TRACK1 | RECTWAVE_1_8, 0, NO_SWEEP, $fb, $28, $3c ; WAVE_01 db RECT_TRACK1 | RECTWAVE_1_8, 0, NO_SWEEP, $f0, $10, $3c ; WAVE_02 @@ -122,10 +123,12 @@ Waves: db WAVEFORM_SQUARE_4_8, 0, NO_SWEEP, $fa, $6c, $3c ; WAVE_78 db WAVEFORM_SPIKY, 0, NO_SWEEP, $fa, $4c, $3c ; WAVE_79 db WAVEFORM_SQUARE_1_8, 0, NO_SWEEP, $ff, $ff, $3c ; WAVE_7A + assert_table_length NUM_WAVES WaveSamples: ; These are streams of 32 nibbles (4-bit values) used as wave patterns. ; Plot them as a line chart to see the wave's shape. + table_width 16, WaveSamples dn 0, 0, 1, 1, 2, 3, 5, 6, 8, 9, 10, 12, 13, 14, 14, 15, 15, 15, 14, 14, 13, 12, 10, 9, 8, 6, 5, 3, 2, 1, 1, 0 ; WAVEFORM_SINE dn 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ; WAVEFORM_TRIANGLE dn 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0 ; WAVEFORM_SAWTOOTH @@ -138,3 +141,4 @@ WaveSamples: dn 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ; WAVEFORM_SQUARE_1_4_SAWTOOTH dn 7, 7, 7, 7, 5, 1, 10, 2, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; WAVEFORM_SPIKY dn 7, 10, 12, 14, 15, 15, 15, 8, 7, 9, 9, 7, 7, 7, 7, 5, 5, 6, 6, 4, 4, 4, 4, 3, 3, 2, 2, 2, 2, 1, 1, 0 ; WAVEFORM_SQUISHED_SINE + assert_table_length NUM_WAVEFORMS diff --git a/src/constants/audio_constants.asm b/src/constants/audio_constants.asm index 8729670..c91240e 100644 --- a/src/constants/audio_constants.asm +++ b/src/constants/audio_constants.asm @@ -190,6 +190,7 @@ DEF RECT_TRACK2 EQU (1 << 3) const WAVEFORM_SQUARE_1_4_SAWTOOTH ; $19 (square & sawtooth) const WAVEFORM_SPIKY ; $1a (spiky) const WAVEFORM_SQUISHED_SINE ; $1b (squished sine) +DEF NUM_WAVEFORMS EQU const_value - $10 DEF NOISE_POLYCOUNTER_15 EQU 0 DEF NOISE_POLYCOUNTER_07 EQU 1 @@ -332,6 +333,7 @@ DEF SWEEP_TIME_7 EQU (%111 << 4) ; 54.7 ms const WAVE_78 ; $78 const WAVE_79 ; $79 const WAVE_7A ; $7a +DEF NUM_WAVES EQU const_value const_def $cf const NOTE_DURATION_0 ; $cf diff --git a/src/constants/cutscene_constants.asm b/src/constants/cutscene_constants.asm index 338e1ed..db7d29c 100644 --- a/src/constants/cutscene_constants.asm +++ b/src/constants/cutscene_constants.asm @@ -90,7 +90,7 @@ const CUTSCENE_58 ; $58 const CUTSCENE_59 ; $59 const CUTSCENE_5A ; $5a -DEF NUM_CUTSCENES EQU const_value - 1 +DEF NUM_CUTSCENES EQU const_value const_def ; WarioIdleGfx @@ -182,7 +182,7 @@ DEF SCENEWARIO_GROUP_12 EQU const_value ; WarioClearGfx const SCENEWARIO_IDLE_FRONT ; $3c DEF SCENEWARIO_GROUP_13 EQU const_value -DEF NUM_SCENEWARIO_STATES EQU const_value - 1 +DEF NUM_SCENEWARIO_STATES EQU const_value DEF SCENEWARIO_GROUP_NONE EQU $ff diff --git a/src/constants/level_constants.asm b/src/constants/level_constants.asm index 8ce1947..67b4408 100644 --- a/src/constants/level_constants.asm +++ b/src/constants/level_constants.asm @@ -120,3 +120,7 @@ DEF COIN_COOLDOWN EQU 100 ; number of torches that need to be lit ; to destroy the Flame Block DEF NUM_FLAME_BLOCK_TORCHES EQU 3 + +; number of different types of blocks +; that can fit inside a single room +DEF NUM_ROOM_BLOCK_TYPES EQU $80 diff --git a/src/constants/object_constants.asm b/src/constants/object_constants.asm index b62847c..44f8e2f 100644 --- a/src/constants/object_constants.asm +++ b/src/constants/object_constants.asm @@ -79,95 +79,96 @@ DEF INTERACTION_DOWN EQU (1 << INTERACTION_DOWN_F) ; $80 ; object interaction types const_def - const OBJ_INTERACTION_00 ; 00 - const OBJ_INTERACTION_01 ; 01 - const OBJ_INTERACTION_FRONT_STING ; 02 - const OBJ_INTERACTION_BACK_STING ; 03 - const OBJ_INTERACTION_TOP_STING ; 04 - const OBJ_INTERACTION_FULL_STING ; 05 - const OBJ_INTERACTION_06 ; 06 - const OBJ_INTERACTION_07 ; 07 - const OBJ_INTERACTION_08 ; 08 - const OBJ_INTERACTION_09 ; 09 - const OBJ_INTERACTION_0A ; 0a - const OBJ_INTERACTION_0B ; 0b - const OBJ_INTERACTION_WALKABLE ; 0c - const OBJ_INTERACTION_MUSICAL_COIN ; 0d - const OBJ_INTERACTION_FIRE ; 0e - const OBJ_INTERACTION_RICHTERTOFFEN ; 0f - const OBJ_INTERACTION_GREY_KEY ; 10 - const OBJ_INTERACTION_RED_KEY ; 11 - const OBJ_INTERACTION_GREEN_KEY ; 12 - const OBJ_INTERACTION_BLUE_KEY ; 13 - const OBJ_INTERACTION_GREY_TREASURE ; 14 - const OBJ_INTERACTION_RED_TREASURE ; 15 - const OBJ_INTERACTION_GREEN_TREASURE ; 16 - const OBJ_INTERACTION_BLUE_TREASURE ; 17 - const OBJ_INTERACTION_18 ; 18 - const OBJ_INTERACTION_19 ; 19 - const OBJ_INTERACTION_1A ; 1a - const OBJ_INTERACTION_REGULAR_COIN ; 1b - const OBJ_INTERACTION_ELECTRIC ; 1c - const OBJ_INTERACTION_1D ; 1d - const OBJ_INTERACTION_1E ; 1e - const OBJ_INTERACTION_1F ; 1f - const OBJ_INTERACTION_BOUNCY ; 20 - const OBJ_INTERACTION_21 ; 21 - const OBJ_INTERACTION_SOLID ; 22 - const OBJ_INTERACTION_23 ; 23 - const OBJ_INTERACTION_24 ; 24 - const OBJ_INTERACTION_VAMPIRE ; 25 - const OBJ_INTERACTION_BUBBLE ; 26 - const OBJ_INTERACTION_ICE ; 27 - const OBJ_INTERACTION_OWL ; 28 - const OBJ_INTERACTION_RAIL ; 29 - const OBJ_INTERACTION_2A ; 2a - const OBJ_INTERACTION_2B ; 2b - const OBJ_INTERACTION_2C ; 2c - const OBJ_INTERACTION_2D ; 2d - const OBJ_INTERACTION_UNLIT_TORCH ; 2e - const OBJ_INTERACTION_STOVE ; 2f - const OBJ_INTERACTION_30 ; 30 - const OBJ_INTERACTION_31 ; 31 - const OBJ_INTERACTION_32 ; 32 - const OBJ_INTERACTION_33 ; 33 - const OBJ_INTERACTION_WORMWOULD ; 34 - const OBJ_INTERACTION_35 ; 35 - const OBJ_INTERACTION_36 ; 36 - const OBJ_INTERACTION_37 ; 37 - const OBJ_INTERACTION_38 ; 38 - const OBJ_INTERACTION_WATER_DROP ; 39 - const OBJ_INTERACTION_3A ; 3a - const OBJ_INTERACTION_3B ; 3b - const OBJ_INTERACTION_3C ; 3c - const OBJ_INTERACTION_3D ; 3d - const OBJ_INTERACTION_PRINCE_FROGGY ; 3e - const OBJ_INTERACTION_3F ; 3f - const OBJ_INTERACTION_WATER_TELEPORTING ; 40 - const OBJ_INTERACTION_41 ; 41 - const OBJ_INTERACTION_42 ; 42 - const OBJ_INTERACTION_43 ; 43 - const OBJ_INTERACTION_44 ; 44 - const OBJ_INTERACTION_45 ; 45 - const OBJ_INTERACTION_46 ; 46 - const OBJ_INTERACTION_47 ; 47 - const OBJ_INTERACTION_48 ; 48 - const OBJ_INTERACTION_49 ; 49 - const OBJ_INTERACTION_COLOUR_COIN ; 4a - const OBJ_INTERACTION_4B ; 4b - const OBJ_INTERACTION_BOTTOM_STING ; 4c - const OBJ_INTERACTION_4D ; 4d - const OBJ_INTERACTION_4E ; 4e - const OBJ_INTERACTION_4F ; 4f - const OBJ_INTERACTION_50 ; 50 - const OBJ_INTERACTION_51 ; 51 - const OBJ_INTERACTION_52 ; 52 - const OBJ_INTERACTION_UNUSED_1 ; 53 - const OBJ_INTERACTION_UNUSED_2 ; 54 - const OBJ_INTERACTION_UNUSED_3 ; 55 - const OBJ_INTERACTION_UNUSED_4 ; 56 - const OBJ_INTERACTION_UNUSED_5 ; 57 - const OBJ_INTERACTION_UNUSED_6 ; 58 + const OBJ_INTERACTION_00 ; $00 + const OBJ_INTERACTION_01 ; $01 + const OBJ_INTERACTION_FRONT_STING ; $02 + const OBJ_INTERACTION_BACK_STING ; $03 + const OBJ_INTERACTION_TOP_STING ; $04 + const OBJ_INTERACTION_FULL_STING ; $05 + const OBJ_INTERACTION_06 ; $06 + const OBJ_INTERACTION_07 ; $07 + const OBJ_INTERACTION_08 ; $08 + const OBJ_INTERACTION_09 ; $09 + const OBJ_INTERACTION_0A ; $0a + const OBJ_INTERACTION_0B ; $0b + const OBJ_INTERACTION_WALKABLE ; $0c + const OBJ_INTERACTION_MUSICAL_COIN ; $0d + const OBJ_INTERACTION_FIRE ; $0e + const OBJ_INTERACTION_RICHTERTOFFEN ; $0f + const OBJ_INTERACTION_GREY_KEY ; $10 + const OBJ_INTERACTION_RED_KEY ; $11 + const OBJ_INTERACTION_GREEN_KEY ; $12 + const OBJ_INTERACTION_BLUE_KEY ; $13 + const OBJ_INTERACTION_GREY_TREASURE ; $14 + const OBJ_INTERACTION_RED_TREASURE ; $15 + const OBJ_INTERACTION_GREEN_TREASURE ; $16 + const OBJ_INTERACTION_BLUE_TREASURE ; $17 + const OBJ_INTERACTION_18 ; $18 + const OBJ_INTERACTION_19 ; $19 + const OBJ_INTERACTION_1A ; $1a + const OBJ_INTERACTION_REGULAR_COIN ; $1b + const OBJ_INTERACTION_ELECTRIC ; $1c + const OBJ_INTERACTION_1D ; $1d + const OBJ_INTERACTION_1E ; $1e + const OBJ_INTERACTION_1F ; $1f + const OBJ_INTERACTION_BOUNCY ; $20 + const OBJ_INTERACTION_21 ; $21 + const OBJ_INTERACTION_SOLID ; $22 + const OBJ_INTERACTION_23 ; $23 + const OBJ_INTERACTION_24 ; $24 + const OBJ_INTERACTION_VAMPIRE ; $25 + const OBJ_INTERACTION_BUBBLE ; $26 + const OBJ_INTERACTION_ICE ; $27 + const OBJ_INTERACTION_OWL ; $28 + const OBJ_INTERACTION_RAIL ; $29 + const OBJ_INTERACTION_2A ; $2a + const OBJ_INTERACTION_2B ; $2b + const OBJ_INTERACTION_2C ; $2c + const OBJ_INTERACTION_2D ; $2d + const OBJ_INTERACTION_UNLIT_TORCH ; $2e + const OBJ_INTERACTION_STOVE ; $2f + const OBJ_INTERACTION_30 ; $30 + const OBJ_INTERACTION_31 ; $31 + const OBJ_INTERACTION_32 ; $32 + const OBJ_INTERACTION_33 ; $33 + const OBJ_INTERACTION_WORMWOULD ; $34 + const OBJ_INTERACTION_35 ; $35 + const OBJ_INTERACTION_36 ; $36 + const OBJ_INTERACTION_37 ; $37 + const OBJ_INTERACTION_38 ; $38 + const OBJ_INTERACTION_WATER_DROP ; $39 + const OBJ_INTERACTION_3A ; $3a + const OBJ_INTERACTION_3B ; $3b + const OBJ_INTERACTION_3C ; $3c + const OBJ_INTERACTION_3D ; $3d + const OBJ_INTERACTION_PRINCE_FROGGY ; $3e + const OBJ_INTERACTION_3F ; $3f + const OBJ_INTERACTION_WATER_TELEPORTING ; $40 + const OBJ_INTERACTION_41 ; $41 + const OBJ_INTERACTION_42 ; $42 + const OBJ_INTERACTION_43 ; $43 + const OBJ_INTERACTION_44 ; $44 + const OBJ_INTERACTION_45 ; $45 + const OBJ_INTERACTION_46 ; $46 + const OBJ_INTERACTION_47 ; $47 + const OBJ_INTERACTION_48 ; $48 + const OBJ_INTERACTION_49 ; $49 + const OBJ_INTERACTION_COLOUR_COIN ; $4a + const OBJ_INTERACTION_4B ; $4b + const OBJ_INTERACTION_BOTTOM_STING ; $4c + const OBJ_INTERACTION_4D ; $4d + const OBJ_INTERACTION_4E ; $4e + const OBJ_INTERACTION_4F ; $4f + const OBJ_INTERACTION_50 ; $50 + const OBJ_INTERACTION_51 ; $51 + const OBJ_INTERACTION_52 ; $52 + const OBJ_INTERACTION_UNUSED_1 ; $53 + const OBJ_INTERACTION_UNUSED_2 ; $54 + const OBJ_INTERACTION_UNUSED_3 ; $55 + const OBJ_INTERACTION_UNUSED_4 ; $56 + const OBJ_INTERACTION_UNUSED_5 ; $57 + const OBJ_INTERACTION_UNUSED_6 ; $58 +DEF NUM_OBJ_INTERACTIONS EQU const_value ; enemies with InteractionType with ; this flag set are considered heavy @@ -294,6 +295,7 @@ DEF INTERACTION_MASK EQU $ff ^ HEAVY_OBJ const OBJACTION_11 ; $11 const OBJACTION_12 ; $12 const OBJACTION_13 ; $13 +DEF NUM_OBJ_ACTIONS EQU const_value DEF NO_ACTIONS_F EQU 7 DEF NO_ACTIONS EQU (1 << NO_ACTIONS_F) @@ -449,5 +451,6 @@ DEF NO_ACTIONS_FOR EQUS "(1 << NO_ACTIONS_F) |" const ENEMY_GROUP_143 ; $8f const ENEMY_GROUP_144 ; $90 const ENEMY_GROUP_145 ; $91 +DEF NUM_ENEMY_GROUPS EQU const_value const_def 240 const ENEMY_GROUP_HIDDEN_FIGURE ; $f0 diff --git a/src/constants/particle_constants.asm b/src/constants/particle_constants.asm index ee854a7..70fcc3f 100644 --- a/src/constants/particle_constants.asm +++ b/src/constants/particle_constants.asm @@ -19,13 +19,14 @@ const PARTICLE_MAGIC_1 ; $10 const PARTICLE_MAGIC_2 ; $11 const PARTICLE_MAGIC_STOP ; $12 - const PARTICLE_13 ; $13 (unused) - const PARTICLE_14 ; $14 (unused) - const PARTICLE_15 ; $15 (unused) - const PARTICLE_16 ; $16 (unused) + const PARTICLE_UNUSED_13 ; $13 + const PARTICLE_UNUSED_14 ; $14 + const PARTICLE_UNUSED_15 ; $15 + const PARTICLE_UNUSED_16 ; $16 +DEF NUM_PARTICLES EQU const_value ; the maximum number of active particles -DEF NUM_PARTICLES EQU 4 +DEF MAX_NUM_PARTICLES EQU 4 ; wObjects structs constants RSRESET diff --git a/src/constants/room_constants.asm b/src/constants/room_constants.asm index 7db4b16..b53e827 100644 --- a/src/constants/room_constants.asm +++ b/src/constants/room_constants.asm @@ -154,6 +154,15 @@ const ROOM_152 ; $98 const ROOM_153 ; $99 const ROOM_154 ; $9a + const ROOM_UNUSED_155 ; $9b + const ROOM_UNUSED_156 ; $9c + const ROOM_UNUSED_157 ; $9d + const ROOM_UNUSED_158 ; $9e + const ROOM_UNUSED_159 ; $9f + const ROOM_UNUSED_160 ; $a0 + const ROOM_UNUSED_161 ; $a1 + const ROOM_UNUSED_162 ; $a2 +DEF NUM_ROOMS EQU const_value const_def const TILE_MAP_00 ; $00 diff --git a/src/constants/sound_constants.asm b/src/constants/sound_constants.asm index c6813b9..3058e19 100644 --- a/src/constants/sound_constants.asm +++ b/src/constants/sound_constants.asm @@ -60,6 +60,7 @@ const MUSIC_EPILOGUE ; 038 const MUSIC_HIDDEN_FIGURE_REVEAL ; 039 const MUSIC_HIDDEN_FIGURE_BATTLE_2 ; 03a +DEF NUM_MUSICS EQU const_value - 1 const_def $101 const SFX_JUMP ; 101 diff --git a/src/constants/treasure_constants.asm b/src/constants/treasure_constants.asm index 8f2af99..6101e2f 100644 --- a/src/constants/treasure_constants.asm +++ b/src/constants/treasure_constants.asm @@ -100,7 +100,7 @@ const CRAYON_CYAN_T ; $62 const CRAYON_BLUE_T ; $63 const CRAYON_PINK_T ; $64 -DEF NUM_TREASURES EQU const_value - 1 +DEF NUM_TREASURES EQU const_value const TREASURE_DUMMY ; $65 const_def $80 const INVALID_TREASURE ; $80 diff --git a/src/constants/wario_constants.asm b/src/constants/wario_constants.asm index 9c83fbc..c5cba7d 100644 --- a/src/constants/wario_constants.asm +++ b/src/constants/wario_constants.asm @@ -31,7 +31,8 @@ DEF NUM_TOTAL_POWER_UPS EQU const_value DEF POWER_UP_MASK EQU %111111 ; transformation constants - const_def 1 + const_def + const TRANSFORMATION_NONE_ID ; $00 const TRANSFORMATION_HOT_WARIO_ID ; $01 const TRANSFORMATION_FLAT_WARIO_ID ; $02 const TRANSFORMATION_BALL_O_STRING_WARIO_ID ; $03 @@ -54,6 +55,16 @@ DEF POWER_UP_MASK EQU %111111 const TRANSFORMATION_LAUNCHED_ID ; $14 const TRANSFORMATION_MAGIC_ID ; $15 const TRANSFORMATION_BALL_ID ; $16 + const TRANSFORMATION_UNUSED_17_ID ; $17 + const TRANSFORMATION_UNUSED_18_ID ; $18 + const TRANSFORMATION_UNUSED_19_ID ; $19 + const TRANSFORMATION_UNUSED_1A_ID ; $1a + const TRANSFORMATION_UNUSED_1B_ID ; $1b + const TRANSFORMATION_UNUSED_1C_ID ; $1c + const TRANSFORMATION_UNUSED_1D_ID ; $1d + const TRANSFORMATION_UNUSED_1E_ID ; $1e + const TRANSFORMATION_UNUSED_1F_ID ; $1f +DEF NUM_TRANSFORMATIONS EQU const_value ; flags that give a transformation some more properties: ; - persistent flag which makes Wario immune to other transformations, @@ -65,6 +76,7 @@ DEF POWER_UP_MASK EQU %111111 DEF TRANSFORMATIONF_PERSISTENT EQU 1 << TRANSFORMATIONF_PERSISTENT_F DEF TRANSFORMATIONF_SUPER_SMASH EQU 1 << TRANSFORMATIONF_SUPER_SMASH_F +DEF TRANSFORMATION_NONE EQU TRANSFORMATION_NONE_ID DEF TRANSFORMATION_HOT_WARIO EQU TRANSFORMATION_HOT_WARIO_ID | TRANSFORMATIONF_PERSISTENT | TRANSFORMATIONF_SUPER_SMASH DEF TRANSFORMATION_FLAT_WARIO EQU TRANSFORMATION_FLAT_WARIO_ID | TRANSFORMATIONF_PERSISTENT DEF TRANSFORMATION_BALL_O_STRING_WARIO EQU TRANSFORMATION_BALL_O_STRING_WARIO_ID | TRANSFORMATIONF_PERSISTENT | TRANSFORMATIONF_SUPER_SMASH diff --git a/src/data/levels/function_tables1.asm b/src/data/levels/function_tables1.asm index 22a8be5..b3ad015 100644 --- a/src/data/levels/function_tables1.asm +++ b/src/data/levels/function_tables1.asm @@ -99,6 +99,7 @@ BlockFunctionTablePointers:: dw NULL BlockFunctionTable0: + table_width 2, BlockFunctionTable0 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -227,8 +228,10 @@ BlockFunctionTable0: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable1: + table_width 2, BlockFunctionTable1 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -357,8 +360,10 @@ BlockFunctionTable1: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable2: + table_width 2, BlockFunctionTable2 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -487,8 +492,10 @@ BlockFunctionTable2: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable3: + table_width 2, BlockFunctionTable3 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -617,8 +624,10 @@ BlockFunctionTable3: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable4: + table_width 2, BlockFunctionTable4 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -747,8 +756,10 @@ BlockFunctionTable4: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable5: + table_width 2, BlockFunctionTable5 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -877,8 +888,10 @@ BlockFunctionTable5: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable6: + table_width 2, BlockFunctionTable6 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1007,8 +1020,10 @@ BlockFunctionTable6: dw BlockFunc_Free ; $7d dw BlockFunc_Door ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable7: + table_width 2, BlockFunctionTable7 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1137,8 +1152,10 @@ BlockFunctionTable7: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable8: + table_width 2, BlockFunctionTable8 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1267,8 +1284,10 @@ BlockFunctionTable8: dw BlockFunc_188ba ; $7d dw BlockFunc_WalkthroughPipe ; $7e dw BlockFunc_188ba ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable9: + table_width 2, BlockFunctionTable9 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1397,8 +1416,10 @@ BlockFunctionTable9: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable10: + table_width 2, BlockFunctionTable10 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1527,8 +1548,10 @@ BlockFunctionTable10: dw BlockFunc_Free ; $7d dw BlockFunc_Door ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable11: + table_width 2, BlockFunctionTable11 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1657,8 +1680,10 @@ BlockFunctionTable11: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable12: + table_width 2, BlockFunctionTable12 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1787,8 +1812,10 @@ BlockFunctionTable12: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable13: + table_width 2, BlockFunctionTable13 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1917,8 +1944,10 @@ BlockFunctionTable13: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable14: + table_width 2, BlockFunctionTable14 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2047,8 +2076,10 @@ BlockFunctionTable14: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable15: + table_width 2, BlockFunctionTable15 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2177,8 +2208,10 @@ BlockFunctionTable15: dw BlockFunc_Door ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable16: + table_width 2, BlockFunctionTable16 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2307,8 +2340,10 @@ BlockFunctionTable16: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable17: + table_width 2, BlockFunctionTable17 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2437,8 +2472,10 @@ BlockFunctionTable17: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Door ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable18: + table_width 2, BlockFunctionTable18 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2567,8 +2604,10 @@ BlockFunctionTable18: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable19: + table_width 2, BlockFunctionTable19 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2697,8 +2736,10 @@ BlockFunctionTable19: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable20: + table_width 2, BlockFunctionTable20 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2827,8 +2868,10 @@ BlockFunctionTable20: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable21: + table_width 2, BlockFunctionTable21 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2957,8 +3000,10 @@ BlockFunctionTable21: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable22: + table_width 2, BlockFunctionTable22 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3087,8 +3132,10 @@ BlockFunctionTable22: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable23: + table_width 2, BlockFunctionTable23 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3217,8 +3264,10 @@ BlockFunctionTable23: dw BlockFunc_Free ; $7d dw BlockFunc_Water ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable24: + table_width 2, BlockFunctionTable24 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Free ; $02 @@ -3347,8 +3396,10 @@ BlockFunctionTable24: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable25: + table_width 2, BlockFunctionTable25 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3477,8 +3528,10 @@ BlockFunctionTable25: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable26: + table_width 2, BlockFunctionTable26 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3607,8 +3660,10 @@ BlockFunctionTable26: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable27: + table_width 2, BlockFunctionTable27 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3737,8 +3792,10 @@ BlockFunctionTable27: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable28: + table_width 2, BlockFunctionTable28 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3867,8 +3924,10 @@ BlockFunctionTable28: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable29: + table_width 2, BlockFunctionTable29 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3997,8 +4056,10 @@ BlockFunctionTable29: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable30: + table_width 2, BlockFunctionTable30 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -4127,8 +4188,10 @@ BlockFunctionTable30: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable31: + table_width 2, BlockFunctionTable31 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -4257,8 +4320,10 @@ BlockFunctionTable31: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable32: + table_width 2, BlockFunctionTable32 dw BlockFunc_SlipperySolid ; $00 dw BlockFunc_SlipperySolid ; $01 dw BlockFunc_SlipperySolid ; $02 @@ -4387,8 +4452,10 @@ BlockFunctionTable32: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable33: + table_width 2, BlockFunctionTable33 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -4517,8 +4584,10 @@ BlockFunctionTable33: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable34: + table_width 2, BlockFunctionTable34 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -4647,8 +4716,10 @@ BlockFunctionTable34: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable35: + table_width 2, BlockFunctionTable35 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -4777,8 +4848,10 @@ BlockFunctionTable35: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable36: + table_width 2, BlockFunctionTable36 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -4907,8 +4980,10 @@ BlockFunctionTable36: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_MinigameDoor ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable37: + table_width 2, BlockFunctionTable37 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -5037,8 +5112,10 @@ BlockFunctionTable37: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable38: + table_width 2, BlockFunctionTable38 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -5167,8 +5244,10 @@ BlockFunctionTable38: dw BlockFunc_EnemyBlock_7a ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable39: + table_width 2, BlockFunctionTable39 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -5297,8 +5376,10 @@ BlockFunctionTable39: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable40: + table_width 2, BlockFunctionTable40 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -5427,8 +5508,10 @@ BlockFunctionTable40: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable41: + table_width 2, BlockFunctionTable41 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -5557,8 +5640,10 @@ BlockFunctionTable41: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable42: + table_width 2, BlockFunctionTable42 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -5687,8 +5772,10 @@ BlockFunctionTable42: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable43: + table_width 2, BlockFunctionTable43 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -5817,8 +5904,10 @@ BlockFunctionTable43: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable44: + table_width 2, BlockFunctionTable44 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -5947,8 +6036,10 @@ BlockFunctionTable44: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable45: + table_width 2, BlockFunctionTable45 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -6077,8 +6168,10 @@ BlockFunctionTable45: dw BlockFunc_Solid ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Door ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable46: + table_width 2, BlockFunctionTable46 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -6207,8 +6300,10 @@ BlockFunctionTable46: dw BlockFunc_188ba ; $7d dw BlockFunc_WalkthroughPipe ; $7e dw BlockFunc_188ba ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable47: + table_width 2, BlockFunctionTable47 dw BlockFunc_SlipperySolid ; $00 dw BlockFunc_SlipperySolid ; $01 dw BlockFunc_SlipperySolid ; $02 @@ -6337,8 +6432,10 @@ BlockFunctionTable47: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable48: + table_width 2, BlockFunctionTable48 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -6467,8 +6564,10 @@ BlockFunctionTable48: dw BlockFunc_188ba ; $7d dw BlockFunc_WalkthroughPipe ; $7e dw BlockFunc_188ba ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable49: + table_width 2, BlockFunctionTable49 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -6597,8 +6696,10 @@ BlockFunctionTable49: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable50: + table_width 2, BlockFunctionTable50 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -6727,8 +6828,10 @@ BlockFunctionTable50: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable51: + table_width 2, BlockFunctionTable51 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -6857,8 +6960,10 @@ BlockFunctionTable51: dw BlockFunc_Free ; $7d dw BlockFunc_18e2a ; $7e dw BlockFunc_18ebe ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable52: + table_width 2, BlockFunctionTable52 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -6987,8 +7092,10 @@ BlockFunctionTable52: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable53: + table_width 2, BlockFunctionTable53 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -7117,8 +7224,10 @@ BlockFunctionTable53: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable54: + table_width 2, BlockFunctionTable54 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Free ; $02 @@ -7247,8 +7356,10 @@ BlockFunctionTable54: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable55: + table_width 2, BlockFunctionTable55 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -7377,8 +7488,10 @@ BlockFunctionTable55: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable56: + table_width 2, BlockFunctionTable56 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -7507,8 +7620,10 @@ BlockFunctionTable56: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable57: + table_width 2, BlockFunctionTable57 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -7637,8 +7752,10 @@ BlockFunctionTable57: dw BlockFunc_Free ; $7d dw BlockFunc_18e2a ; $7e dw BlockFunc_18ebe ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable58: + table_width 2, BlockFunctionTable58 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -7767,8 +7884,10 @@ BlockFunctionTable58: dw BlockFunc_Free ; $7d dw BlockFunc_18e2a ; $7e dw BlockFunc_18ebe ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable59: + table_width 2, BlockFunctionTable59 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -7897,8 +8016,10 @@ BlockFunctionTable59: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable60: + table_width 2, BlockFunctionTable60 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -8027,8 +8148,10 @@ BlockFunctionTable60: dw BlockFunc_Solid ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable61: + table_width 2, BlockFunctionTable61 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -8157,8 +8280,10 @@ BlockFunctionTable61: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable62: + table_width 2, BlockFunctionTable62 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -8287,3 +8412,4 @@ BlockFunctionTable62: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES diff --git a/src/data/levels/function_tables2.asm b/src/data/levels/function_tables2.asm index da6dcdb..11e6b9a 100644 --- a/src/data/levels/function_tables2.asm +++ b/src/data/levels/function_tables2.asm @@ -1,4 +1,5 @@ BlockFunctionTable63: + table_width 2, BlockFunctionTable63 dw BlockFunc_SlipperySolid ; $00 dw BlockFunc_SlipperySolid ; $01 dw BlockFunc_SlipperySolid ; $02 @@ -127,8 +128,10 @@ BlockFunctionTable63: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable64: + table_width 2, BlockFunctionTable64 dw BlockFunc_SlipperySolid ; $00 dw BlockFunc_SlipperySolid ; $01 dw BlockFunc_SlipperySolid ; $02 @@ -257,8 +260,10 @@ BlockFunctionTable64: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable65: + table_width 2, BlockFunctionTable65 dw BlockFunc_SlipperySolid ; $00 dw BlockFunc_SlipperySolid ; $01 dw BlockFunc_SlipperySolid ; $02 @@ -387,8 +392,10 @@ BlockFunctionTable65: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable66: + table_width 2, BlockFunctionTable66 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -517,8 +524,10 @@ BlockFunctionTable66: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable67: + table_width 2, BlockFunctionTable67 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -647,8 +656,10 @@ BlockFunctionTable67: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable68: + table_width 2, BlockFunctionTable68 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -777,8 +788,10 @@ BlockFunctionTable68: dw BlockFunc_Free ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable69: + table_width 2, BlockFunctionTable69 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -907,8 +920,10 @@ BlockFunctionTable69: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable70: + table_width 2, BlockFunctionTable70 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1037,8 +1052,10 @@ BlockFunctionTable70: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable71: + table_width 2, BlockFunctionTable71 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1167,8 +1184,10 @@ BlockFunctionTable71: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable72: + table_width 2, BlockFunctionTable72 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1297,8 +1316,10 @@ BlockFunctionTable72: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable73: + table_width 2, BlockFunctionTable73 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1427,8 +1448,10 @@ BlockFunctionTable73: dw BlockFunc_Free ; $7d dw BlockFunc_Water ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable74: + table_width 2, BlockFunctionTable74 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1557,8 +1580,10 @@ BlockFunctionTable74: dw BlockFunc_Free ; $7d dw BlockFunc_Water ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable75: + table_width 2, BlockFunctionTable75 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1687,8 +1712,10 @@ BlockFunctionTable75: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable76: + table_width 2, BlockFunctionTable76 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1817,8 +1844,10 @@ BlockFunctionTable76: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable77: + table_width 2, BlockFunctionTable77 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -1947,8 +1976,10 @@ BlockFunctionTable77: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable78: + table_width 2, BlockFunctionTable78 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2077,8 +2108,10 @@ BlockFunctionTable78: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable79: + table_width 2, BlockFunctionTable79 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2207,8 +2240,10 @@ BlockFunctionTable79: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable80: + table_width 2, BlockFunctionTable80 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2337,8 +2372,10 @@ BlockFunctionTable80: dw BlockFunc_EnemyBlock_7a ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable81: + table_width 2, BlockFunctionTable81 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2467,8 +2504,10 @@ BlockFunctionTable81: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_MinigameDoor ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable82: + table_width 2, BlockFunctionTable82 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2597,8 +2636,10 @@ BlockFunctionTable82: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable83: + table_width 2, BlockFunctionTable83 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2727,8 +2768,10 @@ BlockFunctionTable83: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable84: + table_width 2, BlockFunctionTable84 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2857,8 +2900,10 @@ BlockFunctionTable84: dw BlockFunc_Solid ; $7d dw BlockFunc_Solid ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable85: + table_width 2, BlockFunctionTable85 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -2987,8 +3032,10 @@ BlockFunctionTable85: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Solid ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable86: + table_width 2, BlockFunctionTable86 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3117,8 +3164,10 @@ BlockFunctionTable86: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable87: + table_width 2, BlockFunctionTable87 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3247,8 +3296,10 @@ BlockFunctionTable87: dw BlockFunc_Free ; $7d dw BlockFunc_Free ; $7e dw BlockFunc_Free ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES BlockFunctionTable88: + table_width 2, BlockFunctionTable88 dw BlockFunc_Solid ; $00 dw BlockFunc_Solid ; $01 dw BlockFunc_Solid ; $02 @@ -3377,3 +3428,4 @@ BlockFunctionTable88: dw BlockFunc_188ba ; $7d dw BlockFunc_WalkthroughPipe ; $7e dw BlockFunc_188ba ; $7f + assert_table_length NUM_ROOM_BLOCK_TYPES diff --git a/src/engine/action_help/main_power_ups.asm b/src/engine/action_help/main_power_ups.asm index 3990170..8aa6c9f 100644 --- a/src/engine/action_help/main_power_ups.asm +++ b/src/engine/action_help/main_power_ups.asm @@ -3,6 +3,8 @@ ExecuteMainPowerUpActionHelp: ld a, [wActionHelpPowerUp] jumptable +.table + table_width 2, ExecuteMainPowerUpActionHelp.table dw NoPowerUpActionHelp ; NO_POWER_UP dw LeadOverallsActionHelp ; LEAD_OVERALLS dw SwimmingFlippersActionHelp ; SWIMMING_FLIPPERS @@ -13,3 +15,4 @@ ExecuteMainPowerUpActionHelp: dw HighJumpBootsActionHelp ; HIGH_JUMP_BOOTS dw PrinceFrogsGlovesActionHelp ; PRINCE_FROGS_GLOVES dw SuperGrabGloveActionHelp ; SUPER_GRAB_GLOVES + assert_table_length NUM_MAIN_POWER_UPS diff --git a/src/engine/bank18.asm b/src/engine/bank18.asm index 36dd54f..71d0664 100644 --- a/src/engine/bank18.asm +++ b/src/engine/bank18.asm @@ -1098,6 +1098,8 @@ DoObjectAction: .jump jumptable +.table + table_width 2, DoObjectAction.table dw .None ; OBJACTION_NONE dw .Bump ; OBJACTION_BUMP dw .Attack ; OBJACTION_ATTACK @@ -1118,6 +1120,7 @@ DoObjectAction: dw .Action11 ; OBJACTION_11 dw .Action12 ; OBJACTION_12 dw .Func_6179c ; OBJACTION_13 + assert_table_length NUM_OBJ_ACTIONS .Func_6179c: ld hl, wCurObjAction diff --git a/src/engine/bank19.asm b/src/engine/bank19.asm index cec426f..6d69e8e 100644 --- a/src/engine/bank19.asm +++ b/src/engine/bank19.asm @@ -2364,6 +2364,7 @@ Data_64ffb: rgb 5, 0, 0 EnemyGroups: + table_width 4, EnemyGroups dw Data_64fc3, EnemyGroupGfx0 ; ENEMY_GROUP_000 dw Data_64fdf, EnemyGroupGfx2 ; ENEMY_GROUP_001 dw Data_64fd1, EnemyGroupGfx3 ; ENEMY_GROUP_002 @@ -2510,6 +2511,7 @@ EnemyGroups: dw Data_64fdf, EnemyGroupGfx43 ; ENEMY_GROUP_143 dw Data_64fd1, EnemyGroupGfx44 ; ENEMY_GROUP_144 dw Data_64ffb, EnemyGroupGfx117 ; ENEMY_GROUP_145 + assert_table_length NUM_ENEMY_GROUPS EnemyGroupGfx0: db $00 diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index 219cb19..bc2eb50 100644 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -3656,6 +3656,8 @@ LoadCutsceneTreasures: ret CutsceneTreasures: + table_width 3, CutsceneTreasures + ; CUTSCENE_00 db INVALID_TREASURE db INVALID_TREASURE @@ -4111,6 +4113,8 @@ CutsceneTreasures: db INVALID_TREASURE db INVALID_TREASURE + assert_table_length NUM_CUTSCENES + db TREASURES_END ; input: @@ -4692,7 +4696,7 @@ Func_81dce: call .Func_81e16 ld a, [wCutscene] inc a - cp NUM_CUTSCENES + 1 + cp NUM_CUTSCENES jr z, .asm_81e0d ld [wCutscene], a jr .asm_81de5 diff --git a/src/engine/bank26.asm b/src/engine/bank26.asm index de6269a..0bec093 100644 --- a/src/engine/bank26.asm +++ b/src/engine/bank26.asm @@ -378,7 +378,7 @@ _InitTreasureCollection: ld a, [wTransitionParam] and a jr z, .got_page - cp NUM_TREASURES + 1 + cp NUM_TREASURES jr nc, .got_page .loop_find_page cp NUM_COLLECTION_CELLS + 1 @@ -1541,6 +1541,7 @@ FillBottomBarTreasureIDs: ret TreasureOBPals: + table_width 1, TreasureOBPals db OBPAL_TREASURE_YELLOW ; TREASURE_NONE db OBPAL_TREASURE_YELLOW ; YELLOW_MUSIC_BOX db OBPAL_TREASURE_BLUE ; BLUE_MUSIC_BOX @@ -1642,7 +1643,8 @@ TreasureOBPals: db OBPAL_TREASURE_BLUE ; CRAYON_CYAN_T db OBPAL_TREASURE_BLUE ; CRAYON_BLUE_T db OBPAL_TREASURE_RED ; CRAYON_PINK_T - db $03 ; 101 + db $03 ; TREASURE_DUMMY + assert_table_length NUM_TREASURES + 1 OAM_9ac5d: dw .frame_0 diff --git a/src/engine/bank27.asm b/src/engine/bank27.asm index dac7787..76bc148 100644 --- a/src/engine/bank27.asm +++ b/src/engine/bank27.asm @@ -74,6 +74,7 @@ Func_9c072: jumptable .table + table_width 2, Func_9c072.table dw Func_9c000 ; CUTSCENE_00 dw .Func_9c15e ; CUTSCENE_01 dw .InitCutscene02 ; CUTSCENE_02 @@ -165,6 +166,7 @@ Func_9c072: dw .Func_9c7a5 ; CUTSCENE_58 dw Func_9c000 ; CUTSCENE_59 dw Func_9c000 ; CUTSCENE_5A + assert_table_length NUM_CUTSCENES .Func_9c15e: farcall _InitPrologueSequence @@ -1416,9 +1418,12 @@ Func_9ce28: ld c, l ld a, [w2d01e] - cp NUM_CUTSCENES + 1 + cp NUM_CUTSCENES jp nc, .OutOfBoundsCutscene jumptable + +.table + table_width 2, Func_9ce28.table dw .InvalidCutscene ; CUTSCENE_00 dw Cutscene01Func ; CUTSCENE_01 dw Cutscene02Func ; CUTSCENE_02 @@ -1510,6 +1515,7 @@ Func_9ce28: dw Cutscene58Func ; CUTSCENE_58 dw .InvalidCutscene ; CUTSCENE_59 dw .InvalidCutscene ; CUTSCENE_5A + assert_table_length NUM_CUTSCENES .OutOfBoundsCutscene debug_nop diff --git a/src/engine/bank2b.asm b/src/engine/bank2b.asm index c6e3b47..6511b42 100644 --- a/src/engine/bank2b.asm +++ b/src/engine/bank2b.asm @@ -843,6 +843,8 @@ UpdateSceneWarioAnimation: ld a, [wSceneWarioState] jumptable +.table + table_width 2, UpdateSceneWarioAnimation.table dw .None ; SCENEWARIO_NONE dw .LookFront ; SCENEWARIO_LOOK_FRONT dw .LookBack ; SCENEWARIO_LOOK_BACK @@ -904,6 +906,7 @@ UpdateSceneWarioAnimation: dw .PanicRunLeft ; SCENEWARIO_PANIC_RUN_LEFT dw .PanicRunRight ; SCENEWARIO_PANIC_RUN_RIGHT dw .IdleFront ; SCENEWARIO_IDLE_FRONT + assert_table_length NUM_SCENEWARIO_STATES .None ret @@ -1355,7 +1358,7 @@ DebugSceneWario: dec a jr .got_state .d_right - cp NUM_SCENEWARIO_STATES + cp NUM_SCENEWARIO_STATES - 1 jr nc, .got_state inc a .got_state diff --git a/src/engine/bank30.asm b/src/engine/bank30.asm index b2a2558..7a50593 100644 --- a/src/engine/bank30.asm +++ b/src/engine/bank30.asm @@ -651,6 +651,7 @@ MACRO room ENDM RoomBlockAndGfxData: + table_width 2, RoomBlockAndGfxData dw NULL ; ROOM_000 dw .room_001 ; ROOM_001 dw .room_002 ; ROOM_002 @@ -806,14 +807,15 @@ RoomBlockAndGfxData: dw .room_152 ; ROOM_152 dw .room_153 ; ROOM_153 dw .room_154 ; ROOM_154 - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL - dw NULL + dw NULL ; ROOM_UNUSED_155 + dw NULL ; ROOM_UNUSED_156 + dw NULL ; ROOM_UNUSED_157 + dw NULL ; ROOM_UNUSED_158 + dw NULL ; ROOM_UNUSED_159 + dw NULL ; ROOM_UNUSED_160 + dw NULL ; ROOM_UNUSED_161 + dw NULL ; ROOM_UNUSED_162 + assert_table_length NUM_ROOMS .room_001 room BLOCK_FUNCTION_TABLE_00, TILE_MAP_00, MAIN_TILES_00, SPECIAL_TILES_0, ROOM_PAL_000 diff --git a/src/engine/bank35.asm b/src/engine/bank35.asm index f8c377b..6bf4b73 100644 --- a/src/engine/bank35.asm +++ b/src/engine/bank35.asm @@ -884,7 +884,7 @@ UpdateNumCollectedTreasures: xor a ld [wNumCollectedTreasures + 1], a ld [wNumCollectedTreasures + 0], a - ld a, NUM_TREASURES + ld a, NUM_TREASURES - 1 .loop_treasures push af call IsTreasureCollected diff --git a/src/engine/bank8.asm b/src/engine/bank8.asm index a65bd92..8471d17 100644 --- a/src/engine/bank8.asm +++ b/src/engine/bank8.asm @@ -209,6 +209,8 @@ ProcessInteractions: and INTERACTION_MASK jumptable +.table + table_width 2, ProcessInteractions.table dw Func_20b6b ; OBJ_INTERACTION_00 dw Func_20d1d ; OBJ_INTERACTION_01 dw ObjInteraction_FrontSting ; OBJ_INTERACTION_FRONT_STING @@ -298,6 +300,7 @@ ProcessInteractions: dw ObjInteraction_None ; OBJ_INTERACTION_UNUSED_4 dw ObjInteraction_None ; OBJ_INTERACTION_UNUSED_5 dw ObjInteraction_None ; OBJ_INTERACTION_UNUSED_6 + assert_table_length NUM_OBJ_INTERACTIONS ObjInteraction_None: ret diff --git a/src/engine/golf/level.asm b/src/engine/golf/level.asm index 1ef7f78..ee8e594 100644 --- a/src/engine/golf/level.asm +++ b/src/engine/golf/level.asm @@ -133,7 +133,7 @@ PickAndLoadGolfLevel: jr .loop_division .got_golf_level - ld hl, .GolfLevels + ld hl, GolfLevels ld a, c and a jr z, .got_golf_level_data @@ -206,7 +206,8 @@ PickAndLoadGolfLevel: ld [wGolfLevelHoleXPos + 1], a ret -.GolfLevels +GolfLevels: + table_width 10, GolfLevels dw GolfLevel00, BGMap_1c18fd, BGMap_1c1869, BGMap_1c1973, BGMap_1c18be ; GOLF_LEVEL_00 dw GolfLevel01, BGMap_1c1824, BGMap_1c1756, BGMap_1c1850, BGMap_1c17c6 ; GOLF_LEVEL_01 dw GolfLevel02, BGMap_1c2287, BGMap_1c21e7, BGMap_1c2303, BGMap_1c224f ; GOLF_LEVEL_02 @@ -227,6 +228,7 @@ PickAndLoadGolfLevel: dw GolfLevel17, BGMap_1c2d30, BGMap_1c2c9e, BGMap_1c2d93, BGMap_1c2cec ; GOLF_LEVEL_17 dw GolfLevel18, BGMap_1c2410, BGMap_1c2361, BGMap_1c247d, BGMap_1c23bc ; GOLF_LEVEL_18 dw GolfLevel19, BGMap_1c316a, BGMap_1c30b7, BGMap_1c31e4, BGMap_1c3119 ; GOLF_LEVEL_19 + assert_table_length NUM_GOLF_LEVELS ShowGolfLevelFlagAndPar: ld a, BANK("VRAM1") diff --git a/src/engine/level/particles.asm b/src/engine/level/particles.asm index 2c835c1..50fd412 100644 --- a/src/engine/level/particles.asm +++ b/src/engine/level/particles.asm @@ -46,7 +46,7 @@ UpdateParticles: and a ret z -FOR n, 1, NUM_PARTICLES + 1 +FOR n, 1, MAX_NUM_PARTICLES + 1 ld hl, wParticle{u:n} ld a, [hl] and a @@ -62,6 +62,8 @@ ENDR ld a, [hl] jumptable +.table + table_width 2, UpdateParticles.table dw ParticleFunc_None ; PARTICLE_NONE dw ParticleFunc_Debris ; PARTICLE_DEBRIS dw ParticleFunc_Stars ; PARTICLE_STARS @@ -77,14 +79,15 @@ ENDR dw ParticleFunc_Ice ; PARTICLE_ICE dw ParticleFunc_TreasureGlow ; PARTICLE_TREASURE_GLOW dw ParticleFunc_Owl ; PARTICLE_OWL - dw ParticleFunc_Snow ; PARTICLE_SNOW + dw ParticleFunc_Snow ; PARTICLE_SNOW dw ParticleFunc_Magic1 ; PARTICLE_MAGIC_1 dw ParticleFunc_Magic2 ; PARTICLE_MAGIC_2 dw ParticleFunc_MagicStop ; PARTICLE_MAGIC_STOP - dw ParticleFunc_None ; PARTICLE_13 - dw ParticleFunc_None ; PARTICLE_14 - dw ParticleFunc_None ; PARTICLE_15 - dw ParticleFunc_None ; PARTICLE_16 + dw ParticleFunc_None ; PARTICLE_UNUSED_13 + dw ParticleFunc_None ; PARTICLE_UNUSED_14 + dw ParticleFunc_None ; PARTICLE_UNUSED_15 + dw ParticleFunc_None ; PARTICLE_UNUSED_16 + assert_table_length NUM_PARTICLES ParticleFunc_None: ret diff --git a/src/home/home1.asm b/src/home/home1.asm index 140019d..a185372 100644 --- a/src/home/home1.asm +++ b/src/home/home1.asm @@ -1154,7 +1154,7 @@ DoGroundShake:: ClearParticles:: ld hl, wParticles - ld b, PARTICLE_STRUCT_LENGTH * NUM_PARTICLES + 2 + ld b, PARTICLE_STRUCT_LENGTH * MAX_NUM_PARTICLES + 2 xor a call WriteAToHL_BTimes ret diff --git a/src/includes.asm b/src/includes.asm index 29e11d6..8c9ecc5 100644 --- a/src/includes.asm +++ b/src/includes.asm @@ -1,5 +1,6 @@ INCLUDE "charmaps.asm" +INCLUDE "macros/asserts.asm" INCLUDE "macros/audio.asm" INCLUDE "macros/audio_commands.asm" INCLUDE "macros/constants.asm" diff --git a/src/macros/asserts.asm b/src/macros/asserts.asm new file mode 100644 index 0000000..edd26b3 --- /dev/null +++ b/src/macros/asserts.asm @@ -0,0 +1,17 @@ +; Macros to verify assumptions about the data or code + +MACRO table_width +DEF CURRENT_TABLE_WIDTH = \1 +IF _NARG == 2 +REDEF CURRENT_TABLE_START EQUS "\2" +ELSE +REDEF CURRENT_TABLE_START EQUS "._table_width\@" +{CURRENT_TABLE_START}: +ENDC +ENDM + +MACRO assert_table_length +DEF x = \1 + ASSERT x * CURRENT_TABLE_WIDTH == @ - {CURRENT_TABLE_START}, \ + "{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes" +ENDM