summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorElectroDeoxys <ElectroDeoxys@gmail.com>2019-09-12 08:58:08 +0100
committerElectroDeoxys <ElectroDeoxys@gmail.com>2019-09-12 08:58:08 +0100
commitfe96fdf1a5bf4fc28f44c8c9d257d063f2c9bbaa (patch)
treece2ee7334997c19a906bcd7a360a1920118150f1 /src
parent5646f1bc834dc15f74f28dce9bb43fe250f648b4 (diff)
Document CheckIfEvolutionNeedsEnergyForMove
Diffstat (limited to 'src')
-rw-r--r--src/engine/bank05.asm52
-rw-r--r--src/wram.asm5
2 files changed, 47 insertions, 10 deletions
diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm
index eeadfda..da50053 100644
--- a/src/engine/bank05.asm
+++ b/src/engine/bank05.asm
@@ -4398,8 +4398,45 @@ FindPlayAreaCardWithHighestAIScore: ; 167b5 (5:67b5)
ret
; 0x16805
-Func_16805 ; 16805 (5:6805)
- INCROM $16805, $1683b
+; returns carry if there's an evolution card
+; that can evolve card in hTempPlayAreaLocation_ff9d,
+; and that card needs energy to use wSelectedMove.
+CheckIfEvolutionNeedsEnergyForMove: ; 16805 (5:6805)
+ call CreateHandCardList
+ ldh a, [hTempPlayAreaLocation_ff9d]
+ add DUELVARS_ARENA_CARD
+ call GetTurnDuelistVariable
+ call CheckCardEvolutionInHandOrDeck
+ jr c, .has_evolution
+ or a
+ ret
+
+.has_evolution
+ ld b, a
+ ldh a, [hTempPlayAreaLocation_ff9d]
+ add DUELVARS_ARENA_CARD
+ call GetTurnDuelistVariable
+ push af
+ ld [hl], b
+ call CheckEnergyNeededForAttack
+ jr c, .not_enough_energy
+ ldh a, [hTempPlayAreaLocation_ff9d]
+ add DUELVARS_ARENA_CARD
+ call GetTurnDuelistVariable
+ pop af
+ ld [hl], a
+ or a
+ ret
+
+.not_enough_energy
+ ldh a, [hTempPlayAreaLocation_ff9d]
+ add DUELVARS_ARENA_CARD
+ call GetTurnDuelistVariable
+ pop af
+ ld [hl], a
+ scf
+ ret
+; 0x1683b
Func_1683b ; 1683b (5:683b)
INCROM $1683b, $1689f
@@ -4451,7 +4488,7 @@ Func_1689f: ; 1689f (5:689f)
ld a, MOVE_FLAG2_ADDRESS | DISCARD_ENERGY_F
call CheckLoadedMoveFlag
jr c, .energy_boost_or_discard_energy
- call Func_16805
+ call CheckIfEvolutionNeedsEnergyForMove
ret nc
call CreateEnergyCardListFromHand
@@ -5894,16 +5931,19 @@ CalculateParticularAttachedEnergyNeeded: ; 17258 (5:7258)
; 0x17274
; return carry if there is a card that
-; can evolve a Pokémon in hand or deck
+; can evolve a Pokémon in hand or deck.
; input:
-; a = deck index of card to check
+; a = deck index of card to check;
+; output:
+; a = deck index of evolution in hand, if found;
+; carry set if there's a card in hand that can evolve.
CheckCardEvolutionInHandOrDeck: ; 17274 (5:7274)
ld b, a
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
push af
ld [hl], b
- ld e, $00
+ ld e, 0
.loop
ld a, DUELVARS_CARD_LOCATIONS
diff --git a/src/wram.asm b/src/wram.asm
index f6a58fa..36ec201 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -1230,10 +1230,7 @@ wAIScore:: ; cdbe
wPlayAreaAIScore:: ; cdbf
ds MAX_PLAY_AREA_POKEMON
-wcdc0:: ; cdc0
- ds MAX_PLAY_AREA_POKEMON
-
- ds $4
+ ds $0a
; information about the defending Pokémon and
; the prize card count on both sides for AI: