mirror of
https://github.com/thornAvery/kep-hack.git
synced 2026-01-01 23:19:35 +13:00
named CountSetBits output variable
This commit is contained in:
parent
8d30191707
commit
525f1b96f3
|
|
@ -19,8 +19,8 @@ DisplayOakLabRightPoster: ; 1e965 (7:6965)
|
||||||
ld hl, wPokedexOwned
|
ld hl, wPokedexOwned
|
||||||
ld b, wPokedexOwnedEnd - wPokedexOwned
|
ld b, wPokedexOwnedEnd - wPokedexOwned
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
ld a, [wd11e]
|
ld a, [wNumSetBits]
|
||||||
cp $2
|
cp 2
|
||||||
tx_pre_id SaveOptionText
|
tx_pre_id SaveOptionText
|
||||||
jr c, .ownThreeOrMoreMon
|
jr c, .ownThreeOrMoreMon
|
||||||
tx_pre_id StrengthsAndWeaknessesText
|
tx_pre_id StrengthsAndWeaknessesText
|
||||||
|
|
|
||||||
|
|
@ -395,7 +395,7 @@ PrintNumBadges: ; 5e2f (1:5e2f)
|
||||||
ld b, $1
|
ld b, $1
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
pop hl
|
pop hl
|
||||||
ld de, wd11e
|
ld de, wNumSetBits
|
||||||
lb bc, 1, 2
|
lb bc, 1, 2
|
||||||
jp PrintNumber
|
jp PrintNumber
|
||||||
|
|
||||||
|
|
@ -405,7 +405,7 @@ PrintNumOwnedMons: ; 5e42 (1:5e42)
|
||||||
ld b, wPokedexOwnedEnd - wPokedexOwned
|
ld b, wPokedexOwnedEnd - wPokedexOwned
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
pop hl
|
pop hl
|
||||||
ld de, wd11e
|
ld de, wNumSetBits
|
||||||
lb bc, 1, 3
|
lb bc, 1, 3
|
||||||
jp PrintNumber
|
jp PrintNumber
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,14 +169,14 @@ HandlePokedexListMenu: ; 40111 (10:4111)
|
||||||
ld hl,wPokedexSeen
|
ld hl,wPokedexSeen
|
||||||
ld b,wPokedexSeenEnd - wPokedexSeen
|
ld b,wPokedexSeenEnd - wPokedexSeen
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
ld de,wd11e
|
ld de, wNumSetBits
|
||||||
coord hl, 16, 3
|
coord hl, 16, 3
|
||||||
lb bc, 1, 3
|
lb bc, 1, 3
|
||||||
call PrintNumber ; print number of seen pokemon
|
call PrintNumber ; print number of seen pokemon
|
||||||
ld hl,wPokedexOwned
|
ld hl,wPokedexOwned
|
||||||
ld b,wPokedexOwnedEnd - wPokedexOwned
|
ld b,wPokedexOwnedEnd - wPokedexOwned
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
ld de,wd11e
|
ld de, wNumSetBits
|
||||||
coord hl, 16, 6
|
coord hl, 16, 6
|
||||||
lb bc, 1, 3
|
lb bc, 1, 3
|
||||||
call PrintNumber ; print number of owned pokemon
|
call PrintNumber ; print number of owned pokemon
|
||||||
|
|
|
||||||
|
|
@ -4,45 +4,45 @@ OaksAideScript: ; 0x59035
|
||||||
call YesNoChoice
|
call YesNoChoice
|
||||||
ld a, [wCurrentMenuItem]
|
ld a, [wCurrentMenuItem]
|
||||||
and a
|
and a
|
||||||
jr nz, .asm_59086
|
jr nz, .choseNo
|
||||||
ld hl, wPokedexOwned
|
ld hl, wPokedexOwned
|
||||||
ld b, wPokedexOwnedEnd - wPokedexOwned
|
ld b, wPokedexOwnedEnd - wPokedexOwned
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
ld a, [wd11e]
|
ld a, [wNumSetBits]
|
||||||
ld [$ffdd], a
|
ld [hOaksAideNumMonsOwned], a
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [$ffdb]
|
ld a, [hOaksAideRequirement]
|
||||||
cp b
|
cp b
|
||||||
jr z, .asm_59059
|
jr z, .giveItem
|
||||||
jr nc, .asm_5907c
|
jr nc, .notEnoughOwnedMons
|
||||||
.asm_59059
|
.giveItem
|
||||||
ld hl, OaksAideHereYouGoText
|
ld hl, OaksAideHereYouGoText
|
||||||
call PrintText
|
call PrintText
|
||||||
ld a, [$ffdc]
|
ld a, [hOaksAideItemReward]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld c, 1
|
ld c, 1
|
||||||
call GiveItem
|
call GiveItem
|
||||||
jr nc, .BagFull
|
jr nc, .bagFull
|
||||||
ld hl, OaksAideGotItemText
|
ld hl, OaksAideGotItemText
|
||||||
call PrintText
|
call PrintText
|
||||||
ld a, $1
|
ld a, $1
|
||||||
jr .asm_5908e
|
jr .done
|
||||||
.BagFull
|
.bagFull
|
||||||
ld hl, OaksAideNoRoomText
|
ld hl, OaksAideNoRoomText
|
||||||
call PrintText
|
call PrintText
|
||||||
xor a
|
xor a
|
||||||
jr .asm_5908e
|
jr .done
|
||||||
.asm_5907c
|
.notEnoughOwnedMons
|
||||||
ld hl, OaksAideUhOhText
|
ld hl, OaksAideUhOhText
|
||||||
call PrintText
|
call PrintText
|
||||||
ld a, $80
|
ld a, $80
|
||||||
jr .asm_5908e
|
jr .done
|
||||||
.asm_59086
|
.choseNo
|
||||||
ld hl, OaksAideComeBackText
|
ld hl, OaksAideComeBackText
|
||||||
call PrintText
|
call PrintText
|
||||||
ld a, $ff
|
ld a, $ff
|
||||||
.asm_5908e
|
.done
|
||||||
ld [$ffdb], a
|
ld [hOaksAideResult], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
OaksAideHiText: ; 59091 (16:5091)
|
OaksAideHiText: ; 59091 (16:5091)
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,18 @@ DisplayDexRating: ; 44169 (11:4169)
|
||||||
ld hl, wPokedexSeen
|
ld hl, wPokedexSeen
|
||||||
ld b, wPokedexSeenEnd - wPokedexSeen
|
ld b, wPokedexSeenEnd - wPokedexSeen
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
ld a, [wd11e] ; result of CountSetBits (seen count)
|
ld a, [wNumSetBits]
|
||||||
ld [$FFDB], a
|
ld [hDexRatingNumMonsSeen], a
|
||||||
ld hl, wPokedexOwned
|
ld hl, wPokedexOwned
|
||||||
ld b, wPokedexOwnedEnd - wPokedexOwned
|
ld b, wPokedexOwnedEnd - wPokedexOwned
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
ld a, [wd11e] ; result of CountSetBits (own count)
|
ld a, [wNumSetBits]
|
||||||
ld [$FFDC], a
|
ld [hDexRatingNumMonsOwned], a
|
||||||
ld hl, DexRatingsTable
|
ld hl, DexRatingsTable
|
||||||
.findRating
|
.findRating
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [$FFDC] ; number of pokemon owned
|
ld a, [hDexRatingNumMonsOwned]
|
||||||
cp b
|
cp b
|
||||||
jr c, .foundRating
|
jr c, .foundRating
|
||||||
inc hl
|
inc hl
|
||||||
|
|
@ -24,30 +24,30 @@ DisplayDexRating: ; 44169 (11:4169)
|
||||||
ld h, [hl]
|
ld h, [hl]
|
||||||
ld l, a ; load text pointer into hl
|
ld l, a ; load text pointer into hl
|
||||||
CheckAndResetEventA EVENT_HALL_OF_FAME_DEX_RATING
|
CheckAndResetEventA EVENT_HALL_OF_FAME_DEX_RATING
|
||||||
jr nz, .label3
|
jr nz, .hallOfFame
|
||||||
push hl
|
push hl
|
||||||
ld hl, PokedexRatingText_441cc
|
ld hl, PokedexRatingText_441cc
|
||||||
call PrintText
|
call PrintText
|
||||||
pop hl
|
pop hl
|
||||||
call PrintText
|
call PrintText
|
||||||
callba PlayPokedexRatingSfx
|
callba PlayPokedexRatingSfx
|
||||||
jp WaitForTextScrollButtonPress ; wait for button press
|
jp WaitForTextScrollButtonPress
|
||||||
.label3
|
.hallOfFame
|
||||||
ld de, wcc5b
|
ld de, wcc5b
|
||||||
ld a, [$FFDB]
|
ld a, [hDexRatingNumMonsSeen]
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
ld a, [$FFDC]
|
ld a, [hDexRatingNumMonsOwned]
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
.label4
|
.copyRatingTextLoop
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
cp a, $50
|
cp a, "@"
|
||||||
jr z, .label5
|
jr z, .doneCopying
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
jr .label4
|
jr .copyRatingTextLoop
|
||||||
.label5
|
.doneCopying
|
||||||
ld [de], a
|
ld [de], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
||||||
4
home.asm
4
home.asm
|
|
@ -1292,7 +1292,7 @@ INCLUDE "engine/menu/start_menu.asm"
|
||||||
; hl = address of string of bytes
|
; hl = address of string of bytes
|
||||||
; b = length of string of bytes
|
; b = length of string of bytes
|
||||||
; OUTPUT:
|
; OUTPUT:
|
||||||
; [wd11e] = number of set bits
|
; [wNumSetBits] = number of set bits
|
||||||
CountSetBits:: ; 2b7f (0:2b7f)
|
CountSetBits:: ; 2b7f (0:2b7f)
|
||||||
ld c,0
|
ld c,0
|
||||||
.loop
|
.loop
|
||||||
|
|
@ -1309,7 +1309,7 @@ CountSetBits:: ; 2b7f (0:2b7f)
|
||||||
dec b
|
dec b
|
||||||
jr nz,.loop
|
jr nz,.loop
|
||||||
ld a,c
|
ld a,c
|
||||||
ld [wd11e],a ; store number of set bits
|
ld [wNumSetBits],a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; subtracts the amount the player paid from their money
|
; subtracts the amount the player paid from their money
|
||||||
|
|
|
||||||
13
hram.asm
13
hram.asm
|
|
@ -273,6 +273,19 @@ hGymGateIndex EQU $FFDB
|
||||||
|
|
||||||
hGymTrashCanRandNumMask 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
|
hItemToRemoveID EQU $FFDB
|
||||||
hItemToRemoveIndex EQU $FFDC
|
hItemToRemoveIndex EQU $FFDC
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ DirectorText: ; 487b2 (12:47b2)
|
||||||
ld hl, wPokedexOwned
|
ld hl, wPokedexOwned
|
||||||
ld b, wPokedexOwnedEnd - wPokedexOwned
|
ld b, wPokedexOwnedEnd - wPokedexOwned
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
ld a, [wd11e]
|
ld a, [wNumSetBits]
|
||||||
cp 150
|
cp 150
|
||||||
jr nc, .CompletedDex
|
jr nc, .CompletedDex
|
||||||
ld hl, .GameDesigner
|
ld hl, .GameDesigner
|
||||||
|
|
|
||||||
|
|
@ -969,8 +969,8 @@ OaksLabText5: ; 1d248 (7:5248)
|
||||||
ld hl, wPokedexOwned
|
ld hl, wPokedexOwned
|
||||||
ld b, wPokedexOwnedEnd - wPokedexOwned
|
ld b, wPokedexOwnedEnd - wPokedexOwned
|
||||||
call CountSetBits
|
call CountSetBits
|
||||||
ld a, [wd11e]
|
ld a, [wNumSetBits]
|
||||||
cp $2
|
cp 2
|
||||||
jr c, .asm_1d279
|
jr c, .asm_1d279
|
||||||
CheckEvent EVENT_GOT_POKEDEX
|
CheckEvent EVENT_GOT_POKEDEX
|
||||||
jr z, .asm_1d279
|
jr z, .asm_1d279
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ Route11GateUpstairsText2: ; 4946c (12:546c)
|
||||||
CheckEvent EVENT_GOT_ITEMFINDER, 1
|
CheckEvent EVENT_GOT_ITEMFINDER, 1
|
||||||
jr c, .asm_4949b
|
jr c, .asm_4949b
|
||||||
ld a, 30 ; pokemon needed
|
ld a, 30 ; pokemon needed
|
||||||
ld [$ffdb], a
|
ld [hOaksAideRequirement], a
|
||||||
ld a, ITEMFINDER ; oak's aide reward
|
ld a, ITEMFINDER ; oak's aide reward
|
||||||
ld [$ffdc], a
|
ld [hOaksAideItemReward], a
|
||||||
ld [wd11e], a
|
ld [wd11e], a
|
||||||
call GetItemName
|
call GetItemName
|
||||||
ld h, d
|
ld h, d
|
||||||
|
|
@ -30,8 +30,8 @@ Route11GateUpstairsText2: ; 4946c (12:546c)
|
||||||
ld de, wcc5b
|
ld de, wcc5b
|
||||||
ld bc, $000d
|
ld bc, $000d
|
||||||
call CopyData
|
call CopyData
|
||||||
predef OaksAideScript ; call oak's aide script
|
predef OaksAideScript
|
||||||
ld a, [$ffdb]
|
ld a, [hOaksAideResult]
|
||||||
dec a
|
dec a
|
||||||
jr nz, .asm_494a1
|
jr nz, .asm_494a1
|
||||||
SetEvent EVENT_GOT_ITEMFINDER
|
SetEvent EVENT_GOT_ITEMFINDER
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,17 @@ Route15GateUpstairsText1: ; 49651 (12:5651)
|
||||||
CheckEvent EVENT_GOT_EXP_ALL
|
CheckEvent EVENT_GOT_EXP_ALL
|
||||||
jr nz, .asm_49683
|
jr nz, .asm_49683
|
||||||
ld a, 50 ; pokemon needed
|
ld a, 50 ; pokemon needed
|
||||||
ld [$ffdb], a
|
ld [hOaksAideRequirement], a
|
||||||
ld a, EXP__ALL ; oak's aide reward
|
ld a, EXP__ALL ; oak's aide reward
|
||||||
ld [$ffdc], a
|
ld [hOaksAideItemReward], a
|
||||||
ld [wd11e], a
|
ld [wd11e], a
|
||||||
call GetItemName
|
call GetItemName
|
||||||
ld hl, wcd6d
|
ld hl, wcd6d
|
||||||
ld de, wcc5b
|
ld de, wcc5b
|
||||||
ld bc, $000d
|
ld bc, $000d
|
||||||
call CopyData
|
call CopyData
|
||||||
predef OaksAideScript ; call oak's aide script
|
predef OaksAideScript
|
||||||
ld a, [$ffdb]
|
ld a, [hOaksAideResult]
|
||||||
cp $1
|
cp $1
|
||||||
jr nz, .asm_49689
|
jr nz, .asm_49689
|
||||||
SetEvent EVENT_GOT_EXP_ALL
|
SetEvent EVENT_GOT_EXP_ALL
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,17 @@ Route2GateText1: ; 5d5db (17:55db)
|
||||||
CheckEvent EVENT_GOT_HM05
|
CheckEvent EVENT_GOT_HM05
|
||||||
jr nz, .asm_5d60d
|
jr nz, .asm_5d60d
|
||||||
ld a, 10 ; pokemon needed
|
ld a, 10 ; pokemon needed
|
||||||
ld [$ffdb], a
|
ld [hOaksAideRequirement], a
|
||||||
ld a, HM_05 ; oak's aide reward
|
ld a, HM_05 ; oak's aide reward
|
||||||
ld [$ffdc], a
|
ld [hOaksAideItemReward], a
|
||||||
ld [wd11e], a
|
ld [wd11e], a
|
||||||
call GetItemName
|
call GetItemName
|
||||||
ld hl, wcd6d
|
ld hl, wcd6d
|
||||||
ld de, wcc5b
|
ld de, wcc5b
|
||||||
ld bc, $000d
|
ld bc, $000d
|
||||||
call CopyData
|
call CopyData
|
||||||
predef OaksAideScript ; call oak's aide script
|
predef OaksAideScript
|
||||||
ld a, [$ffdb]
|
ld a, [hOaksAideResult]
|
||||||
cp $1
|
cp $1
|
||||||
jr nz, .asm_5d613
|
jr nz, .asm_5d613
|
||||||
SetEvent EVENT_GOT_HM05
|
SetEvent EVENT_GOT_HM05
|
||||||
|
|
|
||||||
12
text.asm
12
text.asm
|
|
@ -94,7 +94,7 @@ _OaksAideHiText:: ; 80143 (20:4143)
|
||||||
cont "AIDE!"
|
cont "AIDE!"
|
||||||
|
|
||||||
para "If you caught @"
|
para "If you caught @"
|
||||||
TX_NUM $ffdb, 1, 3
|
TX_NUM hOaksAideRequirement, 1, 3
|
||||||
db $0
|
db $0
|
||||||
line "kinds of #MON,"
|
line "kinds of #MON,"
|
||||||
cont "I'm supposed to"
|
cont "I'm supposed to"
|
||||||
|
|
@ -106,7 +106,7 @@ _OaksAideHiText:: ; 80143 (20:4143)
|
||||||
para "So, ", $52, "! Have"
|
para "So, ", $52, "! Have"
|
||||||
line "you caught at"
|
line "you caught at"
|
||||||
cont "least @"
|
cont "least @"
|
||||||
TX_NUM $ffdb, 1, 3
|
TX_NUM hOaksAideRequirement, 1, 3
|
||||||
text " kinds of"
|
text " kinds of"
|
||||||
cont "#MON?"
|
cont "#MON?"
|
||||||
done
|
done
|
||||||
|
|
@ -115,12 +115,12 @@ _OaksAideUhOhText:: ; 801e4 (20:41e4)
|
||||||
text "Let's see..."
|
text "Let's see..."
|
||||||
line "Uh-oh! You have"
|
line "Uh-oh! You have"
|
||||||
cont "caught only @"
|
cont "caught only @"
|
||||||
TX_NUM $ffdd, 1, 3
|
TX_NUM hOaksAideNumMonsOwned, 1, 3
|
||||||
db $0
|
db $0
|
||||||
cont "kinds of #MON!"
|
cont "kinds of #MON!"
|
||||||
|
|
||||||
para "You need @"
|
para "You need @"
|
||||||
TX_NUM $ffdb, 1, 3
|
TX_NUM hOaksAideRequirement, 1, 3
|
||||||
text " kinds"
|
text " kinds"
|
||||||
line "if you want the"
|
line "if you want the"
|
||||||
cont "@"
|
cont "@"
|
||||||
|
|
@ -132,7 +132,7 @@ _OaksAideComeBackText:: ; 80250 (20:4250)
|
||||||
text "Oh. I see."
|
text "Oh. I see."
|
||||||
|
|
||||||
para "When you get @"
|
para "When you get @"
|
||||||
TX_NUM $ffdb, 1, 3
|
TX_NUM hOaksAideRequirement, 1, 3
|
||||||
db $0
|
db $0
|
||||||
line "kinds, come back"
|
line "kinds, come back"
|
||||||
cont "for @"
|
cont "for @"
|
||||||
|
|
@ -143,7 +143,7 @@ _OaksAideComeBackText:: ; 80250 (20:4250)
|
||||||
_OaksAideHereYouGoText:: ; 8028c (20:428c)
|
_OaksAideHereYouGoText:: ; 8028c (20:428c)
|
||||||
text "Great! You have"
|
text "Great! You have"
|
||||||
line "caught @"
|
line "caught @"
|
||||||
TX_NUM $ffdd, 1, 3
|
TX_NUM hOaksAideNumMonsOwned, 1, 3
|
||||||
text " kinds "
|
text " kinds "
|
||||||
cont "of #MON!"
|
cont "of #MON!"
|
||||||
cont "Congratulations!"
|
cont "Congratulations!"
|
||||||
|
|
|
||||||
|
|
@ -547,10 +547,10 @@ _OaksLabText_441cc:: ; 9580c (25:580c)
|
||||||
line "letion is:"
|
line "letion is:"
|
||||||
|
|
||||||
para "@"
|
para "@"
|
||||||
TX_NUM $ffdb, 1, 3
|
TX_NUM hDexRatingNumMonsSeen, 1, 3
|
||||||
text " #MON seen"
|
text " #MON seen"
|
||||||
line "@"
|
line "@"
|
||||||
TX_NUM $ffdc, 1, 3
|
TX_NUM hDexRatingNumMonsOwned, 1, 3
|
||||||
text " #MON owned"
|
text " #MON owned"
|
||||||
|
|
||||||
para "PROF.OAK's"
|
para "PROF.OAK's"
|
||||||
|
|
|
||||||
2
wram.asm
2
wram.asm
|
|
@ -1882,6 +1882,8 @@ wFirstMonsNotOutYet:: ; d11d
|
||||||
; which will be the first mon sent out.
|
; which will be the first mon sent out.
|
||||||
ds 1
|
ds 1
|
||||||
|
|
||||||
|
wNumSetBits:: ; d11e
|
||||||
|
|
||||||
wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits
|
wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits
|
||||||
|
|
||||||
wForcePlayerToChooseMon:: ; d11f
|
wForcePlayerToChooseMon:: ; d11f
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue