Skip to content

Commit

Permalink
Merge pull request #153 from Sha0den/master
Browse files Browse the repository at this point in the history
Miscellaneous labels
  • Loading branch information
dannye authored Oct 3, 2024
2 parents 6538bde + d1dd98c commit e4cf3fc
Show file tree
Hide file tree
Showing 41 changed files with 486 additions and 442 deletions.
4 changes: 4 additions & 0 deletions src/constants/text_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ DEF TX_CTRL_END EQU $10
; wFontWidth constants
DEF FULL_WIDTH EQU $0
DEF HALF_WIDTH EQU $1 ; non-0

; wLineSeparation constants
DEF DOUBLE_SPACED EQU 0
DEF SINGLE_SPACED EQU 1 ; non-0
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, SINGLE_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, 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 'ClearMemory_Bank2',
; 'ClearMemory_Bank5' and 'ClearMemory_Bank6'.
; 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

0 comments on commit e4cf3fc

Please sign in to comment.