Skip to content

Commit

Permalink
named CountSetBits output variable
Browse files Browse the repository at this point in the history
  • Loading branch information
YamaArashi committed Aug 7, 2015
1 parent 8d30191 commit 525f1b9
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 63 deletions.
4 changes: 2 additions & 2 deletions engine/hidden_object_functions7.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions engine/menu/main_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions engine/menu/pokedex.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions engine/overworld/oaks_aide.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 15 additions & 15 deletions engine/pokedex_rating.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions home.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions hram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/celadonmansion3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/oakslab.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions scripts/route11gateupstairs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ 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
ld l, e
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
Expand Down
8 changes: 4 additions & 4 deletions scripts/route15gateupstairs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions scripts/route2gate.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions text.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 "@"
Expand All @@ -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 @"
Expand All @@ -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!"
Expand Down
4 changes: 2 additions & 2 deletions text/maps/oaks_lab.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 525f1b9

Please sign in to comment.