Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous labels #153

Merged
merged 9 commits into from
Oct 3, 2024
2 changes: 1 addition & 1 deletion src/engine/bank20.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ Func_80baa:
Func_80c64: ; unreferenced
ld a, [wLineSeparation]
push af
ld a, $01 ; no line separator
ld a, $01 ; text isn't double-spaced
ld [wLineSeparation], a
; load opponent's name
ld a, [wOpponentName]
Expand Down
2 changes: 1 addition & 1 deletion src/engine/challenge_machine.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ChallengeMachine_Reset:
; if a challenge is already in progress, then resume
; otherwise, start a new 5 round challenge
ChallengeMachine_Start::
ld a, 0
ld a, 0 ; text is double-spaced
ld [wLineSeparation], a
call LoadConsolePaletteData
call ChallengeMachine_Initialize
Expand Down
12 changes: 6 additions & 6 deletions src/engine/duel/ai/attacks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ GetAIScoreOfAttack:
ld a, $50
ld [wAIScore], a

xor a
xor a ; PLAY_AREA_ARENA
ldh [hTempPlayAreaLocation_ff9d], a
call CheckIfSelectedAttackIsUnusable
jr nc, .usable
Expand Down Expand Up @@ -254,7 +254,7 @@ GetAIScoreOfAttack:
ld [wTempAI], a
or a
jr z, .no_damage
call CalculateByteTensDigit
call ConvertHPToDamageCounters_Bank5
call AddToAIScore
jr .check_recoil
.no_damage
Expand Down Expand Up @@ -292,7 +292,7 @@ GetAIScoreOfAttack:
ld [wDamage], a
call ApplyDamageModifiers_DamageToSelf
ld a, e
call CalculateByteTensDigit
call ConvertHPToDamageCounters_Bank5
call SubFromAIScore

push de
Expand Down Expand Up @@ -570,7 +570,7 @@ GetAIScoreOfAttack:
cp 1
jr z, .tally_heal_score
ld a, [wTempAI]
call CalculateByteTensDigit
call ConvertHPToDamageCounters_Bank5
ld b, a
ld a, [wLoadedAttackEffectParam]
cp 3
Expand All @@ -581,15 +581,15 @@ GetAIScoreOfAttack:
.asm_16cec
ld a, DUELVARS_ARENA_CARD_HP
call GetTurnDuelistVariable
call CalculateByteTensDigit
call ConvertHPToDamageCounters_Bank5
cp b
jr c, .tally_heal_score
ld a, b
.tally_heal_score
push af
ld e, PLAY_AREA_ARENA
call GetCardDamageAndMaxHP
call CalculateByteTensDigit
call ConvertHPToDamageCounters_Bank5
pop bc
cp b ; wLoadedAttackEffectParam
jr c, .add_heal_score
Expand Down
43 changes: 27 additions & 16 deletions src/engine/duel/ai/common.asm
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,26 @@ PickTwoAttachedEnergyCards:
ld a, $ff
ret

; copies $ff terminated buffer from hl to de
CopyBuffer:
; copies an $ff-terminated list from hl to de
; preserves bc
; input:
; hl = address from which to start copying the data
; de = where to copy the data
CopyListWithFFTerminatorFromHLToDE_Bank8:
ld a, [hli]
ld [de], a
cp $ff
ret z
inc de
jr CopyBuffer
jr CopyListWithFFTerminatorFromHLToDE_Bank8

; zeroes a bytes starting at hl
; zeroes a bytes starting from hl.
; this function is identical to 'ClearNBytesFromHL' in Bank $2,
; as well as ClearMemory_Bank5' and 'ClearMemory_Bank6'.
dannye marked this conversation as resolved.
Show resolved Hide resolved
; preserves all registers
; input:
; a = number of bytes to clear
; hl = where to begin erasing
ClearMemory_Bank8:
push af
push bc
Expand Down Expand Up @@ -435,12 +445,13 @@ CountOppEnergyCardsInHand:
or a
ret

; converts HP in a to number of equivalent damage counters
; converts an HP value or amount of damage to the number of equivalent damage counters
; preserves all registers except af
; input:
; a = HP
; a = HP value to convert
; output:
; a = number of damage counters
ConvertHPToCounters:
ConvertHPToDamageCounters_Bank8:
push bc
ld c, 0
.loop
Expand Down Expand Up @@ -493,10 +504,10 @@ CalculateBDividedByA_Bank8:
; input:
; a = CARD_LOCATION_*
; e = card ID to look for
LookForCardIDInLocation:
LookForCardIDInLocation_Bank8:
ld b, a
ld c, e
lb de, $00, 0 ; d is never used
lb de, 0, 0 ; d is never used
.loop
ld a, DUELVARS_CARD_LOCATIONS
add e
Expand Down Expand Up @@ -574,7 +585,7 @@ LookForCardIDInDeck_GivenCardIDInHandAndPlayArea:
; look for the card ID 1 in deck
ld e, a
ld a, CARD_LOCATION_DECK
call LookForCardIDInLocation
call LookForCardIDInLocation_Bank8
ret nc

; was found, store its deck index in memory
Expand Down Expand Up @@ -641,7 +652,7 @@ LookForCardIDInDeck_GivenCardIDInHand:
; look for the card ID 1 in deck
ld e, a
ld a, CARD_LOCATION_DECK
call LookForCardIDInLocation
call LookForCardIDInLocation_Bank8
ret nc

; was found, store its deck index in memory
Expand Down Expand Up @@ -684,22 +695,22 @@ LookForCardIDInPlayArea_Bank8:
call GetTurnDuelistVariable
cp $ff
ret z

call LoadCardDataToBuffer1_FromDeckIndex
ld c, a
ld a, [wTempCardIDToLook]
cp c
jr z, .is_same

jr z, .found
inc b
ld a, MAX_PLAY_AREA_POKEMON
cp b
jr nz, .loop

; not found
ld b, $ff
or a
ret

.is_same
.found
ld a, b
scf
ret
Expand Down Expand Up @@ -807,7 +818,7 @@ LookForCardIDToTradeWithDifferentHandCard:
ld a, [wTempAI]
ld e, a
ld a, CARD_LOCATION_DECK
call LookForCardIDInLocation
call LookForCardIDInLocation_Bank8
jr nc, .no_carry

; store its deck index
Expand Down
Loading