Verify data table sizes with table_width and assert_table_length macros

This was discussed in #706

It also uncovered some off-by-one issues with defining some constants.

A few structs now use rsreset/_RS to define their offset constants, as discussed in #739
This commit is contained in:
Rangi
2021-03-03 22:22:41 -05:00
parent 9c17fb14c8
commit 40902ffe24
148 changed files with 608 additions and 237 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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"