summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxCrystal <rgr.crystal@gmail.com>2018-02-22 19:41:55 +0100
committerxCrystal <rgr.crystal@gmail.com>2018-02-22 19:41:55 +0100
commit46416da9fa3e33738fce25bbd79d9b61476b5164 (patch)
treef07535871e6efa7606a520f8ad6cafdf071c6ea2 /src
parentd543a896fd381046dee795f3020237d6da623a9e (diff)
More duel related disassembly and more DUELVAR constants
Diffstat (limited to 'src')
-rw-r--r--src/constants/card_data_constants.asm40
-rw-r--r--src/constants/duel_constants.asm23
-rw-r--r--src/engine/bank1.asm18
-rw-r--r--src/engine/bank8.asm2
-rw-r--r--src/engine/effect_functions.asm4
-rw-r--r--src/engine/home.asm321
-rw-r--r--src/macros/wram.asm6
-rw-r--r--src/wram.asm70
8 files changed, 342 insertions, 142 deletions
diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm
index d5a44bf..fb17a53 100644
--- a/src/constants/card_data_constants.asm
+++ b/src/constants/card_data_constants.asm
@@ -64,7 +64,7 @@ CARD_DATA_UNKNOWN2 EQU $40
PKMN_CARD_DATA_LENGTH EQU $41
-; generic type constants
+; generic type (color) constants
const_def
const FIRE ; $0
const GRASS ; $1
@@ -78,25 +78,25 @@ NUM_COLORED_TYPES EQU const_value
NUM_TYPES EQU const_value
; CARD_DATA_TYPE constants
-TYPE_PKMN_FIRE EQUS "FIRE"
-TYPE_PKMN_GRASS EQUS "GRASS"
-TYPE_PKMN_LIGHTNING EQUS "LIGHTNING"
-TYPE_PKMN_WATER EQUS "WATER"
-TYPE_PKMN_FIGHTING EQUS "FIGHTING"
-TYPE_PKMN_PSYCHIC EQUS "PSYCHIC"
-TYPE_PKMN_COLORLESS EQUS "COLORLESS"
-TYPE_PKMN_UNUSED EQUS "UNUSED_TYPE"
+TYPE_PKMN_FIRE EQU FIRE
+TYPE_PKMN_GRASS EQU GRASS
+TYPE_PKMN_LIGHTNING EQU LIGHTNING
+TYPE_PKMN_WATER EQU WATER
+TYPE_PKMN_FIGHTING EQU FIGHTING
+TYPE_PKMN_PSYCHIC EQU PSYCHIC
+TYPE_PKMN_COLORLESS EQU COLORLESS
+TYPE_PKMN_UNUSED EQU UNUSED_TYPE
const_def TYPE_PKMN_UNUSED + 1 - TYPE_PKMN_FIRE
- const TYPE_ENERGY_FIRE ; $8
- const TYPE_ENERGY_GRASS ; $9
- const TYPE_ENERGY_LIGHTNING ; $A
- const TYPE_ENERGY_WATER ; $B
- const TYPE_ENERGY_FIGHTING ; $C
- const TYPE_ENERGY_PSYCHIC ; $D
- const TYPE_ENERGY_DOUBLE_COLORLESS ; $E
- const TYPE_ENERGY_UNUSED ; $F
- const TYPE_TRAINER ; $10
- const TYPE_TRAINER_UNUSED ; $11
+ const TYPE_ENERGY_FIRE ; $08
+ const TYPE_ENERGY_GRASS ; $09
+ const TYPE_ENERGY_LIGHTNING ; $0a
+ const TYPE_ENERGY_WATER ; $0b
+ const TYPE_ENERGY_FIGHTING ; $0c
+ const TYPE_ENERGY_PSYCHIC ; $0d
+ const TYPE_ENERGY_DOUBLE_COLORLESS ; $0e
+ const TYPE_ENERGY_UNUSED ; $0f
+ const TYPE_TRAINER ; $10
+ const TYPE_TRAINER_UNUSED ; $11
NUM_CARD_TYPES EQU const_value + -1
TYPE_PKMN EQU %111
@@ -107,7 +107,7 @@ TYPE_TRAINER_F EQU 4
CIRCLE EQU $0
DIAMOND EQU $1
STAR EQU $2
-PROMOSTAR EQU $FF
+PROMOSTAR EQU $ff
; CARD_DATA_SET constants (set 1)
COLOSSEUM EQU $00
diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm
index 956f84d..ebbb4c9 100644
--- a/src/constants/duel_constants.asm
+++ b/src/constants/duel_constants.asm
@@ -1,7 +1,7 @@
-DECK_NAME_SIZE EQU 24
-DECK_SIZE EQU 60
-BENCH_SIZE EQU 5
-MAX_POKEMON_IN_PLAY EQU 6 ; arena + bench
+DECK_NAME_SIZE EQU 24
+DECK_SIZE EQU 60
+MAX_BENCH_POKEMON EQU 5
+MAX_PLAY_AREA_POKEMON EQU 6 ; arena + bench
; hWhoseTurn constants
PLAYER_TURN EQUS "HIGH(wPlayerDuelVariables)"
@@ -35,11 +35,17 @@ DUELVARS_BENCH2_CARD_HP EQUS "LOW(wPlayerBench2CardHP)"
DUELVARS_BENCH3_CARD_HP EQUS "LOW(wPlayerBench3CardHP)" ; cb
DUELVARS_BENCH4_CARD_HP EQUS "LOW(wPlayerBench4CardHP)" ; cc
DUELVARS_BENCH5_CARD_HP EQUS "LOW(wPlayerBench5CardHP)" ; cd
+DUELVARS_ARENA_CARD_CHANGED_TYPE EQUS "LOW(wPlayerArenaCardChangedType)" ; d4
+DUELVARS_BENCH1_CARD_CHANGED_TYPE EQUS "LOW(wPlayerBench1CardChangedType)" ; d5
+DUELVARS_BENCH2_CARD_CHANGED_TYPE EQUS "LOW(wPlayerBench2CardChangedType)" ; d6
+DUELVARS_BENCH3_CARD_CHANGED_TYPE EQUS "LOW(wPlayerBench3CardChangedType)" ; d7
+DUELVARS_BENCH4_CARD_CHANGED_TYPE EQUS "LOW(wPlayerBench4CardChangedType)" ; d8
+DUELVARS_BENCH5_CARD_CHANGED_TYPE EQUS "LOW(wPlayerBench5CardChangedType)" ; d9
DUELVARS_ARENA_CARD_SUBSTATUS1 EQUS "LOW(wPlayerArenaCardSubstatus1)" ; e7
DUELVARS_ARENA_CARD_SUBSTATUS2 EQUS "LOW(wPlayerArenaCardSubstatus2)" ; e8
-DUELVARS_ARENA_CARD_SUBSTATUS3 EQUS "LOW(wPlayerArenaCardSubstatus3)" ; e9
-DUELVARS_ARENA_CARD_SUBSTATUS4 EQUS "LOW(wPlayerArenaCardSubstatus4)" ; ea
-DUELVARS_ARENA_CARD_SUBSTATUS5 EQUS "LOW(wPlayerArenaCardSubstatus5)" ; eb
+DUELVARS_ARENA_CARD_CHANGED_WEAKNESS EQUS "LOW(wPlayerArenaCardChangedWeakness)" ; e9
+DUELVARS_ARENA_CARD_CHANGED_RESISTANCE EQUS "LOW(wPlayerArenaCardChangedResistance)" ; ea
+DUELVARS_ARENA_CARD_SUBSTATUS3 EQUS "LOW(wPlayerArenaCardSubstatus3)" ; eb
DUELVARS_PRIZES EQUS "LOW(wPlayerPrizes)" ; ec
DUELVARS_NUMBER_OF_CARDS_IN_DISCARD_PILE EQUS "LOW(wPlayerNumberOfCardsInDiscardPile)" ; ed
DUELVARS_NUMBER_OF_CARDS_IN_HAND EQUS "LOW(wPlayerNumberOfCardsInHand)" ; ee
@@ -108,7 +114,8 @@ SUBSTATUS2_UNABLE_RETREAT EQU $09
SUBSTATUS2_BONE_ATTACK EQU $0b
SUBSTATUS2_GROWL EQU $12
-SUBSTATUS5_THIS_TURN_DOUBLE_DAMAGE EQU 0
+SUBSTATUS3_THIS_TURN_DOUBLE_DAMAGE EQU 0
+SUBSTATUS3_HEADACHE EQU 1
; wNoDamageOrEffect constants
NO_DAMAGE_OR_EFFECT_AGILITY EQU $01
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm
index 47873bc..73c1a8a 100644
--- a/src/engine/bank1.asm
+++ b/src/engine/bank1.asm
@@ -123,7 +123,7 @@ StartDuel: ; 409f (1:409f)
.main_duel_loop ; 40ee (1:40ee)
xor a
ld [wCurrentDuelMenuItem], a
- call HandleSwordsDanceOrFocusEnergySubstatus
+ call UpdateSubstatusConditions_StartOfTurn
call $54c8
call HandleTurn
@@ -132,7 +132,7 @@ StartDuel: ; 409f (1:409f)
ld a, [wDuelFinished]
or a
jr nz, .duel_finished
- call UpdateSubstatusConditions
+ call UpdateSubstatusConditions_EndOfTurn
call $6baf
call Func_3b31
call Func_0f58
@@ -306,7 +306,7 @@ HandleTurn: ; 4225 (1:4225)
cp DUELIST_TYPE_PLAYER
jr z, Func_4262
call SwapTurn
- call Func_34e2
+ call IsClairvoyanceActive
call SwapTurn
call c, $4b2c
jr DuelMainScene
@@ -470,7 +470,7 @@ PlayerActivePokemonScreen: ; 4370 (1:4370)
Func_4376: ; 4376 (1:4376)
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
- cp $ff
+ cp -1
ret z
call GetCardIDFromDeckIndex
call LoadCardDataToBuffer1
@@ -1193,7 +1193,7 @@ Func_4cd5: ; 4cd5 (1:4cd5)
ret
.asm_4d12
- jp Func_0f35
+ jp DuelTransmissionError
.asm_4d15
call EmptyScreen
@@ -1235,7 +1235,7 @@ Func_4cd5: ; 4cd5 (1:4cd5)
jr c, .asm_4d8e
ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY
call GetTurnDuelistVariable
- cp MAX_POKEMON_IN_PLAY
+ cp MAX_PLAY_AREA_POKEMON
jr nc, .asm_4d86
ldh a, [hTempCardIndex_ff98]
call Func_1485
@@ -1341,7 +1341,7 @@ AIMakeDecision: ; 67be (1:67be)
INCROM $67fb, $695e
AIActionTable: ; 695e (1:695e)
- dw Func_0f35
+ dw DuelTransmissionError
dw $69e0
dw $69c5
dw AIUseEnergyCard
@@ -1476,9 +1476,9 @@ InitializeDuelVariables: ; 7107 (1:7107)
dec c
jr nz, .init_duel_variables_loop
ld l, DUELVARS_ARENA_CARD
- ld c, 1 + BENCH_SIZE + 1
+ ld c, 1 + MAX_BENCH_POKEMON + 1
.init_play_area
-; initialize to $ff card in arena as well as cards in bench (plus a terminator?)
+; initialize to $ff card in arena as well as cards in bench (plus a terminator)
ld [hl], $ff
inc l
dec c
diff --git a/src/engine/bank8.asm b/src/engine/bank8.asm
index dd3026f..8923a9e 100644
--- a/src/engine/bank8.asm
+++ b/src/engine/bank8.asm
@@ -48,7 +48,7 @@ Func_200e5: ; 200e5 (8:40e5)
ldh [hTempCardIndex_ff9f], a
bank1call $35a9
jp c, $41a8
- call Func_1944
+ call LoadNonPokemonCardEffectCommands
ld a, $1
call TryExecuteEffectCommandFunction
jp c, $41a8
diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm
index 22d7cec..45aad3b 100644
--- a/src/engine/effect_functions.asm
+++ b/src/engine/effect_functions.asm
@@ -44,12 +44,12 @@ ApplyStatusEffect:
jr z, .cant_induce_status
cp MYSTERIOUS_FOSSIL
jr z, .cant_induce_status
- ; snorlax's thick skinned prevents it from being statused...
+ ; Snorlax's Thick Skinned prevents it from being statused...
cp SNORLAX
jr nz, .can_induce_status
call SwapTurn
xor a
- ; ...unless already so, or if affected by muk's toxic gas
+ ; ...unless already so, or if affected by Muk's Toxic Gas
call CheckIfUnderAnyCannotUseStatus2
call SwapTurn
jr c, .can_induce_status
diff --git a/src/engine/home.asm b/src/engine/home.asm
index a889228..0903aec 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -2452,7 +2452,7 @@ Func_0ed5: ; 0ed5 (0:0ed5)
INCROM $0ef1, $0f35
-Func_0f35: ; 0f35 (0:0f35)
+DuelTransmissionError: ; 0f35 (0:0f35)
ld a, [wSerialFlags]
ld l, a
ld h, $0
@@ -2490,7 +2490,7 @@ Func_0f58: ; 0f58 (0:0f58)
.asm_f76
ld c, $3
call Func_0e63
- jp c, Func_0f35
+ jp c, DuelTransmissionError
ret
; sets hAIActionTableIndex to an AI action specified in register a
@@ -2568,7 +2568,7 @@ Func_0fac: ; 0fac (0:0fac)
ld hl, wcbed
ld bc, $0008
call Func_0ebf
- jp c, Func_0f35
+ jp c, DuelTransmissionError
pop bc
pop de
pop hl
@@ -2581,7 +2581,7 @@ Func_0fe9: ; 0fe9 (0:0fe9)
ld bc, $0008
push hl
call Func_0ed5
- jp c, Func_0f35
+ jp c, DuelTransmissionError
pop hl
ld e, [hl]
inc hl
@@ -3298,7 +3298,7 @@ Func_1485: ; 1485 (0:1485)
push af
ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY
call GetTurnDuelistVariable
- cp MAX_POKEMON_IN_PLAY
+ cp MAX_PLAY_AREA_POKEMON
jr nc, .already_max_pkmn_in_play
inc [hl]
ld e, a
@@ -3424,7 +3424,7 @@ GetAttachedEnergies: ; 159f (0:159f)
; returns in a how many times card e can be found in location b
; e = card id to search
-; b = location to consider (deck, hand, arena...)
+; b = location to consider (CARD_LOCATION_*)
; h = PLAYER_TURN or OPPONENT_TURN
CountCardIDInLocation: ; 15ef (0:15ef)
push bc
@@ -3433,15 +3433,15 @@ CountCardIDInLocation: ; 15ef (0:15ef)
.next_card
ld a, [hl]
cp b
- jr nz, .unmatching_card_location_orID
+ jr nz, .unmatching_card_location_or_ID
ld a, l
push hl
call _GetCardIDFromDeckIndex
cp e
pop hl
- jr nz, .unmatching_card_location_orID
+ jr nz, .unmatching_card_location_or_ID
inc c
-.unmatching_card_location_orID
+.unmatching_card_location_or_ID
inc l
ld a, l
cp DECK_SIZE
@@ -3475,7 +3475,7 @@ GetNonTurnDuelistVariable: ; 1611 (0:1611)
INCROM $161e, $16c0
-; copies from card identified by register d (0-59):
+; copies from card identified by register d (0-59 deck index):
; - Move1 (if e == 0) or Move2 (if e == 1) data into wLoadedMove
; - Also from that move, its Damage field into wDamage
CopyMoveDataAndDamage: ; 16c0 (0:16c0)
@@ -3775,12 +3775,12 @@ CheckSelfConfusionDamage: ; 18d7 (0:18d7)
INCROM $18f9, $1944
-; this loads HP and Stage (1 byte each) of the card with deck index (0-59) at hTempCardIndex_ff9f
+; loads the effect commands of a (trainer or energy) card with deck index (0-59) at hTempCardIndex_ff9f
; into wLoadedMoveEffectCommands
-Func_1944: ; 1944 (0:1944)
+LoadNonPokemonCardEffectCommands: ; 1944 (0:1944)
ldh a, [hTempCardIndex_ff9f]
call LoadDeckCardToBuffer1
- ld hl, wLoadedCard1HP
+ ld hl, wLoadedCard1EffectCommands
ld de, wLoadedMoveEffectCommands
ld a, [hli]
ld [de], a
@@ -3851,7 +3851,7 @@ Func_1994: ; 1994 (0:1994)
or d
ret z
ldh a, [hTempPlayAreaLocationOffset_ff9d]
- call Func_36f7
+ call GetPlayAreaCardColor
call Func_1a0e
ld b, a
call SwapTurn
@@ -3914,7 +3914,7 @@ Func_1a22: ; 1a22 (0:1a22)
ld d, [hl]
dec hl
ld e, [hl]
- call Func_36f6
+ call GetArenaCardColor
call Func_1a0e
ld b, a
call GetArenaPokemonWeakness
@@ -5723,7 +5723,7 @@ CardTypeToSymbolID: ; 2988 (0:2988)
ld a, 11
ret
.pokemon_card
- ld a, [wLoadedCard1Stage]
+ ld a, [wLoadedCard1Stage] ; different symbol for each evolution stage
add 8
ret
; 0x299f
@@ -7172,9 +7172,9 @@ Func_3212: ; 3212 (0:3212)
; doubles the damage at de if swords dance or focus energy was used in the last turn
HandleDoubleDamageSubstatus: ; 321d (0:321d)
- ld a, DUELVARS_ARENA_CARD_SUBSTATUS5
+ ld a, DUELVARS_ARENA_CARD_SUBSTATUS3
call GetTurnDuelistVariable
- bit SUBSTATUS5_THIS_TURN_DOUBLE_DAMAGE, [hl]
+ bit SUBSTATUS3_THIS_TURN_DOUBLE_DAMAGE, [hl]
call nz, DoubleDamageAtDE
ld a, DUELVARS_ARENA_CARD_SUBSTATUS1
call GetTurnDuelistVariable
@@ -7511,13 +7511,14 @@ NoDamageOrEffectTextPointerTable: ; 34d8 (0:34d8)
tx NoDamageOrEffectDueToNShieldText ; NO_DAMAGE_OR_EFFECT_NSHIELD
; 0x34e2
-Func_34e2: ; 34e2 (0:34e2)
- ld a, $27
- call Func_3509
+; return carry if turn holder has Omanyte and its Clairvoyance Pkmn Power is active
+IsClairvoyanceActive: ; 34e2 (0:34e2)
+ ld a, MUK
+ call CountPokemonIDInBothPlayAreas
ccf
ret nc
- ld a, $5c
- call Func_3525
+ ld a, OMANYTE
+ call CountPokemonIDInPlayArea
ret
; returns carry if paralyzed, asleep, confused, and/or toxic gas in play,
@@ -7537,81 +7538,183 @@ CheckIfUnderAnyCannotUseStatus2: ; 34f0 (0:34f0)
jr nz, .done ; return carry
.check_toxic_gas
ld a, MUK
- call Func_3509
+ call CountPokemonIDInBothPlayAreas
ldtx hl, UnableDueToToxicGasText
.done
ret
-Func_3509: ; 3509 (0:3509)
+; return, in a, the amount of times that the Pokemon card with a given ID is found in the
+; play area of both duelists. Also return carry if the Pokemon card is at least found once.
+; if the arena Pokemon is asleep, confused, or paralyzed (Pkmn Power-incapable), it doesn't count.
+; input: a = Pokemon card ID to search
+CountPokemonIDInBothPlayAreas: ; 3509 (0:3509)
push bc
- ld [wce7c], a
- call Func_3525
+ ld [wTempPokemonID], a
+ call CountPokemonIDInPlayArea
ld c, a
call SwapTurn
- ld a, [wce7c]
- call Func_3525
+ ld a, [wTempPokemonID]
+ call CountPokemonIDInPlayArea
call SwapTurn
add c
or a
scf
- jr nz, .asm_3523
+ jr nz, .found
or a
-.asm_3523
+.found
pop bc
ret
-Func_3525: ; 3525 (0:3525)
+; return, in a, the amount of times that the Pokemon card with a given ID is found in the
+; turn holder's play area. Also return carry if the Pokemon card is at least found once.
+; if the arena Pokemon is asleep, confused, or paralyzed (Pkmn Power-incapable), it doesn't count.
+; input: a = Pokemon card ID to search
+CountPokemonIDInPlayArea: ; 3525 (0:3525)
push hl
push de
push bc
- ld [wce7c], a
+ ld [wTempPokemonID], a
ld c, $0
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
- cp $ff
- jr z, .asm_3549
+ cp -1
+ jr z, .check_bench
call GetCardIDFromDeckIndex
- ld a, [wce7c]
+ ld a, [wTempPokemonID]
cp e
- jr nz, .asm_3549
+ jr nz, .check_bench
ld a, DUELVARS_ARENA_CARD_STATUS
call GetTurnDuelistVariable
and PASSIVE_STATUS_MASK
- jr nz, .asm_3549
+ jr nz, .check_bench
inc c
-.asm_3549
+.check_bench
ld a, DUELVARS_BENCH
call GetTurnDuelistVariable
-.asm_354e
+.next_bench_slot
ld a, [hli]
- cp $ff
- jr z, .asm_3560
+ cp -1
+ jr z, .done
call GetCardIDFromDeckIndex
- ld a, [wce7c]
+ ld a, [wTempPokemonID]
cp e
- jr nz, .asm_355d
+ jr nz, .skip
inc c
-.asm_355d
+.skip
inc b
- jr .asm_354e
-.asm_3560
+ jr .next_bench_slot
+.done
ld a, c
or a
scf
- jr nz, .asm_3566
+ jr nz, .found
or a
-.asm_3566
+.found
pop bc
pop de
pop hl
ret
; 0x356a
- INCROM $356a, $35e6
+; return, in a, the retreat cost of the card in wLoadedCard1,
+; adjusting for any Dodrio's Retreat Aid Pkmn Power that is active.
+GetLoadedCard1RetreatCost: ; 356a (0:356a)
+ ld c, 0
+ ld a, DUELVARS_BENCH
+ call GetTurnDuelistVariable
+.check_bench_loop
+ ld a, [hli]
+ cp -1
+ jr z, .no_more_bench
+ call GetCardIDFromDeckIndex
+ ld a, e
+ cp DODRIO
+ jr nz, .not_dodrio
+ inc c
+.not_dodrio
+ jr .check_bench_loop
+.no_more_bench
+ ld a, c
+ or a
+ jr nz, .dodrio_found
+.muk_found
+ ld a, [wLoadedCard1RetreatCost] ; return regular retreat cost
+ ret
+.dodrio_found
+ ld a, MUK
+ call CountPokemonIDInBothPlayAreas
+ jr c, .muk_found
+ ld a, [wLoadedCard1RetreatCost]
+ sub c ; apply Retreat Aid for each Pkmn Power-capable Dodrio
+ ret nc
+ xor a
+ ret
+; 0x3597
+
+; return carry if the turn holder's active Pokemon is affected by Acid and can't retreat
+CheckCantRetreatDueToAcid: ; 3597 (0:3597)
+ ld a, DUELVARS_ARENA_CARD_SUBSTATUS2
+ call GetTurnDuelistVariable
+ or a
+ ret z
+ cp SUBSTATUS2_UNABLE_RETREAT
+ jr z, .cant_retreat
+ or a
+ ret
+.cant_retreat
+ ldtx hl, UnableToRetreatDueToAcidText
+ scf
+ ret
+; 0x35a9
+
+; return carry if the turn holder's active Pokemon is affected by Headache and trainer cards can't be used
+CheckCantUseTrainerDueToHeadache: ; 35a9 (0:35a9)
+ ld a, DUELVARS_ARENA_CARD_SUBSTATUS3
+ call GetTurnDuelistVariable
+ or a
+ bit SUBSTATUS3_HEADACHE, [hl]
+ ret z
+ ldtx hl, UnableToUseTrainerDueToHeadacheText
+ scf
+ ret
+; 0x35b7
+
+; return carry if turn holder has Aerodactyl and its Prehistoric Power Pkmn Power is active
+IsPrehistoricPowerActive: ; 35b7 (0:35b7)
+ ld a, AERODACTYL
+ call CountPokemonIDInBothPlayAreas
+ ret nc
+ ld a, MUK
+ call CountPokemonIDInBothPlayAreas
+ ldtx hl, UnableToEvolveDueToPrehistoricPowerText
+ ccf
+ ret
+; 0x35c7
+
+; clears some substatus 2 conditions from the turn holder's active Pokemon
+Func_35c7: ; 35c7 (0:35c7)
+ ld a, DUELVARS_ARENA_CARD_SUBSTATUS2
+ call GetTurnDuelistVariable
+ or a
+ ret z
+ cp SUBSTATUS2_REDUCE_BY_20
+ jr z, .zero
+ cp SUBSTATUS2_POUNCE
+ jr z, .zero
+ cp SUBSTATUS2_GROWL
+ jr z, .zero
+ cp SUBSTATUS2_TAIL_WAG
+ jr z, .zero
+ cp SUBSTATUS2_LEER
+ jr z, .zero
+ ret
+.zero
+ ld [hl], 0
+ ret
+; 0x35e6
-; if swords dance or focus energy was used this turn,
-; mark that the base power of the next turn's attack has to be doubled
-HandleSwordsDanceOrFocusEnergySubstatus: ; 35e6 (0:35e6)
+; clears the substatus 1 and updates the double damage condition of the player about to start his turn
+UpdateSubstatusConditions_StartOfTurn: ; 35e6 (0:35e6)
ld a, DUELVARS_ARENA_CARD_SUBSTATUS1
call GetTurnDuelistVariable
ld [hl], $0
@@ -7619,16 +7722,16 @@ HandleSwordsDanceOrFocusEnergySubstatus: ; 35e6 (0:35e6)
ret z
cp SUBSTATUS1_NEXT_TURN_DOUBLE_DAMAGE
ret nz
- ld a, DUELVARS_ARENA_CARD_SUBSTATUS5
+ ld a, DUELVARS_ARENA_CARD_SUBSTATUS3
call GetTurnDuelistVariable
- set SUBSTATUS5_THIS_TURN_DOUBLE_DAMAGE, [hl]
+ set SUBSTATUS3_THIS_TURN_DOUBLE_DAMAGE, [hl]
ret
-; clears the substatus 2 and updates the double damage condition of the turn holder
-UpdateSubstatusConditions: ; 35fa (0:35fa)
- ld a, DUELVARS_ARENA_CARD_SUBSTATUS5
+; clears the substatus 2, Headache, and updates the double damage condition of the player ending his turn
+UpdateSubstatusConditions_EndOfTurn: ; 35fa (0:35fa)
+ ld a, DUELVARS_ARENA_CARD_SUBSTATUS3
call GetTurnDuelistVariable
- res 1, [hl]
+ res SUBSTATUS3_HEADACHE, [hl]
push hl
ld a, DUELVARS_ARENA_CARD_SUBSTATUS2
call GetTurnDuelistVariable
@@ -7639,11 +7742,39 @@ UpdateSubstatusConditions: ; 35fa (0:35fa)
pop hl
cp SUBSTATUS1_NEXT_TURN_DOUBLE_DAMAGE
ret z
- res SUBSTATUS5_THIS_TURN_DOUBLE_DAMAGE, [hl]
+ res SUBSTATUS3_THIS_TURN_DOUBLE_DAMAGE, [hl]
ret
; 0x3615
- INCROM $3615, $363b
+; return carry if turn holder has Blastoise and its Rain Dance Pkmn Power is active
+IsRainDanceActive: ; 3615 (0:3615)
+ ld a, BLASTOISE
+ call CountPokemonIDInPlayArea
+ ret nc ; return if no Pkmn Power-capable Blastoise found in turn holder's play area
+ ld a, MUK
+ call CountPokemonIDInBothPlayAreas
+ ccf
+ ret
+; 0x3622
+
+; return carry if card at [hTempCardIndex_ff98] is a water energy card AND
+; if card at [hTempPlayAreaLocationOffset_ff9d] is a water Pokemon card.
+Func_3622: ; 3622 (0:3622)
+ ldh a, [hTempCardIndex_ff98]
+ call GetCardIDFromDeckIndex
+ call GetCardType
+ cp TYPE_ENERGY_WATER
+ jr nz, .done
+ ldh a, [hTempPlayAreaLocationOffset_ff9d]
+ call GetPlayAreaCardColor
+ cp TYPE_PKMN_WATER
+ jr nz, .done
+ scf
+ ret
+.done
+ or a
+ ret
+; 0x363b
; if the target card's HP is 0 and the attacking card's HP is not,
; the attacking card faints if it was affected by destiny bond
@@ -7657,7 +7788,7 @@ HandleDestinyBondSubstatus: ; 363b (0:363b)
.check_hp
ld a, DUELVARS_ARENA_CARD
call GetNonTurnDuelistVariable
- cp $ff
+ cp -1
ret z
ld a, DUELVARS_ARENA_CARD_HP
call GetNonTurnDuelistVariable
@@ -7740,38 +7871,62 @@ ApplyStrikesBack: ; 36a2 (0:36a2)
ret
; 0x36d9
- INCROM $36d9, $36f6
+; if the id of the card provided in register a as a deck index is Muk,
+; clear the changed type of all arena and bench Pokemon
+ClearChangedTypesIfMuk: ; 36d9 (0:36d9)
+ call GetCardIDFromDeckIndex
+ ld a, e
+ cp MUK
+ ret nz
+ call SwapTurn
+ call .zero_changed_types
+ call SwapTurn
+.zero_changed_types
+ ld a, DUELVARS_ARENA_CARD_CHANGED_TYPE
+ call GetTurnDuelistVariable
+ ld c, MAX_PLAY_AREA_POKEMON
+.zero_changed_types_loop
+ xor a
+ ld [hli], a
+ dec c
+ jr nz, .zero_changed_types_loop
+ ret
+; 0x36f6
-Func_36f6: ; 36f6 (0:36f6)
+; return the arena card's color in a, accounting for Venomoth's Shift Pokemon Power if active
+GetArenaCardColor: ; 36f6 (0:36f6)
xor a
+; fallthrough
-Func_36f7: ; 36f7 (0:36f7)
+; input: a = play area location offset of the desired card
+; return the card's color in a, accounting for Venomoth's Shift Pokemon Power if active
+GetPlayAreaCardColor: ; 36f7 (0:36f7)
push hl
push de
ld e, a
- add $d4
+ add DUELVARS_ARENA_CARD_CHANGED_TYPE
call GetTurnDuelistVariable
bit 7, a
- jr nz, .asm_3718
-.has_status
+ jr nz, .has_changed_color
+.regular_color
ld a, e
add DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
call GetCardIDFromDeckIndex
call GetCardType
cp TYPE_TRAINER
- jr nz, .asm_3715
- ld a, $6
-.asm_3715
+ jr nz, .got_type
+ ld a, COLORLESS
+.got_type
pop de
pop hl
ret
-.asm_3718
+.has_changed_color
ld a, e
call CheckIfUnderAnyCannotUseStatus2
- jr c, .has_status
+ jr c, .regular_color ; jump if can't use Shift
ld a, e
- add $d4
+ add DUELVARS_ARENA_CARD_CHANGED_TYPE
call GetTurnDuelistVariable
pop de
pop hl
@@ -7780,17 +7935,18 @@ Func_36f7: ; 36f7 (0:36f7)
; 0x3729
; return in a the weakness of the arena Pokemon (a == 0) or of a bench Pokemon (a > 0)
-; if a == 0 and [DUELVARS_ARENA_CARD_SUBSTATUS3] != 0, return [DUELVARS_ARENA_CARD_SUBSTATUS3] instead
+; if a == 0 and [DUELVARS_ARENA_CARD_CHANGED_WEAKNESS] != 0,
+; return [DUELVARS_ARENA_CARD_CHANGED_WEAKNESS] instead
GetPlayAreaPokemonWeakness: ; 3729 (0:3729)
or a
jr z, GetArenaPokemonWeakness
add DUELVARS_ARENA_CARD
jr GetPokemonWeakness
-; return [DUELVARS_ARENA_CARD_SUBSTATUS3] in a
-; if [DUELVARS_ARENA_CARD_SUBSTATUS3] == 0, return the Pokemon's weakness value instead
+; return in a the weakness of the arena Pokemon
+; if [DUELVARS_ARENA_CARD_CHANGED_WEAKNESS] != 0, return it instead
GetArenaPokemonWeakness: ; 3730 (0:3730)
- ld a, DUELVARS_ARENA_CARD_SUBSTATUS3
+ ld a, DUELVARS_ARENA_CARD_CHANGED_WEAKNESS
call GetTurnDuelistVariable
or a
ret nz
@@ -7805,17 +7961,18 @@ GetPokemonWeakness:
; 0x3743
; return in a the resistance of the arena Pokemon (a == 0) or of a bench Pokemon (a > 0)
-; if a == 0 and [DUELVARS_ARENA_CARD_SUBSTATUS4] != 0, return [DUELVARS_ARENA_CARD_SUBSTATUS4] instead
+; if a == 0 and [DUELVARS_ARENA_CARD_CHANGED_RESISTANCE] != 0,
+; return [DUELVARS_ARENA_CARD_CHANGED_RESISTANCE] instead
GetPlayAreaPokemonResistance: ; 3743 (0:3743)
or a
jr z, GetArenaPokemonResistance
add DUELVARS_ARENA_CARD
jr GetPokemonResistance
-; return [DUELVARS_ARENA_CARD_SUBSTATUS4] in a
-; if [DUELVARS_ARENA_CARD_SUBSTATUS4] == 0, return the Pokemon's resistance value instead
+; return in a the resistance of the arena Pokemon
+; if [DUELVARS_ARENA_CARD_CHANGED_RESISTANCE] != 0, return it instead
GetArenaPokemonResistance: ; 374a (0:374a)
- ld a, DUELVARS_ARENA_CARD_SUBSTATUS4
+ ld a, DUELVARS_ARENA_CARD_CHANGED_RESISTANCE
call GetTurnDuelistVariable
or a
ret nz
diff --git a/src/macros/wram.asm b/src/macros/wram.asm
index 9a7ffc2..9825a36 100644
--- a/src/macros/wram.asm
+++ b/src/macros/wram.asm
@@ -5,12 +5,10 @@ card_data_struct: MACRO
\1Rarity:: db
\1Set:: db
\1ID:: db
-\1EnergyCardEffectCommands:: ; dw
-\1TrainerCardEffectCommands:: ; dw
+\1EffectCommands:: ; dw
\1HP:: db
\1Stage:: db
-\1EnergyCardDescription:: ; dw
-\1TrainerCardDescription:: ; dw
+\1NonPokemonDescription:: ; dw
\1PreEvoName:: dw
\1Move1:: move_data_struct \1Move1
\1Move2:: move_data_struct \1Move2
diff --git a/src/wram.asm b/src/wram.asm
index 4a57b98..cd7b1a0 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -53,14 +53,16 @@ wPlayerNumberOfCardsNotInDeck:: ; c2ba
ds $1
; Which card is in player's side of the field, as number 0 to 59
+; -1 indicates no pokemon
wPlayerArenaCard:: ; c2bb
ds $1
-; Which cards are in player's bench, as numbers 0 to 59
+; Which cards are in player's bench, as numbers 0 to 59, plus an $ff (-1) terminator
+; -1 indicates no pokemon
wPlayerBench:: ; c2bc
- ds BENCH_SIZE
+ ds MAX_BENCH_POKEMON + 1
- ds $7
+ ds $6
wPlayerArenaCardHP:: ; c2c8
ds $1
@@ -75,7 +77,24 @@ wPlayerBench4CardHP:: ; c2cc
wPlayerBench5CardHP:: ; c2cd
ds $1
- ds $19
+ ds $6
+
+; changed type from Venomoth's Shift Pokemon Power
+; if bit 7 == 1, then bits 0-3 override the Pokemon's actual type
+wPlayerArenaCardChangedType:: ; c2d4
+ ds $1
+wPlayerBench1CardChangedType:: ; c2d5
+ ds $1
+wPlayerBench2CardChangedType:: ; c2d6
+ ds $1
+wPlayerBench3CardChangedType:: ; c2d7
+ ds $1
+wPlayerBench4CardChangedType:: ; c2d8
+ ds $1
+wPlayerBench5CardChangedType:: ; c2d9
+ ds $1
+
+ ds $d
wPlayerArenaCardSubstatus1:: ; c2e7
ds $1
@@ -83,13 +102,15 @@ wPlayerArenaCardSubstatus1:: ; c2e7
wPlayerArenaCardSubstatus2:: ; c2e8
ds $1
-wPlayerArenaCardSubstatus3:: ; c2e9
+; changed weakness from Conversion 1
+wPlayerArenaCardChangedWeakness:: ; c2e9
ds $1
-wPlayerArenaCardSubstatus4:: ; c2ea
+; changed resistance from Conversion 2
+wPlayerArenaCardChangedResistance:: ; c2ea
ds $1
-wPlayerArenaCardSubstatus5:: ; c2eb
+wPlayerArenaCardSubstatus3:: ; c2eb
ds $1
; Each bit represents a prize (1 = not taken ; 0 = taken)
@@ -141,9 +162,9 @@ wOpponentArenaCard:: ; c3bb
ds $1
wOpponentBench:: ; c3bc
- ds BENCH_SIZE
+ ds MAX_BENCH_POKEMON + 1
- ds $7
+ ds $6
wOpponentArenaCardHP:: ; c3c8
ds $1
@@ -158,7 +179,22 @@ wOpponentBench4CardHP:: ; c3cc
wOpponentBench5CardHP:: ; c3cd
ds $1
- ds $19
+ ds $6
+
+wOpponentArenaCardChangedType:: ; c2d4
+ ds $1
+wOpponentBench1CardChangedType:: ; c2d5
+ ds $1
+wOpponentBench2CardChangedType:: ; c2d6
+ ds $1
+wOpponentBench3CardChangedType:: ; c2d7
+ ds $1
+wOpponentBench4CardChangedType:: ; c2d8
+ ds $1
+wOpponentBench5CardChangedType:: ; c2d9
+ ds $1
+
+ ds $d
wOpponentArenaCardSubstatus1:: ; c3e7
ds $1
@@ -166,13 +202,13 @@ wOpponentArenaCardSubstatus1:: ; c3e7
wOpponentArenaCardSubstatus2:: ; c3e8
ds $1
-wOpponentArenaCardSubstatus3:: ; c3e9
+wOpponentArenaCardChangedWeakness:: ; c3e9
ds $1
-wOpponentArenaCardSubstatus4:: ; c3ea
+wOpponentArenaCardChangedResistance:: ; c3ea
ds $1
-wOpponentArenaCardSubstatus5:: ; c3eb
+wOpponentArenaCardSubstatus3:: ; c3eb
ds $1
wOpponentPrizes:: ; c3ec
@@ -703,7 +739,7 @@ wTileBehindCursor:: ; cd16
ds $1
wcd17:: ; cd17
- ds 2
+ ds $2
ds $7f
@@ -798,8 +834,10 @@ wce6e:: ; ce6e
wce6f:: ; ce6f
ds $d
-wce7c:: ; ce7c
- ds $27
+wTempPokemonID:: ; ce7c
+ ds $1
+
+ ds $26
wcea3:: ; cea3
ds $c