From 22b607b664b1b350ad96340b39440c8e4296006c Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Wed, 10 Jan 2018 11:30:12 -0500 Subject: Move radio channel data into data/ --- engine/radio.asm | 136 ++++++++++++++++--------------------------------------- 1 file changed, 39 insertions(+), 97 deletions(-) (limited to 'engine/radio.asm') diff --git a/engine/radio.asm b/engine/radio.asm index 42db63ab0..54cee3894 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -28,6 +28,7 @@ PlayRadioShow: jp hl RadioJumptable: +; entries correspond to constants/radio_constants.asm dw OaksPkmnTalk1 ; $00 dw PokedexShow1 ; $01 dw BenMonMusic1 ; $02 @@ -203,11 +204,11 @@ OaksPkmnTalk4: ; Choose a random route, and a random Pokemon from that route. .sample call Random - and $1f - cp $f ; so wasteful + and %11111 + cp (OaksPkmnTalkRoutesEnd - OaksPkmnTalkRoutes) / 2 jr nc, .sample ; We now have a number between 0 and 14. - ld hl, .routes + ld hl, OaksPkmnTalkRoutes ld c, a ld b, 0 add hl, bc @@ -239,14 +240,15 @@ OaksPkmnTalk4: jr .loop .done + ; Point hl to the list of morning Pokémon., skipping percentages rept 4 inc hl endr ; Generate a number, either 0, 1, or 2, to choose a time of day. .loop2 call Random - and 3 - cp 3 + and $3 + cp DARKNESS_F jr z, .loop2 ld bc, 2 * NUM_GRASSMON @@ -273,6 +275,7 @@ endr ld de, wMonOrItemNameBuffer ld bc, PKMN_NAME_LENGTH call CopyBytes + ; Now that we've chosen our wild Pokemon, ; let's recover the map index info and get its name. pop bc @@ -289,22 +292,7 @@ endr ld a, OAKS_POKEMON_TALK jp PrintRadioLine -.routes - map ROUTE_29 - map ROUTE_46 - map ROUTE_30 - map ROUTE_32 - map ROUTE_34 - map ROUTE_35 - map ROUTE_37 - map ROUTE_38 - map ROUTE_39 - map ROUTE_42 - map ROUTE_43 - map ROUTE_44 - map ROUTE_45 - map ROUTE_36 - map ROUTE_31 +INCLUDE "data/radio/oaks_pkmn_talk_routes.asm" OaksPkmnTalk5: ld hl, OPT_OakText2 @@ -361,7 +349,7 @@ OPT_MaryText1: OaksPkmnTalk8: call Random - and $f + and $f ; 0-15 are all the valid indexes into .Descriptors ld e, a ld d, 0 ld hl, .Descriptors @@ -473,7 +461,7 @@ OaksPkmnTalk8: OaksPkmnTalk9: call Random - and $f + and $f ; 0-15 are all the valid indexes into .Descriptors ld e, a ld d, 0 ld hl, .Descriptors @@ -652,7 +640,7 @@ OaksPkmnTalk14: ld hl, wRadioTextDelay dec [hl] ret nz - ld de, $1d + ld de, MUSIC_POKEMON_TALK callfar RadioMusicRestartDE ld hl, .terminator call PrintText @@ -1146,7 +1134,7 @@ PeoplePlaces2: PeoplePlaces3: ld hl, PnP_Text3 call Random - cp $7b ; 48 percent + cp 49 percent - 1 ld a, PLACES_AND_PEOPLE_4 ; People jr c, .ok ld a, PLACES_AND_PEOPLE_6 ; Places @@ -1175,15 +1163,15 @@ PeoplePlaces4: ; People cp NUM_TRAINER_CLASSES - 1 jr nc, PeoplePlaces4 push af - ld hl, .E4Names + ld hl, PnP_HiddenPeople ld a, [wStatusFlags] bit 6, a ; ENGINE_CREDITS_SKIP jr z, .ok - ld hl, .KantoLeaderNames + ld hl, PnP_HiddenPeople_BeatE4 ld a, [wKantoBadges] - cp %11111111 + cp %11111111 ; all badges jr nz, .ok - ld hl, .MiscNames + ld hl, PnP_HiddenPeople_BeatKanto .ok pop af ld c, a @@ -1203,10 +1191,7 @@ PeoplePlaces4: ; People ld a, PLACES_AND_PEOPLE_5 jp NextRadioLine -.E4Names: db WILL, BRUNO, KAREN, KOGA, CHAMPION -.KantoLeaderNames: db BROCK, MISTY, LT_SURGE, ERIKA, JANINE, SABRINA, BLAINE, BLUE -.MiscNames: db RIVAL1, POKEMON_PROF, CAL, RIVAL2, RED - db -1 +INCLUDE "data/radio/pnp_hidden_people.asm" PnP_Text4: ; @ @ @ @@ -1215,7 +1200,7 @@ PnP_Text4: PeoplePlaces5: call Random - and $f + and $f ; 0-15 are all the valid indexes into .Descriptors ld e, a ld d, 0 ld hl, .Descriptors @@ -1225,11 +1210,11 @@ PeoplePlaces5: ld h, [hl] ld l, a call Random - cp $a ; 6.25 percent + cp 4 percent ld a, PLACES_AND_PEOPLE jr c, .ok call Random - cp $7b ; 48 percent + cp 49 percent - 1 ld a, PLACES_AND_PEOPLE_4 ; People jr c, .ok ld a, PLACES_AND_PEOPLE_6 ; Places @@ -1336,9 +1321,9 @@ PnP_odd: PeoplePlaces6: ; Places call Random - cp 9 + cp (PnP_HiddenPlacesEnd - PnP_HiddenPlaces) / 2 jr nc, PeoplePlaces6 - ld hl, .Maps + ld hl, PnP_HiddenPlaces ld c, a ld b, 0 add hl, bc @@ -1353,16 +1338,7 @@ PeoplePlaces6: ; Places ld a, PLACES_AND_PEOPLE_7 jp NextRadioLine -.Maps: - map PALLET_TOWN - map ROUTE_22 - map PEWTER_CITY - map CERULEAN_POLICE_STATION - map ROUTE_12 - map ROUTE_11 - map ROUTE_16 - map ROUTE_14 - map CINNABAR_POKECENTER_2F_BETA +INCLUDE "data/radio/pnp_hidden_places.asm" PnP_Text5: ; @ @ @@ -1371,7 +1347,7 @@ PnP_Text5: PeoplePlaces7: call Random - and $f + and $f ; 0-15 are all the valid indexes into .Descriptors ld e, a ld d, 0 ld hl, .Descriptors @@ -1386,7 +1362,7 @@ PeoplePlaces7: ld a, PLACES_AND_PEOPLE jr c, .ok call Random - cp 1 + 48 percent + cp 49 percent - 1 ld a, PLACES_AND_PEOPLE_4 ; People jr c, .ok ld a, PLACES_AND_PEOPLE_6 ; Places @@ -1572,7 +1548,7 @@ BuenasPassword4: ld a, [wBuenasPassword] ; If we already generated the password today, we don't need to generate a new one. ld hl, wWeeklyFlags - bit 7, [hl] + bit 7, [hl] ; ENGINE_BUENAS_PASSWORD jr nz, .AlreadyGotIt ; There are only 11 groups to choose from. .greater_than_11 @@ -1586,7 +1562,7 @@ BuenasPassword4: ; For each group, choose one of the three passwords. .greater_than_three call Random - and $3 + maskbits NUM_PASSWORDS_PER_CATEGORY cp NUM_PASSWORDS_PER_CATEGORY jr nc, .greater_than_three ; The high nybble of wBuenasPassword will now contain the password group index, and the low nybble contains the actual password. @@ -1594,7 +1570,7 @@ BuenasPassword4: ld [wBuenasPassword], a ; Set the flag so that we don't generate a new password this week. ld hl, wWeeklyFlags - set 7, [hl] + set 7, [hl] ; ENGINE_BUENAS_PASSWORD .AlreadyGotIt: ld c, a call GetBuenasPassword @@ -1608,7 +1584,7 @@ GetBuenasPassword: ld a, c swap a and $f - ld hl, PasswordTable + ld hl, BuenasPasswordTable ld d, 0 ld e, a add hl, de @@ -1640,11 +1616,11 @@ GetBuenasPassword: ret .StringFunctionJumpTable: - dw .Mon - dw .Item - dw .Move - dw .RawString - +; entries correspond to BUENA_* constants + dw .Mon ; BUENA_MON + dw .Item ; BUENA_ITEM + dw .Move ; BUENA_MOVE + dw .RawString ; BUENA_STRING .Mon: call .GetTheIndex @@ -1693,30 +1669,7 @@ GetBuenasPassword: ld de, StringBuffer1 ret -PasswordTable: - dw .JohtoStarters - dw .Beverages - dw .HealingItems - dw .Balls - dw .Pokemon1 - dw .Pokemon2 - dw .JohtoTowns - dw .Types - dw .Moves - dw .XItems - dw .RadioStations - ; string type, points, option 1, option 2, option 3 -.JohtoStarters: db BUENA_MON, 10, CYNDAQUIL, TOTODILE, CHIKORITA -.Beverages: db BUENA_ITEM, 12, FRESH_WATER, SODA_POP, LEMONADE -.HealingItems: db BUENA_ITEM, 12, POTION, ANTIDOTE, PARLYZ_HEAL -.Balls: db BUENA_ITEM, 12, POKE_BALL, GREAT_BALL, ULTRA_BALL -.Pokemon1: db BUENA_MON, 10, PIKACHU, RATTATA, GEODUDE -.Pokemon2: db BUENA_MON, 10, HOOTHOOT, SPINARAK, DROWZEE -.JohtoTowns: db BUENA_STRING, 16, "NEW BARK TOWN@", "CHERRYGROVE CITY@", "AZALEA TOWN@" -.Types: db BUENA_STRING, 6, "FLYING@", "BUG@", "GRASS@" -.Moves: db BUENA_MOVE, 12, TACKLE, GROWL, MUD_SLAP -.XItems: db BUENA_ITEM, 12, X_ATTACK, X_DEFEND, X_SPEED -.RadioStations: db BUENA_STRING, 13, "#MON Talk@", "#MON Music@", "Lucky Channel@" +INCLUDE "data/radio/buenas_passwords.asm" BuenasPassword5: ld hl, BuenaRadioText5 @@ -1738,14 +1691,14 @@ BuenasPassword7: BuenasPasswordAfterMidnight: push hl ld hl, wWeeklyFlags - res 7, [hl] + res 7, [hl] ; ENGINE_BUENAS_PASSWORD pop hl ld a, BUENAS_PASSWORD_8 jp NextRadioLine BuenasPassword8: ld hl, wWeeklyFlags - res 7, [hl] + res 7, [hl] ; ENGINE_BUENAS_PASSWORD ld hl, BuenaRadioMidnightText10 ld a, BUENAS_PASSWORD_9 jp NextRadioLine @@ -1958,18 +1911,7 @@ StartRadioStation: callfar RadioMusicRestartDE ret -RadioChannelSongs: - dw MUSIC_POKEMON_TALK - dw MUSIC_POKEMON_CENTER - dw MUSIC_TITLE - dw MUSIC_GAME_CORNER - dw MUSIC_BUENAS_PASSWORD - dw MUSIC_VIRIDIAN_CITY - dw MUSIC_BICYCLE - dw MUSIC_ROCKET_OVERTURE - dw MUSIC_POKE_FLUTE_CHANNEL - dw MUSIC_RUINS_OF_ALPH_RADIO - dw MUSIC_LAKE_OF_RAGE_ROCKET_RADIO +INCLUDE "data/radio/channel_music.asm" NextRadioLine: push af -- cgit v1.2.3 From cc95d1208d4a6b8291a5430a8d652a9337074788 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Wed, 10 Jan 2018 11:57:28 -0500 Subject: Use maskbits more, and clarify its usage --- engine/radio.asm | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'engine/radio.asm') diff --git a/engine/radio.asm b/engine/radio.asm index 54cee3894..06cc3a59a 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -348,11 +348,13 @@ OPT_MaryText1: db "@" OaksPkmnTalk8: + ; 0-15 are all valid indexes into .Adverbs, + ; so no need for a retry loop call Random - and $f ; 0-15 are all the valid indexes into .Descriptors + maskbits NUM_OAKS_MON_TALK_ADVERBS +- 1 ld e, a ld d, 0 - ld hl, .Descriptors + ld hl, .Adverbs add hl, de add hl, de ld a, [hli] @@ -361,7 +363,8 @@ OaksPkmnTalk8: ld a, OAKS_POKEMON_TALK_9 jp NextRadioLine -.Descriptors: +.Adverbs: +; there are NUM_OAKS_MON_TALK_ADVERBS entries dw .sweetadorably dw .wigglyslickly dw .aptlynamed @@ -460,11 +463,13 @@ OaksPkmnTalk8: db "@" OaksPkmnTalk9: + ; 0-15 are all valid indexes into .Adjectives, + ; so no need for a retry loop call Random - and $f ; 0-15 are all the valid indexes into .Descriptors + maskbits NUM_OAKS_MON_TALK_ADJECTIVES +- 1 ld e, a ld d, 0 - ld hl, .Descriptors + ld hl, .Adjectives add hl, de add hl, de ld a, [hli] @@ -481,7 +486,8 @@ OaksPkmnTalk9: .ok jp NextRadioLine -.Descriptors: +.Adjectives: +; there are NUM_OAKS_MON_TALK_ADJECTIVES entries dw .cute dw .weird dw .pleasant @@ -1158,7 +1164,7 @@ PnP_Text3: PeoplePlaces4: ; People call Random - and $7f + maskbits NUM_TRAINER_CLASSES +- 1 inc a cp NUM_TRAINER_CLASSES - 1 jr nc, PeoplePlaces4 @@ -1199,11 +1205,13 @@ PnP_Text4: db "@" PeoplePlaces5: + ; 0-15 are all valid indexes into .Adjectives, + ; so no need for a retry loop call Random - and $f ; 0-15 are all the valid indexes into .Descriptors + maskbits NUM_PNP_PEOPLE_ADJECTIVES +- 1 ld e, a ld d, 0 - ld hl, .Descriptors + ld hl, .Adjectives add hl, de add hl, de ld a, [hli] @@ -1221,7 +1229,8 @@ PeoplePlaces5: .ok jp NextRadioLine -.Descriptors: +.Adjectives: +; there are NUM_PNP_PEOPLE_ADJECTIVES entries dw PnP_cute dw PnP_lazy dw PnP_happy @@ -1346,11 +1355,13 @@ PnP_Text5: db "@" PeoplePlaces7: + ; 0-15 are all valid indexes into .Adjectives, + ; so no need for a retry loop call Random - and $f ; 0-15 are all the valid indexes into .Descriptors + maskbits NUM_PNP_PLACES_ADJECTIVES +- 1 ld e, a ld d, 0 - ld hl, .Descriptors + ld hl, .Adjectives add hl, de add hl, de ld a, [hli] @@ -1369,7 +1380,8 @@ PeoplePlaces7: .ok jp PrintRadioLine -.Descriptors: +.Adjectives: +; there are NUM_PNP_PLACES_ADJECTIVES entries dw PnP_cute dw PnP_lazy dw PnP_happy @@ -1553,7 +1565,7 @@ BuenasPassword4: ; There are only 11 groups to choose from. .greater_than_11 call Random - maskbits NUM_PASSWORD_CATEGORIES + maskbits NUM_PASSWORD_CATEGORIES +- 1 cp NUM_PASSWORD_CATEGORIES jr nc, .greater_than_11 ; Store it in the high nybble of e. @@ -1562,7 +1574,7 @@ BuenasPassword4: ; For each group, choose one of the three passwords. .greater_than_three call Random - maskbits NUM_PASSWORDS_PER_CATEGORY + maskbits NUM_PASSWORDS_PER_CATEGORY +- 1 cp NUM_PASSWORDS_PER_CATEGORY jr nc, .greater_than_three ; The high nybble of wBuenasPassword will now contain the password group index, and the low nybble contains the actual password. -- cgit v1.2.3 From 94d6a327218fc56753238b424df208245092d96c Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Thu, 11 Jan 2018 12:00:01 -0500 Subject: Use maskbits some more --- engine/radio.asm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engine/radio.asm') diff --git a/engine/radio.asm b/engine/radio.asm index 06cc3a59a..de19a289c 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -247,7 +247,7 @@ endr ; Generate a number, either 0, 1, or 2, to choose a time of day. .loop2 call Random - and $3 + maskbits NUM_DAYTIMES +- 1 cp DARKNESS_F jr z, .loop2 @@ -692,8 +692,8 @@ PokedexShow_GetDexEntryBank: dec a rlca rlca - and 3 - ld hl, .pokedexbanks + maskbits NUM_DEX_ENTRY_BANKS +- 1 + ld hl, .PokedexEntryBanks ld d, 0 ld e, a add hl, de @@ -702,7 +702,7 @@ PokedexShow_GetDexEntryBank: pop hl ret -.pokedexbanks +.PokedexEntryBanks db BANK(PokedexEntries1) db BANK(PokedexEntries2) db BANK(PokedexEntries3) -- cgit v1.2.3 From 7b3de85a06e81d14ac0c73e8f9e1ab8e4a474beb Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Tue, 16 Jan 2018 17:27:50 -0500 Subject: Avoid "+- 1" at every maskbits --- engine/radio.asm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engine/radio.asm') diff --git a/engine/radio.asm b/engine/radio.asm index de19a289c..bfc95404e 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -247,7 +247,7 @@ endr ; Generate a number, either 0, 1, or 2, to choose a time of day. .loop2 call Random - maskbits NUM_DAYTIMES +- 1 + maskbits NUM_DAYTIMES cp DARKNESS_F jr z, .loop2 @@ -351,7 +351,7 @@ OaksPkmnTalk8: ; 0-15 are all valid indexes into .Adverbs, ; so no need for a retry loop call Random - maskbits NUM_OAKS_MON_TALK_ADVERBS +- 1 + maskbits NUM_OAKS_MON_TALK_ADVERBS ld e, a ld d, 0 ld hl, .Adverbs @@ -466,7 +466,7 @@ OaksPkmnTalk9: ; 0-15 are all valid indexes into .Adjectives, ; so no need for a retry loop call Random - maskbits NUM_OAKS_MON_TALK_ADJECTIVES +- 1 + maskbits NUM_OAKS_MON_TALK_ADJECTIVES ld e, a ld d, 0 ld hl, .Adjectives @@ -692,7 +692,7 @@ PokedexShow_GetDexEntryBank: dec a rlca rlca - maskbits NUM_DEX_ENTRY_BANKS +- 1 + maskbits NUM_DEX_ENTRY_BANKS ld hl, .PokedexEntryBanks ld d, 0 ld e, a @@ -1164,7 +1164,7 @@ PnP_Text3: PeoplePlaces4: ; People call Random - maskbits NUM_TRAINER_CLASSES +- 1 + maskbits NUM_TRAINER_CLASSES inc a cp NUM_TRAINER_CLASSES - 1 jr nc, PeoplePlaces4 @@ -1208,7 +1208,7 @@ PeoplePlaces5: ; 0-15 are all valid indexes into .Adjectives, ; so no need for a retry loop call Random - maskbits NUM_PNP_PEOPLE_ADJECTIVES +- 1 + maskbits NUM_PNP_PEOPLE_ADJECTIVES ld e, a ld d, 0 ld hl, .Adjectives @@ -1358,7 +1358,7 @@ PeoplePlaces7: ; 0-15 are all valid indexes into .Adjectives, ; so no need for a retry loop call Random - maskbits NUM_PNP_PLACES_ADJECTIVES +- 1 + maskbits NUM_PNP_PLACES_ADJECTIVES ld e, a ld d, 0 ld hl, .Adjectives @@ -1565,7 +1565,7 @@ BuenasPassword4: ; There are only 11 groups to choose from. .greater_than_11 call Random - maskbits NUM_PASSWORD_CATEGORIES +- 1 + maskbits NUM_PASSWORD_CATEGORIES cp NUM_PASSWORD_CATEGORIES jr nc, .greater_than_11 ; Store it in the high nybble of e. @@ -1574,7 +1574,7 @@ BuenasPassword4: ; For each group, choose one of the three passwords. .greater_than_three call Random - maskbits NUM_PASSWORDS_PER_CATEGORY +- 1 + maskbits NUM_PASSWORDS_PER_CATEGORY cp NUM_PASSWORDS_PER_CATEGORY jr nc, .greater_than_three ; The high nybble of wBuenasPassword will now contain the password group index, and the low nybble contains the actual password. -- cgit v1.2.3 From 2acaa96cf16ce953a7149f300d54e5440abc27d8 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Thu, 18 Jan 2018 18:34:20 -0500 Subject: More charmap and home/text.asm documentation for JP chars --- engine/radio.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/radio.asm') diff --git a/engine/radio.asm b/engine/radio.asm index bfc95404e..54da69255 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -134,7 +134,7 @@ PrintRadioLine: cp 2 jr nc, .print inc hl - ld [hl], "" + ld [hl], TX_START inc a ld [wNumRadioLinesPrinted], a cp 2 @@ -813,7 +813,7 @@ CopyDexEntryPart1: ld bc, SCREEN_WIDTH - 1 call FarCopyBytes ld hl, wPokedexShowPointerAddr - ld [hl], "" + ld [hl], TX_START inc hl ld [hl], "" inc hl -- cgit v1.2.3 From 05382d3e3c03616d6edf21833e89a8264a8cd10a Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Sat, 20 Jan 2018 12:25:55 -0500 Subject: PARTY_LENGTH; MON_NAME; sgb_border.bin --- engine/radio.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/radio.asm') diff --git a/engine/radio.asm b/engine/radio.asm index 54da69255..df0d81679 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -273,7 +273,7 @@ endr call GetPokemonName ld hl, StringBuffer1 ld de, wMonOrItemNameBuffer - ld bc, PKMN_NAME_LENGTH + ld bc, MON_NAME_LENGTH call CopyBytes ; Now that we've chosen our wild Pokemon, -- cgit v1.2.3