Skip to content

Commit

Permalink
Verify data table and name list sizes with assertion macros
Browse files Browse the repository at this point in the history
Fixes #312
  • Loading branch information
Rangi42 committed Mar 25, 2021
1 parent e1f6bb5 commit 95ec2cf
Show file tree
Hide file tree
Showing 139 changed files with 862 additions and 436 deletions.
2 changes: 2 additions & 0 deletions audio/notes.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; This file is INCLUDEd three times, once in each audio engine.

table_width 2
dw $F82C ; C_
dw $F89D ; C#
dw $F907 ; D_
Expand All @@ -12,3 +13,4 @@
dw $FB58 ; A_
dw $FB9B ; A#
dw $FBDA ; B_
assert_table_length NUM_NOTES
10 changes: 5 additions & 5 deletions constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ INCLUDE "constants/gfx_constants.asm"
INCLUDE "constants/input_constants.asm"
INCLUDE "constants/serial_constants.asm"
INCLUDE "constants/script_constants.asm"
INCLUDE "constants/pokemon_constants.asm"
INCLUDE "constants/pokedex_constants.asm"
INCLUDE "constants/pokemon_data_constants.asm"
INCLUDE "constants/trainer_constants.asm"
INCLUDE "constants/type_constants.asm"
INCLUDE "constants/battle_constants.asm"
INCLUDE "constants/move_constants.asm"
INCLUDE "constants/move_animation_constants.asm"
INCLUDE "constants/move_effect_constants.asm"
INCLUDE "constants/battle_constants.asm"
INCLUDE "constants/item_constants.asm"
INCLUDE "constants/pokemon_constants.asm"
INCLUDE "constants/pokedex_constants.asm"
INCLUDE "constants/pokemon_data_constants.asm"
INCLUDE "constants/trainer_constants.asm"
INCLUDE "constants/icon_constants.asm"
INCLUDE "constants/sprite_constants.asm"
INCLUDE "constants/sprite_data_constants.asm"
Expand Down
1 change: 1 addition & 0 deletions constants/audio_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
const A_ ; 9
const A# ; A
const B_ ; B
NUM_NOTES EQU const_value

; channel
; Audio[1|2|3]_HWChannelBaseAddresses, Audio[1|2|3]_HWChannelDisableMasks,
Expand Down
35 changes: 31 additions & 4 deletions constants/battle_constants.asm
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
MAX_LEVEL EQU 100

NUM_MOVES EQU 4
NUM_STATS EQU 5
NUM_STAT_MODS EQU 8
NUM_DVS EQU 2
NUM_MOVES EQU 4

; VitaminStats indexes (see data/battle/stat_names.asm)
const_def
const STAT_HEALTH
const STAT_ATTACK
const STAT_DEFENSE
const STAT_SPEED
const STAT_SPECIAL
NUM_STATS EQU const_value

; StatModTextStrings indexes (see data/battle/stat_mod_names.asm)
const_def
const MOD_ATTACK
const MOD_DEFENSE
const MOD_SPEED
const MOD_SPECIAL
const MOD_ACCURACY
const MOD_EVASION
const_skip 2
NUM_STAT_MODS EQU const_value

; Moves struct fields (see data/moves/moves.asm)
rsreset
MOVE_ANIM rb
MOVE_EFFECT rb
MOVE_POWER rb
MOVE_TYPE rb
MOVE_ACC rb
MOVE_PP rb
MOVE_LENGTH EQU _RS

; D733 flags
BIT_TEST_BATTLE EQU 0
Expand Down
1 change: 1 addition & 0 deletions constants/credits_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
const CRED_FUKUI ; $3D
const CRED_CLUB ; $3E
const CRED_PAAD ; $3F
NUM_CRED_STRINGS EQU const_value

const_def -1, -1
const CRED_TEXT_FADE_MON ; $FF
Expand Down
1 change: 1 addition & 0 deletions constants/gfx_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ REDRAW_ROW EQU 2
const TILEMAP_GENGAR_INTRO_3
const TILEMAP_GAME_BOY
const TILEMAP_LINK_CABLE
NUM_TILEMAPS EQU const_value
1 change: 1 addition & 0 deletions constants/hide_show_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,4 @@ SHOW EQU $15
const HS_SEAFOAM_ISLANDS_B4F_BOULDER_1 ; E1
const HS_SEAFOAM_ISLANDS_B4F_BOULDER_2 ; E2
const HS_ARTICUNO ; E3 X
NUM_HS_OBJECTS EQU const_value
4 changes: 4 additions & 0 deletions constants/item_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ SAFARI_ROCK EQU $16 ; overload
const MAX_ETHER ; $51
const ELIXER ; $52
const MAX_ELIXER ; $53
NUM_ITEMS EQU const_value - 1

