diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-08-13 13:47:57 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-08-13 13:47:57 -0400 |
commit | 2556704a43578787262a1a5bc34989eea98496c0 (patch) | |
tree | 497a50daac68d6dc3c199fe6e54e7921c102d297 | |
parent | 7d8a73220cdcdeb409b901a8c90dbdf591d499dc (diff) |
Consistent constants for radio data table sizes (could still be better)
-rw-r--r-- | constants/radio_constants.asm | 7 | ||||
-rw-r--r-- | data/radio/oaks_pkmn_talk_routes.asm | 3 | ||||
-rw-r--r-- | engine/overworld/wildmons.asm | 13 | ||||
-rw-r--r-- | engine/pokegear/radio.asm | 6 |
4 files changed, 17 insertions, 12 deletions
diff --git a/constants/radio_constants.asm b/constants/radio_constants.asm index e9b54176..557b7dde 100644 --- a/constants/radio_constants.asm +++ b/constants/radio_constants.asm @@ -85,9 +85,12 @@ const MAPRADIO_LETS_ALL_SING const MAPRADIO_ROCKET +; OaksPKMNTalkRoutes size (see data/radio/oaks_pkmn_talk_routes.asm) +NUM_OAKS_POKEMON_TALK_ROUTES EQU 15 + ; These tables in engine/pokegear/radio.asm are all sized to a power of 2 ; so there's no need for a rejection sampling loop NUM_OAKS_POKEMON_TALK_ADVERBS EQU 16 ; OaksPKMNTalk8.Adverbs NUM_OAKS_POKEMON_TALK_ADJECTIVES EQU 16 ; OaksPKMNTalk9.Adjectives -NUM_PNP_PEOPLE_ADJECTIVES EQU 16 ; PeoplePlaces5.Adjectives -NUM_PNP_PLACES_ADJECTIVES EQU 16 ; PeoplePlaces7.Adjectives +NUM_PNP_PEOPLE_ADJECTIVES EQU 16 ; PeoplePlaces5.Adjectives +NUM_PNP_PLACES_ADJECTIVES EQU 16 ; PeoplePlaces7.Adjectives diff --git a/data/radio/oaks_pkmn_talk_routes.asm b/data/radio/oaks_pkmn_talk_routes.asm index acef4bdd..254dd8e5 100644 --- a/data/radio/oaks_pkmn_talk_routes.asm +++ b/data/radio/oaks_pkmn_talk_routes.asm @@ -1,6 +1,6 @@ ; Oak's Pokémon Talk will list wild Pokémon on these maps. -OaksPKMNTalkRoutes: +OaksPKMNTalkRoutes:; there are NUM_OAKS_POKEMON_TALK_ROUTES entries map_id ROUTE_29 map_id ROUTE_46 map_id ROUTE_30 @@ -16,4 +16,3 @@ OaksPKMNTalkRoutes: map_id ROUTE_45 map_id ROUTE_36 map_id ROUTE_31 -.End diff --git a/engine/overworld/wildmons.asm b/engine/overworld/wildmons.asm index c06020e1..124a7bbf 100644 --- a/engine/overworld/wildmons.asm +++ b/engine/overworld/wildmons.asm @@ -710,11 +710,14 @@ JumpRoamMons: JumpRoamMon: .loop ld hl, RoamMaps -.innerloop1 ; This loop happens to be unnecessary. - call Random ; Choose a random number. - maskbits NUM_ROAMMON_MAPS ; Mask the number to limit it between 0 and 15. - cp NUM_ROAMMON_MAPS ; If the number is not less than 16, try again. - jr nc, .innerloop1 ; I'm sure you can guess why this check is bogus. +.innerloop1 + ; 0-15 are all valid indexes into RoamMaps, + ; so this retry loop is unnecessary + ; since NUM_ROAMMON_MAPS happens to be 16 + call Random + maskbits NUM_ROAMMON_MAPS + cp NUM_ROAMMON_MAPS + jr nc, .innerloop1 inc a ld b, a .innerloop2 ; Loop to get hl to the address of the chosen roam map. diff --git a/engine/pokegear/radio.asm b/engine/pokegear/radio.asm index a13de99b..27af019d 100644 --- a/engine/pokegear/radio.asm +++ b/engine/pokegear/radio.asm @@ -172,10 +172,10 @@ OaksPKMNTalk4: ; Choose a random route, and a random Pokemon from that route. .sample call Random - and %11111 - cp (OaksPKMNTalkRoutes.End - OaksPKMNTalkRoutes) / 2 + and %11111 ; maskbits NUM_OAKS_POKEMON_TALK_ROUTES would be more efficient + cp NUM_OAKS_POKEMON_TALK_ROUTES jr nc, .sample - ; We now have a number between 0 and 14. + ; We now have a number between 0 and NUM_OAKS_POKEMON_TALK_ROUTES - 1. ld hl, OaksPKMNTalkRoutes ld c, a ld b, 0 |