summaryrefslogtreecommitdiff
path: root/engine/pokegear
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2021-03-03 22:22:41 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2021-03-05 16:10:25 -0500
commit5454e1e0deefc6b4fc8c4de0e63314052fceebc0 (patch)
tree565805b252fa596aab3f80b3128ebc91b1fae540 /engine/pokegear
parentb423e94be700cc6434465cf1dcccf0b677489192 (diff)
Verify data table sizes with table_width and assert_table_length macros
It also uncovered some off-by-one issues with defining some constants. A few structs now use rsreset/_RS to define their offset constants.
Diffstat (limited to 'engine/pokegear')
-rw-r--r--engine/pokegear/radio.asm22
1 files changed, 14 insertions, 8 deletions
diff --git a/engine/pokegear/radio.asm b/engine/pokegear/radio.asm
index 41292f6e..61ff5bb4 100644
--- a/engine/pokegear/radio.asm
+++ b/engine/pokegear/radio.asm
@@ -20,6 +20,7 @@ PlayRadioShow:
RadioJumptable:
; entries correspond to constants/radio_constants.asm
+ table_width 2, RadioJumptable
dw OaksPKMNTalk1 ; $00
dw PokedexShow1 ; $01
dw BenMonMusic1 ; $02
@@ -30,6 +31,7 @@ RadioJumptable:
dw PokeFluteRadio ; $07
dw UnownRadio ; $08
dw EvolutionRadio ; $09
+ assert_table_length NUM_RADIO_CHANNELS
; OaksPKMNTalk
dw OaksPKMNTalk2 ; $0a
dw OaksPKMNTalk3 ; $0b
@@ -94,6 +96,7 @@ RadioJumptable:
dw PokedexShow6 ; $40
dw PokedexShow7 ; $41
dw PokedexShow8 ; $42
+ assert_table_length NUM_RADIO_SEGMENTS
PrintRadioLine:
ld [wNextRadioLine], a
@@ -171,10 +174,9 @@ OaksPKMNTalk4:
; Choose a random route, and a random Pokemon from that route.
.sample
call Random
- and %11111 ; maskbits NUM_OAKS_POKEMON_TALK_ROUTES would be more efficient
- cp NUM_OAKS_POKEMON_TALK_ROUTES
+ and %11111
+ cp (OaksPKMNTalkRoutes.End - OaksPKMNTalkRoutes) / 2
jr nc, .sample
- ; We now have a number between 0 and NUM_OAKS_POKEMON_TALK_ROUTES - 1.
ld hl, OaksPKMNTalkRoutes
ld c, a
ld b, 0
@@ -325,7 +327,7 @@ OaksPKMNTalk8:
jp NextRadioLine
.Adverbs:
-; there are NUM_OAKS_POKEMON_TALK_ADVERBS entries
+ table_width 2, OaksPKMNTalk8.Adverbs
dw .OPT_SweetAdorablyText
dw .OPT_WigglySlicklyText
dw .OPT_AptlyNamedText
@@ -342,6 +344,7 @@ OaksPKMNTalk8:
dw .OPT_ProvocativelyText
dw .OPT_FlippedOutText
dw .OPT_HeartMeltinglyText
+ assert_table_length NUM_OAKS_POKEMON_TALK_ADVERBS
.OPT_SweetAdorablyText:
text_far _OPT_SweetAdorablyText
@@ -433,7 +436,7 @@ OaksPKMNTalk9:
jp NextRadioLine
.Adjectives:
-; there are NUM_OAKS_POKEMON_TALK_ADJECTIVES entries
+ table_width 2, OaksPKMNTalk9.Adjectives
dw .OPT_CuteText
dw .OPT_WeirdText
dw .OPT_PleasantText
@@ -450,6 +453,7 @@ OaksPKMNTalk9:
dw .OPT_GuardedText
dw .OPT_LovelyText
dw .OPT_SpeedyText
+ assert_table_length NUM_OAKS_POKEMON_TALK_ADJECTIVES
.OPT_CuteText:
text_far _OPT_CuteText
@@ -1050,7 +1054,7 @@ PeoplePlaces4: ; People
call Random
maskbits NUM_TRAINER_CLASSES
inc a
- cp NUM_TRAINER_CLASSES
+ cp NUM_TRAINER_CLASSES + 1
jr nc, PeoplePlaces4
push af
ld hl, PnP_HiddenPeople
@@ -1114,7 +1118,7 @@ PeoplePlaces5:
jp NextRadioLine
.Adjectives:
-; there are NUM_PNP_PEOPLE_ADJECTIVES entries
+ table_width 2, PeoplePlaces5.Adjectives
dw PnP_CuteText
dw PnP_LazyText
dw PnP_HappyText
@@ -1131,6 +1135,7 @@ PeoplePlaces5:
dw PnP_WeirdText
dw PnP_RightForMeText
dw PnP_OddText
+ assert_table_length NUM_PNP_PEOPLE_ADJECTIVES
PnP_CuteText:
text_far _PnP_CuteText
@@ -1249,7 +1254,7 @@ PeoplePlaces7:
jp PrintRadioLine
.Adjectives:
-; there are NUM_PNP_PLACES_ADJECTIVES entries
+ table_width 2, PeoplePlaces7.Adjectives
dw PnP_CuteText
dw PnP_LazyText
dw PnP_HappyText
@@ -1266,6 +1271,7 @@ PeoplePlaces7:
dw PnP_WeirdText
dw PnP_RightForMeText
dw PnP_OddText
+ assert_table_length NUM_PNP_PLACES_ADJECTIVES
RocketRadio1:
call StartRadioStation