Use maskbits some more
This commit is contained in:
@@ -17,7 +17,7 @@ SpecialBuenasPassword: ; 8af6b
|
||||
ld a, [MenuSelection]
|
||||
ld c, a
|
||||
ld a, [wBuenasPassword]
|
||||
and $3
|
||||
maskbits NUM_PASSWORDS_PER_CATEGORY +- 1
|
||||
cp c
|
||||
jr nz, .wrong
|
||||
ld b, $1
|
||||
@@ -46,7 +46,7 @@ SpecialBuenasPassword: ; 8af6b
|
||||
; 0x8afb4
|
||||
|
||||
.PasswordIndices: ; 8afb8
|
||||
db 3
|
||||
db NUM_PASSWORDS_PER_CATEGORY
|
||||
db 0, 1, 2
|
||||
db -1
|
||||
|
||||
|
@@ -2,7 +2,7 @@ Special_SelectRandomBugContestContestants: ; 139a8
|
||||
; Select five random people to participate in the current contest.
|
||||
|
||||
; First we have to make sure that any old data is cleared away.
|
||||
ld c, 10 ; Number of people to choose from.
|
||||
ld c, NUM_BUG_CONTESTANTS
|
||||
ld hl, BugCatchingContestantEventFlagTable
|
||||
.loop1
|
||||
push bc
|
||||
@@ -26,9 +26,9 @@ Special_SelectRandomBugContestContestants: ; 139a8
|
||||
.next
|
||||
; Choose a flag at uniform random to be set.
|
||||
call Random
|
||||
cp 250
|
||||
cp $ff / NUM_BUG_CONTESTANTS * NUM_BUG_CONTESTANTS
|
||||
jr nc, .next
|
||||
ld c, 25
|
||||
ld c, $ff / NUM_BUG_CONTESTANTS
|
||||
call SimpleDivide
|
||||
ld e, b
|
||||
ld d, 0
|
||||
@@ -59,7 +59,7 @@ Special_SelectRandomBugContestContestants: ; 139a8
|
||||
Special_CheckBugContestContestantFlag: ; 139ed
|
||||
; Checks the flag of the Bug Catching Contestant whose index is loaded in a.
|
||||
|
||||
; Bug: If a >= 10 when this is called, it will read beyond the table.
|
||||
; Bug: If a >= NUM_BUG_CONTESTANTS when this is called, it will read beyond the table.
|
||||
|
||||
ld hl, BugCatchingContestantEventFlagTable
|
||||
ld e, a
|
||||
@@ -74,18 +74,7 @@ Special_CheckBugContestContestantFlag: ; 139ed
|
||||
ret
|
||||
; 139fe
|
||||
|
||||
BugCatchingContestantEventFlagTable: ; 139fe
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_1A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_2A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_3A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_4A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_5A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_6A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_7A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_8A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_9A
|
||||
dw EVENT_BUG_CATCHING_CONTESTANT_10A
|
||||
; 13a12
|
||||
INCLUDE "data/bug_contest_flags.asm"
|
||||
|
||||
ContestDropOffMons: ; 13a12
|
||||
ld hl, PartyMon1HP
|
||||
@@ -101,7 +90,7 @@ ContestDropOffMons: ; 13a12
|
||||
ld a, [hl]
|
||||
ld [wBugContestSecondPartySpecies], a
|
||||
; ... and replacing it with the terminator byte
|
||||
ld [hl], $ff
|
||||
ld [hl], -1
|
||||
xor a
|
||||
ld [ScriptVar], a
|
||||
ret
|
||||
@@ -118,7 +107,7 @@ ContestReturnMons: ; 13a31
|
||||
ld a, [wBugContestSecondPartySpecies]
|
||||
ld [hl], a
|
||||
; Restore the party count, which must be recomputed.
|
||||
ld b, $1
|
||||
ld b, 1
|
||||
.loop
|
||||
ld a, [hli]
|
||||
cp -1
|
||||
|
@@ -77,9 +77,8 @@ BugContest_ThirdPlaceScoreText: ; 0x1372b
|
||||
; 0x13730
|
||||
|
||||
LoadContestantName: ; 13730
|
||||
|
||||
; If a = 0, get your name.
|
||||
dec a
|
||||
; If a = 1, get your name.
|
||||
dec a ; BUG_CONTEST_PLAYER
|
||||
jr z, .player
|
||||
; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a.
|
||||
ld c, a
|
||||
@@ -141,11 +140,11 @@ INCLUDE "data/bug_contest_winners.asm"
|
||||
|
||||
BugContest_GetPlayersResult: ; 13807
|
||||
ld hl, wBugContestThirdPlaceWinnerID
|
||||
ld de, -4
|
||||
ld b, 3
|
||||
ld de, - BUG_CONTESTANT_SIZE
|
||||
ld b, 3 ; 3rd, 2nd, or 1st
|
||||
.loop
|
||||
ld a, [hl]
|
||||
cp 1 ; Player
|
||||
cp BUG_CONTEST_PLAYER
|
||||
jr z, .done
|
||||
add hl, de
|
||||
dec b
|
||||
@@ -159,7 +158,7 @@ BugContest_JudgeContestants: ; 13819
|
||||
call ClearContestResults
|
||||
call ComputeAIContestantScores
|
||||
ld hl, wBugContestTempWinnerID
|
||||
ld a, 1 ; Player
|
||||
ld a, BUG_CONTEST_PLAYER
|
||||
ld [hli], a
|
||||
ld a, [wContestMon]
|
||||
ld [hli], a
|
||||
@@ -190,11 +189,11 @@ DetermineContestWinners: ; 1383e
|
||||
jr c, .not_first_place
|
||||
ld hl, wBugContestSecondPlaceWinnerID
|
||||
ld de, wBugContestThirdPlaceWinnerID
|
||||
ld bc, 4
|
||||
ld bc, BUG_CONTESTANT_SIZE
|
||||
call CopyBytes
|
||||
ld hl, wBugContestFirstPlaceWinnerID
|
||||
ld de, wBugContestSecondPlaceWinnerID
|
||||
ld bc, 4
|
||||
ld bc, BUG_CONTESTANT_SIZE
|
||||
call CopyBytes
|
||||
ld hl, wBugContestFirstPlaceWinnerID
|
||||
call CopyTempContestant
|
||||
@@ -208,7 +207,7 @@ DetermineContestWinners: ; 1383e
|
||||
jr c, .not_second_place
|
||||
ld hl, wBugContestSecondPlaceWinnerID
|
||||
ld de, wBugContestThirdPlaceWinnerID
|
||||
ld bc, 4
|
||||
ld bc, BUG_CONTESTANT_SIZE
|
||||
call CopyBytes
|
||||
ld hl, wBugContestSecondPlaceWinnerID
|
||||
call CopyTempContestant
|
||||
@@ -230,7 +229,7 @@ DetermineContestWinners: ; 1383e
|
||||
CopyTempContestant: ; 138a0
|
||||
; Could've just called CopyBytes.
|
||||
ld de, wBugContestTempWinnerID
|
||||
rept 3
|
||||
rept BUG_CONTESTANT_SIZE +- 1
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [hli], a
|
||||
@@ -264,6 +263,7 @@ ComputeAIContestantScores: ; 138b0
|
||||
inc hl
|
||||
inc hl
|
||||
.loop2
|
||||
; 0, 1, or 2 for 1st, 2nd, or 3rd
|
||||
call Random
|
||||
and 3
|
||||
cp 3
|
||||
@@ -278,8 +278,9 @@ ComputeAIContestantScores: ; 138b0
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
; randomly perturb score
|
||||
call Random
|
||||
and 7
|
||||
and %111
|
||||
ld c, a
|
||||
ld b, 0
|
||||
add hl, bc
|
||||
@@ -294,7 +295,7 @@ ComputeAIContestantScores: ; 138b0
|
||||
.done
|
||||
inc e
|
||||
ld a, e
|
||||
cp 10
|
||||
cp NUM_BUG_CONTESTANTS
|
||||
jr nz, .loop
|
||||
ret
|
||||
; 13900
|
||||
@@ -337,26 +338,26 @@ ContestScore: ; 13900
|
||||
; DVs
|
||||
ld a, [wContestMonDVs + 0]
|
||||
ld b, a
|
||||
and 2
|
||||
and %0010
|
||||
add a
|
||||
add a
|
||||
ld c, a
|
||||
|
||||
swap b
|
||||
ld a, b
|
||||
and 2
|
||||
and %0010
|
||||
add a
|
||||
add c
|
||||
ld d, a
|
||||
|
||||
ld a, [wContestMonDVs + 1]
|
||||
ld b, a
|
||||
and 2
|
||||
and %0010
|
||||
ld c, a
|
||||
|
||||
swap b
|
||||
ld a, b
|
||||
and 2
|
||||
and %0010
|
||||
srl a
|
||||
add c
|
||||
add c
|
||||
|
@@ -80,7 +80,7 @@ rept 4
|
||||
endr
|
||||
|
||||
ld a, [TimeOfDay]
|
||||
and 3
|
||||
maskbits NUM_DAYTIMES +- 1
|
||||
cp NITE_F
|
||||
jr c, .time_species
|
||||
inc hl
|
||||
|
@@ -435,7 +435,7 @@ MagnetTrain_Jumptable_FirstRunThrough: ; 8ceae
|
||||
ld a, [wEnvironment]
|
||||
push af
|
||||
ld a, [TimeOfDay]
|
||||
and $3
|
||||
maskbits NUM_DAYTIMES +- 1
|
||||
ld [TimeOfDayPal], a
|
||||
ld a, $1
|
||||
ld [wEnvironment], a
|
||||
|
@@ -10,8 +10,8 @@ LoadPoisonBGPals: ; cbcdd
|
||||
and a
|
||||
jr nz, .cgb
|
||||
ld a, [TimeOfDayPal]
|
||||
and $3
|
||||
cp $3
|
||||
maskbits NUM_DAYTIMES +- 1
|
||||
cp DARKNESS_F
|
||||
ld a, %00000000
|
||||
jr z, .convert_pals
|
||||
ld a, %10101010
|
||||
|
@@ -20,7 +20,7 @@ SpecialPokeSeer: ; 4f0bc
|
||||
call PrintSeerText
|
||||
call JoyWaitAorB
|
||||
|
||||
ld b, $6
|
||||
ld b, PARTY_LENGTH
|
||||
farcall SelectMonFromParty
|
||||
jr c, .cancel
|
||||
|
||||
@@ -163,11 +163,11 @@ GetCaughtLevel: ; 4f18c
|
||||
call ByteFill
|
||||
|
||||
; caught level
|
||||
; Limited to between 1 and 63 for some reason.
|
||||
; Limited to between 1 and 63 since it's a 6-bit quantity.
|
||||
ld a, [wSeerCaughtData]
|
||||
and $3f
|
||||
and CAUGHT_LEVEL_MASK
|
||||
jr z, .unknown
|
||||
cp 1 ; hatched from an egg
|
||||
cp CAUGHT_EGG_LEVEL ; egg marker value
|
||||
jr nz, .print
|
||||
ld a, EGG_LEVEL ; egg hatch level
|
||||
|
||||
@@ -193,7 +193,7 @@ GetCaughtLevel: ; 4f18c
|
||||
|
||||
GetCaughtTime: ; 4f1c5
|
||||
ld a, [wSeerCaughtData]
|
||||
and $c0
|
||||
and CAUGHT_TIME_MASK
|
||||
jr z, .none
|
||||
|
||||
rlca
|
||||
@@ -233,11 +233,11 @@ UnknownCaughtData: ; 4f1f8
|
||||
|
||||
GetCaughtLocation: ; 4f20a
|
||||
ld a, [wSeerCaughtGender]
|
||||
and $7f
|
||||
and CAUGHT_LOCATION_MASK
|
||||
jr z, .Unknown
|
||||
cp $7f
|
||||
cp EVENT_LOCATION
|
||||
jr z, .event
|
||||
cp $7e
|
||||
cp GIFT_LOCATION
|
||||
jr z, .fail
|
||||
ld e, a
|
||||
farcall GetLandmarkName
|
||||
@@ -440,22 +440,22 @@ GetCaughtGender: ; 4f301
|
||||
add hl, bc
|
||||
|
||||
ld a, [hl]
|
||||
and $7f
|
||||
and CAUGHT_LOCATION_MASK
|
||||
jr z, .genderless
|
||||
cp $7f
|
||||
cp EVENT_LOCATION
|
||||
jr z, .genderless
|
||||
|
||||
ld a, [hl]
|
||||
and $80
|
||||
and CAUGHT_GENDER_MASK
|
||||
jr nz, .male
|
||||
ld c, 1
|
||||
ld c, CAUGHT_BY_GIRL
|
||||
ret
|
||||
|
||||
.male
|
||||
ld c, 2
|
||||
ld c, CAUGHT_BY_BOY
|
||||
ret
|
||||
|
||||
.genderless
|
||||
ld c, 0
|
||||
ld c, CAUGHT_BY_UNKNOWN
|
||||
ret
|
||||
; 4f31c
|
||||
|
Reference in New Issue
Block a user