Skip to content

Commit

Permalink
Many More Optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sha0den committed May 9, 2024
1 parent eb38cd2 commit 569060c
Show file tree
Hide file tree
Showing 36 changed files with 246 additions and 349 deletions.
3 changes: 1 addition & 2 deletions src/audio/sfx.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SFX_UpdateSFX:
SFX_Play:
ld hl, NumberOfSFX
cp [hl]
jr nc, .invalidID
ret nc ; invalid ID
add a
ld c, a
ld b, $0
Expand Down Expand Up @@ -56,7 +56,6 @@ SFX_Play:
ld a, $4
cp c
jr nz, .asm_fc031
.invalidID
ret

SFX_Update:
Expand Down
3 changes: 1 addition & 2 deletions src/engine/bank20.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ Func_80cd7:
add hl, bc
ld a, [hli]
cp $ff
jr z, .skip_draw_sprite
ret z ; skip draw sprite
farcall CreateSpriteAndAnimBufferEntry
ld a, [wConsole]
cp CONSOLE_CGB
Expand All @@ -1419,7 +1419,6 @@ Func_80cd7:
ld [hli], a
ld a, $40
ld [hl], a ; SPRITE_ANIM_COORD_Y
.skip_draw_sprite
ret

.NPCSpriteAnimData
Expand Down
6 changes: 2 additions & 4 deletions src/engine/credits.asm
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ Func_1d705:
call Func_1d7ee
ld hl, Func_3e31
call SetDoFrameFunction
call .Func_1d720 ; can be fallthrough
ret
; fallthrough

.Func_1d720
ld a, $91
Expand All @@ -53,8 +52,7 @@ Func_1d705:
ld [wd64a], a
call Func_1d765
call SetWindowOn
call .Func_1d73a ; can be fallthrough
ret
; fallthrough

.Func_1d73a
push hl
Expand Down
4 changes: 2 additions & 2 deletions src/engine/duel/ai/attacks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RetrievePlayAreaAIScoreFromBackup:
AIProcessAndTryToUseAttack:
xor a
ld [wAIExecuteProcessedAttack], a
; fallthrough
; fallthrough

; checks which of the Active card's attacks for AI to use.
; If any of the attacks has enough AI score to be used,
Expand Down Expand Up @@ -495,7 +495,7 @@ GetAIScoreOfAttack:
call SwapTurn
pop de
cp d
jr c, .set_carry
ret c
jr z, .set_carry
or a
ret
Expand Down
13 changes: 7 additions & 6 deletions src/engine/duel/ai/common.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CheckIfPlayerHasPokemonOtherThanMewtwoLv53:
pop de
ld a, [wLoadedCard2Type]
cp TYPE_ENERGY
jp nc, .next ; can be a jr
jr nc, .next
ld a, [wLoadedCard2ID]
cp MEWTWO_LV53
jr nz, .not_mewtwo1
Expand Down Expand Up @@ -51,14 +51,18 @@ HandleAIAntiMewtwoDeckStrategy:
; and return carry.
xor a
ld [wAIBarrierFlagCounter], a
jr .set_carry
; fallthrough
.set_carry
scf
ret

; else, check number of Pokemon that are set up in Bench
; if less than 4, return carry.
.count_bench
farcall CountNumberOfSetUpBenchPokemon
cp 4
jr c, .set_carry
ret c

; if there's at least 4 Pokemon in the Bench set up,
; process Trainer hand cards of AI_TRAINER_CARD_PHASE_05
Expand All @@ -67,9 +71,6 @@ HandleAIAntiMewtwoDeckStrategy:
or a
ret

.set_carry
scf
ret

; lists in wDuelTempList all the basic energy cards
; in card location of a.
Expand Down
14 changes: 7 additions & 7 deletions src/engine/duel/ai/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ CheckDamageToMrMime:
jr nz, .set_carry
ld a, b
call CheckIfCanDamageDefendingPokemon
jr c, .set_carry
ret c
or a
ret
.set_carry
Expand Down Expand Up @@ -1918,7 +1918,7 @@ AISelectSpecialAttackParameters:
; the location of card to select to devolve
ld a, [wSelectedAttack]
or a
jp z, .no_carry ; can be jr
jr z, .no_carry

ld a, $01
ldh [hTemp_ffa0], a
Expand All @@ -1932,7 +1932,7 @@ AISelectSpecialAttackParameters:
; make list from energy cards in Discard Pile
ld a, [wSelectedAttack]
or a
jp nz, .no_carry ; can be jr
jr nz, .no_carry

ld a, $ff
ldh [hTempPlayAreaLocation_ffa1], a
Expand Down Expand Up @@ -1975,7 +1975,7 @@ AISelectSpecialAttackParameters:
; decide Bench card to switch to.
ld a, [wSelectedAttack]
or a
jp nz, .no_carry ; can be jr
jr nz, .no_carry
call AIDecideBenchPokemonToSwitchTo
jr c, .no_carry
ldh [hTemp_ffa0], a
Expand All @@ -1987,20 +1987,20 @@ AISelectSpecialAttackParameters:
; decide basic energy card to fetch from Deck.
ld a, [wSelectedAttack]
or a
jp z, .no_carry ; can be jr
jr z, .no_carry

ld a, CARD_LOCATION_DECK
ld e, LIGHTNING_ENERGY

; if none were found in Deck, return carry...
call CheckIfAnyCardIDinLocation
ldh [hTemp_ffa0], a
jp nc, .no_carry ; can be jr
jr nc, .no_carry

; ...else find a suitable Play Area Pokemon to
; attach the energy card to.
call AIProcessButDontPlayEnergy_SkipEvolution
jp nc, .no_carry ; can be jr
jr nc, .no_carry
ldh a, [hTempPlayAreaLocation_ff9d]
ldh [hTempPlayAreaLocation_ffa1], a
scf
Expand Down
Loading

0 comments on commit 569060c

Please sign in to comment.