Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify data table sizes with table_width and assert_table_length macros #806

Merged
merged 3 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions audio/cry_pointers.asm
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -67,3 +69,4 @@ Cries:
dba Cry_Aipom
dba Cry_Dunsparce
dba Cry_Donphan
assert_table_length NUM_CRIES
2 changes: 2 additions & 0 deletions audio/music_pointers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Music:
; entries correspond to MUSIC_* constants
table_width 3, Music
dba Music_Nothing
dba Music_TitleScreen
dba Music_Route1
Expand Down Expand Up @@ -106,3 +107,4 @@ Music:
dba Music_SuicuneBattle
dba Music_BattleTowerLobby
dba Music_MobileCenter
assert_table_length NUM_MUSIC_SONGS
2 changes: 2 additions & 0 deletions audio/sfx_pointers.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SFX:
; entries correspond to SFX_* constants
table_width 3, SFX
dba Sfx_DexFanfare5079
dba Sfx_Item
dba Sfx_CaughtMon
Expand Down Expand Up @@ -208,3 +209,4 @@ SFX:
dba Sfx_TwoPcBeeps
dba Sfx_4NoteDitty
dba Sfx_Twinkle
assert_table_length NUM_SFX
2 changes: 1 addition & 1 deletion constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
77 changes: 39 additions & 38 deletions constants/audio_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions constants/battle_anim_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions constants/battle_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion constants/battle_tower_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions constants/credits_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions constants/cry_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@
const CRY_AIPOM
const CRY_DUNSPARCE
const CRY_DONPHAN

NUM_CRIES EQU const_value
15 changes: 13 additions & 2 deletions constants/deco_constants.asm
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion constants/gfx_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions constants/icon_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions constants/item_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions constants/landmark_constants.asm
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions constants/map_data_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions constants/map_object_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions constants/menu_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading