Skip to content

Commit

Permalink
Merge pull request #806 from Rangi42/tables
Browse files Browse the repository at this point in the history
Verify data table sizes with table_width and assert_table_length macros
  • Loading branch information
Rangi42 authored Mar 8, 2021
2 parents fb35fe6 + 98da09b commit e791c53
Show file tree
Hide file tree
Showing 154 changed files with 1,087 additions and 513 deletions.
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"
81 changes: 43 additions & 38 deletions constants/audio_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,49 @@ 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
rb_skip 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
rb_skip
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
rb_skip
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
rb_skip
CHANNEL_STRUCT_LENGTH EQU _RS

NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7

Expand Down
59 changes: 33 additions & 26 deletions constants/battle_anim_constants.asm
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
; battle_anim_struct members (see macros/wram.asm)
const_def
const BATTLEANIMSTRUCT_INDEX
const BATTLEANIMSTRUCT_OAMFLAGS
const BATTLEANIMSTRUCT_FIX_Y
const BATTLEANIMSTRUCT_FRAMESET_ID
const BATTLEANIMSTRUCT_FUNCTION
const BATTLEANIMSTRUCT_PALETTE
const BATTLEANIMSTRUCT_TILEID
const BATTLEANIMSTRUCT_XCOORD
const BATTLEANIMSTRUCT_YCOORD
const BATTLEANIMSTRUCT_XOFFSET
const BATTLEANIMSTRUCT_YOFFSET
const BATTLEANIMSTRUCT_PARAM
const BATTLEANIMSTRUCT_DURATION
const BATTLEANIMSTRUCT_FRAME
const BATTLEANIMSTRUCT_JUMPTABLE_INDEX
const BATTLEANIMSTRUCT_VAR1
const BATTLEANIMSTRUCT_VAR2
const_skip 7
BATTLEANIMSTRUCT_LENGTH EQU const_value
rsreset
BATTLEANIMSTRUCT_INDEX rb
BATTLEANIMSTRUCT_OAMFLAGS rb
BATTLEANIMSTRUCT_FIX_Y rb
BATTLEANIMSTRUCT_FRAMESET_ID rb
BATTLEANIMSTRUCT_FUNCTION rb
BATTLEANIMSTRUCT_PALETTE rb
BATTLEANIMSTRUCT_TILEID rb
BATTLEANIMOBJ_LENGTH EQU _RS - 1 ; discount BATTLEANIMSTRUCT_INDEX
BATTLEANIMSTRUCT_XCOORD rb
BATTLEANIMSTRUCT_YCOORD rb
BATTLEANIMSTRUCT_XOFFSET rb
BATTLEANIMSTRUCT_YOFFSET rb
BATTLEANIMSTRUCT_PARAM rb
BATTLEANIMSTRUCT_DURATION rb
BATTLEANIMSTRUCT_FRAME rb
BATTLEANIMSTRUCT_JUMPTABLE_INDEX rb
BATTLEANIMSTRUCT_VAR1 rb
BATTLEANIMSTRUCT_VAR2 rb
rb_skip 7
BATTLEANIMSTRUCT_LENGTH EQU _RS
NUM_ANIM_OBJECTS EQU 10 ; see wActiveAnimObjects

; wBattleAnimTileDict size (see wram.asm)
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,14 +814,15 @@ 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
const BG_EFFECT_STRUCT_FUNCTION
const BG_EFFECT_STRUCT_JT_INDEX
const BG_EFFECT_STRUCT_BATTLE_TURN
const BG_EFFECT_STRUCT_PARAM
BG_EFFECT_STRUCT_LENGTH EQU const_value
rsreset
BG_EFFECT_STRUCT_FUNCTION rb
BG_EFFECT_STRUCT_JT_INDEX rb
BG_EFFECT_STRUCT_BATTLE_TURN rb
BG_EFFECT_STRUCT_PARAM rb
BG_EFFECT_STRUCT_LENGTH EQU _RS
NUM_BG_EFFECTS EQU 5 ; see wActiveBGEffects

; anim_bgeffect battle turn values for some effects
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
14 changes: 12 additions & 2 deletions constants/deco_constants.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
; decoration attributes
rsreset
DECOATTR_TYPE rb
DECOATTR_NAME rb
DECOATTR_ACTION rb
DECOATTR_EVENT_FLAG rw
DECOATTR_SPRITE rb
DECOATTR_STRUCT_LENGTH EQU _RS

; decoration types
const_def 1
const DECO_PLANT
Expand All @@ -6,6 +15,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 +61,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 +136,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
14 changes: 7 additions & 7 deletions 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 Expand Up @@ -34,12 +34,12 @@ HP_YELLOW EQU 1
HP_RED EQU 2

; sprite_oam_struct members (see macros/wram.asm)
const_def
const SPRITEOAMSTRUCT_YCOORD ; 0
const SPRITEOAMSTRUCT_XCOORD ; 1
const SPRITEOAMSTRUCT_TILE_ID ; 2
const SPRITEOAMSTRUCT_ATTRIBUTES ; 3
SPRITEOAMSTRUCT_LENGTH EQU const_value
rsreset
SPRITEOAMSTRUCT_YCOORD rb ; 0
SPRITEOAMSTRUCT_XCOORD rb ; 1
SPRITEOAMSTRUCT_TILE_ID rb ; 2
SPRITEOAMSTRUCT_ATTRIBUTES rb ; 3
SPRITEOAMSTRUCT_LENGTH EQU _RS
NUM_SPRITE_OAM_STRUCTS EQU 40 ; see wVirtualOAM

SPRITE_GFX_LIST_CAPACITY EQU 32 ; see wUsedSprites
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
20 changes: 11 additions & 9 deletions constants/item_data_constants.asm
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
; item_attributes struct members (see data/items/attributes.asm)
const_def
const ITEMATTR_PRICE_LO
const ITEMATTR_PRICE_HI
const ITEMATTR_EFFECT
const ITEMATTR_PARAM
const ITEMATTR_PERMISSIONS
const ITEMATTR_POCKET
const ITEMATTR_HELP
ITEMATTR_STRUCT_LENGTH EQU const_value
rsreset
ITEMATTR_PRICE rw
rsset ITEMATTR_PRICE
ITEMATTR_PRICE_LO rb
ITEMATTR_PRICE_HI rb
ITEMATTR_EFFECT rb
ITEMATTR_PARAM rb
ITEMATTR_PERMISSIONS rb
ITEMATTR_POCKET rb
ITEMATTR_HELP rb
ITEMATTR_STRUCT_LENGTH EQU _RS

; item types
const_def 1
Expand Down
Loading

0 comments on commit e791c53

Please sign in to comment.