summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxCrystal <rgr.crystal@gmail.com>2018-07-25 00:23:53 +0200
committerxCrystal <rgr.crystal@gmail.com>2018-07-25 00:23:53 +0200
commite10c10442021c525590af916829426497aba144d (patch)
tree45c2d55cb88b81850be422267a02e5c9138759a8 /src
parent8ef677ec6e95ff389aff3a51881ef0413ee00cd5 (diff)
More bank 0 and 1 stuff
Diffstat (limited to 'src')
-rw-r--r--src/constants/duel_constants.asm3
-rw-r--r--src/engine/bank01.asm409
-rw-r--r--src/engine/effect_functions.asm27
-rw-r--r--src/engine/home.asm48
-rw-r--r--src/text/text1.asm2
-rw-r--r--src/text/text2.asm14
-rw-r--r--src/text/text_offsets.asm16
-rw-r--r--src/wram.asm49
8 files changed, 492 insertions, 76 deletions
diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm
index eaa9a65..9171854 100644
--- a/src/constants/duel_constants.asm
+++ b/src/constants/duel_constants.asm
@@ -81,6 +81,8 @@ DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA EQUS "LOW(wPlayerNumberOfPokemonInPlayA
DUELVARS_ARENA_CARD_STATUS EQUS "LOW(wPlayerArenaCardStatus)" ; f0
DUELVARS_DUELIST_TYPE EQUS "LOW(wPlayerDuelistType)" ; f1
DUELVARS_ARENA_CARD_DISABLED_MOVE_INDEX EQUS "LOW(wPlayerArenaCardDisabledMoveIndex)" ; f2
+DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE EQUS "LOW(wPlayerArenaCardLastTurnDamage)" ; f3
+DUELVARS_ARENA_CARD_LAST_TURN_STATUS EQUS "LOW(wPlayerArenaCardLastTurnStatus)" ; f5
; card location constants (DUELVARS_CARD_LOCATIONS)
CARD_LOCATION_DECK EQU $00
@@ -123,6 +125,7 @@ POISONED EQU $80
DOUBLE_POISONED EQU $c0
CNF_SLP_PRZ EQU $0f ; confused, asleep or paralyzed
+PSN_DBLPSN EQU $f0 ; poisoned or double poisoned
; substatus conditions (DUELVARS_ARENA_CARD_SUBSTATUS*)
SUBSTATUS1_AGILITY EQU $0c
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm
index 31df46c..9108aaa 100644
--- a/src/engine/bank01.asm
+++ b/src/engine/bank01.asm
@@ -524,7 +524,7 @@ DuelMenu_Done: ; 439a (1:439a)
jp c, Func_4268
ld a, $05
call SetAIAction_SerialSendDuelData
- call Func_717a
+ call ClearNonTurnTemporaryDuelvars
ret
; triggered by selecting the "Retreat" item in the duel menu
@@ -993,7 +993,7 @@ Func_46b7: ; 46b7 (1:46b7)
.asm_46d9
ld a, [wcbfb]
inc b
- call $65b7
+ call WriteTwoDigitNumberInTxSymbolFormat
.asm_46e0
call DoFrame
call HandleCardListInput
@@ -1532,10 +1532,10 @@ Func_49ed: ; 49ed (1:49ed)
ld e, a
ld a, d
lb bc, 16, 10
- call $65b7
+ call WriteTwoDigitNumberInTxSymbolFormat
ld a, e
lb bc, 10, 10
- jp $65b7
+ jp WriteTwoDigitNumberInTxSymbolFormat
.opponent_turn
ld a, [wOpponentNumberOfCardsInHand]
ld hl, wcbe9
@@ -1549,10 +1549,10 @@ Func_49ed: ; 49ed (1:49ed)
ld e, a
ld a, d
lb bc, 5, 3
- call $65b7
+ call WriteTwoDigitNumberInTxSymbolFormat
ld a, e
lb bc, 11, 3
- jp $65b7
+ jp WriteTwoDigitNumberInTxSymbolFormat
; 0x4a35
INCROM $4a35, $4a97
@@ -1630,7 +1630,7 @@ Func_4ae9: ; 4ae9 (1:4ae9)
ld a, DECK_SIZE
sub [hl]
.asm_4b22
- call $65b7
+ call WriteTwoDigitNumberInTxSymbolFormat
ld hl, $7e
call InitTextPrinting_ProcessTextFromID
ret
@@ -3566,7 +3566,7 @@ Func_622a: ; 622a (1:622a)
jr z, .asm_624c
ld d, $0a
.asm_624c
- ld a, [wcbc9 + 1]
+ ld a, [wcbca]
ld b, $01
ld c, a
ld a, [hli]
@@ -3587,7 +3587,175 @@ UnknownData_6264: ; 6264 (1:6264)
INCROM $6264, $627c
Func_627c: ; 627c (1:627c)
- INCROM $627c, $63bb
+ call Func_62d5
+ ld a, [wcbc9]
+ ld e, a
+ ld a, [wcbca]
+ inc a
+ ld c, a
+ ld b, 7
+ call PrintPlayAreaCardAttachedEnergies
+ ld a, [wcbca]
+ inc a
+ ld c, a
+ ld b, 5
+ ld a, SYM_E
+ call WriteByteToBGMap0
+ inc c
+ ld a, SYM_HP
+ call WriteByteToBGMap0
+ ld a, [wcbc9]
+ add DUELVARS_ARENA_CARD_HP
+ call GetTurnDuelistVariable
+ or a
+ jr z, .zero_hp
+ ld e, a
+ ld a, [wLoadedCard1HP]
+ ld d, a
+ call DrawHPBar
+ ld a, [wcbca]
+ inc a
+ inc a
+ ld c, a
+ ld b, 7
+ call BCCoordToBGMap0Address
+ ld hl, wDefaultText
+ ld b, 12
+ call SafeCopyDataHLtoDE
+ ret
+.zero_hp
+ ; if fainted, print "Knock Out" in place of the HP bar
+ ld a, [wcbca]
+ inc a
+ inc a
+ ld e, a
+ ld d, 7
+ ldtx hl, KnockOutText
+ call InitTextPrinting_ProcessTextFromID
+ ret
+; 0x62d5
+
+Func_62d5: ; 62d5 (1:62d5)
+ ld a, [wcbc9]
+ add DUELVARS_ARENA_CARD
+ call GetTurnDuelistVariable
+ call LoadCardDataToBuffer1_FromDeckIndex
+ ld a, [wcbca]
+ ld e, a
+ ld d, 4
+ call InitTextPrinting
+ ld hl, wLoadedCard1Name
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wDefaultText
+ push de
+ ld a, 10 ; card name maximum length
+ call CopyTextData_FromTextID
+ pop hl
+ call ProcessText
+ ld a, [wcbca]
+ ld c, a
+ ld b, 18
+ ld a, [wcbc9]
+ call GetPlayAreaCardColor
+ inc a
+ call JPWriteByteToBGMap0
+ ld b, 14
+ ld a, SYM_Lv
+ call WriteByteToBGMap0
+ ld a, [wcbca]
+ ld c, a
+ ld b, 15
+ ld a, [wLoadedCard1Level]
+ call WriteTwoDigitNumberInTxSymbolFormat
+ ld a, [wcbc9]
+ add DUELVARS_ARENA_CARD_STAGE
+ call GetTurnDuelistVariable
+ add a
+ ld e, a
+ ld d, $00
+ ld hl, FaceDownCardTileNumbers
+ add hl, de
+ ld a, [hli] ; starting tile to fill the 2x2 rectangle with
+ push hl
+ push af
+ lb hl, 1, 2
+ lb bc, 2, 2
+ ld a, [wcbca]
+ ld e, a
+ ld d, 2
+ pop af
+ call FillRectangle
+ pop hl
+ ld a, [wConsole]
+ cp CONSOLE_CGB
+ jr nz, .not_cgb
+ ; in cgb, we have to take care of palettes too
+ ld a, [hl]
+ lb hl, 0, 0
+ lb bc, 2, 2
+ call BankswitchVRAM1
+ call FillRectangle
+ call BankswitchVRAM0
+.not_cgb
+ ld hl, wcbc9
+ ld a, [hli]
+ or a
+ jr nz, .asm_6376
+ ld c, [hl]
+ inc c
+ inc c
+ ld b, 2
+ ld a, DUELVARS_ARENA_CARD_STATUS
+ call GetTurnDuelistVariable
+ call CheckPrintCnfSlpPrz
+ inc b
+ call CheckPrintPoisoned
+ inc b
+ call CheckPrintDoublePoisoned
+.asm_6376
+ ld a, [wcbc9]
+ add DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER
+ call GetTurnDuelistVariable
+ or a
+ jr z, .not_pluspower
+ ld a, [wcbca]
+ inc a
+ ld c, a
+ ld b, 15
+ ld a, SYM_PLUSPOWER
+ call WriteByteToBGMap0
+ inc b
+ ld a, [hl]
+ add SYM_0
+ call WriteByteToBGMap0
+.not_pluspower
+ ld a, [wcbc9]
+ add DUELVARS_ARENA_CARD_ATTACHED_DEFENDER
+ call GetTurnDuelistVariable
+ or a
+ jr z, .not_defender
+ ld a, [wcbca]
+ inc a
+ ld c, a
+ ld b, 17
+ ld a, SYM_DEFENDER
+ call WriteByteToBGMap0
+ inc b
+ ld a, [hl]
+ add SYM_0
+ call WriteByteToBGMap0
+.not_defender
+ ret
+; 0x63b3
+
+FaceDownCardTileNumbers: ; 63b3 (1:63b3)
+ db $d0, $02
+ db $d4, $02
+ db $d8, $01
+ db $dc, $01
+; 0x63bb
; given a card's status in a, print the Poison symbol at bc if it's poisoned
CheckPrintPoisoned: ; 63bb (1:63bb)
@@ -3686,7 +3854,7 @@ Func_6510: ; 6510 (1:6510)
ldh a, [hTempPlayAreaLocationOffset_ff9d]
ld [wcbc9], a
xor a
- ld [wcbc9 + 1], a
+ ld [wcbca], a
call ZeroObjectPositionsAndToggleOAMCopy
call EmptyScreen
call LoadDuelCardSymbolTiles
@@ -3775,7 +3943,75 @@ AttemptRetreat: ; 657a (1:657a)
ret
; 0x659f
- INCROM $659f, $6614
+ INCROM $659f, $65b7
+
+; given a number between 0-99 in a, converts it to TX_SYMBOL format, and writes it
+; to wStringBuffer + 3 and to the BGMap0 address at bc.
+; if the number is between 0-9, the first digit is replaced with SYM_SPACE.
+WriteTwoDigitNumberInTxSymbolFormat: ; 65b7 (1:65b7)
+ push hl
+ push de
+ push bc
+ ld l, a
+ ld h, $00
+ call TwoByteNumberToTxSymbol_TrimLeadingZeros_Bank1
+ pop bc
+ push bc
+ call BCCoordToBGMap0Address
+ ld hl, wStringBuffer + 3
+ ld b, 2
+ call SafeCopyDataHLtoDE
+ pop bc
+ pop de
+ pop hl
+ ret
+; 0x65d1
+
+; convert the number at hl to TX_SYMBOL text format and write it to wStringBuffer
+; replace leading zeros with SYM_SPACE
+TwoByteNumberToTxSymbol_TrimLeadingZeros_Bank1: ; 65d1 (1:65d1)
+ ld de, wStringBuffer
+ ld bc, -10000
+ call .get_digit
+ ld bc, -1000
+ call .get_digit
+ ld bc, -100
+ call .get_digit
+ ld bc, -10
+ call .get_digit
+ ld bc, -1
+ call .get_digit
+ xor a ; TX_END
+ ld [de], a
+ ld hl, wStringBuffer
+ ld b, 4
+.digit_loop
+ ld a, [hl]
+ cp SYM_0
+ jr nz, .done ; jump if not zero
+ ld [hl], SYM_SPACE ; trim leading zero
+ inc hl
+ dec b
+ jr nz, .digit_loop
+.done
+ ret
+
+.get_digit
+ ld a, SYM_0 - 1
+.substract_loop
+ inc a
+ add hl, bc
+ jr c, .substract_loop
+ ld [de], a
+ inc de
+ ld a, l
+ sub c
+ ld l, a
+ ld a, h
+ sbc b
+ ld h, a
+ ret
+; 0x6614
; input d, e: max. HP, current HP
DrawHPBar: ; 6614 (1:6614)
@@ -4064,7 +4300,7 @@ AIAction_DrawCard: ; 698c (1:698c)
AIAction_FinishedTurnNoAttack: ; 6993 (1:6993)
call DrawDuelMainScene
- call Func_717a
+ call ClearNonTurnTemporaryDuelvars
ldtx hl, FinishedTurnWithoutAttackingText
call DrawWideTextBox_WaitForInput
ld a, 1
@@ -4193,7 +4429,7 @@ AIAction_Attack: ; 6a4e (1:6a4e)
call ExchangeRNG
call HandleSandAttackOrSmokescreenSubstatus
ret nc ; attack is successful
- call Func_717a
+ call ClearNonTurnTemporaryDuelvars
; only end the turn if the attack fails
ld a, 1
ld [wAITurnEnded], a
@@ -4424,7 +4660,116 @@ ConvertSpecialTrainerCardToPokemon: ; 6d84 (1:6d84)
db UNABLE_RETREAT ; CARD_DATA_RETREAT_COST
ds $0d ; PKMN_CARD_DATA_LENGTH - (CARD_DATA_RETREAT_COST + 1)
- INCROM $6df1, $70e6
+Func_6df1: ; 6df1 (1:6df1)
+ xor a
+ ld [wPlayerArenaCardLastTurnStatus], a
+ ld [wOpponentArenaCardLastTurnStatus], a
+ ld hl, wEffectFunctionsFeedbackIndex
+ ld a, [hl]
+ or a
+ ret z
+ ld e, [hl]
+ ld d, $00
+ ld hl, wEffectFunctionsFeedback
+ add hl, de
+ ld [hl], $00
+ call CheckNoDamageOrEffect
+ jr c, .asm_6e1b
+ ld hl, wEffectFunctionsFeedback
+.asm_6e0f
+ ld a, [hli]
+ or a
+ jr z, .asm_6e19
+ ld d, a
+ call ApplyStatusConditionToArenaPokemon
+ jr .asm_6e0f
+.asm_6e19
+ scf
+ ret
+.asm_6e1b
+ ld a, l
+ or h
+ call nz, DrawWideTextBox_PrintText
+ ld hl, wEffectFunctionsFeedback
+.asm_6e23
+ ld a, [hli]
+ or a
+ jr z, .asm_6e37
+ ld d, a
+ ld a, [wcc05]
+ cp d
+ jr z, .asm_6e32
+ inc hl
+ inc hl
+ jr .asm_6e23
+.asm_6e32
+ call ApplyStatusConditionToArenaPokemon
+ jr .asm_6e23
+.asm_6e37
+ ret
+; 0x6e38
+
+; apply the status condition at hl+1 to the arena Pokemon
+; discard the arena Pokemon's status conditions contained in the bitmask at hl
+ApplyStatusConditionToArenaPokemon: ; 6e38 (1:6e38)
+ ld e, DUELVARS_ARENA_CARD_STATUS
+ ld a, [de]
+ and [hl]
+ inc hl
+ or [hl]
+ ld [de], a
+ dec hl
+ ld e, DUELVARS_ARENA_CARD_LAST_TURN_STATUS
+ ld a, [de]
+ and [hl]
+ inc hl
+ or [hl]
+ inc hl
+ ld [de], a
+ ret
+; 0x6e49
+
+ INCROM $6e49, $700a
+
+; print one of the "There was no effect from" texts depending
+; on the value at wccf1 ($00 or a status condition constant)
+PrintThereWasNoEffectFromStatusText: ; 700a (1:700a)
+ ld a, [wccf1]
+ or a
+ jr nz, .status
+ ld hl, wLoadedMoveName
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call LoadTxRam2
+ ldtx hl, ThereWasNoEffectFromTxRam2Text
+ ret
+.status
+ ld c, a
+ ldtx hl, ThereWasNoEffectFromPoisonConfusionText
+ cp POISONED | CONFUSED
+ ret z
+ and PSN_DBLPSN
+ jr nz, .poison
+ ld a, c
+ and CNF_SLP_PRZ
+ ldtx hl, ThereWasNoEffectFromParalysisText
+ cp PARALYZED
+ ret z
+ ldtx hl, ThereWasNoEffectFromSleepText
+ cp ASLEEP
+ ret z
+ ldtx hl, ThereWasNoEffectFromConfusionText
+ ret
+.poison
+ ldtx hl, ThereWasNoEffectFromPoisonText
+ cp POISONED
+ ret z
+ ldtx hl, ThereWasNoEffectFromToxicText
+ ret
+; 0x7045
+
+ INCROM $7045, $70e6
Func_70e6: ; 70e6 (1:70e6)
xor a
@@ -4495,7 +4840,9 @@ InitializeDuelVariables: ; 7107 (1:7107)
INCROM $7133, $717a
-Func_717a: ; 717a (1:717a)
+; clear the non-turn holder's duelvars starting at DUELVARS_ARENA_CARD_DISABLED_MOVE_INDEX
+; these duelvars only last a two-player turn at most.
+ClearNonTurnTemporaryDuelvars: ; 717a (1:717a)
ld a, DUELVARS_ARENA_CARD_DISABLED_MOVE_INDEX
call GetNonTurnDuelistVariable
xor a
@@ -4510,7 +4857,33 @@ Func_717a: ; 717a (1:717a)
ret
; 0x7189
- INCROM $7189, $71ad
+; same as ClearNonTurnTemporaryDuelvars, except the non-turn holder's arena
+; Pokemon status condition is copied to wccc5
+ClearNonTurnTemporaryDuelvars_CopyStatus: ; 7189 (1:7189)
+ ld a, DUELVARS_ARENA_CARD_STATUS
+ call GetNonTurnDuelistVariable
+ ld [wccc5], a
+ call ClearNonTurnTemporaryDuelvars
+ ret
+; 0x7195
+
+Func_7195: ; 7195 (1:7195)
+ ld a, DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE
+ call GetNonTurnDuelistVariable
+ ld a, [wccef]
+ or a
+ jr nz, .asm_71a9
+ ld a, [wTempDamage_ccbf]
+ ld [hli], a
+ ld a, [wccc0]
+ ld [hl], a
+ ret
+.asm_71a9
+ xor a
+ ld [hli], a
+ ld [hl], a
+ ret
+; 0x71ad
_TossCoin: ; 71ad (1:71ad)
ld [wcd9c], a
@@ -4562,13 +4935,13 @@ _TossCoin: ; 71ad (1:71ad)
ld bc, $0f0b
ld a, [wcd9f]
inc a
- call $65b7
+ call WriteTwoDigitNumberInTxSymbolFormat
ld b, 17
ld a, $2e
call WriteByteToBGMap0
inc b
ld a, [wcd9c]
- call $65b7
+ call WriteTwoDigitNumberInTxSymbolFormat
.asm_7223
call Func_3b21
diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm
index d699851..de5c9c3 100644
--- a/src/engine/effect_functions.asm
+++ b/src/engine/effect_functions.asm
@@ -4,17 +4,17 @@ Poison50PercentEffect: ; 2c000 (b:4000)
ret nc
PoisonEffect: ; 2c007 (b:4007)
- lb bc, $0f, POISONED
+ lb bc, CNF_SLP_PRZ, POISONED
jr ApplyStatusEffect
- lb bc, $0f, DOUBLE_POISONED
+ lb bc, CNF_SLP_PRZ, DOUBLE_POISONED
jr ApplyStatusEffect
Paralysis50PercentEffect: ; 2c011 (b:4011)
ldtx de, ParalysisCheckText
call TossCoin_BankB
ret nc
- lb bc, $f0, PARALYZED
+ lb bc, PSN_DBLPSN, PARALYZED
jr ApplyStatusEffect
Confusion50PercentEffect: ; 2c01d (b:401d)
@@ -23,7 +23,7 @@ Confusion50PercentEffect: ; 2c01d (b:401d)
ret nc
ConfusionEffect: ; 2c024 (b:4024)
- lb bc, $f0, CONFUSED
+ lb bc, PSN_DBLPSN, CONFUSED
jr ApplyStatusEffect
ldtx de, SleepCheckText
@@ -31,7 +31,7 @@ ConfusionEffect: ; 2c024 (b:4024)
ret nc
SleepEffect: ; 2c030 (b:4030)
- lb bc, $f0, ASLEEP
+ lb bc, PSN_DBLPSN, ASLEEP
jr ApplyStatusEffect
ApplyStatusEffect:
@@ -62,20 +62,21 @@ ApplyStatusEffect:
ret
.can_induce_status
- ld hl, wcccd
+ ld hl, wEffectFunctionsFeedbackIndex
push hl
ld e, [hl]
ld d, $0
- ld hl, wccce
+ ld hl, wEffectFunctionsFeedback
add hl, de
call SwapTurn
ldh a, [hWhoseTurn]
ld [hli], a
call SwapTurn
- ld [hl], b
+ ld [hl], b ; mask of status conditions not to discard on the target
inc hl
- ld [hl], c
+ ld [hl], c ; status condition to inflict to the target
pop hl
+ ; advance wEffectFunctionsFeedbackIndex
inc [hl]
inc [hl]
inc [hl]
@@ -97,14 +98,14 @@ CommentedOut_2c086: ; 2c086 (b:4086)
ret
; 0x2c087
-PlaceTextItems7: ; 2c087 (b:4087)
+Func_2c087: ; 2c087 (b:4087)
xor a
- jr PlaceTextItemsc
+ jr Func_2c08c
-PlaceTextItemsa: ; 2c08a (b:408a)
+Func_2c08a: ; 2c08a (b:408a)
ld a, $1
-PlaceTextItemsc:
+Func_2c08c:
push de
push af
ld a, $11
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 8df064c..a96eba0 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -3810,7 +3810,7 @@ EvolvePokemonCard: ; 13a2 (0:13a2)
ld [hl], $00
ld a, e
or a
- call z, ResetStatusConditions
+ call z, ClearAllStatusConditions
; set the new evolution stage of the card
ldh a, [hTempPlayAreaLocationOffset_ff9d]
add DUELVARS_ARENA_CARD_STAGE
@@ -3911,10 +3911,10 @@ CheckIfCanEvolveInto_BasicToStage2: ; 142b (0:142b)
ret
; 0x1461
-; init the status and all substatuses of the turn holder's arena Pokemon.
-; called when sending a new Pokemon into the arena.
+; clear the status, all substatuses, and temporary duelvars of the turn holder's
+; arena Pokemon. called when sending a new Pokemon into the arena.
; does not reset Headache, since it targets a player rather than a Pokemon.
-ResetStatusConditions: ; 1461 (0:1461)
+ClearAllStatusConditions: ; 1461 (0:1461)
push hl
ldh a, [hWhoseTurn]
ld h, a
@@ -3994,7 +3994,7 @@ PutHandPokemonCardInPlayArea: ; 1485 (0:1485)
ld [hl], a ; set card's evolution stage
ld a, e
or a
- call z, ResetStatusConditions ; only call if Pokemon is being placed in the arena
+ call z, ClearAllStatusConditions ; only call if Pokemon is being placed in the arena
ld a, e
or a
ret
@@ -4103,7 +4103,7 @@ ShiftTurnPokemonToFirstPlayAreaSlots: ; 152b (0:152b)
; reset the status and all substatuses of the arena Pokemon before swapping.
; e is the play area location offset of the bench Pokemon (PLAY_AREA_*).
SwapArenaWithBenchPokemon: ; 1543 (0:1543)
- call ResetStatusConditions
+ call ClearAllStatusConditions
ld d, PLAY_AREA_ARENA
; fallthrough
@@ -4364,7 +4364,7 @@ Func_161e: ; 161e (0:161e)
ldtx hl, WillUseThePokemonPowerText
call DrawWideTextBox_WaitForInput
call ExchangeRNG
- call $7415
+ call Func_7415
ld a, $07
call TryExecuteEffectCommandFunction
ret
@@ -4427,7 +4427,9 @@ CopyMoveDataAndDamage:
ld [hl], a
ret
-; inits hTempCardIndex_ff9f, wTempTurnDuelistCardID, wTempNonTurnDuelistCardID, and other temp variables
+; inits hTempCardIndex_ff9f and wTempTurnDuelistCardID to the turn holder's arena card,
+; wTempNonTurnDuelistCardID to the non-turn holder's arena card, and zeroes other temp
+; variables that only last between each two-player turn.
Func_16f6: ; 16f6 (0:16f6)
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
@@ -4444,13 +4446,13 @@ Func_16f6: ; 16f6 (0:16f6)
call SwapTurn
xor a
ld [wccec], a
- ld [wcccd], a
+ ld [wEffectFunctionsFeedbackIndex], a
ld [wcced], a
ld [wDamageToSelfMode], a
ld [wccef], a
ld [wccf0], a
ld [wccf1], a
- bank1call $7189
+ bank1call ClearNonTurnTemporaryDuelvars_CopyStatus
ret
Func_1730: ; 1730 (0:1730)
@@ -4498,7 +4500,7 @@ Func_1730: ; 1730 (0:1730)
; fallthrough
Func_179a: ; 179a (0:179a)
- call $7415
+ call Func_7415
ld a, [wLoadedMoveCategory]
and RESIDUAL
jr nz, .asm_17ad
@@ -4575,7 +4577,7 @@ Func_1821: ; 1821 (0:1821)
ret
Func_1823: ; 1823 (0:1823)
- bank1call $717a
+ bank1call ClearNonTurnTemporaryDuelvars
or a
ret
@@ -4591,12 +4593,12 @@ DealConfusionDamageToSelf: ; 1828 (0:1828)
call Func_195c
call Func_1bb4
call $6e49
- bank1call $717a
+ bank1call ClearNonTurnTemporaryDuelvars
or a
ret
Func_184b: ; 184b (0:184b)
- call $7415
+ call Func_7415
ld a, $2
call TryExecuteEffectCommandFunction
jr c, Func_1819
@@ -4651,7 +4653,7 @@ Func_189d: ; 189d (0:189d)
call GetNonTurnDuelistVariable
or a
jr nz, .asm_18b9
- ld a, [wcccd]
+ ld a, [wEffectFunctionsFeedbackIndex]
or a
ret z
.asm_18b9
@@ -4765,7 +4767,7 @@ Func_195c: ; 195c (0:195c)
push af
xor a
ld [wNoDamageOrEffect], a
- bank1call $7415
+ bank1call Func_7415
ld a, [wTempNonTurnDuelistCardID]
push af
ld a, [wTempTurnDuelistCardID]
@@ -5174,7 +5176,7 @@ Func_1bca: ; 1bca (0:1bca)
scf
ret
.asm_1bfd
- call $700a
+ call PrintThereWasNoEffectFromStatusText
call DrawWideTextBox_PrintText
scf
ret
@@ -6172,7 +6174,7 @@ LoadDuelCardSymbolTiles2: ; 20c4 (0:20c4)
ld b, $c
jr CopyFontsOrDuelGraphicsTiles
-; load the face down stage0 / stage1 / stage2 card images shown in the ckeck Pokemon screens
+; load the face down basic / stage1 / stage2 card images shown in the ckeck Pokemon screens
LoadDuelFaceDownCardTiles: ; 20d8 (0:20d8)
ld b, $10
jr LoadDuelCheckPokemonScreenTiles.got_num_tiles
@@ -6883,7 +6885,7 @@ TwoByteNumberToTxSymbol_TrimLeadingZeros: ; 245d (0:245d)
call .get_digit
ld bc, -1
call .get_digit
- xor a
+ xor a ; TX_END
ld [de], a
pop hl
ld e, 5
@@ -7865,7 +7867,7 @@ CardSymbolTable:
db $f4, $03 ; TYPE_ENERGY_FIGHTING
db $f8, $00 ; TYPE_ENERGY_DOUBLE_COLORLESS
db $fc, $02 ; TYPE_ENERGY_UNUSED
- db $d0, $02 ; TYPE_PKMN_*, Stage 0
+ db $d0, $02 ; TYPE_PKMN_*, Basic
db $d4, $02 ; TYPE_PKMN_*, Stage 1
db $d8, $01 ; TYPE_PKMN_*, Stage 2
db $dc, $02 ; TYPE_TRAINER
@@ -8767,7 +8769,11 @@ CopyText: ; 2e89 (0:2e89)
jp CopyPlayerName
; 0x2ea9
-Func_2ea9: ; 2ea9 (0:2ea9)
+; copy text of maximum length a (in tiles) from its ID at hl to de,
+; then terminate the text with TX_END if it doesn't contain it already.
+; fill any remaining bytes with spaces plus TX_END to match the length specified in a.
+; return the text's actual length in characters (i.e. before the first TX_END) in e.
+CopyTextData_FromTextID: ; 2ea9 (0:2ea9)
ldh [hff96], a
ldh a, [hBankROM]
push af
diff --git a/src/text/text1.asm b/src/text/text1.asm
index 0274dc2..f773960 100644
--- a/src/text/text1.asm
+++ b/src/text/text1.asm
@@ -331,7 +331,7 @@ Text004d: ; 3685a (d:685a)
text "Bench"
done
-Text004e: ; 36861 (d:6861)
+KnockOutText: ; 36861 (d:6861)
text "Knock Out"
done
diff --git a/src/text/text2.asm b/src/text/text2.asm
index cd3aeed..5afb3c6 100644
--- a/src/text/text2.asm
+++ b/src/text/text2.asm
@@ -478,7 +478,7 @@ WasUnsuccessfulText: ; 393e6 (e:53e6)
line "<RAMTEXT> was unsuccessful."
done
-Text014b: ; 393ff (e:53ff)
+ThereWasNoEffectFromTxRam2Text: ; 393ff (e:53ff)
text "There was no effect"
line "from <RAMTEXT>."
done
@@ -725,32 +725,32 @@ Text017d: ; 39b97 (e:5b97)
text "There was no effect!"
done
-Text017e: ; 39bad (e:5bad)
+ThereWasNoEffectFromToxicText: ; 39bad (e:5bad)
text "There was no effect"
line "from Toxic"
done
-Text017f: ; 39bcd (e:5bcd)
+ThereWasNoEffectFromPoisonText: ; 39bcd (e:5bcd)
text "There was no effect"
line "from Poison."
done
-Text0180: ; 39bef (e:5bef)
+ThereWasNoEffectFromSleepText: ; 39bef (e:5bef)
text "There was no effect"
line "from Sleep."
done
-Text0181: ; 39c10 (e:5c10)
+ThereWasNoEffectFromParalysisText: ; 39c10 (e:5c10)
text "There was no effect"
line "from Paralysis."
done
-Text0182: ; 39c35 (e:5c35)
+ThereWasNoEffectFromConfusionText: ; 39c35 (e:5c35)
text "There was no effect"
line "from Confusion."
done
-Text0183: ; 39c5a (e:5c5a)
+ThereWasNoEffectFromPoisonConfusionText: ; 39c5a (e:5c5a)
text "There was no effet"
line "from Poison, Confusion."
done
diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm
index 7838e80..e2e1725 100644
--- a/src/text/text_offsets.asm
+++ b/src/text/text_offsets.asm
@@ -79,7 +79,7 @@ TextOffsets:: ; 34000 (d:4000)
textpointer Text004b ; 0x004b
textpointer Text004c ; 0x004c
textpointer Text004d ; 0x004d
- textpointer Text004e ; 0x004e
+ textpointer KnockOutText ; 0x004e
textpointer DamageToSelfDueToConfusionText ; 0x004f
textpointer ChooseEnergyCardToDiscardText ; 0x0050
textpointer Text0051 ; 0x0051
@@ -332,7 +332,7 @@ TextOffsets:: ; 34000 (d:4000)
textpointer Text0148 ; 0x0148
textpointer Text0149 ; 0x0149
textpointer WasUnsuccessfulText ; 0x014a
- textpointer Text014b ; 0x014b
+ textpointer ThereWasNoEffectFromTxRam2Text ; 0x014b
textpointer Text014c ; 0x014c
textpointer Text014d ; 0x014d
textpointer Text014e ; 0x014e
@@ -383,12 +383,12 @@ TextOffsets:: ; 34000 (d:4000)
textpointer Text017b ; 0x017b
textpointer Text017c ; 0x017c
textpointer Text017d ; 0x017d
- textpointer Text017e ; 0x017e
- textpointer Text017f ; 0x017f
- textpointer Text0180 ; 0x0180
- textpointer Text0181 ; 0x0181
- textpointer Text0182 ; 0x0182
- textpointer Text0183 ; 0x0183
+ textpointer ThereWasNoEffectFromToxicText ; 0x017e
+ textpointer ThereWasNoEffectFromPoisonText ; 0x017f
+ textpointer ThereWasNoEffectFromSleepText ; 0x0180
+ textpointer ThereWasNoEffectFromParalysisText ; 0x0181
+ textpointer ThereWasNoEffectFromConfusionText ; 0x0182
+ textpointer ThereWasNoEffectFromPoisonConfusionText ; 0x0183
textpointer Text0184 ; 0x0184
textpointer Text0185 ; 0x0185
textpointer Text0186 ; 0x0186
diff --git a/src/wram.asm b/src/wram.asm
index 34ccd9f..9cf0167 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -186,7 +186,17 @@ wPlayerDuelistType:: ; c2f1
wPlayerArenaCardDisabledMoveIndex:: ; c2f2
ds $1
- ds $d
+; damage taken the last time the opponent attacked (0 if no damage)
+wPlayerArenaCardLastTurnDamage:: ; c2f3
+ ds $1
+
+ ds $1
+
+; status condition received the last time the opponent attacked (0 if none)
+wPlayerArenaCardLastTurnStatus:: ; c2f5
+ ds $1
+
+ ds $a
wOpponentDuelVariables:: ; c300
@@ -319,7 +329,15 @@ wOpponentDuelistType:: ; c3f1
wOpponentArenaCardDisabledMoveIndex:: ; c3f2
ds $1
- ds $d
+wOpponentArenaCardLastTurnDamage:: ; c3f3
+ ds $1
+
+ ds $1
+
+wOpponentArenaCardLastTurnStatus:: ; c3f5
+ ds $1
+
+ ds $a
UNION
@@ -607,9 +625,11 @@ wCardPageNumber:: ; cbc7
wcbc8:: ; cbc8
ds $1
-; 2-byte something
wcbc9:: ; cbc9
- ds $2
+ ds $1
+
+wcbca:: ; cbca
+ ds $1
; selected bench slot (1-5, that is, a PLAY_AREA_BENCH_* constant)
wBenchSelectedPokemon:: ; cbcb
@@ -855,7 +875,10 @@ wccbc:: ; ccbc
ds $2
wTempDamage_ccbf:: ; ccbf
- ds $2
+ ds $1
+
+wccc0:: ; ccc0
+ ds $1
; WEAKNESS and RESISTANCE flags for a damaging attack
wDamageEffectiveness:: ; ccc1
@@ -871,6 +894,8 @@ wTempTurnDuelistCardID:: ; ccc3
wTempNonTurnDuelistCardID:: ; ccc4
ds $1
+; the status condition of the defending Pokemon is loaded here after an attack
+wccc5:: ; ccc5
ds $1
; may contain 0 or 1 depending on which move was selected
@@ -887,11 +912,12 @@ wGotHeadsFromConfusionCheck:: ; ccc9
ds $3
-wcccd:: ; cccd
+wEffectFunctionsFeedbackIndex:: ; cccd
ds $1
-; some array used in effect functions with wcccd as the index. unknown length
-wccce:: ; ccce
+; some array used in effect functions with wEffectFunctionsFeedbackIndex
+; as the index, used to return feedback. unknown length.
+wEffectFunctionsFeedback:: ; ccce
ds $18
; this is 1 (non-0) if dealing damage to self due to confusion
@@ -911,18 +937,25 @@ wTempPlayAreaLocationOffset_cceb:: ; cceb
wccec:: ; ccec
ds $1
+; used by the effect functions to return the cause of an effect to fail
+; $01: was not affected by a status condition
+; $02: prints WasUnsuccessfulText
wcced:: ; cced
ds $1
wccee:: ; ccee
ds $1
+; when this is non-0, DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE and the
+; next duelvar are always set to 0 after an attack
wccef:: ; ccef
ds $1
wccf0:: ; ccf0
ds $1
+; effect functions return a status condition constant here when it had no effect
+; on the target, in order to print one of the ThereWasNoEffectFrom* texts
wccf1:: ; ccf1
ds $1