; elevator floors use item IDs
const FLOOR_B2F ; $54
const FLOOR_B1F ; $55
const FLOOR_1F ; $56
Expand All @@ -106,6 +109,7 @@ SAFARI_ROCK EQU $16 ; overload
const FLOOR_10F ; $5F
const FLOOR_11F ; $60
const FLOOR_B4F ; $61
NUM_FLOORS EQU const_value - 1 - NUM_ITEMS

const_next $C4

Expand Down
1 change: 1 addition & 0 deletions constants/map_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ FIRST_INDOOR_MAP EQU const_value
mapconst LORELEIS_ROOM, 6, 5 ; $F5
mapconst BRUNOS_ROOM, 6, 5 ; $F6
mapconst AGATHAS_ROOM, 6, 5 ; $F7
NUM_MAPS EQU const_value

; Indoor maps, such as houses, use this as the Map ID in their exit warps
; This map ID takes the player back to the last outdoor map they were on, stored in wLastMap
Expand Down
1 change: 1 addition & 0 deletions constants/menu_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ PC_ITEM_CAPACITY EQU 50
const TRADE_CANCEL_MENU ; 5
const HEAL_CANCEL_MENU ; 6
const NO_YES_MENU ; 7
NUM_TWO_OPTION_MENUS EQU const_value

; menu exit method constants for list menus and the buy/sell/quit menu
CHOSE_MENU_ITEM EQU 1 ; pressed A
Expand Down
3 changes: 3 additions & 0 deletions constants/move_animation_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ FIRST_SE_ID EQU const_value
const SUBANIM_53
const SUBANIM_54
const SUBANIM_55
NUM_SUBANIMS EQU const_value

; types of subanimations
const_def
Expand Down Expand Up @@ -267,6 +268,7 @@ FIRST_SE_ID EQU const_value
const FRAMEBLOCK_77
const FRAMEBLOCK_78
const FRAMEBLOCK_79
NUM_FRAMEBLOCKS EQU const_value

; base coordinates that are part of subanimations
; FrameBlockBaseCoords indexes (see data/battle_anims/base_coords.asm)
Expand Down Expand Up @@ -448,6 +450,7 @@ FIRST_SE_ID EQU const_value
const BASECOORD_AE
const BASECOORD_AF
const BASECOORD_B0
NUM_BASECOORDS EQU const_value

; frame block modes that are part of subanimations
const_def
Expand Down
6 changes: 3 additions & 3 deletions constants/move_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,8 @@
const SUPER_FANG ; a2
const SLASH ; a3
const SUBSTITUTE ; a4

NUM_ATTACKS EQU const_value - 1

const STRUGGLE ; a5
NUM_ATTACKS EQU const_value - 1

; Moves do double duty as animation identifiers.

Expand Down Expand Up @@ -214,3 +212,5 @@ NUM_ATTACKS EQU const_value - 1
const HIDEPIC_ANIM ; monster disappears
const ROCK_ANIM ; throw rock
const BAIT_ANIM ; throw bait

