summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio/cry_pointers.asm3
-rw-r--r--audio/music_pointers.asm2
-rw-r--r--audio/sfx_pointers.asm2
-rw-r--r--constants.asm2
-rw-r--r--constants/audio_constants.asm77
-rw-r--r--constants/battle_anim_constants.asm7
-rw-r--r--constants/battle_constants.asm3
-rw-r--r--constants/battle_tower_constants.asm2
-rw-r--r--constants/credits_constants.asm1
-rw-r--r--constants/cry_constants.asm2
-rw-r--r--constants/deco_constants.asm15
-rw-r--r--constants/gfx_constants.asm2
-rw-r--r--constants/icon_constants.asm1
-rw-r--r--constants/item_constants.asm1
-rw-r--r--constants/landmark_constants.asm3
-rw-r--r--constants/map_data_constants.asm6
-rw-r--r--constants/map_object_constants.asm5
-rw-r--r--constants/menu_constants.asm2
-rw-r--r--constants/move_constants.asm1
-rw-r--r--constants/move_effect_constants.asm1
-rw-r--r--constants/music_constants.asm1
-rw-r--r--constants/npc_trade_constants.asm22
-rw-r--r--constants/phone_constants.asm3
-rw-r--r--constants/pokemon_data_constants.asm130
-rw-r--r--constants/radio_constants.asm5
-rw-r--r--constants/script_constants.asm4
-rw-r--r--constants/sfx_constants.asm2
-rw-r--r--constants/sprite_anim_constants.asm4
-rw-r--r--constants/sprite_constants.asm2
-rw-r--r--constants/tileset_constants.asm7
-rw-r--r--constants/trainer_constants.asm3
-rw-r--r--constants/type_constants.asm4
-rw-r--r--data/battle/effect_command_pointers.asm2
-rw-r--r--data/battle_anims/framesets.asm2
-rw-r--r--data/battle_anims/oam.asm2
-rw-r--r--data/battle_anims/object_gfx.asm2
-rw-r--r--data/battle_anims/objects.asm2
-rw-r--r--data/battle_tower/classes.asm4
-rw-r--r--data/battle_tower/parties.asm3
-rw-r--r--data/battle_tower/unknown.asm3
-rw-r--r--data/collision/collision_permissions.asm2
-rw-r--r--data/credits_strings.asm2
-rw-r--r--data/decorations/attributes.asm4
-rw-r--r--data/decorations/decorations.asm3
-rw-r--r--data/default_options.asm2
-rw-r--r--data/events/bug_contest_flags.asm3
-rw-r--r--data/events/bug_contest_winners.asm3
-rw-r--r--data/events/elevator_floors.asm2
-rw-r--r--data/events/engine_flags.asm3
-rw-r--r--data/events/happiness_changes.asm4
-rw-r--r--data/events/npc_trades.asm2
-rw-r--r--data/events/odd_eggs.asm7
-rw-r--r--data/icon_pointers.asm4
-rw-r--r--data/items/attributes.asm7
-rw-r--r--data/items/buena_prizes.asm3
-rw-r--r--data/items/descriptions.asm5
-rw-r--r--data/items/fruit_trees.asm2
-rw-r--r--data/items/marts.asm4
-rw-r--r--data/maps/landmarks.asm3
-rw-r--r--data/maps/maps.asm2
-rw-r--r--data/maps/outdoor_sprites.asm2
-rw-r--r--data/maps/roofs.asm5
-rw-r--r--data/maps/sgb_roof_pal_inds.asm2
-rw-r--r--data/maps/spawn_points.asm3
-rw-r--r--data/mon_menu.asm4
-rw-r--r--data/moves/animations.asm4
-rw-r--r--data/moves/descriptions.asm3
-rw-r--r--data/moves/effects_pointers.asm2
-rw-r--r--data/moves/moves.asm4
-rw-r--r--data/moves/tmhm_moves.asm3
-rw-r--r--data/party_menu_qualities.asm2
-rw-r--r--data/phone/non_trainer_names.asm4
-rw-r--r--data/phone/phone_contacts.asm2
-rw-r--r--data/phone/special_calls.asm2
-rw-r--r--data/pokemon/base_stats.asm4
-rw-r--r--data/pokemon/cries.asm3
-rw-r--r--data/pokemon/dex_entry_pointers.asm2
-rw-r--r--data/pokemon/dex_order_alpha.asm2
-rw-r--r--data/pokemon/dex_order_new.asm2
-rw-r--r--data/pokemon/egg_move_pointers.asm2
-rw-r--r--data/pokemon/evos_attacks_pointers.asm2
-rw-r--r--data/pokemon/gen1_base_special.asm2
-rw-r--r--data/pokemon/gen1_order.asm4
-rw-r--r--data/pokemon/menu_icons.asm2
-rw-r--r--data/pokemon/names.asm4
-rw-r--r--data/pokemon/palettes.asm9
-rw-r--r--data/pokemon/pic_pointers.asm3
-rw-r--r--data/pokemon/unown_pic_pointers.asm2
-rw-r--r--data/pokemon/unown_words.asm4
-rw-r--r--data/radio/buenas_passwords.asm3
-rw-r--r--data/radio/channel_music.asm4
-rw-r--r--data/radio/oaks_pkmn_talk_routes.asm2
-rw-r--r--data/sprite_anims/framesets.asm4
-rw-r--r--data/sprite_anims/oam.asm4
-rw-r--r--data/sprite_anims/sequences.asm4
-rw-r--r--data/sprites/emotes.asm2
-rw-r--r--data/sprites/facings.asm9
-rw-r--r--data/sprites/map_objects.asm3
-rw-r--r--data/sprites/sprite_mons.asm2
-rw-r--r--data/sprites/sprites.asm2
-rw-r--r--data/tilesets.asm4
-rw-r--r--data/trainers/attributes.asm3
-rw-r--r--data/trainers/dvs.asm2
-rw-r--r--data/trainers/encounter_music.asm8
-rw-r--r--data/trainers/genders.asm2
-rw-r--r--data/trainers/palettes.asm4
-rw-r--r--data/trainers/party_pointers.asm2
-rw-r--r--data/trainers/pic_pointers.asm2
-rw-r--r--data/trainers/sprites.asm2
-rw-r--r--data/types/names.asm4
-rw-r--r--data/types/search_strings.asm2
-rw-r--r--data/types/search_types.asm2
-rw-r--r--data/wild/fish.asm2
-rw-r--r--data/wild/probabilities.asm4
-rw-r--r--data/wild/treemons.asm4
-rw-r--r--engine/battle/move_effects/conversion2.asm2
-rw-r--r--engine/battle_anims/core.asm2
-rw-r--r--engine/debug/color_picker.asm4
-rw-r--r--engine/gfx/color.asm2
-rw-r--r--engine/gfx/load_pics.asm2
-rw-r--r--engine/gfx/sprite_anims.asm4
-rw-r--r--engine/items/item_effects.asm18
-rw-r--r--engine/overworld/decorations.asm116
-rw-r--r--engine/overworld/map_object_action.asm4
-rw-r--r--engine/overworld/map_objects.asm8
-rw-r--r--engine/overworld/overworld.asm2
-rw-r--r--engine/overworld/player_movement.asm6
-rw-r--r--engine/phone/phone.asm4
-rw-r--r--engine/pokedex/pokedex.asm8
-rw-r--r--engine/pokegear/radio.asm22
-rw-r--r--engine/tilesets/mapgroup_roofs.asm4
-rw-r--r--gfx/footprints.asm4
-rw-r--r--gfx/pokemon/anim_pointers.asm2
-rw-r--r--gfx/pokemon/bitmask_pointers.asm2
-rw-r--r--gfx/pokemon/frame_pointers.asm2
-rw-r--r--gfx/pokemon/idle_pointers.asm2
-rw-r--r--gfx/pokemon/unown_anim_pointers.asm2
-rw-r--r--gfx/pokemon/unown_bitmask_pointers.asm2
-rw-r--r--gfx/pokemon/unown_frame_pointers.asm2
-rw-r--r--gfx/pokemon/unown_idle_pointers.asm2
-rw-r--r--home/audio.asm2
-rw-r--r--home/battle_vars.asm4
-rw-r--r--home/map.asm4
-rw-r--r--home/pokemon.asm2
-rw-r--r--macros.asm1
-rw-r--r--macros/asserts.asm20
-rw-r--r--macros/scripts/battle_commands.asm1
-rw-r--r--wram.asm2
148 files changed, 611 insertions, 240 deletions
diff --git a/audio/cry_pointers.asm b/audio/cry_pointers.asm
index ec6b17e01..58b948a0b 100644
--- a/audio/cry_pointers.asm
+++ b/audio/cry_pointers.asm
@@ -1,4 +1,6 @@
Cries:
+; entries correspond to CRY_* constants (see constants/cry_constants.asm)
+ table_width 3, Cries
dba Cry_Nidoran_M
dba Cry_Nidoran_F
dba Cry_Slowpoke
@@ -67,3 +69,4 @@ Cries:
dba Cry_Aipom
dba Cry_Dunsparce
dba Cry_Donphan
+ assert_table_length NUM_CRIES
diff --git a/audio/music_pointers.asm b/audio/music_pointers.asm
index 192962735..f3124c790 100644
--- a/audio/music_pointers.asm
+++ b/audio/music_pointers.asm
@@ -2,6 +2,7 @@
Music:
; entries correspond to MUSIC_* constants
+ table_width 3, Music
dba Music_Nothing
dba Music_TitleScreen
dba Music_Route1
@@ -106,3 +107,4 @@ Music:
dba Music_SuicuneBattle
dba Music_BattleTowerLobby
dba Music_MobileCenter
+ assert_table_length NUM_MUSIC_SONGS
diff --git a/audio/sfx_pointers.asm b/audio/sfx_pointers.asm
index 815a65708..6b4d9df24 100644
--- a/audio/sfx_pointers.asm
+++ b/audio/sfx_pointers.asm
@@ -1,5 +1,6 @@
SFX:
; entries correspond to SFX_* constants
+ table_width 3, SFX
dba Sfx_DexFanfare5079
dba Sfx_Item
dba Sfx_CaughtMon
@@ -208,3 +209,4 @@ SFX:
dba Sfx_TwoPcBeeps
dba Sfx_4NoteDitty
dba Sfx_Twinkle
+ assert_table_length NUM_SFX
diff --git a/constants.asm b/constants.asm
index 71bd2c4dc..32c8d814c 100644
--- a/constants.asm
+++ b/constants.asm
@@ -12,7 +12,6 @@ INCLUDE "constants/text_constants.asm"
INCLUDE "constants/audio_constants.asm"
INCLUDE "constants/battle_anim_constants.asm"
INCLUDE "constants/battle_constants.asm"
-INCLUDE "constants/battle_tower_constants.asm"
INCLUDE "constants/collision_constants.asm"
INCLUDE "constants/credits_constants.asm"
INCLUDE "constants/cry_constants.asm"
@@ -50,3 +49,4 @@ INCLUDE "constants/tileset_constants.asm"
INCLUDE "constants/trainer_constants.asm"
INCLUDE "constants/trainer_data_constants.asm"
INCLUDE "constants/type_constants.asm"
+INCLUDE "constants/battle_tower_constants.asm"
diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm
index f5895dd98..88d318926 100644
--- a/constants/audio_constants.asm
+++ b/constants/audio_constants.asm
@@ -30,44 +30,45 @@ NUM_NOISE_CHANS EQU const_value - NUM_MUSIC_CHANS
NUM_CHANNELS EQU const_value
; channel_struct members (see macros/wram.asm)
-CHANNEL_MUSIC_ID EQUS "(wChannel1MusicID - wChannel1)"
-CHANNEL_MUSIC_BANK EQUS "(wChannel1MusicBank - wChannel1)"
-CHANNEL_FLAGS1 EQUS "(wChannel1Flags1 - wChannel1)"
-CHANNEL_FLAGS2 EQUS "(wChannel1Flags2 - wChannel1)"
-CHANNEL_FLAGS3 EQUS "(wChannel1Flags3 - wChannel1)"
-CHANNEL_MUSIC_ADDRESS EQUS "(wChannel1MusicAddress - wChannel1)"
-CHANNEL_LAST_MUSIC_ADDRESS EQUS "(wChannel1LastMusicAddress - wChannel1)"
-CHANNEL_NOTE_FLAGS EQUS "(wChannel1NoteFlags - wChannel1)"
-CHANNEL_CONDITION EQUS "(wChannel1Condition - wChannel1)"
-CHANNEL_DUTY_CYCLE EQUS "(wChannel1DutyCycle - wChannel1)"
-CHANNEL_VOLUME_ENVELOPE EQUS "(wChannel1VolumeEnvelope - wChannel1)"
-CHANNEL_FREQUENCY EQUS "(wChannel1Frequency - wChannel1)"
-CHANNEL_PITCH EQUS "(wChannel1Pitch - wChannel1)"
-CHANNEL_OCTAVE EQUS "(wChannel1Octave - wChannel1)"
-CHANNEL_TRANSPOSITION EQUS "(wChannel1Transposition - wChannel1)"
-CHANNEL_NOTE_DURATION EQUS "(wChannel1NoteDuration - wChannel1)"
-CHANNEL_FIELD16 EQUS "(wChannel1Field16 - wChannel1)"
-CHANNEL_LOOP_COUNT EQUS "(wChannel1LoopCount - wChannel1)"
-CHANNEL_TEMPO EQUS "(wChannel1Tempo - wChannel1)"
-CHANNEL_TRACKS EQUS "(wChannel1Tracks - wChannel1)"
-CHANNEL_DUTY_CYCLE_PATTERN EQUS "(wChannel1DutyCyclePattern - wChannel1)"
-CHANNEL_VIBRATO_DELAY_COUNT EQUS "(wChannel1VibratoDelayCount - wChannel1)"
-CHANNEL_VIBRATO_DELAY EQUS "(wChannel1VibratoDelay - wChannel1)"
-CHANNEL_VIBRATO_EXTENT EQUS "(wChannel1VibratoExtent - wChannel1)"
-CHANNEL_VIBRATO_RATE EQUS "(wChannel1VibratoRate - wChannel1)"
-CHANNEL_PITCH_SLIDE_TARGET EQUS "(wChannel1PitchSlideTarget - wChannel1)"
-CHANNEL_PITCH_SLIDE_AMOUNT EQUS "(wChannel1PitchSlideAmount - wChannel1)"
-CHANNEL_PITCH_SLIDE_AMOUNT_FRACTION EQUS "(wChannel1PitchSlideAmountFraction - wChannel1)"
-CHANNEL_FIELD25 EQUS "(wChannel1Field25 - wChannel1)"
-CHANNEL_PITCH_OFFSET EQUS "(wChannel1PitchOffset - wChannel1)"
-CHANNEL_FIELD29 EQUS "(wChannel1Field29 - wChannel1)"
-CHANNEL_FIELD2A EQUS "(wChannel1Field2a - wChannel1)"
-CHANNEL_FIELD2C EQUS "(wChannel1Field2c - wChannel1)"
-CHANNEL_NOTE_LENGTH EQUS "(wChannel1NoteLength - wChannel1)"
-CHANNEL_FIELD2E EQUS "(wChannel1Field2e - wChannel1)"
-CHANNEL_FIELD2F EQUS "(wChannel1Field2f - wChannel1)"
-CHANNEL_FIELD30 EQUS "(wChannel1Field30 - wChannel1)"
-CHANNEL_STRUCT_LENGTH EQUS "(wChannel2 - wChannel1)"
+rsreset
+CHANNEL_MUSIC_ID rw
+CHANNEL_MUSIC_BANK rb
+CHANNEL_FLAGS1 rb
+CHANNEL_FLAGS2 rb
+CHANNEL_FLAGS3 rb
+CHANNEL_MUSIC_ADDRESS rw
+CHANNEL_LAST_MUSIC_ADDRESS rw 2
+CHANNEL_NOTE_FLAGS rb
+CHANNEL_CONDITION rb
+CHANNEL_DUTY_CYCLE rb
+CHANNEL_VOLUME_ENVELOPE rb
+CHANNEL_FREQUENCY rw
+CHANNEL_PITCH rb
+CHANNEL_OCTAVE rb
+CHANNEL_TRANSPOSITION rb
+CHANNEL_NOTE_DURATION rb
+CHANNEL_FIELD16 rb 2
+CHANNEL_LOOP_COUNT rb
+CHANNEL_TEMPO rw
+CHANNEL_TRACKS rb
+CHANNEL_DUTY_CYCLE_PATTERN rb
+CHANNEL_VIBRATO_DELAY_COUNT rb
+CHANNEL_VIBRATO_DELAY rb
+CHANNEL_VIBRATO_EXTENT rb
+CHANNEL_VIBRATO_RATE rb
+CHANNEL_PITCH_SLIDE_TARGET rw
+CHANNEL_PITCH_SLIDE_AMOUNT rb
+CHANNEL_PITCH_SLIDE_AMOUNT_FRACTION rb
+CHANNEL_FIELD25 rb 2
+CHANNEL_PITCH_OFFSET rw
+CHANNEL_FIELD29 rb
+CHANNEL_FIELD2A rw
+CHANNEL_FIELD2C rb
+CHANNEL_NOTE_LENGTH rb
+CHANNEL_FIELD2E rb
+CHANNEL_FIELD2F rb
+CHANNEL_FIELD30 rb 2
+CHANNEL_STRUCT_LENGTH EQU _RS
NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7
diff --git a/constants/battle_anim_constants.asm b/constants/battle_anim_constants.asm
index 351c90453..b91927d0d 100644
--- a/constants/battle_anim_constants.asm
+++ b/constants/battle_anim_constants.asm
@@ -7,6 +7,7 @@
const BATTLEANIMSTRUCT_FUNCTION
const BATTLEANIMSTRUCT_PALETTE
const BATTLEANIMSTRUCT_TILEID
+BATTLEANIMOBJ_LENGTH EQU const_value - 1 ; discount BATTLEANIMSTRUCT_INDEX
const BATTLEANIMSTRUCT_XCOORD
const BATTLEANIMSTRUCT_YCOORD
const BATTLEANIMSTRUCT_XOFFSET
@@ -217,6 +218,7 @@ BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
const ANIM_OBJ_PLAYERHEAD_1ROW
const ANIM_OBJ_ENEMYFEET_2ROW
const ANIM_OBJ_PLAYERHEAD_2ROW
+NUM_ANIM_OBJS EQU const_value
; DoBattleAnimFrame arguments (see engine/battle_anims/functions.asm)
const_def
@@ -300,6 +302,7 @@ BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
const BATTLEANIMFUNC_ANCIENT_POWER
const BATTLEANIMFUNC_ROCK_SMASH
const BATTLEANIMFUNC_COTTON
+NUM_BATTLEANIMFUNCS EQU const_value
; BattleAnimFrameData indexes (see data/battle_anims/framesets.asm)
const_def
@@ -488,6 +491,7 @@ BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
const BATTLEANIMFRAMESET_B6
const BATTLEANIMFRAMESET_B7
const BATTLEANIMFRAMESET_B8
+NUM_BATTLEANIMFRAMESETS EQU const_value
; BattleAnimOAMData indexes (see data/battle_anims/oam.asm)
const_def
@@ -707,6 +711,7 @@ BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
const BATTLEANIMOAMSET_D5
const BATTLEANIMOAMSET_D6
const BATTLEANIMOAMSET_D7
+NUM_BATTLEANIMOAMSETS EQU const_value
; BattleBGEffects indexes (see engine/battle_anims/bg_effects.asm)
const_def 1
@@ -763,6 +768,7 @@ BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
const ANIM_BG_VIBRATE_MON
const ANIM_BG_WOBBLE_PLAYER
const ANIM_BG_WOBBLE_SCREEN
+NUM_ANIM_BGS EQU const_value - 1
; wBattleAnimTileDict keys (see wram.asm)
; AnimObjGFX indexes (see data/battle_anims/object_gfx.asm)
@@ -808,6 +814,7 @@ BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
const ANIM_GFX_AEROBLAST
const ANIM_GFX_PLAYERHEAD
const ANIM_GFX_ENEMYFEET
+NUM_ANIM_GFX EQU const_value - 1
; battle_bg_effect struct members (see macros/wram.asm)
const_def
diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm
index d66778a55..d8d1a3a84 100644
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -120,6 +120,7 @@ SPDSPCDV_SHINY EQU $AA
const BATTLE_VARS_LAST_COUNTER_MOVE_OPP
const BATTLE_VARS_LAST_MOVE
const BATTLE_VARS_LAST_MOVE_OPP
+NUM_BATTLE_VARS EQU const_value
; BattleVarLocations indexes (see home/battle.asm)
const_def
@@ -149,6 +150,8 @@ SPDSPCDV_SHINY EQU $AA
const ENEMY_COUNTER_MOVE
const PLAYER_LAST_MOVE
const ENEMY_LAST_MOVE
+assert const_value % 2 == 0
+NUM_BATTLE_VAR_LOCATION_PAIRS EQU const_value / 2
; status condition bit flags
SLP EQU %111 ; 0-7 turns
diff --git a/constants/battle_tower_constants.asm b/constants/battle_tower_constants.asm
index 419d364c7..82d5bf448 100644
--- a/constants/battle_tower_constants.asm
+++ b/constants/battle_tower_constants.asm
@@ -5,7 +5,7 @@ BATTLETOWER_NUM_UNIQUE_MON EQU 21
BATTLETOWER_NUM_UNIQUE_TRAINERS EQU 70
BATTLETOWER_TRAINERDATALENGTH EQU $24
-BATTLE_TOWER_STRUCT_LENGTH EQUS "(NAME_LENGTH + BATTLETOWER_PARTY_LENGTH * NICKNAMED_MON_STRUCT_LENGTH + BATTLETOWER_TRAINERDATALENGTH)"
+BATTLE_TOWER_STRUCT_LENGTH EQU NAME_LENGTH + BATTLETOWER_PARTY_LENGTH * NICKNAMED_MON_STRUCT_LENGTH + BATTLETOWER_TRAINERDATALENGTH
; BattleTowerAction setval arguments (see engine/events/battle_tower/battle_tower.asm)
const_def
diff --git a/constants/credits_constants.asm b/constants/credits_constants.asm
index a3d20eb46..8be909a85 100644
--- a/constants/credits_constants.asm
+++ b/constants/credits_constants.asm
@@ -103,6 +103,7 @@
const US_COORDINATION
const TEXT_TRANSLATION
const PAAD_TESTING
+NUM_CREDITS_STRINGS EQU const_value
; CreditsScript indexes (see data/credits_script.asm)
const_def -1, -1
diff --git a/constants/cry_constants.asm b/constants/cry_constants.asm
index 654aac523..94db303a6 100644
--- a/constants/cry_constants.asm
+++ b/constants/cry_constants.asm
@@ -72,3 +72,5 @@
const CRY_AIPOM
const CRY_DUNSPARCE
const CRY_DONPHAN
+
+NUM_CRIES EQU const_value
diff --git a/constants/deco_constants.asm b/constants/deco_constants.asm
index 29aea301e..a00849277 100644
--- a/constants/deco_constants.asm
+++ b/constants/deco_constants.asm
@@ -1,3 +1,13 @@
+; decoration attributes
+ const_def
+ const DECOATTR_TYPE
+ const DECOATTR_NAME
+ const DECOATTR_ACTION
+ const DECOATTR_EVENT_FLAG
+ const_skip ; high DECOATTR_EVENT_FLAG byte
+ const DECOATTR_SPRITE
+DECOATTR_STRUCT_LENGTH EQU const_value
+
; decoration types
const_def 1
const DECO_PLANT
@@ -6,6 +16,7 @@
const DECO_POSTER
const DECO_DOLL
const DECO_BIGDOLL
+NUM_DECO_TYPES EQU const_value - 1
; DecorationNames indexes (see data/decorations/names.asm)
const_def 1
@@ -51,8 +62,7 @@
const PUT_AWAY_BIG_DOLL
const SET_UP_DOLL
const PUT_AWAY_DOLL
- const SET_UP_ORNAMENT
- const PUT_AWAY_ORNAMENT
+NUM_DECO_ACTIONS EQU const_value - 1
__deco_value__ = 0
@@ -127,3 +137,4 @@ NUM_NON_TROPHY_DECOS EQU __deco_value__
deco GOLD_TROPHY_DOLL
deco SILVER_TROPHY_DOLL
NUM_DECOS EQU __deco_value__
+NUM_DECO_CATEGORIES EQU const_value - 1 - NUM_DECOS
diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm
index 5e7391458..c05c0fb8b 100644
--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -6,7 +6,7 @@ NUM_PAL_COLORS EQU 4
PAL_COLOR_SIZE EQU 2
PALETTE_SIZE EQU NUM_PAL_COLORS * PAL_COLOR_SIZE
-PALRGB_WHITE EQUS "palred 31 + palgreen 31 + palblue 31" ; $7fff
+PALRGB_WHITE EQU palred 31 + palgreen 31 + palblue 31 ; $7fff
SCREEN_WIDTH EQU 20 ; tiles
SCREEN_HEIGHT EQU 18 ; tiles
diff --git a/constants/icon_constants.asm b/constants/icon_constants.asm
index 870175f45..d4fbf28c0 100644
--- a/constants/icon_constants.asm
+++ b/constants/icon_constants.asm
@@ -39,6 +39,7 @@
const ICON_SLOWPOKE
const ICON_SUDOWOODO
const ICON_BIGMON
+NUM_ICONS EQU const_value - 1
; LoadMenuMonIcon.Jumptable indexes (see engine/gfx/mon_icons.asm)
const_def
diff --git a/constants/item_constants.asm b/constants/item_constants.asm
index 2a4d8ee25..fc24deb05 100644
--- a/constants/item_constants.asm
+++ b/constants/item_constants.asm
@@ -196,6 +196,7 @@
const MUSIC_MAIL ; bc
const MIRAGE_MAIL ; bd
const ITEM_BE ; be
+NUM_ITEMS EQU const_value - 1
__tmhm_value__ = 1
diff --git a/constants/landmark_constants.asm b/constants/landmark_constants.asm
index 9b562288c..18461cdb1 100644
--- a/constants/landmark_constants.asm
+++ b/constants/landmark_constants.asm
@@ -1,6 +1,5 @@
; Landmarks indexes (see data/maps/landmarks.asm)
const_def
-
; Johto landmarks
const LANDMARK_SPECIAL ; 00
const LANDMARK_NEW_BARK_TOWN ; 01
@@ -49,7 +48,6 @@
const LANDMARK_DARK_CAVE ; 2c
const LANDMARK_ROUTE_46 ; 2d
const LANDMARK_SILVER_CAVE ; 2e
-
KANTO_LANDMARK EQU const_value
const LANDMARK_PALLET_TOWN ; 2f
const LANDMARK_ROUTE_1 ; 30
@@ -100,6 +98,7 @@ KANTO_LANDMARK EQU const_value
const LANDMARK_TOHJO_FALLS ; 5d
const LANDMARK_ROUTE_28 ; 5e
const LANDMARK_FAST_SHIP ; 5f
+NUM_LANDMARKS EQU const_value
; used in CaughtData
const_def $7f, -1
diff --git a/constants/map_data_constants.asm b/constants/map_data_constants.asm
index 533157101..5e16e65ae 100644
--- a/constants/map_data_constants.asm
+++ b/constants/map_data_constants.asm
@@ -50,6 +50,7 @@ NUM_MAP_PALETTES EQU const_value
const FISHGROUP_QWILFISH
const FISHGROUP_REMORAID
const FISHGROUP_QWILFISH_NO_SWARM
+NUM_FISHGROUPS EQU const_value - 1
; connection directions (see data/maps/data.asm)
const_def
@@ -66,8 +67,7 @@ NUM_MAP_PALETTES EQU const_value
shift_const NORTH
; SpawnPoints indexes (see data/maps/spawn_points.asm)
- const_def -1
- const SPAWN_N_A
+ const_def
const SPAWN_HOME
const SPAWN_DEBUG
; kanto
@@ -100,6 +100,8 @@ NUM_MAP_PALETTES EQU const_value
const SPAWN_FAST_SHIP
NUM_SPAWNS EQU const_value
+SPAWN_N_A EQU -1
+
; Flypoints indexes (see data/maps/flypoints.asm)
const_def
; johto
diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm
index 59a98bce5..29f2c9d05 100644
--- a/constants/map_object_constants.asm
+++ b/constants/map_object_constants.asm
@@ -199,6 +199,7 @@ NUM_SPRITEMOVEDATA EQU const_value
const SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE ; 19
const SPRITEMOVEFN_BOULDERDUST ; 1a
const SPRITEMOVEFN_GRASS ; 1b
+NUM_SPRITEMOVEFN EQU const_value
; StepTypesJumptable indexes (see engine/overworld/map_objects.asm)
const_def
@@ -228,6 +229,7 @@ NUM_SPRITEMOVEDATA EQU const_value
const STEP_TYPE_17 ; 17
const STEP_TYPE_DELETE ; 18
const STEP_TYPE_SKYFALL_TOP ; 19
+NUM_STEP_TYPES EQU const_value
; ObjectActionPairPointers indexes (see engine/overworld/map_object_action.asm)
const_def
@@ -248,6 +250,7 @@ NUM_SPRITEMOVEDATA EQU const_value
const OBJECT_ACTION_BOULDER_DUST ; 0e
const OBJECT_ACTION_GRASS_SHAKE ; 0f
const OBJECT_ACTION_SKYFALL ; 10
+NUM_OBJECT_ACTIONS EQU const_value
; Facings indexes (see data/sprites/facings.asm)
const_def
@@ -283,6 +286,7 @@ NUM_SPRITEMOVEDATA EQU const_value
const FACING_BOULDER_DUST_2 ; 1d
const FACING_GRASS_1 ; 1e
const FACING_GRASS_2 ; 1f
+NUM_FACINGS EQU const_value
; DoPlayerMovement.DoStep arguments (see engine/overworld/player_movement.asm)
const_def
@@ -294,3 +298,4 @@ NUM_SPRITEMOVEDATA EQU const_value
const STEP_TURN ; 5
const STEP_BACK_LEDGE ; 6
const STEP_WALK_IN_PLACE ; 7
+NUM_STEPS EQU const_value
diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm
index 031a5e2bf..060bfc453 100644
--- a/constants/menu_constants.asm
+++ b/constants/menu_constants.asm
@@ -63,6 +63,7 @@
const MONMENUITEM_MOVE ; 19
const MONMENUITEM_MAIL ; 20
const MONMENUITEM_ERROR ; 21
+NUM_MONMENUITEMS EQU const_value - 1
; MonMenuOptions categories
MONMENU_FIELD_MOVE EQU 0
@@ -86,6 +87,7 @@ HMENURETURN_ASM EQU %11111111
const PARTYMENUACTION_GIVE_MON_FEMALE ; unused
const PARTYMENUACTION_GIVE_ITEM
const PARTYMENUACTION_MOBILE ; mobile
+NUM_PARTYMENUACTIONS EQU const_value
; PrintPartyMenuActionText arguments (see engine/pokemon/party_menu.asm)
const_next $f0
const PARTYMENUTEXT_HEAL_PSN
diff --git a/constants/move_constants.asm b/constants/move_constants.asm
index 1a3d4f1ae..5f6bff0cb 100644
--- a/constants/move_constants.asm
+++ b/constants/move_constants.asm
@@ -285,6 +285,7 @@ NUM_ATTACKS EQU const_value - 1
const ANIM_WOBBLE ; 113
const ANIM_SHAKE ; 114
const ANIM_HIT_CONFUSION ; 115
+NUM_BATTLE_ANIMS EQU const_value - 1
; wNumHits uses offsets from ANIM_MISS
const_def
diff --git a/constants/move_effect_constants.asm b/constants/move_effect_constants.asm
index 0ca97f380..79babcf74 100644
--- a/constants/move_effect_constants.asm
+++ b/constants/move_effect_constants.asm
@@ -157,3 +157,4 @@
const EFFECT_BEAT_UP
const EFFECT_FLY
const EFFECT_DEFENSE_CURL
+NUM_MOVE_EFECTS EQU const_value
diff --git a/constants/music_constants.asm b/constants/music_constants.asm
index 83085ef0c..941cb2bfb 100644
--- a/constants/music_constants.asm
+++ b/constants/music_constants.asm
@@ -107,6 +107,7 @@
const MUSIC_SUICUNE_BATTLE ; 64
const MUSIC_BATTLE_TOWER_LOBBY ; 65
const MUSIC_MOBILE_CENTER ; 66
+NUM_MUSIC_SONGS EQU const_value
; GetMapMusic picks music for this value (see home/map.asm)
MUSIC_MAHOGANY_MART EQU $64
diff --git a/constants/npc_trade_constants.asm b/constants/npc_trade_constants.asm
index f84db5df4..e0218e1d5 100644
--- a/constants/npc_trade_constants.asm
+++ b/constants/npc_trade_constants.asm
@@ -1,14 +1,16 @@
; npctrade struct members (see data/events/npc_trades.asm)
-NPCTRADE_DIALOG EQU 0 ; db
-NPCTRADE_GIVEMON EQU 1 ; db
-NPCTRADE_GETMON EQU 2 ; db
-NPCTRADE_NICK EQU 3 ; ds MON_NAME_LENGTH
-NPCTRADE_DVS EQU 14 ; dw
-NPCTRADE_ITEM EQU 16 ; db
-NPCTRADE_OT_ID EQU 17 ; dw
-NPCTRADE_OT_NAME EQU 19 ; ds NAME_LENGTH
-NPCTRADE_GENDER EQU 30 ; db
-NPCTRADE_PADDING EQU 31 ; db
+rsreset
+NPCTRADE_DIALOG rb
+NPCTRADE_GIVEMON rb
+NPCTRADE_GETMON rb
+NPCTRADE_NICK rb MON_NAME_LENGTH
+NPCTRADE_DVS rw
+NPCTRADE_ITEM rb
+NPCTRADE_OT_ID rw
+NPCTRADE_OT_NAME rb NAME_LENGTH
+NPCTRADE_GENDER rb
+NPCTRADE_PADDING rb
+NPCTRADE_STRUCT_LENGTH EQU _RS
; NPCTrades indexes (see data/events/npc_trades.asm)
const_def
diff --git a/constants/phone_constants.asm b/constants/phone_constants.asm
index 273044c4d..4c318dbbd 100644
--- a/constants/phone_constants.asm
+++ b/constants/phone_constants.asm
@@ -38,6 +38,7 @@
const PHONE_HIKER_PARRY
const PHONE_PICNICKER_ERIN
const PHONE_BUENA
+NUM_PHONE_CONTACTS EQU const_value - 1
; SpecialPhoneCallList indexes (see data/phone/special_calls.asm)
const_def
@@ -50,6 +51,8 @@
const SPECIALCALL_BIKESHOP
const SPECIALCALL_WORRIED
const SPECIALCALL_MASTERBALL
+NUM_SPECIALCALLS EQU const_value - 1
+SPECIALCALL_SIZE EQU 6
; phone struct members
const_def
diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm
index 328a6a6fa..cbb7de8f7 100644
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -1,30 +1,35 @@
; base data struct members (see data/pokemon/base_stats/*.asm)
-BASE_DEX_NO EQUS "(wBaseDexNo - wCurBaseData)"
-BASE_STATS EQUS "(wBaseStats - wCurBaseData)"
-BASE_HP EQUS "(wBaseHP - wCurBaseData)"
-BASE_ATK EQUS "(wBaseAttack - wCurBaseData)"
-BASE_SPD EQUS "(wBaseSpeed - wCurBaseData)"
-BASE_SAT EQUS "(wBaseSpecialAttack - wCurBaseData)"
-BASE_SDF EQUS "(wBaseSpecialDefense - wCurBaseData)"
-BASE_TYPES EQUS "(wBaseType - wCurBaseData)"
-BASE_TYPE_1 EQUS "(wBaseType1 - wCurBaseData)"
-BASE_TYPE_2 EQUS "(wBaseType2 - wCurBaseData)"
-BASE_CATCH_RATE EQUS "(wBaseCatchRate - wCurBaseData)"
-BASE_EXP EQUS "(wBaseExp - wCurBaseData)"
-BASE_ITEMS EQUS "(wBaseItems - wCurBaseData)"
-BASE_ITEM_1 EQUS "(wBaseItem1 - wCurBaseData)"
-BASE_ITEM_2 EQUS "(wBaseItem2 - wCurBaseData)"
-BASE_GENDER EQUS "(wBaseGender - wCurBaseData)"
-BASE_UNKNOWN_1 EQUS "(wBaseUnknown1 - wCurBaseData)"
-BASE_EGG_STEPS EQUS "(wBaseEggSteps - wCurBaseData)"
-BASE_UNKNOWN_2 EQUS "(wBaseUnknown2 - wCurBaseData)"
-BASE_PIC_SIZE EQUS "(wBasePicSize - wCurBaseData)"
-BASE_FRONTPIC EQUS "(wBaseUnusedFrontpic - wCurBaseData)"
-BASE_BACKPIC EQUS "(wBaseUnusedBackpic - wCurBaseData)"
-BASE_GROWTH_RATE EQUS "(wBaseGrowthRate - wCurBaseData)"
-BASE_EGG_GROUPS EQUS "(wBaseEggGroups - wCurBaseData)"
-BASE_TMHM EQUS "(wBaseTMHM - wCurBaseData)"
-BASE_DATA_SIZE EQUS "(wCurBaseDataEnd - wCurBaseData)"
+rsreset
+BASE_DEX_NO rb
+BASE_STATS rb NUM_STATS
+rsset BASE_STATS
+BASE_HP rb
+BASE_ATK rb
+BASE_DEF rb
+BASE_SPD rb
+BASE_SAT rb
+BASE_SDF rb
+BASE_TYPES rw
+rsset BASE_TYPES
+BASE_TYPE_1 rb
+BASE_TYPE_2 rb
+BASE_CATCH_RATE rb
+BASE_EXP rb
+BASE_ITEMS rw
+rsset BASE_ITEMS
+BASE_ITEM_1 rb
+BASE_ITEM_2 rb
+BASE_GENDER rb
+BASE_UNKNOWN_1 rb
+BASE_EGG_STEPS rb
+BASE_UNKNOWN_2 rb
+BASE_PIC_SIZE rb
+BASE_FRONTPIC rw
+BASE_BACKPIC rw
+BASE_GROWTH_RATE rb
+BASE_EGG_GROUPS rb
+BASE_TMHM rb (NUM_TM_HM_TUTOR + 7) / 8
+BASE_DATA_SIZE EQU _RS
; gender ratio constants
GENDER_F0 EQU 0 percent
@@ -67,39 +72,43 @@ GENDER_UNKNOWN EQU -1
NUM_DEX_ENTRY_BANKS EQU 4
; party_struct members (see macros/wram.asm)
-MON_SPECIES EQUS "(wPartyMon1Species - wPartyMon1)"
-MON_ITEM EQUS "(wPartyMon1Item - wPartyMon1)"
-MON_MOVES EQUS "(wPartyMon1Moves - wPartyMon1)"
-MON_ID EQUS "(wPartyMon1ID - wPartyMon1)"
-MON_EXP EQUS "(wPartyMon1Exp - wPartyMon1)"
-MON_STAT_EXP EQUS "(wPartyMon1StatExp - wPartyMon1)"
-MON_HP_EXP EQUS "(wPartyMon1HPExp - wPartyMon1)"
-MON_ATK_EXP EQUS "(wPartyMon1AtkExp - wPartyMon1)"
-MON_DEF_EXP EQUS "(wPartyMon1DefExp - wPartyMon1)"
-MON_SPD_EXP EQUS "(wPartyMon1SpdExp - wPartyMon1)"
-MON_SPC_EXP EQUS "(wPartyMon1SpcExp - wPartyMon1)"
-MON_DVS EQUS "(wPartyMon1DVs - wPartyMon1)"
-MON_PP EQUS "(wPartyMon1PP - wPartyMon1)"
-MON_HAPPINESS EQUS "(wPartyMon1Happiness - wPartyMon1)"
-MON_PKRUS EQUS "(wPartyMon1PokerusStatus - wPartyMon1)"
-MON_CAUGHTDATA EQUS "(wPartyMon1CaughtData - wPartyMon1)"
-MON_CAUGHTLEVEL EQUS "(wPartyMon1CaughtLevel - wPartyMon1)"
-MON_CAUGHTTIME EQUS "(wPartyMon1CaughtTime - wPartyMon1)"
-MON_CAUGHTGENDER EQUS "(wPartyMon1CaughtGender - wPartyMon1)"
-MON_CAUGHTLOCATION EQUS "(wPartyMon1CaughtLocation - wPartyMon1)"
-MON_LEVEL EQUS "(wPartyMon1Level - wPartyMon1)"
-MON_STATUS EQUS "(wPartyMon1Status - wPartyMon1)"
-MON_HP EQUS "(wPartyMon1HP - wPartyMon1)"
-MON_MAXHP EQUS "(wPartyMon1MaxHP - wPartyMon1)"
-MON_ATK EQUS "(wPartyMon1Attack - wPartyMon1)"
-MON_DEF EQUS "(wPartyMon1Defense - wPartyMon1)"
-MON_SPD EQUS "(wPartyMon1Speed - wPartyMon1)"
-MON_SAT EQUS "(wPartyMon1SpclAtk - wPartyMon1)"
-MON_SDF EQUS "(wPartyMon1SpclDef - wPartyMon1)"
-BOXMON_STRUCT_LENGTH EQUS "(wPartyMon1BoxEnd - wPartyMon1)"
-PARTYMON_STRUCT_LENGTH EQUS "(wPartyMon1StructEnd - wPartyMon1)"
-
-NICKNAMED_MON_STRUCT_LENGTH EQUS "(PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH)"
+rsreset
+MON_SPECIES rb
+MON_ITEM rb
+MON_MOVES rb NUM_MOVES
+MON_ID rw
+MON_EXP rb 3
+MON_STAT_EXP rw NUM_EXP_STATS
+rsset MON_STAT_EXP
+MON_HP_EXP rw
+MON_ATK_EXP rw
+MON_DEF_EXP rw
+MON_SPD_EXP rw
+MON_SPC_EXP rw
+MON_DVS rw
+MON_PP rb NUM_MOVES
+MON_HAPPINESS rb
+MON_PKRUS rb
+MON_CAUGHTDATA rw
+rsset MON_CAUGHTDATA
+MON_CAUGHTTIME rb
+MON_CAUGHTGENDER rb
+rsset MON_CAUGHTDATA
+MON_CAUGHTLEVEL rb
+MON_CAUGHTLOCATION rb
+MON_LEVEL rb
+BOXMON_STRUCT_LENGTH EQU _RS
+MON_STATUS rb 2
+MON_HP rw
+MON_MAXHP rw
+MON_ATK rw
+MON_DEF rw
+MON_SPD rw
+MON_SAT rw
+MON_SDF rw
+PARTYMON_STRUCT_LENGTH EQU _RS
+
+NICKNAMED_MON_STRUCT_LENGTH EQU PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH
REDMON_STRUCT_LENGTH EQU 44
; caught data
@@ -116,6 +125,8 @@ CAUGHT_BY_BOY EQU 2
CAUGHT_EGG_LEVEL EQU 1
+MON_CRY_LENGTH EQU 6
+
; maximum number of party pokemon
PARTY_LENGTH EQU 6
@@ -199,6 +210,7 @@ NUM_TREEMON_SETS EQU const_value
const HAPPINESS_REVIVALHERB ; 11
const HAPPINESS_GROOMING ; 12
const HAPPINESS_GAINLEVELATHOME ; 13
+NUM_HAPPINESS_CHANGES EQU const_value - 1
; significant happiness values
BASE_HAPPINESS EQU 70
diff --git a/constants/radio_constants.asm b/constants/radio_constants.asm
index 11143f6ee..f8f32588f 100644
--- a/constants/radio_constants.asm
+++ b/constants/radio_constants.asm
@@ -15,6 +15,7 @@
const POKE_FLUTE_RADIO ; 08
const UNOWN_RADIO ; 09
const EVOLUTION_RADIO ; 0a
+NUM_RADIO_CHANNELS EQU const_value
; internal indexes for channel segments
const OAKS_POKEMON_TALK_2 ; 0b
const OAKS_POKEMON_TALK_3 ; 0c
@@ -93,6 +94,7 @@
const POKEDEX_SHOW_6 ; 55
const POKEDEX_SHOW_7 ; 56
const POKEDEX_SHOW_8 ; 57
+NUM_RADIO_SEGMENTS EQU const_value
; PlayRadio.StationPointers indexes (see engine/pokegear/pokegear.asm)
const_def
@@ -106,9 +108,6 @@
const MAPRADIO_LETS_ALL_SING
const MAPRADIO_ROCKET
-; OaksPKMNTalkRoutes size (see data/radio/oaks_pkmn_talk_routes.asm)
-NUM_OAKS_POKEMON_TALK_ROUTES EQU 15
-
; These tables in engine/pokegear/radio.asm are all sized to a power of 2
; so there's no need for a rejection sampling loop
NUM_OAKS_POKEMON_TALK_ADVERBS EQU 16 ; OaksPKMNTalk8.Adverbs
diff --git a/constants/script_constants.asm b/constants/script_constants.asm
index fe5d2d7c4..7c9881988 100644
--- a/constants/script_constants.asm
+++ b/constants/script_constants.asm
@@ -175,6 +175,7 @@ NUM_CMDQUEUE_TYPES EQU const_value
const FLOOR_10F
const FLOOR_11F
const FLOOR_ROOF
+NUM_FLOORS EQU const_value
; showemote arguments
; Emotes indexes (see data/sprites/emotes.asm)
@@ -191,7 +192,9 @@ NUM_CMDQUEUE_TYPES EQU const_value
const EMOTE_ROD ; 9
const EMOTE_BOULDER_DUST ; 10
const EMOTE_GRASS_RUSTLE ; 11
+NUM_EMOTES EQU const_value
EMOTE_FROM_MEM EQU -1
+EMOTE_LENGTH EQU 6
; fruittree arguments
; FruitTreeItems indexes (see data/items/fruit_trees.asm)
@@ -236,6 +239,7 @@ NUM_FRUIT_TREES EQU const_value - 1
const DECODESC_RIGHT_DOLL ; 2
const DECODESC_BIG_DOLL ; 3
const DECODESC_CONSOLE ; 4
+NUM_DECODESCS EQU const_value
; swarm arguments
; StoreSwarmMapIndices arguments
diff --git a/constants/sfx_constants.asm b/constants/sfx_constants.asm
index 113cf5f39..ed2f6eb4c 100644
--- a/constants/sfx_constants.asm
+++ b/constants/sfx_constants.asm
@@ -210,3 +210,5 @@
const SFX_TWO_PC_BEEPS ; cc
const SFX_4_NOTE_DITTY ; cd
const SFX_TWINKLE ; ce
+
+NUM_SFX EQU const_value
diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm
index 474f2a23f..32ed7befd 100644
--- a/constants/sprite_anim_constants.asm
+++ b/constants/sprite_anim_constants.asm
@@ -79,6 +79,7 @@ NUM_SPRITEANIMDICT_ENTRIES EQU 10
const SPRITE_ANIM_INDEX_INTRO_UNOWN_F ; 2a
const SPRITE_ANIM_INDEX_INTRO_SUICUNE_AWAY ; 2b
const SPRITE_ANIM_INDEX_CELEBI ; 2c
+NUM_SPRITE_ANIM_INDEXES EQU const_value
; DoAnimFrame.Jumptable indexes (see engine/gfx/sprite_anims.asm)
const_def
@@ -117,6 +118,7 @@ NUM_SPRITEANIMDICT_ENTRIES EQU 10
const SPRITE_ANIM_SEQ_INTRO_UNOWN ; 20
const SPRITE_ANIM_SEQ_INTRO_UNOWN_F ; 21
const SPRITE_ANIM_SEQ_INTRO_SUICUNE_AWAY ; 22
+NUM_SPRITE_ANIM_SEQS EQU const_value
; SpriteAnimFrameData indexes (see data/sprite_anims/framesets.asm)
const_def
@@ -186,6 +188,7 @@ NUM_SPRITEANIMDICT_ENTRIES EQU 10
const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_F ; 3f
const SPRITE_ANIM_FRAMESET_CELEBI_LEFT ; 40
const SPRITE_ANIM_FRAMESET_CELEBI_RIGHT ; 41
+NUM_SPRITE_ANIM_FRAMESETS EQU const_value
; SpriteAnimOAMData indexes (see data/sprite_anims/oam.asm)
const_def
@@ -329,3 +332,4 @@ NUM_SPRITEANIMDICT_ENTRIES EQU 10
const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_9 ; 89
const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_10 ; 8a
const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_11 ; 8b
+NUM_SPRITE_ANIM_OAMSETS EQU const_value
diff --git a/constants/sprite_constants.asm b/constants/sprite_constants.asm
index 0909aef25..288f2e9a8 100644
--- a/constants/sprite_constants.asm
+++ b/constants/sprite_constants.asm
@@ -104,6 +104,7 @@
const SPRITE_ENTEI ; 64
const SPRITE_RAIKOU ; 65
const SPRITE_STANDING_YOUNGSTER ; 66
+NUM_OVERWORLD_SPRITES EQU const_value - 1
; SpriteMons indexes (see data/sprites/sprite_mons.asm)
const_next $80
@@ -143,6 +144,7 @@ SPRITE_POKEMON EQU const_value
const SPRITE_GYARADOS ; a0
const SPRITE_LUGIA ; a1
const SPRITE_HO_OH ; a2
+NUM_POKEMON_SPRITES EQU const_value - SPRITE_POKEMON
; special GetMonSprite values (see engine/overworld/overworld.asm)
const_next $e0
diff --git a/constants/tileset_constants.asm b/constants/tileset_constants.asm
index 79be4ad57..a77b26587 100644
--- a/constants/tileset_constants.asm
+++ b/constants/tileset_constants.asm
@@ -36,6 +36,13 @@
const TILESET_KABUTO_WORD_ROOM ; 22
const TILESET_OMANYTE_WORD_ROOM ; 23
const TILESET_AERODACTYL_WORD_ROOM ; 24
+NUM_TILESETS EQU const_value - 1
+
+; wTileset struct size
+TILESET_LENGTH EQU 15
+
+; roof length (see gfx/tilesets/roofs)
+ROOF_LENGTH EQU 9
; bg palette values (see gfx/tilesets/*_palette_map.asm)
; TilesetBGPalette indexes (see gfx/tilesets/bg_tiles.pal)
diff --git a/constants/trainer_constants.asm b/constants/trainer_constants.asm
index 80231fb67..d71df38e1 100644
--- a/constants/trainer_constants.asm
+++ b/constants/trainer_constants.asm
@@ -25,6 +25,7 @@ CHRIS EQU __trainer_class__
const PHONECONTACT_BILL
const PHONECONTACT_ELM
const PHONECONTACT_BUENA
+NUM_NONTRAINER_PHONECONTACTS EQU const_value - 1
KRIS EQU __trainer_class__
trainerclass FALKNER ; 1
@@ -702,4 +703,4 @@ KRIS EQU __trainer_class__
trainerclass MYSTICALMAN ; 43
const EUSINE
-NUM_TRAINER_CLASSES EQU __trainer_class__
+NUM_TRAINER_CLASSES EQU __trainer_class__ - 1
diff --git a/constants/type_constants.asm b/constants/type_constants.asm
index c18d71c73..5bce009d5 100644
--- a/constants/type_constants.asm
+++ b/constants/type_constants.asm
@@ -34,4 +34,6 @@ SPECIAL EQU const_value
const DARK
TYPES_END EQU const_value
-NUM_TYPES EQU TYPES_END + UNUSED_TYPES - UNUSED_TYPES_END
+NUM_TYPES EQU TYPES_END + UNUSED_TYPES - UNUSED_TYPES_END - 1 ; discount BIRD
+
+POKEDEX_TYPE_STRING_LENGTH EQU 9
diff --git a/data/battle/effect_command_pointers.asm b/data/battle/effect_command_pointers.asm
index d1f747a1f..7239e8150 100644
--- a/data/battle/effect_command_pointers.asm
+++ b/data/battle/effect_command_pointers.asm
@@ -4,6 +4,7 @@
BattleCommandPointers:
; entries correspond to macros/scripts/battle_commands.asm
+ table_width 2, BattleCommandPointers
dw BattleCommand_CheckTurn
dw BattleCommand_CheckObedience
dw BattleCommand_UsedMoveText
@@ -179,3 +180,4 @@ BattleCommandPointers:
dw BattleCommand_SuperEffectiveLoopText
dw BattleCommand_StartLoop
dw BattleCommand_Curl
+ assert_table_length NUM_EFFECT_COMMANDS
diff --git a/data/battle_anims/framesets.asm b/data/battle_anims/framesets.asm
index a5641570c..555ec30f1 100644
--- a/data/battle_anims/framesets.asm
+++ b/data/battle_anims/framesets.asm
@@ -1,5 +1,6 @@
BattleAnimFrameData:
; entries correspond to BATTLEANIMFRAMESET_* constants
+ table_width 2, BattleAnimFrameData
dw .Frameset_00 ; BATTLEANIMFRAMESET_00
dw .Frameset_01 ; BATTLEANIMFRAMESET_01
dw .Frameset_02 ; BATTLEANIMFRAMESET_02
@@ -185,6 +186,7 @@ BattleAnimFrameData:
dw .Frameset_b6 ; BATTLEANIMFRAMESET_B6
dw .Frameset_b7 ; BATTLEANIMFRAMESET_B7
dw .Frameset_b8 ; BATTLEANIMFRAMESET_B8
+ assert_table_length NUM_BATTLEANIMFRAMESETS
.Frameset_00:
frame BATTLEANIMOAMSET_00, 6
diff --git a/data/battle_anims/oam.asm b/data/battle_anims/oam.asm
index 4bf4a331e..73f24ec54 100644
--- a/data/battle_anims/oam.asm
+++ b/data/battle_anims/oam.asm
@@ -1,5 +1,6 @@
BattleAnimOAMData:
; entries correspond to BATTLEANIMOAMSET_* constants
+ table_width 4, BattleAnimOAMData
; vtile offset, data length, data pointer
dbbw $00, 16, .OAMData_00 ; BATTLEANIMOAMSET_00
dbbw $04, 9, .OAMData_01 ; BATTLEANIMOAMSET_01
@@ -217,6 +218,7 @@ BattleAnimOAMData:
dbbw $00, 6, .OAMData_d5 ; BATTLEANIMOAMSET_D5
dbbw $00, 14, .OAMData_d6 ; BATTLEANIMOAMSET_D6
dbbw $00, 12, .OAMData_d7 ; BATTLEANIMOAMSET_D7
+ assert_table_length NUM_BATTLEANIMOAMSETS
.OAMData_11:
dbsprite -1, -1, 4, 0, $00, $0
diff --git a/data/battle_anims/object_gfx.asm b/data/battle_anims/object_gfx.asm
index b132c0ed6..103b97ebe 100644
--- a/data/battle_anims/object_gfx.asm
+++ b/data/battle_anims/object_gfx.asm
@@ -6,6 +6,7 @@ ENDM
AnimObjGFX:
; entries correspond to ANIM_GFX_* constants
+ table_width 4, AnimObjGFX
anim_obj_gfx 0, AnimObj00GFX
anim_obj_gfx 21, AnimObjHitGFX
anim_obj_gfx 6, AnimObjCutGFX
@@ -48,3 +49,4 @@ AnimObjGFX:
anim_obj_gfx 24, AnimObjAeroblastGFX
anim_obj_gfx 1, NULL
anim_obj_gfx 1, NULL
+ assert_table_length NUM_ANIM_GFX + 1
diff --git a/data/battle_anims/objects.asm b/data/battle_anims/objects.asm
index 16dc7e653..1f7d7b4ab 100644
--- a/data/battle_anims/objects.asm
+++ b/data/battle_anims/objects.asm
@@ -18,6 +18,7 @@ ENDM
BattleAnimObjects:
; entries correspond to ANIM_OBJ_* constants
+ table_width BATTLEANIMOBJ_LENGTH, BattleAnimObjects
; ANIM_OBJ_HIT_BIG_YFIX
battleanimobj RELATIVE_X, $ff, BATTLEANIMFRAMESET_00, BATTLEANIMFUNC_NULL, PAL_BATTLE_OB_GRAY, ANIM_GFX_HIT
; ANIM_OBJ_HIT_YFIX
@@ -394,3 +395,4 @@ BattleAnimObjects:
battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B7, BATTLEANIMFUNC_NULL, PAL_BATTLE_OB_ENEMY, ANIM_GFX_PLAYERHEAD
; ANIM_OBJ_PLAYERHEAD_2ROW
battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B8, BATTLEANIMFUNC_NULL, PAL_BATTLE_OB_PLAYER, ANIM_GFX_ENEMYFEET
+ assert_table_length NUM_ANIM_OBJS
diff --git a/data/battle_tower/classes.asm b/data/battle_tower/classes.asm
index c53197548..863759c70 100644
--- a/data/battle_tower/classes.asm
+++ b/data/battle_tower/classes.asm
@@ -2,6 +2,8 @@ BattleTowerTrainers:
; The trainer class is not used in Crystal 1.0 due to a bug.
; Instead, the sixth character in the trainer's name is used.
; See BattleTowerText in engine/events/battle_tower/trainer_text.asm.
+ table_width (NAME_LENGTH - 1) + 1, BattleTowerTrainers
+ ; name, class
db "HANSON@@@@", FISHER
db "SAWYER@@@@", POKEMANIAC
db "MASUDA@@@@", GUITARIST
@@ -23,6 +25,7 @@ BattleTowerTrainers:
db "KAUFMAN@@@", SWIMMERM
db "LANCASTER@", SKIER
db "McMAHILL@@", CAMPER
+ assert_table_length BATTLETOWER_NUM_UNIQUE_MON
; The following can only be sampled in Crystal 1.1.
db "OBRIEN@@@@", GENTLEMAN
db "FROST@@@@@", BEAUTY
@@ -73,3 +76,4 @@ BattleTowerTrainers:
db "DYKSTRA@@@", SWIMMERF
db "EATON@@@@@", BIKER
db "WONG@@@@@@", FIREBREATHER
+ assert_table_length BATTLETOWER_NUM_UNIQUE_TRAINERS
diff --git a/data/battle_tower/parties.asm b/data/battle_tower/parties.asm
index 9c67c2f72..d972944b6 100644
--- a/data/battle_tower/parties.asm
+++ b/data/battle_tower/parties.asm
@@ -1,5 +1,6 @@
BattleTowerMons:
; 10 groups (one per floor level) of 21 mons (BATTLETOWER_NUM_UNIQUE_MON).
+ table_width NICKNAMED_MON_STRUCT_LENGTH, BattleTowerMons
; BattleTowerMons group 1
@@ -5489,3 +5490,5 @@ BattleTowerMons:
bigdw 214 ; SAtk
bigdw 214 ; SDef
db "RANTA-N@@@@"
+
+ assert_table_length 10 * BATTLETOWER_NUM_UNIQUE_MON
diff --git a/data/battle_tower/unknown.asm b/data/battle_tower/unknown.asm
index 3437c444b..af51b1e83 100644
--- a/data/battle_tower/unknown.asm
+++ b/data/battle_tower/unknown.asm
@@ -1,6 +1,7 @@
BattleTowerTrainerData:: ; ???
; 70 tables (BATTLETOWER_NUM_UNIQUE_TRAINERS) of 18 two-argument entries (total size BATTLETOWER_TRAINERDATALENGTH).
; Second argument points to an entry in Unknown_170470, to which the first argument is compared.
+ table_width BATTLETOWER_TRAINERDATALENGTH, BattleTowerTrainerData
; BattleTowerTrainerData table 1:
db $37, 3
@@ -1401,3 +1402,5 @@ BattleTowerTrainerData:: ; ???
db $22, 7
db $d1, 0
db $32, 13
+
+ assert_table_length BATTLETOWER_NUM_UNIQUE_TRAINERS
diff --git a/data/collision/collision_permissions.asm b/data/collision/collision_permissions.asm
index 57172ca51..188338ca9 100644
--- a/data/collision/collision_permissions.asm
+++ b/data/collision/collision_permissions.asm
@@ -1,5 +1,6 @@
TileCollisionTable::
; entries correspond to COLL_* constants
+ table_width 1, TileCollisionTable
db LAND_TILE ; COLL_FLOOR
db LAND_TILE ; COLL_01
db LAND_TILE ; 02
@@ -256,3 +257,4 @@ TileCollisionTable::
db LAND_TILE ; fd
db LAND_TILE ; fe
db WALL_TILE ; COLL_FF
+ assert_table_length $100
diff --git a/data/credits_strings.asm b/data/credits_strings.asm
index 22ee7c382..c3a502088 100644
--- a/data/credits_strings.asm
+++ b/data/credits_strings.asm
@@ -1,5 +1,6 @@
CreditsStringsPointers:
; entries correspond to constants/credits_constants.asm
+ table_width 2, CreditsStringsPointers
dw .SatoshiTajiri
dw .JunichiMasuda
dw .TetsuyaWatanabe
@@ -103,6 +104,7 @@ CreditsStringsPointers:
dw .UsCoordination
dw .TextTranslation
dw .PaadTesting
+ assert_table_length NUM_CREDITS_STRINGS
.SatoshiTajiri: db " SATOSHI TAJIRI@" ; "たじり さとし@"
.JunichiMasuda: db " JUNICHI MASUDA@" ; "ますだ じゅんいち@"
diff --git a/data/decorations/attributes.asm b/data/decorations/attributes.asm
index 77cd1388b..5e62c3a11 100644
--- a/data/decorations/attributes.asm
+++ b/data/decorations/attributes.asm
@@ -1,5 +1,5 @@
decoration: MACRO
- ; type, name, command, event flag, tile/sprite
+ ; type, name, action, event flag, tile/sprite
db \1, \2, \3
dw \4
db \5
@@ -7,6 +7,7 @@ ENDM
DecorationAttributes:
; entries correspond to deco constants
+ table_width DECOATTR_STRUCT_LENGTH, DecorationAttributes
decoration DECO_PLANT, 0, 0, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_BED, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
decoration DECO_BED, FEATHERY_BED, SET_UP_BED, EVENT_DECO_BED_1, $1b
@@ -60,3 +61,4 @@ DecorationAttributes:
decoration DECO_DOLL, TENTACOOL, SET_UP_DOLL, EVENT_DECO_TENTACOOL_DOLL, SPRITE_TENTACOOL
decoration DECO_PLANT, GOLD_TROPHY, SET_UP_DOLL, EVENT_DECO_GOLD_TROPHY, SPRITE_GOLD_TROPHY
decoration DECO_PLANT, SILVER_TROPHY, SET_UP_DOLL, EVENT_DECO_SILVER_TROPHY, SPRITE_SILVER_TROPHY
+ assert_table_length NUM_DECOS + NUM_DECO_CATEGORIES + 1
diff --git a/data/decorations/decorations.asm b/data/decorations/decorations.asm
index e3ec28f1c..a5519efa0 100644
--- a/data/decorations/decorations.asm
+++ b/data/decorations/decorations.asm
@@ -1,5 +1,7 @@
DecorationIDs:
; see constants/deco_constants.asm
+ table_width 1, DecorationIDs
+
db DECO_FEATHERY_BED ; 2
db DECO_PINK_BED ; 3
db DECO_POLKADOT_BED ; 4
@@ -52,4 +54,5 @@ DecorationIDs:
db DECO_GOLD_TROPHY_DOLL ; 33
db DECO_SILVER_TROPHY_DOLL ; 34
+ assert_table_length NUM_DECOS
db -1 ; end
diff --git a/data/default_options.asm b/data/default_options.asm
index 00fcfa10e..76de34387 100644
--- a/data/default_options.asm
+++ b/data/default_options.asm
@@ -14,3 +14,5 @@ DefaultOptions:
db $00
db $00
+.End
+ assert DefaultOptions.End - DefaultOptions == wOptionsEnd - wOptions
diff --git a/data/events/bug_contest_flags.asm b/data/events/bug_contest_flags.asm
index 734bf11f8..f3d9ff74d 100644
--- a/data/events/bug_contest_flags.asm
+++ b/data/events/bug_contest_flags.asm
@@ -1,5 +1,5 @@
BugCatchingContestantEventFlagTable:
-; there are NUM_BUG_CONTESTANTS entries
+ table_width 2, BugCatchingContestantEventFlagTable
dw EVENT_BUG_CATCHING_CONTESTANT_1A
dw EVENT_BUG_CATCHING_CONTESTANT_2A
dw EVENT_BUG_CATCHING_CONTESTANT_3A
@@ -10,3 +10,4 @@ BugCatchingContestantEventFlagTable:
dw EVENT_BUG_CATCHING_CONTESTANT_8A
dw EVENT_BUG_CATCHING_CONTESTANT_9A
dw EVENT_BUG_CATCHING_CONTESTANT_10A
+ assert_table_length NUM_BUG_CONTESTANTS
diff --git a/data/events/bug_contest_winners.asm b/data/events/bug_contest_winners.asm
index e29ce0436..525283afb 100644
--- a/data/events/bug_contest_winners.asm
+++ b/data/events/bug_contest_winners.asm
@@ -1,5 +1,5 @@
BugContestantPointers:
-; there are NUM_BUG_CONTESTANTS + 1 entries
+ table_width 2, BugContestantPointers
dw BugContestant_BugCatcherDon ; this reverts back to the player
dw BugContestant_BugCatcherDon
dw BugContestant_BugCatcherEd
@@ -11,6 +11,7 @@ BugContestantPointers:
dw BugContestant_BugCatcherJosh
dw BugContestant_YoungsterSamuel
dw BugContestant_SchoolboyKipp
+ assert_table_length NUM_BUG_CONTESTANTS + 1
; contestant format:
; db class, id
diff --git a/data/events/elevator_floors.asm b/data/events/elevator_floors.asm
index abc793cf2..861653bae 100644
--- a/data/events/elevator_floors.asm
+++ b/data/events/elevator_floors.asm
@@ -1,5 +1,6 @@
ElevatorFloorNames:
; entries correspond to FLOOR_* constants
+ table_width 2, ElevatorFloorNames
dw .B4F
dw .B3F
dw .B2F
@@ -16,6 +17,7 @@ ElevatorFloorNames:
dw ._10F
dw ._11F
dw .ROOF
+ assert_table_length NUM_FLOORS
.B4F: db "B4F@"
.B3F: db "B3F@"
diff --git a/data/events/engine_flags.asm b/data/events/engine_flags.asm
index 526413651..8b5d6b89e 100644
--- a/data/events/engine_flags.asm
+++ b/data/events/engine_flags.asm
@@ -6,6 +6,7 @@ ENDM
EngineFlags:
; entries correspond to ENGINE_* constants
+ table_width 3, EngineFlags
; pokegear
engine_flag wPokegearFlags, POKEGEAR_RADIO_CARD_F
@@ -197,3 +198,5 @@ EngineFlags:
engine_flag wSwarmFlags, SWARMFLAGS_DUNSPARCE_SWARM_F
engine_flag wSwarmFlags, SWARMFLAGS_YANMA_SWARM_F
+
+ assert_table_length NUM_ENGINE_FLAGS
diff --git a/data/events/happiness_changes.asm b/data/events/happiness_changes.asm
index c0c7b0101..e6228cf08 100644
--- a/data/events/happiness_changes.asm
+++ b/data/events/happiness_changes.asm
@@ -1,6 +1,7 @@
HappinessChanges:
; entries correspond to HAPPINESS_* constants
-; change if happiness < 100, change if happiness < 200, change otherwise
+ table_width 3, HappinessChanges
+ ; change if happiness < 100, change if happiness < 200, change otherwise
db +5, +3, +2 ; Gained a level
db +5, +3, +2 ; Vitamin
db +1, +1, +0 ; X Item
@@ -20,3 +21,4 @@ HappinessChanges:
db -15, -15, -20 ; Used Revival Herb (bitter)
db +3, +3, +1 ; Grooming
db +10, +6, +4 ; Gained a level in the place where it was caught
+ assert_table_length NUM_HAPPINESS_CHANGES
diff --git a/data/events/npc_trades.asm b/data/events/npc_trades.asm
index 03d409571..543a50b1e 100644
--- a/data/events/npc_trades.asm
+++ b/data/events/npc_trades.asm
@@ -8,6 +8,7 @@ ENDM
NPCTrades:
; entries correspond to NPCTRADE_* constants
+ table_width NPCTRADE_STRUCT_LENGTH, NPCTrades
npctrade TRADE_DIALOGSET_COLLECTOR, ABRA, MACHOP, "MUSCLE@@@@@", $37, $66, GOLD_BERRY, 37460, "MIKE@@@@@@@", TRADE_GENDER_EITHER
npctrade TRADE_DIALOGSET_COLLECTOR, BELLSPROUT, ONIX, "ROCKY@@@@@@", $96, $66, BITTER_BERRY, 48926, "KYLE@@@@@@@", TRADE_GENDER_EITHER
npctrade TRADE_DIALOGSET_HAPPY, KRABBY, VOLTORB, "VOLTY@@@@@@", $98, $88, PRZCUREBERRY, 29189, "TIM@@@@@@@@", TRADE_GENDER_EITHER
@@ -15,3 +16,4 @@ NPCTrades:
npctrade TRADE_DIALOGSET_NEWBIE, HAUNTER, XATU, "PAUL@@@@@@@", $96, $86, MYSTERYBERRY, 15616, "CHRIS@@@@@@", TRADE_GENDER_EITHER
npctrade TRADE_DIALOGSET_GIRL, CHANSEY, AERODACTYL, "AEROY@@@@@@", $96, $66, GOLD_BERRY, 26491, "KIM@@@@@@@@", TRADE_GENDER_EITHER
npctrade TRADE_DIALOGSET_COLLECTOR, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $96, $66, METAL_COAT, 50082, "FOREST@@@@@", TRADE_GENDER_EITHER
+ assert_table_length NUM_NPC_TRADES
diff --git a/data/events/odd_eggs.asm b/data/events/odd_eggs.asm
index 5b251645a..20bac2dc1 100644
--- a/data/events/odd_eggs.asm
+++ b/data/events/odd_eggs.asm
@@ -1,9 +1,12 @@
+NUM_ODD_EGGS EQU 14
+
prob: MACRO
prob_total = prob_total + (\1)
dw prob_total * $ffff / 100
ENDM
OddEggProbabilities:
+ table_width 2, OddEggProbabilities
prob_total = 0
; Pichu
prob 8
@@ -26,8 +29,10 @@ prob_total = 0
; Tyrogue
prob 10
prob 1
+ assert_table_length NUM_ODD_EGGS
OddEggs:
+ table_width NICKNAMED_MON_STRUCT_LENGTH, OddEggs
db PICHU
db NO_ITEM
@@ -392,3 +397,5 @@ OddEggs:
bigdw 9 ; SAtk
bigdw 9 ; SDef
db "EGG@@@@@@@@"
+
+ assert_table_length NUM_ODD_EGGS
diff --git a/data/icon_pointers.asm b/data/icon_pointers.asm
index bfe07abb6..1ad361c1c 100644
--- a/data/icon_pointers.asm
+++ b/data/icon_pointers.asm
@@ -1,5 +1,6 @@
IconPointers:
-; entries correspond to ICON_* constants
+; entries correspond to ICON_* constants (see constants/icon_constants.asm)
+ table_width 2, IconPointers
dw NullIcon
dw PoliwagIcon
dw JigglypuffIcon
@@ -39,3 +40,4 @@ IconPointers:
dw SlowpokeIcon
dw SudowoodoIcon
dw BigmonIcon
+ assert_table_length NUM_ICONS + 1
diff --git a/data/items/attributes.asm b/data/items/attributes.asm
index 60ada8b6e..459212835 100644
--- a/data/items/attributes.asm
+++ b/data/items/attributes.asm
@@ -6,7 +6,8 @@ item_attribute: MACRO
ENDM
ItemAttributes:
-; entries correspond to item ids
+; entries correspond to item ids (see constants/item_constants.asm)
+ table_width ITEMATTR_STRUCT_LENGTH, ItemAttributes
; MASTER_BALL
item_attribute 0, HELD_NONE, 0, CANT_SELECT, BALL, ITEMMENU_NOUSE, ITEMMENU_CLOSE
; ULTRA_BALL
@@ -387,6 +388,7 @@ ItemAttributes:
item_attribute 50, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
; ITEM_BE
item_attribute $9999, HELD_NONE, 0, NO_LIMITS, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
+ assert_table_length NUM_ITEMS
; TM01
item_attribute 3000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_NOUSE
; TM02
@@ -491,6 +493,7 @@ ItemAttributes:
item_attribute 3000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_NOUSE
; TM50
item_attribute 2000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_NOUSE
+ assert_table_length NUM_ITEMS + NUM_TMS + 2 ; count ITEM_C3 and ITEM_DC
; HM01
item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_NOUSE
; HM02
@@ -505,6 +508,7 @@ ItemAttributes:
item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_NOUSE
; HM07
item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_NOUSE
+ assert_table_length NUM_ITEMS + NUM_TMS + 2 + NUM_HMS ; count ITEM_C3 and ITEM_DC
; ITEM_FA
item_attribute $9999, HELD_NONE, 0, NO_LIMITS, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
; $fb
@@ -519,3 +523,4 @@ ItemAttributes:
item_attribute $9999, HELD_NONE, 0, NO_LIMITS, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
; $00
item_attribute $9999, HELD_NONE, 0, NO_LIMITS, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
+ assert_table_length $100
diff --git a/data/items/buena_prizes.asm b/data/items/buena_prizes.asm
index 673082a8d..4e2005c4b 100644
--- a/data/items/buena_prizes.asm
+++ b/data/items/buena_prizes.asm
@@ -1,5 +1,5 @@
BuenaPrizeItems:
-; there are NUM_BUENA_PRIZES entries
+ table_width 2, BuenaPrizeItems
db ULTRA_BALL, 2
db FULL_RESTORE, 2
db NUGGET, 3
@@ -9,3 +9,4 @@ BuenaPrizeItems:
db CARBOS, 5
db CALCIUM, 5
db HP_UP, 5
+ assert_table_length NUM_BUENA_PRIZES
diff --git a/data/items/descriptions.asm b/data/items/descriptions.asm
index 2a7900b3a..2654a3194 100644
--- a/data/items/descriptions.asm
+++ b/data/items/descriptions.asm
@@ -1,5 +1,6 @@
ItemDescriptions:
-; entries correspond to item ids
+; entries correspond to item ids (see constants/item_constants.asm)
+ table_width 2, ItemDescriptions
dw MasterBallDesc
dw UltraBallDesc
dw BrightpowderDesc
@@ -190,6 +191,7 @@ ItemDescriptions:
dw MusicMailDesc
dw MirageMailDesc
dw TeruSama25Desc
+ assert_table_length NUM_ITEMS
dw TeruSama26Desc
dw TeruSama26Desc
dw TeruSama26Desc
@@ -255,6 +257,7 @@ ItemDescriptions:
dw TeruSama31Desc
dw TeruSama32Desc
dw TeruSama33Desc
+ assert_table_length $ff
MasterBallDesc:
db "The best BALL. It"
diff --git a/data/items/fruit_trees.asm b/data/items/fruit_trees.asm
index 9c4e4793d..ff39551e7 100644
--- a/data/items/fruit_trees.asm
+++ b/data/items/fruit_trees.asm
@@ -1,5 +1,6 @@
FruitTreeItems:
; entries correspond to FRUITTREE_* constants
+ table_width 1, FruitTreeItems
db BERRY ; ROUTE_29
db BERRY ; ROUTE_30_1
db BERRY ; ROUTE_38
@@ -30,3 +31,4 @@ FruitTreeItems:
db ICE_BERRY ; PEWTER_CITY_1
db MINT_BERRY ; PEWTER_CITY_2
db BURNT_BERRY ; FUCHSIA_CITY
+ assert_table_length NUM_FRUIT_TREES
diff --git a/data/items/marts.asm b/data/items/marts.asm
index 37bf846b4..d96281dfd 100644
--- a/data/items/marts.asm
+++ b/data/items/marts.asm
@@ -1,5 +1,6 @@
Marts:
-; entries correspond to MART_* constants
+; entries correspond to MART_* constants (see constants/mart_constants.asm)
+ table_width 2, Marts
dw MartCherrygrove
dw MartCherrygroveDex
dw MartViolet
@@ -34,6 +35,7 @@ Marts:
dw MartMtMoon
dw MartIndigoPlateau
dw MartUnderground
+ assert_table_length NUM_MARTS
MartCherrygrove:
db 4 ; # items
diff --git a/data/maps/landmarks.asm b/data/maps/landmarks.asm
index 9a28ee52e..8dfff34dc 100644
--- a/data/maps/landmarks.asm
+++ b/data/maps/landmarks.asm
@@ -6,6 +6,7 @@ ENDM
Landmarks:
; entries correspond to constants/landmark_constants.asm
+ table_width 4, Landmarks
dbbw 0, 0, SpecialMapName
landmark 140, 100, NewBarkTownName
landmark 128, 100, Route29Name
@@ -53,6 +54,7 @@ Landmarks:
landmark 112, 72, DarkCaveName
landmark 124, 88, Route46Name
landmark 148, 68, SilverCaveName
+ assert_table_length KANTO_LANDMARK
landmark 52, 108, PalletTownName
landmark 52, 92, Route1Name
landmark 52, 76, ViridianCityName
@@ -102,6 +104,7 @@ Landmarks:
landmark 12, 100, TohjoFallsName
landmark 20, 68, Route28Name
landmark 140, 116, FastShipName
+ assert_table_length NUM_LANDMARKS
NewBarkTownName: db "NEW BARK¯TOWN@"
CherrygroveCityName: db "CHERRYGROVE¯CITY@"
diff --git a/data/maps/maps.asm b/data/maps/maps.asm
index bfbd91c34..381e5328f 100644
--- a/data/maps/maps.asm
+++ b/data/maps/maps.asm
@@ -16,6 +16,7 @@ ENDM
MapGroupPointers::
; pointers to the first map of each map group
+ table_width 2, MapGroupPointers
dw MapGroup_Olivine ; 1
dw MapGroup_Mahogany ; 2
dw MapGroup_Dungeons ; 3
@@ -42,6 +43,7 @@ MapGroupPointers::
dw MapGroup_NewBark ; 24
dw MapGroup_Saffron ; 25
dw MapGroup_Cherrygrove ; 26
+ assert_table_length NUM_MAP_GROUPS
MapGroup_Olivine:
map OlivinePokecenter1F, TILESET_POKECENTER, INDOOR, LANDMARK_OLIVINE_CITY, MUSIC_POKEMON_CENTER, FALSE, PALETTE_DAY, FISHGROUP_SHORE
diff --git a/data/maps/outdoor_sprites.asm b/data/maps/outdoor_sprites.asm
index 6398a9511..d666aec75 100644
--- a/data/maps/outdoor_sprites.asm
+++ b/data/maps/outdoor_sprites.asm
@@ -3,6 +3,7 @@
OutdoorSprites:
; entries correspond to map groups
+ table_width 2, OutdoorSprites
dw OlivineGroupSprites
dw MahoganyGroupSprites
dw DungeonsGroupSprites
@@ -29,6 +30,7 @@ OutdoorSprites:
dw NewBarkGroupSprites
dw SaffronGroupSprites
dw CherrygroveGroupSprites
+ assert_table_length NUM_MAP_GROUPS
PalletGroupSprites:
db SPRITE_SUICUNE
diff --git a/data/maps/roofs.asm b/data/maps/roofs.asm
index ac1ea5569..dee4991d0 100644
--- a/data/maps/roofs.asm
+++ b/data/maps/roofs.asm
@@ -5,10 +5,12 @@
const ROOF_AZALEA ; 2
const ROOF_OLIVINE ; 3
const ROOF_GOLDENROD ; 4
+NUM_ROOFS EQU const_value
MapGroupRoofs:
; entries correspond to map groups
; values are indexes for Roofs (see below)
+ table_width 1, MapGroupRoofs
db -1 ; 0
db ROOF_OLIVINE ; 1 (Olivine)
db ROOF_AZALEA ; 2 (Mahogany)
@@ -36,11 +38,14 @@ MapGroupRoofs:
db ROOF_NEW_BARK ; 24 (New Bark)
db -1 ; 25
db ROOF_NEW_BARK ; 26 (Cherrygrove)
+ assert_table_length NUM_MAP_GROUPS + 1
Roofs:
; entries correspond to ROOF_* constants
+ table_width ROOF_LENGTH * LEN_2BPP_TILE, Roofs
INCBIN "gfx/tilesets/roofs/new_bark.2bpp"
INCBIN "gfx/tilesets/roofs/violet.2bpp"
INCBIN "gfx/tilesets/roofs/azalea.2bpp"
INCBIN "gfx/tilesets/roofs/olivine.2bpp"
INCBIN "gfx/tilesets/roofs/goldenrod.2bpp"
+ assert_table_length NUM_ROOFS
diff --git a/data/maps/sgb_roof_pal_inds.asm b/data/maps/sgb_roof_pal_inds.asm
index a2620e194..617b0041a 100644
--- a/data/maps/sgb_roof_pal_inds.asm
+++ b/data/maps/sgb_roof_pal_inds.asm
@@ -2,6 +2,7 @@
MapGroupRoofSGBPalInds:
; entries correspond to map groups
+ table_width 1, MapGroupRoofSGBPalInds
db PREDEFPAL_ROUTES
db PREDEFPAL_OLIVINE
db PREDEFPAL_MAHOGANY
@@ -29,3 +30,4 @@ MapGroupRoofSGBPalInds:
db PREDEFPAL_NEW_BARK
db PREDEFPAL_SAFFRON
db PREDEFPAL_CHERRYGROVE
+ assert_table_length NUM_MAP_GROUPS + 1
diff --git a/data/maps/spawn_points.asm b/data/maps/spawn_points.asm
index 2d99fff73..326995485 100644
--- a/data/maps/spawn_points.asm
+++ b/data/maps/spawn_points.asm
@@ -6,6 +6,7 @@ ENDM
SpawnPoints:
; entries correspond to SPAWN_* constants
+ table_width 4, SpawnPoints
spawn PLAYERS_HOUSE_2F, 3, 3
spawn VIRIDIAN_POKECENTER_1F, 5, 3
@@ -39,3 +40,5 @@ SpawnPoints:
spawn FAST_SHIP_CABINS_SW_SSW_NW, 6, 2
spawn N_A, -1, -1
+
+ assert_table_length NUM_SPAWNS + 1
diff --git a/data/mon_menu.asm b/data/mon_menu.asm
index f2b9f3ac0..a69f4132f 100644
--- a/data/mon_menu.asm
+++ b/data/mon_menu.asm
@@ -20,6 +20,7 @@ MonMenuOptionStrings:
MonMenuOptions:
; category, item, value; actions are in PokemonActionSubmenu (see engine/pokemon/mon_menu.asm)
+ table_width 3, MonMenuOptions
; moves
db MONMENU_FIELD_MOVE, MONMENUITEM_CUT, CUT
db MONMENU_FIELD_MOVE, MONMENUITEM_FLY, FLY
@@ -43,4 +44,5 @@ MonMenuOptions:
db MONMENU_MENUOPTION, MONMENUITEM_MOVE, MONMENUVALUE_MOVE
db MONMENU_MENUOPTION, MONMENUITEM_MAIL, MONMENUVALUE_MAIL
db MONMENU_MENUOPTION, MONMENUITEM_ERROR, MONMENUVALUE_ERROR
- db -1
+ assert_table_length NUM_MONMENUITEMS
+ db -1 ; end
diff --git a/data/moves/animations.asm b/data/moves/animations.asm
index bba0d186f..87b904c0f 100644
--- a/data/moves/animations.asm
+++ b/data/moves/animations.asm
@@ -1,5 +1,6 @@
BattleAnimations::
; entries correspond to constants/move_constants.asm
+ table_width 2, BattleAnimations
dw BattleAnim_0
dw BattleAnim_Pound
dw BattleAnim_KarateChop
@@ -252,10 +253,12 @@ BattleAnimations::
dw BattleAnim_RockSmash
dw BattleAnim_Whirlpool
dw BattleAnim_BeatUp
+ assert_table_length NUM_ATTACKS + 1
dw BattleAnim_252
dw BattleAnim_253
dw BattleAnim_254
dw BattleAnim_SweetScent2
+ assert_table_length $100
; $100
dw BattleAnim_ThrowPokeBall
dw BattleAnim_SendOutMon
@@ -279,6 +282,7 @@ BattleAnimations::
dw BattleAnim_Wobble
dw BattleAnim_Shake
dw BattleAnim_HitConfusion
+ assert_table_length NUM_BATTLE_ANIMS + 1
BattleAnim_0:
BattleAnim_252:
diff --git a/data/moves/descriptions.asm b/data/moves/descriptions.asm
index 1d2e5b37f..697be13ee 100644
--- a/data/moves/descriptions.asm
+++ b/data/moves/descriptions.asm
@@ -1,5 +1,6 @@
MoveDescriptions::
; entries correspond to move ids (see constants/move_constants.asm)
+ table_width 2, MoveDescriptions
dw PoundDescription
dw KarateChopDescription
dw DoubleslapDescription
@@ -251,11 +252,13 @@ MoveDescriptions::
dw RockSmashDescription
dw WhirlpoolDescription
dw BeatUpDescription
+ assert_table_length NUM_ATTACKS
dw MoveFCDescription
dw MoveFDDescription
dw MoveFEDescription
dw MoveFFDescription
dw Move00Description
+ assert_table_length $100
MoveFCDescription:
MoveFDDescription:
diff --git a/data/moves/effects_pointers.asm b/data/moves/effects_pointers.asm
index 94834de71..6f8fb2e99 100644
--- a/data/moves/effects_pointers.asm
+++ b/data/moves/effects_pointers.asm
@@ -1,5 +1,6 @@
MoveEffectsPointers:
; entries correspond to EFFECT_* constants
+ table_width 2, MoveEffectsPointers
dw NormalHit
dw DoSleep
dw PoisonHit
@@ -157,3 +158,4 @@ MoveEffectsPointers:
dw BeatUp
dw Fly
dw DefenseCurl
+ assert_table_length NUM_MOVE_EFECTS
diff --git a/data/moves/moves.asm b/data/moves/moves.asm
index 49c17d9bc..31f9d27d0 100644
--- a/data/moves/moves.asm
+++ b/data/moves/moves.asm
@@ -11,7 +11,8 @@ move: MACRO
ENDM
Moves:
-; entries correspond to constants/move_constants.asm
+; entries correspond to move ids (see constants/move_constants.asm)
+ table_width MOVE_LENGTH, Moves
move POUND, EFFECT_NORMAL_HIT, 40, NORMAL, 100, 35, 0
move KARATE_CHOP, EFFECT_NORMAL_HIT, 50, FIGHTING, 100, 25, 0
move DOUBLESLAP, EFFECT_MULTI_HIT, 15, NORMAL, 85, 10, 0
@@ -263,3 +264,4 @@ Moves:
move ROCK_SMASH, EFFECT_DEFENSE_DOWN_HIT, 20, FIGHTING, 100, 15, 50
move WHIRLPOOL, EFFECT_TRAP_TARGET, 15, WATER, 70, 15, 0
move BEAT_UP, EFFECT_BEAT_UP, 10, DARK, 100, 10, 0
+ assert_table_length NUM_ATTACKS
diff --git a/data/moves/tmhm_moves.asm b/data/moves/tmhm_moves.asm
index 28f28c24d..7ecf9fec8 100644
--- a/data/moves/tmhm_moves.asm
+++ b/data/moves/tmhm_moves.asm
@@ -3,6 +3,7 @@
TMHMMoves:
; entries correspond to *_TMNUM constants (see constants/item_constants.asm)
+ table_width 1, TMHMMoves
; TMs
n = 1
@@ -43,4 +44,6 @@ PURGE MOVE_FOR_MT
n = n + 1
endr
+ assert_table_length NUM_TM_HM_TUTOR
+
db 0 ; end
diff --git a/data/party_menu_qualities.asm b/data/party_menu_qualities.asm
index 7250743af..a89e6beef 100644
--- a/data/party_menu_qualities.asm
+++ b/data/party_menu_qualities.asm
@@ -20,6 +20,7 @@ ENDM
PartyMenuQualityPointers:
; entries correspond to PARTYMENUACTION_* constants
+ table_width 2, PartyMenuQualityPointers
dw .Default ; PARTYMENUACTION_CHOOSE_POKEMON
dw .Default ; PARTYMENUACTION_HEALING_ITEM
dw .Default ; PARTYMENUACTION_SWITCH
@@ -30,6 +31,7 @@ PartyMenuQualityPointers:
dw .Gender ; PARTYMENUACTION_GIVE_MON_FEMALE
dw .Default ; PARTYMENUACTION_GIVE_ITEM
dw .Mobile ; PARTYMENUACTION_MOBILE
+ assert_table_length NUM_PARTYMENUACTIONS
.Default: partymenuqualities NICKNAMES, HP_BAR, HP_DIGITS, LEVEL, STATUS
.TMHM: partymenuqualities NICKNAMES, TMHM_COMPAT, LEVEL, STATUS
diff --git a/data/phone/non_trainer_names.asm b/data/phone/non_trainer_names.asm
index 1792c506a..deef730d5 100644
--- a/data/phone/non_trainer_names.asm
+++ b/data/phone/non_trainer_names.asm
@@ -1,11 +1,13 @@
NonTrainerCallerNames:
-; entries correspond to PHONECONTACT_* constants
+; entries correspond to PHONECONTACT_* constants (see constants/trainer_constants.asm)
+ table_width 2, NonTrainerCallerNames
dw .none
dw .mom
dw .bikeshop
dw .bill
dw .elm
dw .buena
+ assert_table_length NUM_NONTRAINER_PHONECONTACTS + 1
.none: db "----------@"
.mom: db "MOM:@"
diff --git a/data/phone/phone_contacts.asm b/data/phone/phone_contacts.asm
index 0c67e5109..aad39ae23 100644
--- a/data/phone/phone_contacts.asm
+++ b/data/phone/phone_contacts.asm
@@ -10,6 +10,7 @@ ENDM
PhoneContacts:
; entries correspond to PHONE_* constants
+ table_width PHONE_CONTACT_SIZE, PhoneContacts
phone TRAINER_NONE, PHONE_00, N_A, 0, UnusedPhoneScript, 0, UnusedPhoneScript
phone TRAINER_NONE, PHONECONTACT_MOM, PLAYERS_HOUSE_1F, ANYTIME, MomPhoneCalleeScript, 0, UnusedPhoneScript
phone TRAINER_NONE, PHONECONTACT_BIKESHOP, OAKS_LAB, 0, UnusedPhoneScript, 0, UnusedPhoneScript
@@ -48,3 +49,4 @@ PhoneContacts:
phone HIKER, PARRY1, ROUTE_45, ANYTIME, ParryPhoneCalleeScript, ANYTIME, ParryPhoneCallerScript
phone PICNICKER, ERIN1, ROUTE_46, ANYTIME, ErinPhoneCalleeScript, ANYTIME, ErinPhoneCallerScript
phone TRAINER_NONE, PHONECONTACT_BUENA, GOLDENROD_DEPT_STORE_ROOF, ANYTIME, BuenaPhoneCalleeScript, ANYTIME, BuenaPhoneCallerScript
+ assert_table_length NUM_PHONE_CONTACTS + 1
diff --git a/data/phone/special_calls.asm b/data/phone/special_calls.asm
index 826a5d283..a516e5957 100644
--- a/data/phone/special_calls.asm
+++ b/data/phone/special_calls.asm
@@ -7,6 +7,7 @@ ENDM
SpecialPhoneCallList:
; entries correspond to SPECIALCALL_* constants
+ table_width SPECIALCALL_SIZE, SpecialPhoneCallList
specialcall SpecialCallOnlyWhenOutside, PHONECONTACT_ELM, ElmPhoneCallerScript
specialcall SpecialCallOnlyWhenOutside, PHONECONTACT_ELM, ElmPhoneCallerScript
specialcall SpecialCallOnlyWhenOutside, PHONECONTACT_ELM, ElmPhoneCallerScript
@@ -15,3 +16,4 @@ SpecialPhoneCallList:
specialcall SpecialCallWhereverYouAre, PHONECONTACT_BIKESHOP, BikeShopPhoneCallerScript
specialcall SpecialCallWhereverYouAre, PHONECONTACT_MOM, MomPhoneLectureScript
specialcall SpecialCallOnlyWhenOutside, PHONECONTACT_ELM, ElmPhoneCallerScript
+ assert_table_length NUM_SPECIALCALLS
diff --git a/data/pokemon/base_stats.asm b/data/pokemon/base_stats.asm
index 74928d860..0bd395fd8 100644
--- a/data/pokemon/base_stats.asm
+++ b/data/pokemon/base_stats.asm
@@ -32,6 +32,7 @@ endr
ENDM
BaseData::
+ table_width BASE_DATA_SIZE, BaseData
INCLUDE "data/pokemon/base_stats/bulbasaur.asm"
INCLUDE "data/pokemon/base_stats/ivysaur.asm"
INCLUDE "data/pokemon/base_stats/venusaur.asm"
@@ -283,5 +284,4 @@ INCLUDE "data/pokemon/base_stats/tyranitar.asm"
INCLUDE "data/pokemon/base_stats/lugia.asm"
INCLUDE "data/pokemon/base_stats/ho_oh.asm"
INCLUDE "data/pokemon/base_stats/celebi.asm"
-.End:
- assert BaseData.End - BaseData == NUM_POKEMON * BASE_DATA_SIZE
+ assert_table_length NUM_POKEMON
diff --git a/data/pokemon/cries.asm b/data/pokemon/cries.asm
index e6255e040..dc0d08df9 100644
--- a/data/pokemon/cries.asm
+++ b/data/pokemon/cries.asm
@@ -5,6 +5,7 @@ ENDM
PokemonCries::
; entries correspond to constants/pokemon_constants.asm
+ table_width MON_CRY_LENGTH, PokemonCries
mon_cry CRY_BULBASAUR, 128, 129 ; BULBASAUR
mon_cry CRY_BULBASAUR, 32, 256 ; IVYSAUR
mon_cry CRY_BULBASAUR, 0, 320 ; VENUSAUR
@@ -256,7 +257,9 @@ PokemonCries::
mon_cry CRY_TYPHLOSION, 0, 256 ; LUGIA
mon_cry CRY_AIPOM, 0, 384 ; HO_OH
mon_cry CRY_ENTEI, 330, 273 ; CELEBI
+ assert_table_length NUM_POKEMON
mon_cry CRY_NIDORAN_M, 0, 0 ; 252
mon_cry CRY_NIDORAN_M, 0, 0 ; 253
mon_cry CRY_NIDORAN_M, 0, 0 ; 254
mon_cry CRY_NIDORAN_M, 0, 0 ; 255
+ assert_table_length $ff
diff --git a/data/pokemon/dex_entry_pointers.asm b/data/pokemon/dex_entry_pointers.asm
index 6081757e5..890745500 100644
--- a/data/pokemon/dex_entry_pointers.asm
+++ b/data/pokemon/dex_entry_pointers.asm
@@ -1,5 +1,6 @@
PokedexDataPointerTable:
; entries correspond to constants/pokemon_constants.asm
+ table_width 2, PokedexDataPointerTable
dw BulbasaurPokedexEntry
dw IvysaurPokedexEntry
dw VenusaurPokedexEntry
@@ -251,3 +252,4 @@ PokedexDataPointerTable:
dw LugiaPokedexEntry
dw HoOhPokedexEntry
dw CelebiPokedexEntry
+ assert_table_length NUM_POKEMON
diff --git a/data/pokemon/dex_order_alpha.asm b/data/pokemon/dex_order_alpha.asm
index b93238cb9..63e80c3c2 100644
--- a/data/pokemon/dex_order_alpha.asm
+++ b/data/pokemon/dex_order_alpha.asm
@@ -1,6 +1,7 @@
; Every Pokémon sorted alphabetically by name.
AlphabeticalPokedexOrder:
+ table_width 1, AlphabeticalPokedexOrder
db ABRA
db AERODACTYL
db AIPOM
@@ -252,3 +253,4 @@ AlphabeticalPokedexOrder:
db YANMA
db ZAPDOS
db ZUBAT
+ assert_table_length NUM_POKEMON
diff --git a/data/pokemon/dex_order_new.asm b/data/pokemon/dex_order_new.asm
index 853fbe73d..77977cb3a 100644
--- a/data/pokemon/dex_order_new.asm
+++ b/data/pokemon/dex_order_new.asm
@@ -1,6 +1,7 @@
; Every Pokémon sorted in New Pokédex Order.
NewPokedexOrder:
+ table_width 1, NewPokedexOrder
db CHIKORITA
db BAYLEEF
db MEGANIUM
@@ -252,3 +253,4 @@ NewPokedexOrder:
db MEWTWO
db MEW
db CELEBI
+ assert_table_length NUM_POKEMON
diff --git a/data/pokemon/egg_move_pointers.asm b/data/pokemon/egg_move_pointers.asm
index dacf4cffd..e6e087bb4 100644
--- a/data/pokemon/egg_move_pointers.asm
+++ b/data/pokemon/egg_move_pointers.asm
@@ -1,4 +1,5 @@
EggMovePointers::
+ table_width 2, EggMovePointers
dw BulbasaurEggMoves
dw NoEggMoves
dw NoEggMoves
@@ -250,3 +251,4 @@ EggMovePointers::
dw NoEggMoves
dw NoEggMoves
dw NoEggMoves
+ assert_table_length NUM_POKEMON
diff --git a/data/pokemon/evos_attacks_pointers.asm b/data/pokemon/evos_attacks_pointers.asm
index 7b27c6a74..3b4155252 100644
--- a/data/pokemon/evos_attacks_pointers.asm
+++ b/data/pokemon/evos_attacks_pointers.asm
@@ -1,6 +1,7 @@
; Evolutions and attacks are grouped together since they're both checked at level-up.
EvosAttacksPointers::
+ table_width 2, EvosAttacksPointers
dw BulbasaurEvosAttacks
dw IvysaurEvosAttacks
dw VenusaurEvosAttacks
@@ -252,3 +253,4 @@ EvosAttacksPointers::
dw LugiaEvosAttacks
dw HoOhEvosAttacks
dw CelebiEvosAttacks
+ assert_table_length NUM_POKEMON
diff --git a/data/pokemon/gen1_base_special.asm b/data/pokemon/gen1_base_special.asm
index 306ce31d9..1c523a014 100644
--- a/data/pokemon/gen1_base_special.asm
+++ b/data/pokemon/gen1_base_special.asm
@@ -1,6 +1,7 @@
; The original base Special stat for each Pokémon from Red/Blue
KantoMonSpecials:
+ table_width 1, KantoMonSpecials
db 65 ; BULBASAUR
db 80 ; IVYSAUR
db 100 ; VENUSAUR
@@ -152,3 +153,4 @@ KantoMonSpecials:
db 100 ; DRAGONITE
db 154 ; MEWTWO
db 100 ; MEW
+ assert_table_length JOHTO_POKEMON - 1
diff --git a/data/pokemon/gen1_order.asm b/data/pokemon/gen1_order.asm
index 45efcafa0..ca40398a4 100644
--- a/data/pokemon/gen1_order.asm
+++ b/data/pokemon/gen1_order.asm
@@ -1,4 +1,5 @@
Pokered_MonIndices:
+ table_width 1, Pokered_MonIndices
db RHYDON
db KANGASKHAN
db NIDORAN_M
@@ -189,7 +190,7 @@ Pokered_MonIndices:
db BELLSPROUT
db WEEPINBELL
db VICTREEBEL
-
+ assert_table_length 190 ; gen 1 mon indexes
db CHIKORITA
db BAYLEEF
db MEGANIUM
@@ -252,3 +253,4 @@ Pokered_MonIndices:
db QWILFISH
db WOBBUFFET
db WOBBUFFET
+ assert_table_length NUM_POKEMON + 1
diff --git a/data/pokemon/menu_icons.asm b/data/pokemon/menu_icons.asm
index f378cbfbe..506d060c3 100644
--- a/data/pokemon/menu_icons.asm
+++ b/data/pokemon/menu_icons.asm
@@ -1,6 +1,7 @@
; party menu icons
MonMenuIcons:
+ table_width 1, MonMenuIcons
db ICON_BULBASAUR ; BULBASAUR
db ICON_BULBASAUR ; IVYSAUR
db ICON_BULBASAUR ; VENUSAUR
@@ -252,3 +253,4 @@ MonMenuIcons:
db ICON_LUGIA ; LUGIA
db ICON_HO_OH ; HO_OH
db ICON_HUMANSHAPE ; CELEBI
+ assert_table_length NUM_POKEMON
diff --git a/data/pokemon/names.asm b/data/pokemon/names.asm
index 266b0c020..ad1d0ef57 100644
--- a/data/pokemon/names.asm
+++ b/data/pokemon/names.asm
@@ -1,4 +1,5 @@
PokemonNames::
+ table_width NAME_LENGTH - 1, PokemonNames
db "BULBASAUR@"
db "IVYSAUR@@@"
db "VENUSAUR@@"
@@ -250,8 +251,11 @@ PokemonNames::
db "LUGIA@@@@@"
db "HO-OH@@@@@"
db "CELEBI@@@@"
+ assert_table_length NUM_POKEMON
db "?????@@@@@"
db "EGG@@@@@@@"
+ assert_table_length EGG
db "?????@@@@@"
db "?????@@@@@"
db "?????@@@@@"
+ assert_table_length $100
diff --git a/data/pokemon/palettes.asm b/data/pokemon/palettes.asm
index 917a629bf..5cefbd38e 100644
--- a/data/pokemon/palettes.asm
+++ b/data/pokemon/palettes.asm
@@ -5,6 +5,9 @@ PokemonPalettes:
; only the middle two colors are included, not black or white.
; Shiny palettes are defined directly, not generated.
+ ; 2 middle palettes, front and shiny, with 2 colors each
+ table_width PAL_COLOR_SIZE * 2 * 2, PokemonPalettes
+
; 000
RGB 30, 22, 17
RGB 16, 14, 19
@@ -515,6 +518,8 @@ INCLUDE "gfx/pokemon/ho_oh/shiny.pal"
INCBIN "gfx/pokemon/celebi/front.gbcpal", middle_colors
INCLUDE "gfx/pokemon/celebi/shiny.pal"
+ assert_table_length NUM_POKEMON + 1
+
; 252
RGB 30, 26, 11
RGB 23, 16, 00
@@ -525,6 +530,8 @@ INCLUDE "gfx/pokemon/celebi/shiny.pal"
INCBIN "gfx/pokemon/egg/front.gbcpal", middle_colors
INCLUDE "gfx/pokemon/egg/shiny.pal"
+ assert_table_length EGG + 1
+
; 254
RGB 30, 26, 11
RGB 23, 16, 00
@@ -538,3 +545,5 @@ INCLUDE "gfx/pokemon/egg/shiny.pal"
; 255 shiny
RGB 23, 23, 23
RGB 17, 17, 17
+
+ assert_table_length $100
diff --git a/data/pokemon/pic_pointers.asm b/data/pokemon/pic_pointers.asm
index c45a9837e..a57c63d83 100644
--- a/data/pokemon/pic_pointers.asm
+++ b/data/pokemon/pic_pointers.asm
@@ -2,6 +2,7 @@
PokemonPicPointers::
; entries correspond to Pokémon species, two apiece
+ table_width 3 * 2, PokemonPicPointers
dba_pic BulbasaurFrontpic
dba_pic BulbasaurBackpic
dba_pic IvysaurFrontpic
@@ -507,7 +508,9 @@ PokemonPicPointers::
dba_pic HoOhBackpic
dba_pic CelebiFrontpic
dba_pic CelebiBackpic
+ assert_table_length NUM_POKEMON
dbw -1, -1 ; unused
dbw -1, -1 ; unused
dba_pic EggPic
dbw -1, -1 ; unused
+ assert_table_length EGG
diff --git a/data/pokemon/unown_pic_pointers.asm b/data/pokemon/unown_pic_pointers.asm
index 1ae0da6b6..6ecfb4e62 100644
--- a/data/pokemon/unown_pic_pointers.asm
+++ b/data/pokemon/unown_pic_pointers.asm
@@ -1,5 +1,6 @@
UnownPicPointers::
; entries correspond to Unown letters, two apiece
+ table_width 3 * 2, UnownPicPointers
dba_pic UnownAFrontpic
dba_pic UnownABackpic
dba_pic UnownBFrontpic
@@ -52,3 +53,4 @@ UnownPicPointers::
dba_pic UnownYBackpic
dba_pic UnownZFrontpic
dba_pic UnownZBackpic
+ assert_table_length NUM_UNOWN
diff --git a/data/pokemon/unown_words.asm b/data/pokemon/unown_words.asm
index 6ddd0f466..329a6aae0 100644
--- a/data/pokemon/unown_words.asm
+++ b/data/pokemon/unown_words.asm
@@ -9,7 +9,8 @@ ENDM
UnownWords:
; entries correspond to UNOWN_* form constants
- dw UnownWordA
+ table_width 2, UnownWords
+ dw UnownWordA ; unused
dw UnownWordA
dw UnownWordB
dw UnownWordC
@@ -36,6 +37,7 @@ UnownWords:
dw UnownWordX
dw UnownWordY
dw UnownWordZ
+ assert_table_length NUM_UNOWN + 1
UnownWordA: unownword "ANGRY"
UnownWordB: unownword "BEAR"
diff --git a/data/radio/buenas_passwords.asm b/data/radio/buenas_passwords.asm
index 85e1b951b..078bcdd4c 100644
--- a/data/radio/buenas_passwords.asm
+++ b/data/radio/buenas_passwords.asm
@@ -1,5 +1,5 @@
BuenasPasswordTable:
-; there are NUM_PASSWORD_CATEGORIES entries
+ table_width 2, BuenasPasswordTable
dw .JohtoStarters
dw .Beverages
dw .HealingItems
@@ -11,6 +11,7 @@ BuenasPasswordTable:
dw .Moves
dw .XItems
dw .RadioStations
+ assert_table_length NUM_PASSWORD_CATEGORIES
; string type, points, option 1, option 2, option 3
.JohtoStarters: db BUENA_MON, 10, CYNDAQUIL, TOTODILE, CHIKORITA
diff --git a/data/radio/channel_music.asm b/data/radio/channel_music.asm
index 62504ed11..5a74ea7ad 100644
--- a/data/radio/channel_music.asm
+++ b/data/radio/channel_music.asm
@@ -1,5 +1,6 @@
RadioChannelSongs:
-; entries correspond to radio channel ids
+; entries correspond to radio channel ids (see constants/radio_constants.asm)
+ table_width 2, RadioChannelSongs
dw MUSIC_POKEMON_TALK
dw MUSIC_POKEMON_CENTER
dw MUSIC_TITLE
@@ -11,3 +12,4 @@ RadioChannelSongs:
dw MUSIC_POKE_FLUTE_CHANNEL
dw MUSIC_RUINS_OF_ALPH_RADIO
dw MUSIC_LAKE_OF_RAGE_ROCKET_RADIO
+ assert_table_length NUM_RADIO_CHANNELS
diff --git a/data/radio/oaks_pkmn_talk_routes.asm b/data/radio/oaks_pkmn_talk_routes.asm
index db2447401..acef4bdd3 100644
--- a/data/radio/oaks_pkmn_talk_routes.asm
+++ b/data/radio/oaks_pkmn_talk_routes.asm
@@ -1,7 +1,6 @@
; Oak's Pokémon Talk will list wild Pokémon on these maps.
OaksPKMNTalkRoutes:
-; there are NUM_OAKS_POKEMON_TALK_ROUTES entries
map_id ROUTE_29
map_id ROUTE_46
map_id ROUTE_30
@@ -17,3 +16,4 @@ OaksPKMNTalkRoutes:
map_id ROUTE_45
map_id ROUTE_36
map_id ROUTE_31
+.End
diff --git a/data/sprite_anims/framesets.asm b/data/sprite_anims/framesets.asm
index 5a154acd8..b7ebc3352 100644
--- a/data/sprite_anims/framesets.asm
+++ b/data/sprite_anims/framesets.asm
@@ -1,5 +1,6 @@
SpriteAnimFrameData:
-; entries correspond to SPRITE_ANIM_FRAMESET_* constants
+; entries correspond to SPRITE_ANIM_FRAMESET_* constants (see constants/sprite_anim_constants.asm)
+ table_width 2, SpriteAnimFrameData
dw .Frameset_00
dw .Frameset_PartyMon
dw .Frameset_PartyMonWithMail
@@ -66,6 +67,7 @@ SpriteAnimFrameData:
dw .Frameset_IntroUnownF
dw .Frameset_CelebiLeft
dw .Frameset_CelebiRight
+ assert_table_length NUM_SPRITE_ANIM_FRAMESETS
.Frameset_00:
frame SPRITE_ANIM_OAMSET_RED_WALK_1, 32
diff --git a/data/sprite_anims/oam.asm b/data/sprite_anims/oam.asm
index 10e6ed1d9..6207c60a5 100644
--- a/data/sprite_anims/oam.asm
+++ b/data/sprite_anims/oam.asm
@@ -1,5 +1,6 @@
SpriteAnimOAMData:
-; entries correspond to SPRITE_ANIM_OAMSET_* constants
+; entries correspond to SPRITE_ANIM_OAMSET_* constants (see constants/sprite_anim_constants.asm)
+ table_width 3, SpriteAnimOAMData
; vtile offset, data pointer
dbw $00, .OAMData_RedWalk ; SPRITE_ANIM_OAMSET_RED_WALK_1
dbw $04, .OAMData_RedWalk ; SPRITE_ANIM_OAMSET_RED_WALK_2
@@ -141,6 +142,7 @@ SpriteAnimOAMData:
dbw $08, .OAMData_GameFreakLogo4_11 ; SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_9
dbw $04, .OAMData_GameFreakLogo4_11 ; SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_10
dbw $00, .OAMData_GameFreakLogo4_11 ; SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_11
+ assert_table_length NUM_SPRITE_ANIM_OAMSETS
.OAMData_1x1_Palette0:
db 1
diff --git a/data/sprite_anims/sequences.asm b/data/sprite_anims/sequences.asm
index d458d2eee..c41e96cc1 100644
--- a/data/sprite_anims/sequences.asm
+++ b/data/sprite_anims/sequences.asm
@@ -1,5 +1,6 @@
SpriteAnimSeqData:
-; entries correspond to SPRITE_ANIM_INDEX_* constants
+; entries correspond to SPRITE_ANIM_INDEX_* constants (see constants/sprite_anim_constants.asm)
+ table_width 3, SpriteAnimSeqData
; frameset, sequence, tile
; SPRITE_ANIM_INDEX_PARTY_MON
db SPRITE_ANIM_FRAMESET_PARTY_MON, SPRITE_ANIM_SEQ_PARTY_MON, SPRITE_ANIM_DICT_DEFAULT
@@ -91,3 +92,4 @@ SpriteAnimSeqData:
db SPRITE_ANIM_FRAMESET_INTRO_SUICUNE_AWAY, SPRITE_ANIM_SEQ_INTRO_SUICUNE_AWAY, SPRITE_ANIM_DICT_DEFAULT
; SPRITE_ANIM_INDEX_CELEBI
db SPRITE_ANIM_FRAMESET_CELEBI_LEFT, SPRITE_ANIM_SEQ_NULL, SPRITE_ANIM_DICT_DEFAULT
+ assert_table_length NUM_SPRITE_ANIM_INDEXES
diff --git a/data/sprites/emotes.asm b/data/sprites/emotes.asm
index 2371c4624..32f4c2598 100644
--- a/data/sprites/emotes.asm
+++ b/data/sprites/emotes.asm
@@ -7,6 +7,7 @@ ENDM
Emotes:
; entries correspond to EMOTE_* constants
+ table_width EMOTE_LENGTH, Emotes
emote ShockEmote, 4, $f8
emote QuestionEmote, 4, $f8
emote HappyEmote, 4, $f8
@@ -19,3 +20,4 @@ Emotes:
emote FishingRodGFX, 2, $fc
emote BoulderDustGFX, 2, $fe
emote GrassRustleGFX, 1, $fe
+ assert_table_length NUM_EMOTES
diff --git a/data/sprites/facings.asm b/data/sprites/facings.asm
index aebf97ff5..b1bc7abf5 100644
--- a/data/sprites/facings.asm
+++ b/data/sprites/facings.asm
@@ -1,5 +1,6 @@
Facings:
-; entries correspond to FACING_* constants
+; entries correspond to FACING_* constants (see constants/map_object_constants.asm)
+ table_width 2, Facings
dw FacingStepDown0
dw FacingStepDown1
dw FacingStepDown2
@@ -32,10 +33,8 @@ Facings:
dw FacingBoulderDust2
dw FacingGrass1
dw FacingGrass2
-.End
- dw 0
-
-NUM_FACINGS EQU (Facings.End - Facings) / 2
+ assert_table_length NUM_FACINGS
+ dw 0 ; end
; Tables used as a reference to transform OAM data.
diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm
index 05b2e084b..60a718131 100644
--- a/data/sprites/map_objects.asm
+++ b/data/sprites/map_objects.asm
@@ -1,5 +1,6 @@
SpriteMovementData::
; entries correspond to SPRITEMOVEDATA_* constants
+ table_width NUM_SPRITEMOVEDATA_FIELDS, SpriteMovementData
; SPRITEMOVEDATA_00
db SPRITEMOVEFN_00 ; movement function
@@ -304,3 +305,5 @@ SpriteMovementData::
db 0 ; flags1
db 0 ; flags2
db 0 ; palette flags
+
+ assert_table_length NUM_SPRITEMOVEDATA + 1
diff --git a/data/sprites/sprite_mons.asm b/data/sprites/sprite_mons.asm
index 3d53804db..9d3e62acd 100644
--- a/data/sprites/sprite_mons.asm
+++ b/data/sprites/sprite_mons.asm
@@ -1,5 +1,6 @@
SpriteMons:
; entries correspond to SPRITE_* constants past SPRITE_POKEMON
+ table_width 1, SpriteMons
db UNOWN
db GEODUDE
db GROWLITHE
@@ -35,3 +36,4 @@ SpriteMons:
db GYARADOS
db LUGIA
db HO_OH
+ assert_table_length NUM_POKEMON_SPRITES
diff --git a/data/sprites/sprites.asm b/data/sprites/sprites.asm
index 39c962b85..0839ec971 100644
--- a/data/sprites/sprites.asm
+++ b/data/sprites/sprites.asm
@@ -6,6 +6,7 @@ ENDM
OverworldSprites:
; entries correspond to SPRITE_* constants
+ table_width NUM_SPRITEDATA_FIELDS, OverworldSprites
overworld_sprite ChrisSpriteGFX, 12, WALKING_SPRITE, PAL_OW_RED
overworld_sprite ChrisBikeSpriteGFX, 12, WALKING_SPRITE, PAL_OW_RED
overworld_sprite GameboyKidSpriteGFX, 12, STANDING_SPRITE, PAL_OW_GREEN
@@ -108,3 +109,4 @@ OverworldSprites:
overworld_sprite EnteiSpriteGFX, 4, STILL_SPRITE, PAL_OW_RED
overworld_sprite RaikouSpriteGFX, 4, STILL_SPRITE, PAL_OW_RED
overworld_sprite StandingYoungsterSpriteGFX, 12, STANDING_SPRITE, PAL_OW_BLUE
+ assert_table_length NUM_OVERWORLD_SPRITES
diff --git a/data/tilesets.asm b/data/tilesets.asm
index eb5b6fe49..9d8f62382 100644
--- a/data/tilesets.asm
+++ b/data/tilesets.asm
@@ -11,7 +11,8 @@ ENDM
; - The *Anim are defined in engine/tilesets/tileset_anims.asm
Tilesets::
-; entries correspond to TILESET_* constants
+; entries correspond to TILESET_* constants (see constants/tileset_constants.asm)
+ table_width TILESET_LENGTH, Tilesets
tileset Tileset0
tileset TilesetJohto
tileset TilesetJohtoModern
@@ -49,3 +50,4 @@ Tilesets::
tileset TilesetKabutoWordRoom
tileset TilesetOmanyteWordRoom
tileset TilesetAerodactylWordRoom
+ assert_table_length NUM_TILESETS + 1
diff --git a/data/trainers/attributes.asm b/data/trainers/attributes.asm
index 67d852d83..70544977d 100644
--- a/data/trainers/attributes.asm
+++ b/data/trainers/attributes.asm
@@ -1,5 +1,6 @@
TrainerClassAttributes:
; entries correspond to trainer classes (see constants/trainer_constants.asm)
+ table_width NUM_TRAINER_ATTRIBUTES, TrainerClassAttributes
; Falkner
db NO_ITEM, NO_ITEM ; items
@@ -402,3 +403,5 @@ TrainerClassAttributes:
db 25 ; base reward
dw AI_BASIC | AI_SETUP | AI_SMART | AI_AGGRESSIVE | AI_CAUTIOUS | AI_STATUS | AI_RISKY
dw CONTEXT_USE | SWITCH_SOMETIMES
+
+ assert_table_length NUM_TRAINER_CLASSES
diff --git a/data/trainers/dvs.asm b/data/trainers/dvs.asm
index 91918b4d9..12bba0da6 100644
--- a/data/trainers/dvs.asm
+++ b/data/trainers/dvs.asm
@@ -1,5 +1,6 @@
TrainerClassDVs:
; entries correspond to trainer classes (see constants/trainer_constants.asm)
+ table_width 2, TrainerClassDVs
; atk,def,spd,spc
dn 9, 10, 7, 7 ; FALKNER
dn 8, 8, 8, 8 ; WHITNEY
@@ -68,3 +69,4 @@ TrainerClassDVs:
dn 9, 8, 8, 8 ; OFFICER
dn 7, 14, 10, 8 ; GRUNTF
dn 9, 8, 8, 8 ; MYSTICALMAN
+ assert_table_length NUM_TRAINER_CLASSES
diff --git a/data/trainers/encounter_music.asm b/data/trainers/encounter_music.asm
index a64d160fe..026646952 100644
--- a/data/trainers/encounter_music.asm
+++ b/data/trainers/encounter_music.asm
@@ -2,6 +2,7 @@
TrainerEncounterMusic::
; entries correspond to trainer classes (see constants/trainer_constants.asm)
+ table_width 1, TrainerEncounterMusic
db MUSIC_HIKER_ENCOUNTER ; none
db MUSIC_YOUNGSTER_ENCOUNTER ; falkner
db MUSIC_LASS_ENCOUNTER ; whitney
@@ -70,6 +71,7 @@ TrainerEncounterMusic::
db MUSIC_HIKER_ENCOUNTER ; officer
db MUSIC_ROCKET_ENCOUNTER ; gruntf
db MUSIC_HIKER_ENCOUNTER ; mysticalman
- db MUSIC_HIKER_ENCOUNTER
- db MUSIC_HIKER_ENCOUNTER
- db MUSIC_HIKER_ENCOUNTER
+ assert_table_length NUM_TRAINER_CLASSES + 1
+ db MUSIC_HIKER_ENCOUNTER ; unused
+ db MUSIC_HIKER_ENCOUNTER ; unused
+ db MUSIC_HIKER_ENCOUNTER ; unused
diff --git a/data/trainers/genders.asm b/data/trainers/genders.asm
index 1bfc925d2..230b29205 100644
--- a/data/trainers/genders.asm
+++ b/data/trainers/genders.asm
@@ -2,6 +2,7 @@
BTTrainerClassGenders:
; entries correspond to trainer classes
+ table_width 1, BTTrainerClassGenders
db MALE ; FALKNER
db FEMALE ; WHITNEY
db FEMALE ; BUGSY
@@ -68,3 +69,4 @@ BTTrainerClassGenders:
db MALE ; BLUE
db MALE ; OFFICER
db FEMALE ; GRUNTF
+ assert_table_length NUM_TRAINER_CLASSES - 1 ; exclude MYSTICALMAN
diff --git a/data/trainers/palettes.asm b/data/trainers/palettes.asm
index abbe519ca..342999647 100644
--- a/data/trainers/palettes.asm
+++ b/data/trainers/palettes.asm
@@ -4,6 +4,8 @@ TrainerPalettes:
; Each .gbcpal is generated from the corresponding .png, and
; only the middle two colors are included, not black or white.
+ table_width PAL_COLOR_SIZE * 2, TrainerPalettes
+
PlayerPalette: ; Chris uses the same colors as Cal
INCBIN "gfx/trainers/cal.gbcpal", middle_colors
KrisPalette: ; Kris shares Falkner's palette
@@ -74,3 +76,5 @@ INCBIN "gfx/trainers/blue.gbcpal", middle_colors
INCBIN "gfx/trainers/officer.gbcpal", middle_colors
INCBIN "gfx/trainers/grunt_f.gbcpal", middle_colors
INCBIN "gfx/trainers/mysticalman.gbcpal", middle_colors
+
+ assert_table_length NUM_TRAINER_CLASSES + 1
diff --git a/data/trainers/party_pointers.asm b/data/trainers/party_pointers.asm
index 45ba65b85..985e81ca4 100644
--- a/data/trainers/party_pointers.asm
+++ b/data/trainers/party_pointers.asm
@@ -2,6 +2,7 @@
TrainerGroups:
; entries correspond to trainer classes (see constants/trainer_constants.asm)
+ table_width 2, TrainerGroups
dw FalknerGroup
dw WhitneyGroup
dw BugsyGroup
@@ -69,3 +70,4 @@ TrainerGroups:
dw OfficerGroup
dw GruntFGroup
dw MysticalmanGroup
+ assert_table_length NUM_TRAINER_CLASSES
diff --git a/data/trainers/pic_pointers.asm b/data/trainers/pic_pointers.asm
index 6fc444eb6..31740ea3d 100644
--- a/data/trainers/pic_pointers.asm
+++ b/data/trainers/pic_pointers.asm
@@ -2,6 +2,7 @@
TrainerPicPointers::
; entries correspond to trainer classes (see constants/trainer_constants.asm)
+ table_width 3, TrainerPicPointers
dba_pic FalknerPic
dba_pic WhitneyPic
dba_pic BugsyPic
@@ -69,3 +70,4 @@ TrainerPicPointers::
dba_pic OfficerPic
dba_pic GruntfPic
dba_pic MysticalmanPic
+ assert_table_length NUM_TRAINER_CLASSES
diff --git a/data/trainers/sprites.asm b/data/trainers/sprites.asm
index b92a9032c..cf2f59961 100644
--- a/data/trainers/sprites.asm
+++ b/data/trainers/sprites.asm
@@ -1,5 +1,6 @@
BTTrainerClassSprites:
; entries correspond to trainer classes
+ table_width 1, BTTrainerClassSprites
db SPRITE_FALKNER
db SPRITE_WHITNEY
db SPRITE_BUGSY
@@ -66,3 +67,4 @@ BTTrainerClassSprites:
db SPRITE_BLUE
db SPRITE_OFFICER
db SPRITE_ROCKET_GIRL
+ assert_table_length NUM_TRAINER_CLASSES - 1 ; exclude MYSTICALMAN
diff --git a/data/types/names.asm b/data/types/names.asm
index 62d8e13bf..94fe67e13 100644
--- a/data/types/names.asm
+++ b/data/types/names.asm
@@ -1,5 +1,6 @@
TypeNames:
; entries correspond to types (see constants/type_constants.asm)
+ table_width 2, TypeNames
dw Normal
dw Fighting
dw Flying
@@ -10,6 +11,7 @@ TypeNames:
dw Bug
dw Ghost
dw Steel
+ assert_table_length UNUSED_TYPES
dw Normal
dw Normal
dw Normal
@@ -20,6 +22,7 @@ TypeNames:
dw Normal
dw Normal
dw CurseType
+ assert_table_length UNUSED_TYPES_END
dw Fire
dw Water
dw Grass
@@ -28,6 +31,7 @@ TypeNames:
dw Ice
dw Dragon
dw Dark
+ assert_table_length TYPES_END
Normal: db "NORMAL@"
Fighting: db "FIGHTING@"
diff --git a/data/types/search_strings.asm b/data/types/search_strings.asm
index d03d2786b..1345c27cd 100644
--- a/data/types/search_strings.asm
+++ b/data/types/search_strings.asm
@@ -1,5 +1,6 @@
PokedexTypeSearchStrings:
; entries correspond with PokedexTypeSearchConversionTable (see data/types/search_types.asm)
+ table_width POKEDEX_TYPE_STRING_LENGTH, PokedexTypeSearchStrings
db " ---- @"
db " NORMAL @"
db " FIRE @"
@@ -18,3 +19,4 @@ PokedexTypeSearchStrings:
db " DRAGON @"
db " DARK @"
db " STEEL @"
+ assert_table_length NUM_TYPES + 1
diff --git a/data/types/search_types.asm b/data/types/search_types.asm
index c3aba3c91..dd9ea5628 100644
--- a/data/types/search_types.asm
+++ b/data/types/search_types.asm
@@ -1,5 +1,6 @@
PokedexTypeSearchConversionTable:
; entries correspond with PokedexTypeSearchStrings (see data/types/search_strings.asm)
+ table_width 1, PokedexTypeSearchConversionTable
db NORMAL
db FIRE
db WATER
@@ -17,3 +18,4 @@ PokedexTypeSearchConversionTable:
db DRAGON
db DARK
db STEEL
+ assert_table_length NUM_TYPES
diff --git a/data/wild/fish.asm b/data/wild/fish.asm
index 1976c8f95..b849b933f 100644
--- a/data/wild/fish.asm
+++ b/data/wild/fish.asm
@@ -7,6 +7,7 @@ ENDM
FishGroups:
; entries correspond to FISHGROUP_* constants
+ table_width FISHGROUP_DATA_LENGTH, FishGroups
fishgroup 50 percent + 1, .Shore_Old, .Shore_Good, .Shore_Super
fishgroup 50 percent + 1, .Ocean_Old, .Ocean_Good, .Ocean_Super
fishgroup 50 percent + 1, .Lake_Old, .Lake_Good, .Lake_Super
@@ -20,6 +21,7 @@ FishGroups:
fishgroup 50 percent + 1, .Qwilfish_Old, .Qwilfish_Good, .Qwilfish_Super
fishgroup 50 percent + 1, .Remoraid_Old, .Remoraid_Good, .Remoraid_Super
fishgroup 50 percent + 1, .Qwilfish_NoSwarm_Old, .Qwilfish_NoSwarm_Good, .Qwilfish_NoSwarm_Super
+ assert_table_length NUM_FISHGROUPS
.Shore_Old:
db 70 percent + 1, MAGIKARP, 10
diff --git a/data/wild/probabilities.asm b/data/wild/probabilities.asm
index bf3144bbe..f3f44e0af 100644
--- a/data/wild/probabilities.asm
+++ b/data/wild/probabilities.asm
@@ -4,6 +4,7 @@ mon_prob: MACRO
ENDM
GrassMonProbTable:
+ table_width 2, GrassMonProbTable
mon_prob 30, 0 ; 30% chance
mon_prob 60, 1 ; 30% chance
mon_prob 80, 2 ; 20% chance
@@ -11,8 +12,11 @@ GrassMonProbTable:
mon_prob 95, 4 ; 5% chance
mon_prob 99, 5 ; 4% chance
mon_prob 100, 6 ; 1% chance
+ assert_table_length NUM_GRASSMON
WaterMonProbTable:
+ table_width 2, WaterMonProbTable
mon_prob 60, 0 ; 60% chance
mon_prob 90, 1 ; 30% chance
mon_prob 100, 2 ; 10% chance
+ assert_table_length NUM_WATERMON
diff --git a/data/wild/treemons.asm b/data/wild/treemons.asm
index a6b1922f3..c24df03c1 100644
--- a/data/wild/treemons.asm
+++ b/data/wild/treemons.asm
@@ -1,5 +1,6 @@
TreeMons:
; entries correspond to TREEMON_SET_* constants
+ table_width 2, TreeMons
dw TreeMonSet_City
dw TreeMonSet_Canyon
dw TreeMonSet_Town
@@ -8,7 +9,8 @@ TreeMons:
dw TreeMonSet_Lake
dw TreeMonSet_Forest
dw TreeMonSet_Rock
- dw TreeMonSet_City
+ assert_table_length NUM_TREEMON_SETS
+ dw TreeMonSet_City ; unused
; Two tables each (common, rare).
; Structure:
diff --git a/engine/battle/move_effects/conversion2.asm b/engine/battle/move_effects/conversion2.asm
index df6d91090..32d4502e3 100644
--- a/engine/battle/move_effects/conversion2.asm
+++ b/engine/battle/move_effects/conversion2.asm
@@ -27,7 +27,7 @@ BattleCommand_Conversion2:
.loop
call BattleRandom
- maskbits NUM_TYPES
+ maskbits TYPES_END
cp UNUSED_TYPES
jr c, .okay
cp UNUSED_TYPES_END
diff --git a/engine/battle_anims/core.asm b/engine/battle_anims/core.asm
index 51916ef42..64be8839d 100644
--- a/engine/battle_anims/core.asm
+++ b/engine/battle_anims/core.asm
@@ -31,7 +31,7 @@ InitBattleAnimation:
ld e, a
ld d, 0
ld hl, BattleAnimObjects
-rept 6
+rept BATTLEANIMOBJ_LENGTH
add hl, de
endr
ld e, l
diff --git a/engine/debug/color_picker.asm b/engine/debug/color_picker.asm
index 502620de5..75f5a22ae 100644
--- a/engine/debug/color_picker.asm
+++ b/engine/debug/color_picker.asm
@@ -99,7 +99,7 @@ DebugColor_InitMonColor:
DebugColor_InitTrainerColor:
ld hl, TrainerPalettes
ld de, wDebugOriginalColors
- ld c, NUM_TRAINER_CLASSES
+ ld c, NUM_TRAINER_CLASSES + 1
.loop
push bc
push hl
@@ -284,7 +284,7 @@ DebugColorMain:
ld a, NUM_POKEMON ; CELEBI
ret
.trainer
- ld a, NUM_TRAINER_CLASSES - 1 ; MYSTICALMAN
+ ld a, NUM_TRAINER_CLASSES ; MYSTICALMAN
ret
.Jumptable:
diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm
index 7e7f075a0..b6d1a2b2e 100644
--- a/engine/gfx/color.asm
+++ b/engine/gfx/color.asm
@@ -1305,7 +1305,9 @@ MapObjectPals::
INCLUDE "gfx/overworld/npc_sprites.pal"
RoofPals:
+ table_width PAL_COLOR_SIZE * 2 * 2, RoofPals
INCLUDE "gfx/tilesets/roofs.pal"
+ assert_table_length NUM_MAP_GROUPS + 1
DiplomaPalettes:
INCLUDE "gfx/diploma/diploma.pal"
diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm
index 9b540d86b..23b0f606d 100644
--- a/engine/gfx/load_pics.asm
+++ b/engine/gfx/load_pics.asm
@@ -311,7 +311,7 @@ GetTrainerPic:
ld a, [wTrainerClass]
and a
ret z
- cp NUM_TRAINER_CLASSES
+ cp NUM_TRAINER_CLASSES + 1
ret nc
call WaitBGMap
xor a
diff --git a/engine/gfx/sprite_anims.asm b/engine/gfx/sprite_anims.asm
index f9b1dc221..d74db175d 100644
--- a/engine/gfx/sprite_anims.asm
+++ b/engine/gfx/sprite_anims.asm
@@ -12,7 +12,8 @@ DoAnimFrame:
jp hl
.Jumptable:
-; entries correspond to SPRITE_ANIM_SEQ_* constants
+; entries correspond to SPRITE_ANIM_SEQ_* constants (see constants/sprite_anim_constants.asm)
+ table_width 2, DoAnimFrame.Jumptable
dw AnimSeq_Null
dw AnimSeq_PartyMon
dw AnimSeq_PartyMonSwitch
@@ -48,6 +49,7 @@ DoAnimFrame:
dw AnimSeq_IntroUnown
dw AnimSeq_IntroUnownF
dw AnimSeq_IntroSuicuneAway
+ assert_table_length NUM_SPRITE_ANIM_SEQS
AnimSeq_Null:
ret
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index d4a969c24..b7d979fd9 100644
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -12,7 +12,8 @@ _DoItemEffect::
ret
ItemEffects:
-; entries correspond to item ids
+; entries correspond to item ids (see constants/item_constants.asm)
+ table_width 2, ItemEffects
dw PokeBallEffect ; MASTER_BALL
dw PokeBallEffect ; ULTRA_BALL
dw NoEffect ; BRIGHTPOWDER
@@ -192,6 +193,21 @@ ItemEffects:
dw PokeBallEffect ; PARK_BALL
dw NoEffect ; RAINBOW_WING
dw NoEffect ; ITEM_B3
+ assert_table_length ITEM_B3
+; The items past ITEM_B3 do not have effect entries:
+; BRICK_PIECE
+; SURF_MAIL
+; LITEBLUEMAIL
+; PORTRAITMAIL
+; LOVELY_MAIL
+; EON_MAIL
+; MORPH_MAIL
+; BLUESKY_MAIL
+; MUSIC_MAIL
+; MIRAGE_MAIL
+; ITEM_BE
+; They all have the ITEMMENU_NOUSE attribute so they can't be used anyway.
+; NoEffect would be appropriate, with the table then being NUM_ITEMS long.
PokeBallEffect:
ld a, [wBattleMode]
diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm
index 288e60d4e..f9b235900 100644
--- a/engine/overworld/decorations.asm
+++ b/engine/overworld/decorations.asm
@@ -23,7 +23,7 @@ _PlayerDecorationMenu:
ld [wCurDecorationCategory], a
jr c, .exit_menu
ld a, [wMenuSelection]
- ld hl, .pointers
+ ld hl, .category_pointers
call MenuJumptable
jr nc, .top_loop
@@ -46,26 +46,28 @@ _PlayerDecorationMenu:
db 0 ; items
dw wNumOwnedDecoCategories
dw PlaceNthMenuStrings
- dw .pointers
-
-.pointers
- dw DecoBedMenu, .bed
- dw DecoCarpetMenu, .carpet
- dw DecoPlantMenu, .plant
- dw DecoPosterMenu, .poster
- dw DecoConsoleMenu, .game
+ dw .category_pointers
+
+.category_pointers:
+ table_width 2 + 2, _PlayerDecorationMenu.category_pointers
+ dw DecoBedMenu, .bed
+ dw DecoCarpetMenu, .carpet
+ dw DecoPlantMenu, .plant
+ dw DecoPosterMenu, .poster
+ dw DecoConsoleMenu, .game
dw DecoOrnamentMenu, .ornament
- dw DecoBigDollMenu, .big_doll
- dw DecoExitMenu, .exit
-
-.bed db "BED@"
-.carpet db "CARPET@"
-.plant db "PLANT@"
-.poster db "POSTER@"
-.game db "GAME CONSOLE@"
-.ornament db "ORNAMENT@"
-.big_doll db "BIG DOLL@"
-.exit db "EXIT@"
+ dw DecoBigDollMenu, .big_doll
+ dw DecoExitMenu, .exit
+ assert_table_length NUM_DECO_CATEGORIES + 1
+
+.bed: db "BED@"
+.carpet: db "CARPET@"
+.plant: db "PLANT@"
+.poster: db "POSTER@"
+.game: db "GAME CONSOLE@"
+.ornament: db "ORNAMENT@"
+.big_doll: db "BIG DOLL@"
+.exit: db "EXIT@"
.FindCategoriesWithOwnedDecos:
xor a
@@ -99,7 +101,7 @@ _PlayerDecorationMenu:
ret
.FindOwnedDecos:
- ld hl, .dw
+ ld hl, .owned_pointers
.loop
ld a, [hli]
ld e, a
@@ -121,14 +123,16 @@ _PlayerDecorationMenu:
.done
ret
-.dw
- dwb FindOwnedBeds, 0 ; bed
- dwb FindOwnedCarpets, 1 ; carpet
- dwb FindOwnedPlants, 2 ; plant
- dwb FindOwnedPosters, 3 ; poster
- dwb FindOwnedConsoles, 4 ; game console
+.owned_pointers:
+ table_width 3, _PlayerDecorationMenu.owned_pointers
+ dwb FindOwnedBeds, 0 ; bed
+ dwb FindOwnedCarpets, 1 ; carpet
+ dwb FindOwnedPlants, 2 ; plant
+ dwb FindOwnedPosters, 3 ; poster
+ dwb FindOwnedConsoles, 4 ; game console
dwb FindOwnedOrnaments, 5 ; ornament
- dwb FindOwnedBigDolls, 6 ; big doll
+ dwb FindOwnedBigDolls, 6 ; big doll
+ assert_table_length NUM_DECO_CATEGORIES
dw 0 ; end
Deco_FillTempWithMinusOne:
@@ -200,7 +204,7 @@ FindOwnedBeds:
ld c, BEDS
jp FindOwnedDecosInCategory
-.beds
+.beds:
db DECO_FEATHERY_BED ; 2
db DECO_PINK_BED ; 3
db DECO_POLKADOT_BED ; 4
@@ -218,7 +222,7 @@ FindOwnedCarpets:
ld c, CARPETS
jp FindOwnedDecosInCategory
-.carpets
+.carpets:
db DECO_RED_CARPET ; 7
db DECO_BLUE_CARPET ; 8
db DECO_YELLOW_CARPET ; 9
@@ -236,7 +240,7 @@ FindOwnedPlants:
ld c, PLANTS
jp FindOwnedDecosInCategory
-.plants
+.plants:
db DECO_MAGNAPLANT ; c
db DECO_TROPICPLANT ; d
db DECO_JUMBOPLANT ; e
@@ -253,7 +257,7 @@ FindOwnedPosters:
ld c, POSTERS
jp FindOwnedDecosInCategory
-.posters
+.posters:
db DECO_TOWN_MAP ; 10
db DECO_PIKACHU_POSTER ; 11
db DECO_CLEFAIRY_POSTER ; 12
@@ -271,7 +275,7 @@ FindOwnedConsoles:
ld c, CONSOLES
jp FindOwnedDecosInCategory
-.consoles
+.consoles:
db DECO_FAMICOM ; 15
db DECO_SNES ; 16
db DECO_N64 ; 17
@@ -289,7 +293,7 @@ FindOwnedOrnaments:
ld c, DOLLS
jp FindOwnedDecosInCategory
-.ornaments
+.ornaments:
db DECO_PIKACHU_DOLL ; 1e
db DECO_SURF_PIKACHU_DOLL ; 1f
db DECO_CLEFAIRY_DOLL ; 20
@@ -326,7 +330,7 @@ FindOwnedBigDolls:
ld c, BIG_DOLLS
jp FindOwnedDecosInCategory
-.big_dolls
+.big_dolls:
db DECO_BIG_SNORLAX_DOLL ; 1a
db DECO_BIG_ONIX_DOLL ; 1b
db DECO_BIG_LAPRAS_DOLL ; 1c
@@ -419,7 +423,7 @@ PopulateDecoCategoryMenu:
GetDecorationData:
ld hl, DecorationAttributes
- ld bc, 6
+ ld bc, DECOATTR_STRUCT_LENGTH
call AddNTimes
ret
@@ -443,7 +447,7 @@ DecorationMenuFunction:
DoDecorationAction2:
ld a, [wMenuSelection]
call GetDecorationData
- ld de, 2 ; function 2
+ ld de, DECOATTR_ACTION
add hl, de
ld a, [hl]
ld hl, .DecoActions
@@ -451,6 +455,7 @@ DoDecorationAction2:
ret
.DecoActions:
+ table_width 2, DoDecorationAction2.DecoActions
dw DecoAction_nothing
dw DecoAction_setupbed
dw DecoAction_putawaybed
@@ -466,10 +471,11 @@ DoDecorationAction2:
dw DecoAction_putawaybigdoll
dw DecoAction_setupornament
dw DecoAction_putawayornament
+ assert_table_length NUM_DECO_ACTIONS + 1
GetDecorationFlag:
call GetDecorationData
- ld de, 3 ; event flag
+ ld de, DECOATTR_EVENT_FLAG
add hl, de
ld a, [hli]
ld d, [hl]
@@ -486,7 +492,7 @@ DecorationFlagAction:
GetDecorationSprite:
ld a, c
call GetDecorationData
- ld de, 5 ; sprite
+ ld de, DECOATTR_SPRITE
add hl, de
ld a, [hl]
ld c, a
@@ -497,8 +503,8 @@ INCLUDE "data/decorations/attributes.asm"
INCLUDE "data/decorations/names.asm"
GetDecoName:
- ld a, [hli]
- ld e, [hl]
+ ld a, [hli] ; DECOATTR_TYPE
+ ld e, [hl] ; DECOATTR_NAME
ld bc, wStringBuffer2
push bc
ld hl, .NameFunctions
@@ -507,6 +513,7 @@ GetDecoName:
ret
.NameFunctions:
+ table_width 2, GetDecoName.NameFunctions
dw .invalid
dw .plant
dw .bed
@@ -514,37 +521,38 @@ GetDecoName:
dw .poster
dw .doll
dw .bigdoll
+ assert_table_length NUM_DECO_TYPES + 1
-.invalid
+.invalid:
ret
-.plant
+.plant:
ld a, e
jr .getdeconame
-.bed
+.bed:
call .plant
ld a, _BED
jr .getdeconame
-.carpet
+.carpet:
call .plant
ld a, _CARPET
jr .getdeconame
-.poster
+.poster:
ld a, e
call .getpokename
ld a, _POSTER
jr .getdeconame
-.doll
+.doll:
ld a, e
call .getpokename
ld a, _DOLL
jr .getdeconame
-.bigdoll
+.bigdoll:
push de
ld a, BIG_
call .getdeconame
@@ -552,25 +560,25 @@ GetDecoName:
ld a, e
jr .getpokename
-.unused ; unreferenced
+.unused: ; unreferenced
push de
call .getdeconame
pop de
ld a, e
jr .getdeconame
-.getpokename
+.getpokename:
push bc
ld [wNamedObjectIndex], a
call GetPokemonName
pop bc
jr .copy
-.getdeconame
+.getdeconame:
call ._getdeconame
jr .copy
-._getdeconame
+._getdeconame:
push bc
ld hl, DecorationNames
call GetNthString
@@ -579,7 +587,7 @@ GetDecoName:
pop bc
ret
-.copy
+.copy:
ld h, b
ld l, c
call CopyName2
@@ -968,11 +976,13 @@ DescribeDecoration::
.JumpTable:
; entries correspond to DECODESC_* constants
+ table_width 2, DescribeDecoration.JumpTable
dw DecorationDesc_Poster
dw DecorationDesc_LeftOrnament
dw DecorationDesc_RightOrnament
dw DecorationDesc_GiantOrnament
dw DecorationDesc_Console
+ assert_table_length NUM_DECODESCS
DecorationDesc_Poster:
ld a, [wDecoPoster]
diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm
index 5c68f6b0f..e44fdfeb0 100644
--- a/engine/overworld/map_object_action.asm
+++ b/engine/overworld/map_object_action.asm
@@ -1,6 +1,7 @@
ObjectActionPairPointers:
-; entries correspond to OBJECT_ACTION_* constants
+; entries correspond to OBJECT_ACTION_* constants (see constants/map_object_constants.asm)
; normal action, frozen action
+ table_width 2 + 2, ObjectActionPairPointers
dw SetFacingStanding, SetFacingStanding
dw SetFacingStandAction, SetFacingCurrent
dw SetFacingStepAction, SetFacingCurrent
@@ -18,6 +19,7 @@ ObjectActionPairPointers:
dw SetFacingBoulderDust, SetFacingStanding
dw SetFacingGrassShake, SetFacingStanding
dw SetFacingSkyfall, SetFacingCurrent
+ assert_table_length NUM_OBJECT_ACTIONS
SetFacingStanding:
ld hl, OBJECT_FACING_STEP
diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm
index 4d7139128..bf809a2e6 100644
--- a/engine/overworld/map_objects.asm
+++ b/engine/overworld/map_objects.asm
@@ -523,7 +523,8 @@ StepFunction_FromMovement:
ret
.Pointers:
-; entries correspond to SPRITEMOVEFN_* constants
+; entries correspond to SPRITEMOVEFN_* constants (see constants/map_object_constants.asm)
+ table_width 2, StepFunction_FromMovement.Pointers
dw MovementFunction_Null ; 00
dw MovementFunction_RandomWalkY ; 01
dw MovementFunction_RandomWalkX ; 02
@@ -552,6 +553,7 @@ StepFunction_FromMovement:
dw MovementFunction_SpinCounterclockwise ; 19
dw MovementFunction_BoulderDust ; 1a
dw MovementFunction_ShakingGrass ; 1b
+ assert_table_length NUM_SPRITEMOVEFN
MovementFunction_Null:
ret
@@ -1085,7 +1087,8 @@ _SetRandomStepDuration:
ret
StepTypesJumptable:
-; entries correspond to STEP_TYPE_* constants
+; entries correspond to STEP_TYPE_* constants (see constants/map_object_constants.asm)
+ table_width 2, StepTypesJumptable
dw StepFunction_Reset ; 00
dw StepFunction_FromMovement ; 01
dw StepFunction_NPCWalk ; 02
@@ -1112,6 +1115,7 @@ StepTypesJumptable:
dw StepFunction_17 ; 17
dw StepFunction_Delete ; 18
dw StepFunction_SkyfallTop ; 19
+ assert_table_length NUM_STEP_TYPES
WaitStep_InPlace:
ld hl, OBJECT_STEP_DURATION
diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm
index f09159f37..e6c8319bf 100644
--- a/engine/overworld/overworld.asm
+++ b/engine/overworld/overworld.asm
@@ -636,7 +636,7 @@ endr
LoadEmote::
; Get the address of the pointer to emote c.
ld a, c
- ld bc, 6 ; sizeof(emote)
+ ld bc, EMOTE_LENGTH
ld hl, Emotes
call AddNTimes
; Load the emote address into de
diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm
index a485cfa93..a5db49970 100644
--- a/engine/overworld/player_movement.asm
+++ b/engine/overworld/player_movement.asm
@@ -1,5 +1,4 @@
DoPlayerMovement::
-
call .GetDPad
ld a, movement_step_sleep
ld [wMovementAnimation], a
@@ -12,7 +11,6 @@ DoPlayerMovement::
ret
.GetDPad:
-
ldh a, [hJoyDown]
ld [wCurInput], a
@@ -469,7 +467,8 @@ DoPlayerMovement::
ret
.Steps:
-; entries correspond to STEP_* constants
+; entries correspond to STEP_* constants (see constants/map_object_constants.asm)
+ table_width 2, DoPlayerMovement.Steps
dw .SlowStep
dw .NormalStep
dw .FastStep
@@ -478,6 +477,7 @@ DoPlayerMovement::
dw .TurningStep
dw .BackJumpStep
dw .FinishFacing
+ assert_table_length NUM_STEPS
.SlowStep:
slow_step DOWN
diff --git a/engine/phone/phone.asm b/engine/phone/phone.asm
index c8c9744ed..3263f8b50 100644
--- a/engine/phone/phone.asm
+++ b/engine/phone/phone.asm
@@ -247,7 +247,7 @@ CheckSpecialPhoneCall::
ld c, a
ld b, 0
ld hl, SpecialPhoneCallList
- ld a, 6
+ ld a, SPECIALCALL_SIZE
call AddNTimes
ld a, [hli]
ld h, [hl]
@@ -291,7 +291,7 @@ CheckSpecialPhoneCall::
ld c, a
ld b, 0
ld hl, SpecialPhoneCallList
- ld a, 6
+ ld a, SPECIALCALL_SIZE
call AddNTimes
ret
diff --git a/engine/pokedex/pokedex.asm b/engine/pokedex/pokedex.asm
index 3cfd30104..1a52d750f 100644
--- a/engine/pokedex/pokedex.asm
+++ b/engine/pokedex/pokedex.asm
@@ -1805,7 +1805,7 @@ Pokedex_PrevSearchMonType:
jr .done
.wrap_around
- ld [hl], NUM_TYPES - 1
+ ld [hl], NUM_TYPES
.done
scf
@@ -1818,7 +1818,7 @@ Pokedex_NextSearchMonType:
ld hl, wDexSearchMonType1
ld a, [hl]
- cp NUM_TYPES - 1
+ cp NUM_TYPES
jr nc, .type1_wrap_around
inc [hl]
jr .done
@@ -1829,7 +1829,7 @@ Pokedex_NextSearchMonType:
.type2
ld hl, wDexSearchMonType2
ld a, [hl]
- cp NUM_TYPES - 1
+ cp NUM_TYPES
jr nc, .type2_wrap_around
inc [hl]
jr .done
@@ -1862,7 +1862,7 @@ Pokedex_PlaceTypeString:
ld e, a
ld d, 0
ld hl, PokedexTypeSearchStrings
-rept 9
+rept POKEDEX_TYPE_STRING_LENGTH
add hl, de
endr
ld e, l
diff --git a/engine/pokegear/radio.asm b/engine/pokegear/radio.asm
index 8257ff565..cc1b504d6 100644
--- a/engine/pokegear/radio.asm
+++ b/engine/pokegear/radio.asm
@@ -20,6 +20,7 @@ PlayRadioShow:
RadioJumptable:
; entries correspond to constants/radio_constants.asm
+ table_width 2, RadioJumptable
dw OaksPKMNTalk1 ; $00
dw PokedexShow1 ; $01
dw BenMonMusic1 ; $02
@@ -31,6 +32,7 @@ RadioJumptable:
dw PokeFluteRadio ; $08
dw UnownRadio ; $09
dw EvolutionRadio ; $0a
+ assert_table_length NUM_RADIO_CHANNELS
; OaksPKMNTalk
dw OaksPKMNTalk2 ; $0b
dw OaksPKMNTalk3 ; $0c
@@ -116,6 +118,7 @@ RadioJumptable:
dw PokedexShow6 ; $55
dw PokedexShow7 ; $56
dw PokedexShow8 ; $57
+ assert_table_length NUM_RADIO_SEGMENTS
PrintRadioLine:
ld [wNextRadioLine], a
@@ -193,10 +196,9 @@ OaksPKMNTalk4:
; Choose a random route, and a random Pokemon from that route.
.sample
call Random
- and %11111 ; maskbits NUM_OAKS_POKEMON_TALK_ROUTES would be more efficient
- cp NUM_OAKS_POKEMON_TALK_ROUTES
+ and %11111
+ cp (OaksPKMNTalkRoutes.End - OaksPKMNTalkRoutes) / 2
jr nc, .sample
- ; We now have a number between 0 and NUM_OAKS_POKEMON_TALK_ROUTES - 1.
ld hl, OaksPKMNTalkRoutes
ld c, a
ld b, 0
@@ -347,7 +349,7 @@ OaksPKMNTalk8:
jp NextRadioLine
.Adverbs:
-; there are NUM_OAKS_POKEMON_TALK_ADVERBS entries
+ table_width 2, OaksPKMNTalk8.Adverbs
dw .OPT_SweetAdorablyText
dw .OPT_WigglySlicklyText
dw .OPT_AptlyNamedText
@@ -364,6 +366,7 @@ OaksPKMNTalk8:
dw .OPT_ProvocativelyText
dw .OPT_FlippedOutText
dw .OPT_HeartMeltinglyText
+ assert_table_length NUM_OAKS_POKEMON_TALK_ADVERBS
.OPT_SweetAdorablyText:
text_far _OPT_SweetAdorablyText
@@ -455,7 +458,7 @@ OaksPKMNTalk9:
jp NextRadioLine
.Adjectives:
-; there are NUM_OAKS_POKEMON_TALK_ADJECTIVES entries
+ table_width 2, OaksPKMNTalk9.Adjectives
dw .OPT_CuteText
dw .OPT_WeirdText
dw .OPT_PleasantText
@@ -472,6 +475,7 @@ OaksPKMNTalk9:
dw .OPT_GuardedText
dw .OPT_LovelyText
dw .OPT_SpeedyText
+ assert_table_length NUM_OAKS_POKEMON_TALK_ADJECTIVES
.OPT_CuteText:
text_far _OPT_CuteText
@@ -1090,7 +1094,7 @@ PeoplePlaces4: ; People
call Random
maskbits NUM_TRAINER_CLASSES
inc a
- cp NUM_TRAINER_CLASSES - 1 ; omit MYSTICALMAN
+ cp NUM_TRAINER_CLASSES
jr nc, PeoplePlaces4
push af
ld hl, PnP_HiddenPeople
@@ -1154,7 +1158,7 @@ PeoplePlaces5:
jp NextRadioLine
.Adjectives:
-; there are NUM_PNP_PEOPLE_ADJECTIVES entries
+ table_width 2, PeoplePlaces5.Adjectives
dw PnP_CuteText
dw PnP_LazyText
dw PnP_HappyText
@@ -1171,6 +1175,7 @@ PeoplePlaces5:
dw PnP_WeirdText
dw PnP_RightForMeText
dw PnP_OddText
+ assert_table_length NUM_PNP_PEOPLE_ADJECTIVES
PnP_CuteText:
text_far _PnP_CuteText
@@ -1289,7 +1294,7 @@ PeoplePlaces7:
jp PrintRadioLine
.Adjectives:
-; there are NUM_PNP_PLACES_ADJECTIVES entries
+ table_width 2, PeoplePlaces7.Adjectives
dw PnP_CuteText
dw PnP_LazyText
dw PnP_HappyText
@@ -1306,6 +1311,7 @@ PeoplePlaces7:
dw PnP_WeirdText
dw PnP_RightForMeText
dw PnP_OddText
+ assert_table_length NUM_PNP_PLACES_ADJECTIVES
RocketRadio1:
call StartRadioStation
diff --git a/engine/tilesets/mapgroup_roofs.asm b/engine/tilesets/mapgroup_roofs.asm
index b269e5277..9db5d64d8 100644
--- a/engine/tilesets/mapgroup_roofs.asm
+++ b/engine/tilesets/mapgroup_roofs.asm
@@ -8,10 +8,10 @@ LoadMapGroupRoof::
cp -1
ret z
ld hl, Roofs
- ld bc, 9 tiles
+ ld bc, ROOF_LENGTH tiles
call AddNTimes
ld de, vTiles2 tile $0a
- ld bc, 9 tiles
+ ld bc, ROOF_LENGTH tiles
call CopyBytes
ret
diff --git a/gfx/footprints.asm b/gfx/footprints.asm
index 24b4e2e92..aeff1658f 100644
--- a/gfx/footprints.asm
+++ b/gfx/footprints.asm
@@ -9,6 +9,8 @@ footprint_bottom EQUS "2 * LEN_1BPP_TILE, 2 * LEN_1BPP_TILE"
; Entries correspond to Pokémon species, two apiece, 8 tops then 8 bottoms
+ table_width LEN_1BPP_TILE * 4, Footprints
+
; 001-008 top halves
INCBIN "gfx/footprints/bulbasaur.1bpp", footprint_top
INCBIN "gfx/footprints/ivysaur.1bpp", footprint_top
@@ -585,3 +587,5 @@ INCBIN "gfx/footprints/253.1bpp", footprint_bottom
INCBIN "gfx/footprints/254.1bpp", footprint_bottom
INCBIN "gfx/footprints/255.1bpp", footprint_bottom
INCBIN "gfx/footprints/256.1bpp", footprint_bottom
+
+ assert_table_length $100
diff --git a/gfx/pokemon/anim_pointers.asm b/gfx/pokemon/anim_pointers.asm
index c14cf56ea..644346c3c 100644
--- a/gfx/pokemon/anim_pointers.asm
+++ b/gfx/pokemon/anim_pointers.asm
@@ -1,4 +1,5 @@
AnimationPointers:
+ table_width 2, AnimationPointers
dw BulbasaurAnimation
dw IvysaurAnimation
dw VenusaurAnimation
@@ -250,3 +251,4 @@ AnimationPointers:
dw LugiaAnimation
dw HoOhAnimation
dw CelebiAnimation
+ assert_table_length NUM_POKEMON
diff --git a/gfx/pokemon/bitmask_pointers.asm b/gfx/pokemon/bitmask_pointers.asm
index 7d87ad8d9..3cb8ac0e2 100644
--- a/gfx/pokemon/bitmask_pointers.asm
+++ b/gfx/pokemon/bitmask_pointers.asm
@@ -1,4 +1,5 @@
BitmasksPointers:
+ table_width 2, BitmasksPointers
dw BulbasaurBitmasks
dw IvysaurBitmasks
dw VenusaurBitmasks
@@ -250,3 +251,4 @@ BitmasksPointers:
dw LugiaBitmasks
dw HoOhBitmasks
dw CelebiBitmasks
+ assert_table_length NUM_POKEMON
diff --git a/gfx/pokemon/frame_pointers.asm b/gfx/pokemon/frame_pointers.asm
index cff10ef33..6e6c61f90 100644
--- a/gfx/pokemon/frame_pointers.asm
+++ b/gfx/pokemon/frame_pointers.asm
@@ -1,4 +1,5 @@
FramesPointers:
+ table_width 2, FramesPointers
dw BulbasaurFrames
dw IvysaurFrames
dw VenusaurFrames
@@ -250,3 +251,4 @@ FramesPointers:
dw LugiaFrames
dw HoOhFrames
dw CelebiFrames
+ assert_table_length NUM_POKEMON
diff --git a/gfx/pokemon/idle_pointers.asm b/gfx/pokemon/idle_pointers.asm
index 34345fe77..d7bc28f77 100644
--- a/gfx/pokemon/idle_pointers.asm
+++ b/gfx/pokemon/idle_pointers.asm
@@ -1,4 +1,5 @@
AnimationIdlePointers:
+ table_width 2, AnimationIdlePointers
dw BulbasaurAnimationIdle
dw IvysaurAnimationIdle
dw VenusaurAnimationIdle
@@ -250,3 +251,4 @@ AnimationIdlePointers:
dw LugiaAnimationIdle
dw HoOhAnimationIdle
dw CelebiAnimationIdle
+ assert_table_length NUM_POKEMON
diff --git a/gfx/pokemon/unown_anim_pointers.asm b/gfx/pokemon/unown_anim_pointers.asm
index 46aa757e4..334a5f9af 100644
--- a/gfx/pokemon/unown_anim_pointers.asm
+++ b/gfx/pokemon/unown_anim_pointers.asm
@@ -1,4 +1,5 @@
UnownAnimationPointers:
+ table_width 2, UnownAnimationPointers
dw UnownAAnimation
dw UnownBAnimation
dw UnownCAnimation
@@ -25,3 +26,4 @@ UnownAnimationPointers:
dw UnownXAnimation
dw UnownYAnimation
dw UnownZAnimation
+ assert_table_length NUM_UNOWN
diff --git a/gfx/pokemon/unown_bitmask_pointers.asm b/gfx/pokemon/unown_bitmask_pointers.asm
index a20db9700..bfdc3eaeb 100644
--- a/gfx/pokemon/unown_bitmask_pointers.asm
+++ b/gfx/pokemon/unown_bitmask_pointers.asm
@@ -1,4 +1,5 @@
UnownBitmasksPointers:
+ table_width 2, UnownBitmasksPointers
dw UnownABitmasks
dw UnownBBitmasks
dw UnownCBitmasks
@@ -25,3 +26,4 @@ UnownBitmasksPointers:
dw UnownXBitmasks
dw UnownYBitmasks
dw UnownZBitmasks
+ assert_table_length NUM_UNOWN
diff --git a/gfx/pokemon/unown_frame_pointers.asm b/gfx/pokemon/unown_frame_pointers.asm
index 8907f5303..245cff0c0 100644
--- a/gfx/pokemon/unown_frame_pointers.asm
+++ b/gfx/pokemon/unown_frame_pointers.asm
@@ -1,4 +1,5 @@
UnownFramesPointers:
+ table_width 2, UnownFramesPointers
dw UnownAFrames
dw UnownBFrames
dw UnownCFrames
@@ -25,3 +26,4 @@ UnownFramesPointers:
dw UnownXFrames
dw UnownYFrames
dw UnownZFrames
+ assert_table_length NUM_UNOWN
diff --git a/gfx/pokemon/unown_idle_pointers.asm b/gfx/pokemon/unown_idle_pointers.asm
index 5b922b0a9..f0af7c677 100644
--- a/gfx/pokemon/unown_idle_pointers.asm
+++ b/gfx/pokemon/unown_idle_pointers.asm
@@ -1,4 +1,5 @@
UnownAnimationIdlePointers:
+ table_width 2, UnownAnimationIdlePointers
dw UnownAAnimationIdle
dw UnownBAnimationIdle
dw UnownCAnimationIdle
@@ -25,3 +26,4 @@ UnownAnimationIdlePointers:
dw UnownXAnimationIdle
dw UnownYAnimationIdle
dw UnownZAnimationIdle
+ assert_table_length NUM_UNOWN
diff --git a/home/audio.asm b/home/audio.asm
index 405f1ec3f..f55d395a5 100644
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -143,7 +143,7 @@ PlayCry::
ld [MBC3RomBank], a
ld hl, PokemonCries
-rept 6 ; sizeof(mon_cry)
+rept MON_CRY_LENGTH
add hl, de
endr
diff --git a/home/battle_vars.asm b/home/battle_vars.asm
index 2ed86484d..70567ce74 100644
--- a/home/battle_vars.asm
+++ b/home/battle_vars.asm
@@ -49,6 +49,7 @@ GetBattleVarAddr::
BattleVarPairs:
; entries correspond to BATTLE_VARS_* constants
+ table_width 2, BattleVarPairs
dw .Substatus1
dw .Substatus2
dw .Substatus3
@@ -70,6 +71,7 @@ BattleVarPairs:
dw .LastCounterOpp
dw .LastMove
dw .LastMoveOpp
+ assert_table_length NUM_BATTLE_VARS
; player enemy
.Substatus1: db PLAYER_SUBSTATUS_1, ENEMY_SUBSTATUS_1
@@ -96,6 +98,7 @@ BattleVarPairs:
BattleVarLocations:
; entries correspond to PLAYER_* and ENEMY_* constants
+ table_width 2 + 2, BattleVarLocations
dw wPlayerSubStatus1, wEnemySubStatus1
dw wPlayerSubStatus2, wEnemySubStatus2
dw wPlayerSubStatus3, wEnemySubStatus3
@@ -109,3 +112,4 @@ BattleVarLocations:
dw wCurPlayerMove, wCurEnemyMove
dw wLastPlayerCounterMove, wLastEnemyCounterMove
dw wLastPlayerMove, wLastEnemyMove
+ assert_table_length NUM_BATTLE_VAR_LOCATION_PAIRS
diff --git a/home/map.asm b/home/map.asm
index 6e99237e0..29593add0 100644
--- a/home/map.asm
+++ b/home/map.asm
@@ -2285,12 +2285,12 @@ LoadMapTileset::
push bc
ld hl, Tilesets
- ld bc, wTilesetEnd - wTileset
+ ld bc, TILESET_LENGTH
ld a, [wMapTileset]
call AddNTimes
ld de, wTilesetBank
- ld bc, wTilesetEnd - wTileset
+ ld bc, TILESET_LENGTH
ld a, BANK(Tilesets)
call FarCopyBytes
diff --git a/home/pokemon.asm b/home/pokemon.asm
index 35f8a0429..086207bdb 100644
--- a/home/pokemon.asm
+++ b/home/pokemon.asm
@@ -166,7 +166,7 @@ LoadCry::
rst Bankswitch
ld hl, PokemonCries
-rept 6 ; sizeof(mon_cry)
+rept MON_CRY_LENGTH
add hl, bc
endr
diff --git a/macros.asm b/macros.asm
index 390d48d16..1c71cba88 100644
--- a/macros.asm
+++ b/macros.asm
@@ -1,3 +1,4 @@
+INCLUDE "macros/asserts.asm"
INCLUDE "macros/const.asm"
INCLUDE "macros/predef.asm"
INCLUDE "macros/rst.asm"
diff --git a/macros/asserts.asm b/macros/asserts.asm
new file mode 100644
index 000000000..e045e2f56
--- /dev/null
+++ b/macros/asserts.asm
@@ -0,0 +1,20 @@
+; Macros to verify assumptions about the data or code
+
+table_width: MACRO
+CURRENT_TABLE_WIDTH = \1
+if DEF(CURRENT_TABLE_START)
+PURGE CURRENT_TABLE_START
+endc
+if _NARG == 2
+CURRENT_TABLE_START EQUS "\2"
+else
+CURRENT_TABLE_START EQUS "._table_width\@"
+CURRENT_TABLE_START:
+endc
+ENDM
+
+assert_table_length: MACRO
+x = \1
+ assert x * CURRENT_TABLE_WIDTH == @ - CURRENT_TABLE_START, \
+ "{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes"
+ENDM
diff --git a/macros/scripts/battle_commands.asm b/macros/scripts/battle_commands.asm
index ad4480199..3e5046154 100644
--- a/macros/scripts/battle_commands.asm
+++ b/macros/scripts/battle_commands.asm
@@ -180,6 +180,7 @@ ENDM
command supereffectivelooptext ; ad
command startloop ; ae
command curl ; af
+NUM_EFFECT_COMMANDS EQU const_value - 1
const_def -1, -1
command endmove ; ff
diff --git a/wram.asm b/wram.asm
index 3f04a81a2..b3cededb2 100644
--- a/wram.asm
+++ b/wram.asm
@@ -2254,6 +2254,7 @@ wTilesetAnim:: dw ; bank 3f
ds 2 ; unused
wTilesetPalettes:: dw ; bank 3f
wTilesetEnd::
+ assert wTilesetEnd - wTileset == TILESET_LENGTH
wEvolvableFlags:: flag_array PARTY_LENGTH
@@ -2489,6 +2490,7 @@ wBaseGrowthRate:: db
wBaseEggGroups:: db
wBaseTMHM:: flag_array NUM_TM_HM_TUTOR
wCurBaseDataEnd::
+ assert wCurBaseDataEnd - wCurBaseData == BASE_DATA_SIZE
wCurDamage:: dw