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

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

View File

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

View File

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

View File

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

View File

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

View File

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