named CountSetBits output variable

This commit is contained in:
YamaArashi 2015-08-07 04:24:06 -07:00
parent 8d30191707
commit 525f1b96f3
15 changed files with 78 additions and 63 deletions

View File

@ -19,8 +19,8 @@ DisplayOakLabRightPoster: ; 1e965 (7:6965)
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

View File

@ -395,7 +395,7 @@ PrintNumBadges: ; 5e2f (1:5e2f)
ld b, $1
call CountSetBits
pop hl
ld de, wd11e
ld de, wNumSetBits
lb bc, 1, 2
jp PrintNumber
@ -405,7 +405,7 @@ PrintNumOwnedMons: ; 5e42 (1:5e42)
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
pop hl
ld de, wd11e
ld de, wNumSetBits
lb bc, 1, 3
jp PrintNumber

View File

@ -169,14 +169,14 @@ HandlePokedexListMenu: ; 40111 (10:4111)
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
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

View File

@ -4,45 +4,45 @@ OaksAideScript: ; 0x59035
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)

View File

@ -2,18 +2,18 @@ DisplayDexRating: ; 44169 (11:4169)
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,30 +24,30 @@ DisplayDexRating: ; 44169 (11:4169)
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
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

View File

@ -1292,7 +1292,7 @@ INCLUDE "engine/menu/start_menu.asm"
; 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 @@ CountSetBits:: ; 2b7f (0:2b7f)
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

View File

@ -273,6 +273,19 @@ hGymGateIndex EQU $FFDB
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

View File

@ -30,7 +30,7 @@ DirectorText: ; 487b2 (12:47b2)
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
ld a, [wd11e]
ld a, [wNumSetBits]
cp 150
jr nc, .CompletedDex
ld hl, .GameDesigner

View File

@ -969,8 +969,8 @@ OaksLabText5: ; 1d248 (7:5248)
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

View File

@ -20,9 +20,9 @@ Route11GateUpstairsText2: ; 4946c (12:546c)
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 @@ Route11GateUpstairsText2: ; 4946c (12:546c)
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

View File

@ -10,17 +10,17 @@ Route15GateUpstairsText1: ; 49651 (12:5651)
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
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

View File

@ -10,17 +10,17 @@ Route2GateText1: ; 5d5db (17:55db)
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
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

View File

@ -94,7 +94,7 @@ _OaksAideHiText:: ; 80143 (20:4143)
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 @@ _OaksAideHiText:: ; 80143 (20:4143)
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 @@ _OaksAideUhOhText:: ; 801e4 (20:41e4)
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 @@ _OaksAideComeBackText:: ; 80250 (20:4250)
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 @@ _OaksAideComeBackText:: ; 80250 (20:4250)
_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!"

View File

@ -547,10 +547,10 @@ _OaksLabText_441cc:: ; 9580c (25:580c)
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"

View File

@ -1882,6 +1882,8 @@ wFirstMonsNotOutYet:: ; d11d
; 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