ref: 525f1b96f390a7b7625574405cad56277f200ef3
parent: 8d30191707758a36b513c4368b9fdb7705730865
author: YamaArashi <shadow962@live.com>
date: Fri Aug 7 00:24:06 EDT 2015
named CountSetBits output variable
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -19,8 +19,8 @@
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e]
- cp $2
+ ld a, [wNumSetBits]
+ cp 2
tx_pre_id SaveOptionText
jr c, .ownThreeOrMoreMon
tx_pre_id StrengthsAndWeaknessesText
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -395,7 +395,7 @@
ld b, $1
call CountSetBits
pop hl
- ld de, wd11e
+ ld de, wNumSetBits
lb bc, 1, 2
jp PrintNumber
@@ -405,7 +405,7 @@
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
pop hl
- ld de, wd11e
+ ld de, wNumSetBits
lb bc, 1, 3
jp PrintNumber
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -169,7 +169,7 @@
ld hl,wPokedexSeen
ld b,wPokedexSeenEnd - wPokedexSeen
call CountSetBits
- ld de,wd11e
+ ld de, wNumSetBits
coord hl, 16, 3
lb bc, 1, 3
call PrintNumber ; print number of seen pokemon
@@ -176,7 +176,7 @@
ld hl,wPokedexOwned
ld b,wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld de,wd11e
+ ld de, wNumSetBits
coord hl, 16, 6
lb bc, 1, 3
call PrintNumber ; print number of owned pokemon
--- a/engine/overworld/oaks_aide.asm
+++ b/engine/overworld/oaks_aide.asm
@@ -4,45 +4,45 @@
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
- jr nz, .asm_59086
+ jr nz, .choseNo
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e]
- ld [$ffdd], a
+ ld a, [wNumSetBits]
+ ld [hOaksAideNumMonsOwned], a
ld b, a
- ld a, [$ffdb]
+ ld a, [hOaksAideRequirement]
cp b
- jr z, .asm_59059
- jr nc, .asm_5907c
-.asm_59059
+ jr z, .giveItem
+ jr nc, .notEnoughOwnedMons
+.giveItem
ld hl, OaksAideHereYouGoText
call PrintText
- ld a, [$ffdc]
+ ld a, [hOaksAideItemReward]
ld b, a
ld c, 1
call GiveItem
- jr nc, .BagFull
+ jr nc, .bagFull
ld hl, OaksAideGotItemText
call PrintText
ld a, $1
- jr .asm_5908e
-.BagFull
+ jr .done
+.bagFull
ld hl, OaksAideNoRoomText
call PrintText
xor a
- jr .asm_5908e
-.asm_5907c
+ jr .done
+.notEnoughOwnedMons
ld hl, OaksAideUhOhText
call PrintText
ld a, $80
- jr .asm_5908e
-.asm_59086
+ jr .done
+.choseNo
ld hl, OaksAideComeBackText
call PrintText
ld a, $ff
-.asm_5908e
- ld [$ffdb], a
+.done
+ ld [hOaksAideResult], a
ret
OaksAideHiText: ; 59091 (16:5091)
--- a/engine/pokedex_rating.asm
+++ b/engine/pokedex_rating.asm
@@ -2,18 +2,18 @@
ld hl, wPokedexSeen
ld b, wPokedexSeenEnd - wPokedexSeen
call CountSetBits
- ld a, [wd11e] ; result of CountSetBits (seen count)
- ld [$FFDB], a
+ ld a, [wNumSetBits]
+ ld [hDexRatingNumMonsSeen], a
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e] ; result of CountSetBits (own count)
- ld [$FFDC], a
+ ld a, [wNumSetBits]
+ ld [hDexRatingNumMonsOwned], a
ld hl, DexRatingsTable
.findRating
ld a, [hli]
ld b, a
- ld a, [$FFDC] ; number of pokemon owned
+ ld a, [hDexRatingNumMonsOwned]
cp b
jr c, .foundRating
inc hl
@@ -24,7 +24,7 @@
ld h, [hl]
ld l, a ; load text pointer into hl
CheckAndResetEventA EVENT_HALL_OF_FAME_DEX_RATING
- jr nz, .label3
+ jr nz, .hallOfFame
push hl
ld hl, PokedexRatingText_441cc
call PrintText
@@ -31,23 +31,23 @@
pop hl
call PrintText
callba PlayPokedexRatingSfx
- jp WaitForTextScrollButtonPress ; wait for button press
-.label3
+ jp WaitForTextScrollButtonPress
+.hallOfFame
ld de, wcc5b
- ld a, [$FFDB]
+ ld a, [hDexRatingNumMonsSeen]
ld [de], a
inc de
- ld a, [$FFDC]
+ ld a, [hDexRatingNumMonsOwned]
ld [de], a
inc de
-.label4
+.copyRatingTextLoop
ld a, [hli]
- cp a, $50
- jr z, .label5
+ cp a, "@"
+ jr z, .doneCopying
ld [de], a
inc de
- jr .label4
-.label5
+ jr .copyRatingTextLoop
+.doneCopying
ld [de], a
ret
--- a/home.asm
+++ b/home.asm
@@ -1292,7 +1292,7 @@
; hl = address of string of bytes
; b = length of string of bytes
; OUTPUT:
-; [wd11e] = number of set bits
+; [wNumSetBits] = number of set bits
CountSetBits:: ; 2b7f (0:2b7f)
ld c,0
.loop
@@ -1309,7 +1309,7 @@
dec b
jr nz,.loop
ld a,c
- ld [wd11e],a ; store number of set bits
+ ld [wNumSetBits],a
ret
; subtracts the amount the player paid from their money
--- a/hram.asm
+++ b/hram.asm
@@ -273,6 +273,19 @@
hGymTrashCanRandNumMask EQU $FFDB
+hDexRatingNumMonsSeen EQU $FFDB
+hDexRatingNumMonsOwned EQU $FFDC
+
+; $00 = bag full
+; $01 = got item
+; $80 = didn't meet required number of owned mons
+; $FF = player cancelled
+hOaksAideResult EQU $FFDB
+
+hOaksAideRequirement EQU $FFDB ; required number of owned mons
+hOaksAideItemReward EQU $FFDC
+hOaksAideNumMonsOwned EQU $FFDD
+
hItemToRemoveID EQU $FFDB
hItemToRemoveIndex EQU $FFDC
--- a/scripts/celadonmansion3.asm
+++ b/scripts/celadonmansion3.asm
@@ -30,7 +30,7 @@
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e]
+ ld a, [wNumSetBits]
cp 150
jr nc, .CompletedDex
ld hl, .GameDesigner
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -969,8 +969,8 @@
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e]
- cp $2
+ ld a, [wNumSetBits]
+ cp 2
jr c, .asm_1d279
CheckEvent EVENT_GOT_POKEDEX
jr z, .asm_1d279
--- a/scripts/route11gateupstairs.asm
+++ b/scripts/route11gateupstairs.asm
@@ -20,9 +20,9 @@
CheckEvent EVENT_GOT_ITEMFINDER, 1
jr c, .asm_4949b
ld a, 30 ; pokemon needed
- ld [$ffdb], a
+ ld [hOaksAideRequirement], a
ld a, ITEMFINDER ; oak's aide reward
- ld [$ffdc], a
+ ld [hOaksAideItemReward], a
ld [wd11e], a
call GetItemName
ld h, d
@@ -30,8 +30,8 @@
ld de, wcc5b
ld bc, $000d
call CopyData
- predef OaksAideScript ; call oak's aide script
- ld a, [$ffdb]
+ predef OaksAideScript
+ ld a, [hOaksAideResult]
dec a
jr nz, .asm_494a1
SetEvent EVENT_GOT_ITEMFINDER
--- a/scripts/route15gateupstairs.asm
+++ b/scripts/route15gateupstairs.asm
@@ -10,9 +10,9 @@
CheckEvent EVENT_GOT_EXP_ALL
jr nz, .asm_49683
ld a, 50 ; pokemon needed
- ld [$ffdb], a
+ ld [hOaksAideRequirement], a
ld a, EXP__ALL ; oak's aide reward
- ld [$ffdc], a
+ ld [hOaksAideItemReward], a
ld [wd11e], a
call GetItemName
ld hl, wcd6d
@@ -19,8 +19,8 @@
ld de, wcc5b
ld bc, $000d
call CopyData
- predef OaksAideScript ; call oak's aide script
- ld a, [$ffdb]
+ predef OaksAideScript
+ ld a, [hOaksAideResult]
cp $1
jr nz, .asm_49689
SetEvent EVENT_GOT_EXP_ALL
--- a/scripts/route2gate.asm
+++ b/scripts/route2gate.asm
@@ -10,9 +10,9 @@
CheckEvent EVENT_GOT_HM05
jr nz, .asm_5d60d
ld a, 10 ; pokemon needed
- ld [$ffdb], a
+ ld [hOaksAideRequirement], a
ld a, HM_05 ; oak's aide reward
- ld [$ffdc], a
+ ld [hOaksAideItemReward], a
ld [wd11e], a
call GetItemName
ld hl, wcd6d
@@ -19,8 +19,8 @@
ld de, wcc5b
ld bc, $000d
call CopyData
- predef OaksAideScript ; call oak's aide script
- ld a, [$ffdb]
+ predef OaksAideScript
+ ld a, [hOaksAideResult]
cp $1
jr nz, .asm_5d613
SetEvent EVENT_GOT_HM05
--- a/text.asm
+++ b/text.asm
@@ -94,7 +94,7 @@
cont "AIDE!"
para "If you caught @"
- TX_NUM $ffdb, 1, 3
+ TX_NUM hOaksAideRequirement, 1, 3
db $0
line "kinds of #MON,"
cont "I'm supposed to"
@@ -106,7 +106,7 @@
para "So, ", $52, "! Have"
line "you caught at"
cont "least @"
- TX_NUM $ffdb, 1, 3
+ TX_NUM hOaksAideRequirement, 1, 3
text " kinds of"
cont "#MON?"
done
@@ -115,12 +115,12 @@
text "Let's see..."
line "Uh-oh! You have"
cont "caught only @"
- TX_NUM $ffdd, 1, 3
+ TX_NUM hOaksAideNumMonsOwned, 1, 3
db $0
cont "kinds of #MON!"
para "You need @"
- TX_NUM $ffdb, 1, 3
+ TX_NUM hOaksAideRequirement, 1, 3
text " kinds"
line "if you want the"
cont "@"
@@ -132,7 +132,7 @@
text "Oh. I see."
para "When you get @"
- TX_NUM $ffdb, 1, 3
+ TX_NUM hOaksAideRequirement, 1, 3
db $0
line "kinds, come back"
cont "for @"
@@ -143,7 +143,7 @@
_OaksAideHereYouGoText:: ; 8028c (20:428c)
text "Great! You have"
line "caught @"
- TX_NUM $ffdd, 1, 3
+ TX_NUM hOaksAideNumMonsOwned, 1, 3
text " kinds "
cont "of #MON!"
cont "Congratulations!"
--- a/text/maps/oaks_lab.asm
+++ b/text/maps/oaks_lab.asm
@@ -547,10 +547,10 @@
line "letion is:"
para "@"
- TX_NUM $ffdb, 1, 3
+ TX_NUM hDexRatingNumMonsSeen, 1, 3
text " #MON seen"
line "@"
- TX_NUM $ffdc, 1, 3
+ TX_NUM hDexRatingNumMonsOwned, 1, 3
text " #MON owned"
para "PROF.OAK's"
--- a/wram.asm
+++ b/wram.asm
@@ -1882,6 +1882,8 @@
; which will be the first mon sent out.
ds 1
+wNumSetBits:: ; d11e
+
wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits
wForcePlayerToChooseMon:: ; d11f