NUM_ATTACK_ANIMS EQU const_value - 1
1 change: 1 addition & 0 deletions constants/move_effect_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@
const LEECH_SEED_EFFECT ; $54
const SPLASH_EFFECT ; $55
const DISABLE_EFFECT ; $56
NUM_MOVE_EFFECTS EQU const_value - 1
1 change: 1 addition & 0 deletions constants/palette_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ SET_PAL_DEFAULT EQU $ff
const PAL_BADGE ; $22
const PAL_CAVE ; $23
const PAL_GAMEFREAK ; $24
NUM_SGB_PALS EQU const_value
31 changes: 31 additions & 0 deletions constants/pokemon_data_constants.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
; base data struct members (see data/pokemon/base_stats/*.asm)
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_SPC rb
BASE_TYPES rw
rsset BASE_TYPES
BASE_TYPE_1 rb
BASE_TYPE_2 rb
BASE_CATCH_RATE rb
BASE_EXP rb
BASE_PIC_SIZE rb
BASE_FRONTPIC rw
BASE_BACKPIC rw
BASE_MOVES rb NUM_MOVES
BASE_GROWTH_RATE rb
BASE_TMHM rb (NUM_TM_HM + 7) / 8
rb_skip
BASE_DATA_SIZE EQU _RS


PARTY_LENGTH EQU 6

MONS_PER_BOX EQU 20
Expand Down Expand Up @@ -39,3 +65,8 @@ EVOLUTION_SIZE EQU 4
const GROWTH_MEDIUM_SLOW
const GROWTH_FAST
const GROWTH_SLOW
NUM_GROWTH_RATES EQU const_value

; wild data (see data/wild/maps/*.asm)
NUM_WILDMONS EQU 10
WILDDATA_LENGTH EQU 1 + NUM_WILDMONS * 2
1 change: 1 addition & 0 deletions constants/script_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SLOTS_SOMEONESKEYS EQU $ff
const TRADE_FOR_DORIS
const TRADE_FOR_CRINKLES
const TRADE_FOR_SPOT
NUM_NPC_TRADES EQU const_value

; in game trade dialog sets
; InGameTradeTextPointers indexes (see engine/events/in_game_trades.asm)
Expand Down
1 change: 1 addition & 0 deletions constants/sprite_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ FIRST_STILL_SPRITE EQU const_value
const SPRITE_UNUSED_GAMBLER_ASLEEP_1 ; $46
const SPRITE_UNUSED_GAMBLER_ASLEEP_2 ; $47
const SPRITE_GAMBLER_ASLEEP ; $48
NUM_SPRITES EQU const_value - 1
1 change: 1 addition & 0 deletions constants/tileset_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
const CLUB ; 21
const FACILITY ; 22
const PLATEAU ; 23
NUM_TILESETS EQU const_value
1 change: 1 addition & 0 deletions constants/trainer_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ ENDM
trainer_const CHANNELER ; $2D
trainer_const AGATHA ; $2E
trainer_const LANCE ; $2F
NUM_TRAINERS EQU const_value - 1
2 changes: 2 additions & 0 deletions constants/type_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ SPECIAL EQU const_value
const PSYCHIC_TYPE ; $18
const ICE ; $19
const DRAGON ; $1A

NUM_TYPES EQU const_value
17 changes: 17 additions & 0 deletions data/battle/stat_mod_names.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; Stats that move effects can raise or lower
; The relevant move effect IDs correspond to the stats

StatModTextStrings:
list_start StatModTextStrings
li "ATTACK"
li "DEFENSE"
li "SPEED"
li "SPECIAL"
assert_list_length SPECIAL_DOWN_SIDE_EFFECT - ATTACK_DOWN_SIDE_EFFECT + 1
li "ACCURACY"
li "EVADE"
assert_list_length NUM_STAT_MODS - 2 ; two bytes are unused
assert_list_length EVASION_UP1_EFFECT - ATTACK_UP1_EFFECT + 1
assert_list_length EVASION_DOWN1_EFFECT - ATTACK_DOWN1_EFFECT + 1
assert_list_length EVASION_UP2_EFFECT - ATTACK_UP2_EFFECT + 1
assert_list_length EVASION_DOWN2_EFFECT - ATTACK_DOWN2_EFFECT + 1
17 changes: 10 additions & 7 deletions data/battle/stat_names.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
StatsTextStrings:
db "ATTACK@"
db "DEFENSE@"
db "SPEED@"
db "SPECIAL@"
db "ACCURACY@"
db "EVADE@"
; Stats that vitamins can raise or lower

VitaminStats:
list_start VitaminStats
li "HEALTH"
li "ATTACK"
li "DEFENSE"
li "SPEED"
li "SPECIAL"
assert_list_length NUM_STATS
2 changes: 2 additions & 0 deletions data/battle_anims/base_coords.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FrameBlockBaseCoords:
table_width 2, FrameBlockBaseCoords
db $10, $68 ; BASECOORD_00
db $10, $70 ; BASECOORD_01
db $10, $78 ; BASECOORD_02
Expand Down Expand Up @@ -176,3 +177,4 @@ FrameBlockBaseCoords:
db $18, $4C ; BASECOORD_AE
db $1C, $48 ; BASECOORD_AF
db $48, $28 ; BASECOORD_B0
assert_table_length NUM_BASECOORDS
2 changes: 2 additions & 0 deletions data/battle_anims/frame_blocks.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FrameBlockPointers:
table_width 2, FrameBlockPointers
dw FrameBlock00
dw FrameBlock01
dw FrameBlock02
Expand Down Expand Up @@ -121,6 +122,7 @@ FrameBlockPointers:
dw FrameBlock77
dw FrameBlock78
dw FrameBlock79
assert_table_length NUM_FRAMEBLOCKS

FrameBlock01:
db 9 ; #
Expand Down
2 changes: 2 additions & 0 deletions data/battle_anims/subanimations.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SubanimationPointers:
table_width 2, SubanimationPointers
dw Subanimation00
dw Subanimation01
dw Subanimation02
Expand Down Expand Up @@ -85,6 +86,7 @@ SubanimationPointers:
dw Subanimation53
dw Subanimation54
dw Subanimation55
assert_table_length NUM_SUBANIMS

; format:
; subanim type, count
Expand Down
1 change: 1 addition & 0 deletions data/credits/credits_mons.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CreditsMons:
; one entry per CRED_TEXT_MON or CRED_TEXT_FADE_MON in CreditsOrder
db VENUSAUR
db ARBOK
db RHYHORN
Expand Down
2 changes: 2 additions & 0 deletions data/credits/credits_text.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CreditsTextPointers:
; entries correspond to CRED_* constants
table_width 2, CreditsTextPointers
dw CredVersion
dw CredTajiri
dw CredTaOota
Expand Down Expand Up @@ -64,6 +65,7 @@ CreditsTextPointers:
dw CredFukui
dw CredClub
dw CredPAAD
assert_table_length NUM_CRED_STRINGS

CredVersion: ; this 1 byte difference makes all bank addresses offset by 1 in the blue version
IF DEF(_RED)
Expand Down
2 changes: 2 additions & 0 deletions data/events/trades.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
TradeMons:
; entries correspond to TRADE_FOR_* constants
table_width 3 + NAME_LENGTH, TradeMons
; give mon, get mon, dialog id, nickname
db NIDORINO, NIDORINA, TRADE_DIALOGSET_CASUAL, "TERRY@@@@@@"
db ABRA, MR_MIME, TRADE_DIALOGSET_CASUAL, "MARCEL@@@@@"
Expand All @@ -11,3 +12,4 @@ TradeMons:
db RAICHU, ELECTRODE, TRADE_DIALOGSET_POLITE, "DORIS@@@@@@"
db VENONAT, TANGELA, TRADE_DIALOGSET_HAPPY, "CRINKLES@@@"
db NIDORAN_M, NIDORAN_F, TRADE_DIALOGSET_HAPPY, "SPOT@@@@@@@"
assert_table_length NUM_NPC_TRADES
2 changes: 2 additions & 0 deletions data/growth_rates.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ ENDM

GrowthRateTable:
; entries correspond to GROWTH_* (see constants/pokemon_data_constants.asm)
table_width 4, GrowthRateTable
growth_rate 1, 1, 0, 0, 0 ; Medium Fast
growth_rate 3, 4, 10, 0, 30 ; Slightly Fast
growth_rate 3, 4, 20, 0, 70 ; Slightly Slow
growth_rate 6, 5, -15, 100, 140 ; Medium Slow
growth_rate 4, 5, 0, 0, 0 ; Fast
growth_rate 5, 4, 0, 0, 0 ; Slow
assert_table_length NUM_GROWTH_RATES
2 changes: 2 additions & 0 deletions data/items/key_items.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ENDC
ENDM

KeyItemBitfield:
table_width 1, KeyItemBitfield
key_item_bits \
FALSE, \ ; MASTER_BALL
FALSE, \ ; ULTRA_BALL
Expand Down Expand Up @@ -101,3 +102,4 @@ KeyItemBitfield:
FALSE, \ ; MAX_ETHER
FALSE, \ ; ELIXER
FALSE ; MAX_ELIXER
assert_table_length (NUM_ITEMS + 7) / 8
Loading

0 comments on commit 95ec2cf

Please sign in to comment.