summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElectroDeoxys <ElectroDeoxys@gmail.com>2019-07-21 19:48:46 +0100
committerElectroDeoxys <ElectroDeoxys@gmail.com>2019-07-21 19:48:46 +0100
commit3d0f752a1dd2da7a61adc6b7e0dcb798af302b45 (patch)
treedc0fe00aa6aaee09e1128bbf0356b9c66e8cac74
parenta34b0ab25738a335b2c87337402e4f25c1d0b526 (diff)
parent92c2fc50a26eddc1bf0dda5afbe45f355dfdaa8f (diff)
Merge branch 'master' of https://github.com/pret/poketcg
-rw-r--r--src/constants/duel_constants.asm4
-rw-r--r--src/data/effect_commands.asm22
-rw-r--r--src/engine/bank01.asm41
-rw-r--r--src/engine/bank02.asm113
-rw-r--r--src/engine/bank06.asm4
-rw-r--r--src/engine/effect_functions.asm216
-rw-r--r--src/engine/home.asm26
-rw-r--r--src/text/text1.asm6
-rw-r--r--src/text/text2.asm2
-rw-r--r--src/text/text_offsets.asm8
-rw-r--r--src/wram.asm48
11 files changed, 324 insertions, 166 deletions
diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm
index d9b9e9c..943881b 100644
--- a/src/constants/duel_constants.asm
+++ b/src/constants/duel_constants.asm
@@ -165,6 +165,10 @@ NO_DAMAGE_OR_EFFECT_NSHIELD EQU $05
WEAKNESS EQU 1
RESISTANCE EQU 2
+; wEffectFailed constants
+EFFECT_FAILED_NO_EFFECT EQU $01
+EFFECT_FAILED_UNSUCCESSFUL EQU $02
+
; Box message id's
const_def
const BOXMSG_PLAYERS_TURN
diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm
index 6dc74ee..fa1bc81 100644
--- a/src/data/effect_commands.asm
+++ b/src/data/effect_commands.asm
@@ -109,8 +109,8 @@ ZubatLeechLifeEffectCommands:
db $00
BeedrillTwineedleEffectCommands:
- dbw $03, $47f5
- dbw $09, $47ed
+ dbw $03, Twineedle_MultiplierEffect
+ dbw $09, Twineedle_AIEffect
db $00
BeedrillPoisonStingEffectCommands:
@@ -127,8 +127,8 @@ ExeggcuteLeechSeedEffectCommands:
db $00
KoffingFoulGasEffectCommands:
- dbw $03, $482a
- dbw $09, $4822
+ dbw $03, FoulGas_PoisonOrConfusionEffect
+ dbw $09, FoulGas_AIEffect
db $00
MetapodStiffenEffectCommands:
@@ -158,19 +158,19 @@ ExeggutorTeleportEffectCommands:
db $00
ExeggutorBigEggsplosionEffectCommands:
- dbw $03, $4944
- dbw $09, $4925
+ dbw $03, BigEggsplosion_MultiplierEffect
+ dbw $09, BigEggsplosion_AIEffect
db $00
NidokingThrashEffectCommands:
- dbw $03, $4973
- dbw $04, $4982
- dbw $09, $496b
+ dbw $03, Thrash_ModifierEffect
+ dbw $04, Func_2c982
+ dbw $09, Thrash_AIEffect
db $00
NidokingToxicEffectCommands:
- dbw $03, $4994
- dbw $09, $498c
+ dbw $03, Toxic_DoublePoisonEffect
+ dbw $09, Toxic_AIEffect
db $00
NidoqueenBoyfriendsEffectCommands:
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm
index 868d284..c7a31d0 100644
--- a/src/engine/bank01.asm
+++ b/src/engine/bank01.asm
@@ -2464,7 +2464,7 @@ DrawDuelHUDs: ; 503a (1:503a)
inc c
call CheckPrintPoisoned
inc c
- call CheckPrintDoublePoisoned
+ call CheckPrintDoublePoisoned ; if double poisoned, print a second poison icon
call SwapTurn
lb de, 7, 0 ; coordinates for opponent's arena card name and info icons
lb bc, 3, 1 ; coordinates for opponent's attached energies and HP bar
@@ -2477,7 +2477,7 @@ DrawDuelHUDs: ; 503a (1:503a)
dec c
call CheckPrintPoisoned
dec c
- call CheckPrintDoublePoisoned
+ call CheckPrintDoublePoisoned ; if double poisoned, print a second poison icon
call SwapTurn
ret
; 0x5093
@@ -5645,9 +5645,9 @@ CheckPrintPoisoned: ; 63bb (1:63bb)
; given a card's status in a, print the Poison symbol at bc if it's double poisoned
CheckPrintDoublePoisoned: ; 63c7 (1:63c7)
push af
- and DOUBLE_POISONED - POISONED
- jr nz, CheckPrintPoisoned.poison ; double poison (print a second symbol)
- jr CheckPrintPoisoned.print ; not double poisoned
+ and DOUBLE_POISONED & (POISONED ^ $ff)
+ jr nz, CheckPrintPoisoned.poison ; double poisoned (print SYM_POISONED)
+ jr CheckPrintPoisoned.print ; not double poisoned (print SYM_SPACE)
; 0x63ce
; given a card's status in a, print the Confusion, Sleep, or Paralysis symbol at bc
@@ -6117,7 +6117,7 @@ DuelDataToSave: ; 6729 (1:6729)
; dw address, number_of_bytes_to_copy
dw wPlayerDuelVariables, wOpponentDuelVariables - wPlayerDuelVariables
dw wOpponentDuelVariables, wPlayerDeck - wOpponentDuelVariables
- dw wPlayerDeck, wNameBuffer + $10 - wPlayerDeck
+ dw wPlayerDeck, wDuelTempList - wPlayerDeck
dw wWhoseTurn, wDuelTheme + $1 - wWhoseTurn
dw hWhoseTurn, $1
dw wRNG1, wRNGCounter + $1 - wRNG1
@@ -6824,12 +6824,12 @@ Func_6ba2: ; 6ba2 (1:6ba2)
; apply and/or refresh status conditions and other events that trigger between turns
HandleBetweenTurnsEvents: ; 6baf (1:6baf)
- call IsArenaPokemonAsleepOrDoublePoisoned
+ call IsArenaPokemonAsleepOrPoisoned
jr c, .something_to_handle
cp PARALYZED
jr z, .something_to_handle
call SwapTurn
- call IsArenaPokemonAsleepOrDoublePoisoned
+ call IsArenaPokemonAsleepOrPoisoned
call SwapTurn
jr c, .something_to_handle
call DiscardAttachedPluspowers
@@ -6839,8 +6839,8 @@ HandleBetweenTurnsEvents: ; 6baf (1:6baf)
ret
.something_to_handle
; either:
- ; 1. turn holder's arena Pokemon is paralyzed, asleep or double poisoned
- ; 2. non-turn holder's arena Pokemon is asleep or double poisoned
+ ; 1. turn holder's arena Pokemon is paralyzed, asleep, poisoned or double poisoned
+ ; 2. non-turn holder's arena Pokemon is asleep, poisoned or double poisoned
call Func_3b21
call ZeroObjectPositionsAndToggleOAMCopy
call EmptyScreen
@@ -6923,14 +6923,16 @@ DiscardAttachedDefenders: ; 6c56 (1:6c56)
jp MoveCardToDiscardPileIfInArena
; 0x6c68
-; return carry if the turn holder's arena Pokemon card is double poisoned or asleep.
+; return carry if the turn holder's arena Pokemon card is asleep, poisoned, or double poisoned.
; also, if confused, paralyzed, or asleep, return the status condition in a.
-IsArenaPokemonAsleepOrDoublePoisoned: ; 6c68 (1:6c68)
+IsArenaPokemonAsleepOrPoisoned: ; 6c68 (1:6c68)
ld a, DUELVARS_ARENA_CARD_STATUS
call GetTurnDuelistVariable
or a
ret z
- and DOUBLE_POISONED
+ ; note that POISONED | DOUBLE_POISONED is the same as just DOUBLE_POISONED ($c0)
+ ; poison status masking is normally done with PSN_DBLPSN ($f0)
+ and POISONED | DOUBLE_POISONED
jr nz, .set_carry
ld a, [hl]
and CNF_SLP_PRZ
@@ -7189,9 +7191,9 @@ Func_6e49: ; 6e49 (1:6e49)
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)
+; on the value at wNoEffectFromStatus (NO_STATUS or a status condition constant)
PrintThereWasNoEffectFromStatusText: ; 700a (1:700a)
- ld a, [wccf1]
+ ld a, [wNoEffectFromStatus]
or a
jr nz, .status
ld hl, wLoadedMoveName
@@ -7413,18 +7415,21 @@ ClearNonTurnTemporaryDuelvars_CopyStatus: ; 7189 (1:7189)
ret
; 0x7195
+; update non-turn holder's DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE
+; if wccef == 0: set to [wDealtDamage]
+; if wceef != 0: set to 0
Func_7195: ; 7195 (1:7195)
ld a, DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE
call GetNonTurnDuelistVariable
ld a, [wccef]
or a
- jr nz, .asm_71a9
+ jr nz, .zero
ld a, [wDealtDamage]
ld [hli], a
- ld a, [wccc0]
+ ld a, [wDealtDamage + 1]
ld [hl], a
ret
-.asm_71a9
+.zero
xor a
ld [hli], a
ld [hl], a
diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm
index 38d74f7..a4a0f62 100644
--- a/src/engine/bank02.asm
+++ b/src/engine/bank02.asm
@@ -53,7 +53,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047)
.draw
ld h, a
ld l, a
- call DrawYourOrOppPlayArea_LoadTurnHolders
+ call DrawYourOrOppPlayAreaScreen
ld a, [wCheckMenuCursorYPosition]
sla a
@@ -93,11 +93,11 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047)
jr .draw
.table ; 8098 (2:4098)
- dw OpenDuelScreen_TurnHolderPlayArea
- dw OpenDuelScreen_TurnHolderHand
- dw OpenDuelScreen_TurnHolderDiscardPile
+ dw OpenYourOrOppPlayAreaScreen_TurnHolderPlayArea
+ dw OpenYourOrOppPlayAreaScreen_TurnHolderHand
+ dw OpenYourOrOppPlayAreaScreen_TurnHolderDiscardPile
-OpenDuelScreen_TurnHolderPlayArea: ; 809e (2:409e)
+OpenYourOrOppPlayAreaScreen_TurnHolderPlayArea: ; 809e (2:409e)
ldh a, [hWhoseTurn]
push af
bank1call OpenTurnHolderPlayAreaScreen
@@ -105,7 +105,7 @@ OpenDuelScreen_TurnHolderPlayArea: ; 809e (2:409e)
ldh [hWhoseTurn], a
ret
-OpenDuelScreen_NonTurnHolderPlayArea:
+OpenYourOrOppPlayAreaScreen_NonTurnHolderPlayArea:
ldh a, [hWhoseTurn]
push af
bank1call OpenNonTurnHolderPlayAreaScreen
@@ -113,7 +113,7 @@ OpenDuelScreen_NonTurnHolderPlayArea:
ldh [hWhoseTurn], a
ret
-OpenDuelScreen_TurnHolderHand:
+OpenYourOrOppPlayAreaScreen_TurnHolderHand:
ldh a, [hWhoseTurn]
push af
bank1call OpenTurnHolderHandScreen_Simple
@@ -121,7 +121,7 @@ OpenDuelScreen_TurnHolderHand:
ldh [hWhoseTurn], a
ret
-OpenDuelScreen_NonTurnHolderHand:
+OpenYourOrOppPlayAreaScreen_NonTurnHolderHand:
ldh a, [hWhoseTurn]
push af
bank1call OpenNonTurnHolderHandScreen_Simple
@@ -129,7 +129,7 @@ OpenDuelScreen_NonTurnHolderHand:
ldh [hWhoseTurn], a
ret
-OpenDuelScreen_TurnHolderDiscardPile:
+OpenYourOrOppPlayAreaScreen_TurnHolderDiscardPile:
ldh a, [hWhoseTurn]
push af
bank1call OpenTurnHolderDiscardPileScreen
@@ -137,7 +137,7 @@ OpenDuelScreen_TurnHolderDiscardPile:
ldh [hWhoseTurn], a
ret
-OpenDuelScreen_NonTurnHolderDiscardPile:
+OpenYourOrOppPlayAreaScreen_NonTurnHolderDiscardPile:
ldh a, [hWhoseTurn]
push af
bank1call OpenNonTurnHolderDiscardPileScreen
@@ -174,7 +174,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da)
ld h, a
.cursor
- call DrawYourOrOppPlayArea_LoadTurnHolders
+ call DrawYourOrOppPlayAreaScreen
; convert cursor position and
; store it in wYourOrOppPlayAreaLastCursorPosition
@@ -230,9 +230,9 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da)
jr .turns
.table
- dw OpenDuelScreen_NonTurnHolderPlayArea
- dw OpenDuelScreen_NonTurnHolderHand
- dw OpenDuelScreen_NonTurnHolderDiscardPile
+ dw OpenYourOrOppPlayAreaScreen_NonTurnHolderPlayArea
+ dw OpenYourOrOppPlayAreaScreen_NonTurnHolderHand
+ dw OpenYourOrOppPlayAreaScreen_NonTurnHolderDiscardPile
CheckMenuData: ; (2:4158)
textitem 2, 14, InPlayAreaText
@@ -384,21 +384,21 @@ YourOrOppPlayAreaArrowPositions_OpponentDiscardPile:
db 0, 8
db $ff
-; loads tiles and icons to display your/opp play area
+; loads tiles and icons to display Your Play Area / Opp. Play Area screen,
; and draws the screen according to the turn player
-; h = turn holder 1
-; l = turn holder 2
-DrawYourOrOppPlayArea_LoadTurnHolders: ; 8209 (2:4209)
+; input: h -> [wCheckMenuPlayAreaWhichDuelist] and l -> [wCheckMenuPlayAreaWhichLayout]
+DrawYourOrOppPlayAreaScreen: ; 8209 (2:4209)
; loads the turn holders
ld a, h
- ld [wTurnHolder1], a
+ ld [wCheckMenuPlayAreaWhichDuelist], a
ld a, l
- ld [wTurnHolder2], a
+ ld [wCheckMenuPlayAreaWhichLayout], a
; fallthrough
; loads tiles and icons to display Your Play Area / Opp. Play Area screen,
; and draws the screen according to the turn player
-_DrawYourOrOppPlayArea: ; 8211 (2:4211)
+; input: [wCheckMenuPlayAreaWhichDuelist] and [wCheckMenuPlayAreaWhichLayout]
+_DrawYourOrOppPlayAreaScreen: ; 8211 (2:4211)
xor a
ld [wTileMapFill], a
call ZeroObjectPositions
@@ -413,7 +413,7 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211)
call LoadSymbolsFont
call LoadDeckAndDiscardPileIcons
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
cp PLAYER_TURN
jr nz, .opp_turn1
@@ -441,7 +441,7 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211)
ldh a, [hWhoseTurn]
cp PLAYER_TURN
jr nz, .opp_turn2
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
cp PLAYER_TURN
jr nz, .swap
.opp_turn2
@@ -453,9 +453,9 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211)
call SwapTurn
.draw
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld b, a
- ld a, [wTurnHolder2]
+ ld a, [wCheckMenuPlayAreaWhichLayout]
cp b
jr nz, .not_equal
@@ -468,7 +468,8 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211)
call DrawPlayArea_BenchCards
xor a
call DrawYourOrOppPlayArea_Icons
- jr .lcd
+ jr .done
+
.not_equal
ld hl, PrizeCardsCoordinateData_YourOrOppPlayArea.opponent
call DrawPlayArea_PrizeCards
@@ -480,14 +481,14 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211)
ld a, $01
call DrawYourOrOppPlayArea_Icons
-.lcd
+.done
call EnableLCD
ret
Func_82b6: ; 82b6 (2:42b6)
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld b, a
- ld a, [wTurnHolder2]
+ ld a, [wCheckMenuPlayAreaWhichLayout]
cp b
jr nz, .not_equal
@@ -502,7 +503,7 @@ Func_82b6: ; 82b6 (2:42b6)
; loads tiles and icons to display the In Play Area screen,
; and draws the screen
-_DrawInPlayArea: ; 82ce (2:42ce)
+DrawInPlayAreaScreen: ; 82ce (2:42ce)
xor a
ld [wTileMapFill], a
call ZeroObjectPositions
@@ -524,8 +525,8 @@ _DrawInPlayArea: ; 82ce (2:42ce)
; reset turn holders
ldh a, [hWhoseTurn]
- ld [wTurnHolder1], a
- ld [wTurnHolder2], a
+ ld [wCheckMenuPlayAreaWhichDuelist], a
+ ld [wCheckMenuPlayAreaWhichLayout], a
; player prize cards
ld hl, PrizeCardsCoordinateData_InPlayArea.player
@@ -541,7 +542,7 @@ _DrawInPlayArea: ; 82ce (2:42ce)
call SwapTurn
ldh a, [hWhoseTurn]
- ld [wTurnHolder1], a
+ ld [wCheckMenuPlayAreaWhichDuelist], a
call SwapTurn
; opponent prize cards
@@ -575,8 +576,8 @@ _DrawPlayersPrizeAndBenchCards: ; 833c (2:433c)
; player cards
ld a, PLAYER_TURN
- ld [wTurnHolder1], a
- ld [wTurnHolder2], a
+ ld [wCheckMenuPlayAreaWhichDuelist], a
+ ld [wCheckMenuPlayAreaWhichLayout], a
ld hl, PrizeCardsCoordinateData_2.player
call DrawPlayArea_PrizeCards
lb de, 5, 10 ; coordinates
@@ -585,7 +586,7 @@ _DrawPlayersPrizeAndBenchCards: ; 833c (2:433c)
; opponent cards
ld a, OPPONENT_TURN
- ld [wTurnHolder1], a
+ ld [wCheckMenuPlayAreaWhichDuelist], a
ld hl, PrizeCardsCoordinateData_2.opponent
call DrawPlayArea_PrizeCards
lb de, 1, 0 ; coordinates
@@ -594,21 +595,21 @@ _DrawPlayersPrizeAndBenchCards: ; 833c (2:433c)
ret
; draws the active card gfx at coordinates de
-; of the player (or opponent) depending on wTurnHolder1
+; of the player (or opponent) depending on wCheckMenuPlayAreaWhichDuelist
; input:
; de = coordinates
DrawYourOrOppPlayArea_ActiveCardGfx: ; 837e (2:437e)
push de
ld a, DUELVARS_ARENA_CARD
ld l, a
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld h, a
ld a, [hl]
cp -1
jr z, .no_pokemon
ld d, a
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld b, a
ldh a, [hWhoseTurn]
cp b
@@ -623,7 +624,7 @@ DrawYourOrOppPlayArea_ActiveCardGfx: ; 837e (2:437e)
call SwapTurn
.draw
- lb de, $8a, $00 ; destination offset of loaded gfx
+ ld de, v0Tiles1 + $20 tiles ; destination offset of loaded gfx
ld hl, wLoadedCard1Gfx
ld a, [hli]
ld h, [hl]
@@ -734,13 +735,13 @@ DrawInPlayArea_ActiveCardGfx: ; 83cc (2:43cc)
ret
; draws prize cards depending on the turn
-; loaded in wTurnHolder1
+; loaded in wCheckMenuPlayAreaWhichDuelist
; input:
; hl = pointer to coordinates
DrawPlayArea_PrizeCards: ; 8464 (2:4464)
push hl
call GetDuelInitialPrizesUpperBitsSet
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld h, a
ld l, DUELVARS_PRIZES
ld a, [hl]
@@ -869,15 +870,15 @@ GetDuelInitialPrizesUpperBitsSet: ; 84fc (2:44fc)
ld [wDuelInitialPrizesUpperBitsSet], a
ret
-; draws filled and empty bench slots depending on the turn loaded in wTurnHolder1
-; if wTurnHolder1 is different from wTurnHolder2 adjusts coordinates of the bench slots
+; draws filled and empty bench slots depending on the turn loaded in wCheckMenuPlayAreaWhichDuelist
+; if wCheckMenuPlayAreaWhichDuelist is different from wCheckMenuPlayAreaWhichLayout adjusts coordinates of the bench slots
; input:
; de = coordinates to draw bench
; c = spacing between slots
DrawPlayArea_BenchCards: ; 8511 (2:4511)
- ld a, [wTurnHolder2]
+ ld a, [wCheckMenuPlayAreaWhichLayout]
ld b, a
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
cp b
jr z, .skip
@@ -896,7 +897,7 @@ DrawPlayArea_BenchCards: ; 8511 (2:4511)
ld c, a
; c = $ff - c + 1
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
.skip
ld h, a
ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA
@@ -952,7 +953,7 @@ DrawPlayArea_BenchCards: ; 8511 (2:4511)
jr .loop_1
.done
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld h, a
ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA
ld b, [hl]
@@ -1007,7 +1008,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa)
.draw
; hand icon and value
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld d, a
ld e, DUELVARS_NUMBER_OF_CARDS_IN_HAND
ld a, [de]
@@ -1016,7 +1017,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa)
call DrawPlayArea_HandText
; deck icon and value
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld d, a
ld e, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK
ld a, [de]
@@ -1028,7 +1029,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa)
call DrawPlayArea_IconWithValue
; discard pile icon and value
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld d, a
ld e, DUELVARS_NUMBER_OF_CARDS_IN_DISCARD_PILE
ld a, [de]
@@ -1386,7 +1387,7 @@ Func_8764: ; 8764 (2:4764)
ldh a, [hWhoseTurn]
ld h, a
ld l, a
- call DrawYourOrOppPlayArea_LoadTurnHolders
+ call DrawYourOrOppPlayAreaScreen
.swap
ld a, [$ce56]
@@ -1419,7 +1420,7 @@ Func_8764: ; 8764 (2:4764)
jp nz, Func_8883 ; jump if not first option
; hCurMenuItem = 0
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld b, a
ldh a, [hWhoseTurn]
cp b
@@ -1428,7 +1429,7 @@ Func_8764: ; 8764 (2:4764)
; switch the play area to draw
ld h, a
ld l, a
- call DrawYourOrOppPlayArea_LoadTurnHolders
+ call DrawYourOrOppPlayAreaScreen
xor a
ld [$ce56], a
@@ -1562,7 +1563,7 @@ Func_8855:
ret
Func_8883: ; 8883 (2:4883)
- ld a, [wTurnHolder1]
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
ld b, a
ldh a, [hWhoseTurn]
cp b
@@ -1578,7 +1579,7 @@ Func_8883: ; 8883 (2:4883)
.draw
ld h, a
- call DrawYourOrOppPlayArea_LoadTurnHolders
+ call DrawYourOrOppPlayAreaScreen
.text
call DrawWideTextBox
diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm
index fbf9016..cb1b0a9 100644
--- a/src/engine/bank06.asm
+++ b/src/engine/bank06.asm
@@ -158,7 +158,7 @@ Func_180d5: ; 180d5 (6:40d5)
.asm_006_40da
xor a
ld [wCheckMenuCursorBlinkCounter], a
- farcall _DrawInPlayArea
+ farcall DrawInPlayAreaScreen
call EnableLCD
call IsClairvoyanceActive
jr c, .asm_006_40ef
@@ -1122,7 +1122,7 @@ Func_006_50fb: ; 190fb (6:50fb)
ld a, [wWhoseTurn]
ld l, a
.asm_006_5127
- call DrawYourOrOppPlayArea
+ call DrawYourOrOppPlayAreaScreen_Bank0
pop af
ld [wDuelDisplayedScreen], a
.asm_006_512e
diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm
index b3c707b..c8d8f24 100644
--- a/src/engine/effect_functions.asm
+++ b/src/engine/effect_functions.asm
@@ -7,6 +7,7 @@ PoisonEffect: ; 2c007 (b:4007)
lb bc, CNF_SLP_PRZ, POISONED
jr ApplyStatusEffect
+DoublePoisonEffect: ; 2c00c (b:400c)
lb bc, CNF_SLP_PRZ, DOUBLE_POISONED
jr ApplyStatusEffect
@@ -56,7 +57,7 @@ ApplyStatusEffect:
.cant_induce_status
ld a, c
- ld [wccf1], a
+ ld [wNoEffectFromStatus], a
call SetNoEffectFromStatus
or a
ret
@@ -118,49 +119,50 @@ Func_2c08c:
; 0x2c09c
SetNoEffectFromStatus: ; 2c09c (b:409c)
- ld a, $1
- ld [wcced], a
+ ld a, EFFECT_FAILED_NO_EFFECT
+ ld [wEffectFailed], a
ret
; 0x2c0a2
SetWasUnsuccessful: ; 2c0a2 (b:40a2)
- ld a, $2
- ld [wcced], a
+ ld a, EFFECT_FAILED_UNSUCCESSFUL
+ ld [wEffectFailed], a
ret
; 0x2c0a8
INCROM $2c0a8, $2c0d4
; Sets some flags for AI use
-; if target double poisoned
-; [wccbb] <- [wDamage]
-; [wccbc] <- [wDamage]
+; if target poisoned
+; [wAIMinDamage] <- [wDamage]
+; [wAIMaxDamage] <- [wDamage]
; else
-; [wccbb] <- [wDamage] + d
-; [wccbc] <- [wDamage] + e
-; [wDamage] <- [wDamage] + a
+; [wAIMinDamage] <- [wDamage] + d
+; [wAIMaxDamage] <- [wDamage] + e
+; [wDamage] <- [wDamage] + a
Func_2c0d4: ; 2c0d4 (b:40d4)
push af
ld a, DUELVARS_ARENA_CARD_STATUS
call GetNonTurnDuelistVariable
- and DOUBLE_POISONED
- jr z, .not_double_poisoned
+ and POISONED | DOUBLE_POISONED
+ jr z, Func_2c0e9.skip_push_af
pop af
ld a, [wDamage]
- ld [wccbb], a
- ld [wccbc], a
+ ld [wAIMinDamage], a
+ ld [wAIMaxDamage], a
ret
+Func_2c0e9: ; 2c0e9 (b:40e9)
push af
-.not_double_poisoned
+.skip_push_af
ld hl, wDamage
ld a, [hl]
add d
- ld [wccbb], a
+ ld [wAIMinDamage], a
ld a, [hl]
add e
- ld [wccbc], a
+ ld [wAIMaxDamage], a
pop af
add [hl]
ld [hl], a
@@ -168,17 +170,17 @@ Func_2c0d4: ; 2c0d4 (b:40d4)
; 0x2c0fb
; Sets some flags for AI use
-; [wDamage] <- a
-; [wccbb] <- d
-; [wccbc] <- e
+; [wDamage] <- a
+; [wAIMinDamage] <- d
+; [wAIMaxDamage] <- e
Func_2c0fb: ; 2c0fb (b:40fb)
ld [wDamage], a
xor a
ld [wDamage + 1], a
ld a, d
- ld [wccbb], a
+ ld [wAIMinDamage], a
ld a, e
- ld [wccbc], a
+ ld [wAIMaxDamage], a
ret
; 0x2c10b
@@ -219,14 +221,24 @@ ApplySubstatus2ToDefendingCard: ; 2c149 (b:4149)
ret
; 0x2c166
- INCROM $2c166, $2c6f0
+Func_2c166: ; 2c166 (b:4166)
+ ld [wDamage], a
+ ld [wAIMinDamage], a
+ ld [wAIMaxDamage], a
+ xor a
+ ld [wDamage + 1], a
+ ret
+; 0x2c174
+
+ INCROM $2c174, $2c6f0
SpitPoison_AIEffect: ; 2c6f0 (b:46f0)
- ld a, $5
- lb de, $0, $a
+ ld a, 5
+ lb de, 0, 10
jp Func_2c0fb
; 0x2c6f8
+; If heads, defending Pokemon becomes poisoned
SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8)
ldtx de, PoisonCheckText
call TossCoin_BankB
@@ -240,19 +252,20 @@ SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8)
INCROM $2c70a, $2c730
PoisonFang_AIEffect: ; 2c730 (b:4730)
- ld a, $a
- lb de, $a, $a
+ ld a, 10
+ lb de, 10, 10
jp Func_2c0d4
; 0x2c738
WeepinbellPoisonPowder_AIEffect: ; 2c738 (b:4738)
- ld a, $5
- lb de, $0, $a
+ ld a, 5
+ lb de, 0, 10
jp Func_2c0d4
; 0x2c740
INCROM $2c740, $2c77e
+; If heads, defending Pokemon can't retreat next turn
AcidEffect: ; 2c77e (b:477e)
ldtx de, AcidCheckText
call TossCoin_BankB
@@ -263,12 +276,12 @@ AcidEffect: ; 2c77e (b:477e)
; 0x2c78b
GloomPoisonPowder_AIEffect: ; 2c78b (b:478b)
- ld a, $a
- lb de, $a, $a
+ ld a, 10
+ lb de, 10, 10
jp Func_2c0d4
; 0x2c793
-; confuses both the target and the user
+; Defending Pokemon and user become confused
FoulOdorEffect: ; 2c793 (b:4793)
call ConfusionEffect
call SwapTurn
@@ -277,6 +290,7 @@ FoulOdorEffect: ; 2c793 (b:4793)
ret
; 0x2c7a0
+; If heads, prevent all damage done to user next turn
KakunaStiffenEffect: ; 2c7a0 (b:47a0)
ldtx de, IfHeadsNoDamageNextTurnText
call TossCoin_BankB
@@ -289,13 +303,14 @@ KakunaStiffenEffect: ; 2c7a0 (b:47a0)
; 0x2c7b4
KakunaPoisonPowder_AIEffect: ; 2c7b4 (b:47b4)
- ld a, $5
- lb de, $0, $a
+ ld a, 5
+ lb de, 0, 10
jp Func_2c0d4
; 0x2c7bc
INCROM $2c7bc, $2c7d0
+; During your next turn, double damage
SwordsDanceEffect: ; 2c7d0 (b:47d0)
ld a, [wTempTurnDuelistCardID]
cp SCYTHER
@@ -305,15 +320,54 @@ SwordsDanceEffect: ; 2c7d0 (b:47d0)
ret
; 0x2c7dc
+; If heads, defending Pokemon becomes confused
ZubatSupersonicEffect: ; 2c7dc (b:47dc)
call Confusion50PercentEffect
call nc, SetNoEffectFromStatus
ret
; 0x2c7e3
- INCROM $2c7e3, $2c836
+ INCROM $2c7e3, $2c7ed
+
+Twineedle_AIEffect: ; 2c7ed (b:47ed)
+ ld a, 30
+ lb de, 0, 60
+ jp Func_2c0fb
+; 0x2c7f5
+
+; Flip 2 coins; deal 30x number of heads
+Twineedle_MultiplierEffect: ; 2c7f5 (b:47f5)
+ ld hl, 30
+ call LoadTxRam3
+ ldtx de, DamageCheckIfHeadsXDamageText
+ ld a, 2
+ call TossCoinATimes_BankB
+ ld e, a
+ add a
+ add e
+ call ATimes10
+ call Func_2c166
+ ret
+; 0x2c80d
+
+ INCROM $2c80d, $2c822
+
+FoulGas_AIEffect: ; 2c822 (b:4822)
+ ld a, 5
+ lb de, 0, 10
+ jp Func_2c0e9
+; 0x2c82a
+
+; If heads, defending Pokemon becomes poisoned. If tails, defending Pokemon becomes confused
+FoulGas_PoisonOrConfusionEffect: ; 2c82a (b:482a)
+ ldtx de, PoisonedIfHeadsConfusedIfTailsText
+ call TossCoin_BankB
+ jp c, PoisonEffect
+ jp ConfusionEffect
+; 0x2c836
; an exact copy of KakunaStiffenEffect
+; If heads, prevent all damage done to user next turn
MetapodStiffenEffect: ; 2c836 (b:4836)
ldtx de, IfHeadsNoDamageNextTurnText
call TossCoin_BankB
@@ -325,4 +379,92 @@ MetapodStiffenEffect: ; 2c836 (b:4836)
ret
; 0x2c84a
- INCROM $2c84a, $30000
+ INCROM $2c84a, $2c925
+
+BigEggsplosion_AIEffect: ; 2c925 (b:4925)
+ ldh a, [hTempPlayAreaLocation_ff9d]
+ ld e, a
+ call GetPlayAreaCardAttachedEnergies
+ ld a, [wTotalAttachedEnergies]
+ call SetDamageToATimes20
+ inc h
+ jr nz, .capped
+ ld l, 255
+.capped
+ ld a, l
+ ld [wAIMaxDamage], a
+ srl a
+ ld [wDamage], a
+ xor a
+ ld [wAIMinDamage], a
+ ret
+; 0x2c944
+
+; Flip coins equal to attached energies; deal 20x number of heads
+BigEggsplosion_MultiplierEffect: ; 2c944 (b:4944)
+ ld e, PLAY_AREA_ARENA
+ call GetPlayAreaCardAttachedEnergies
+ ld hl, 20
+ call LoadTxRam3
+ ld a, [wTotalAttachedEnergies]
+ ldtx de, DamageCheckIfHeadsXDamageText
+ call TossCoinATimes_BankB
+; fallthrough
+
+; set damage to 20*a. Also return result in hl
+SetDamageToATimes20: ; 2c958 (b:4958)
+ ld l, a
+ ld h, $00
+ ld e, l
+ ld d, h
+ add hl, hl
+ add hl, hl
+ add hl, de
+ add hl, hl
+ add hl, hl
+ ld a, l
+ ld [wDamage], a
+ ld a, h
+ ld [wDamage + 1], a
+ ret
+; 0x2c96b
+
+Thrash_AIEffect: ; 2c96b (b:496b)
+ ld a, 35
+ lb de, 30, 40
+ jp Func_2c0fb
+; 0x2c973
+
+; If heads 10 more damage; if tails, 10 damage to itself
+Thrash_ModifierEffect: ; 2c973 (b:4973)
+ ldtx de, IfHeadPlus10IfTails10ToYourselfText
+ call TossCoin_BankB
+ ldh [hTemp_ffa0], a
+ ret nc
+ ld a, 10
+ call AddToDamage
+ ret
+; 0x2c982
+
+Func_2c982: ; 2c982 (b:4982)
+ ldh a, [hTemp_ffa0]
+ or a
+ ret nz
+ ld a, 10
+ call Func_1955
+ ret
+; 0x2c98c
+
+Toxic_AIEffect: ; 2c98c (b:498c)
+ ld a, 20
+ lb de, 20, 20
+ jp Func_2c0e9
+; 0x2c994
+
+; Defending Pokémon becomes poisoned, but takes 20 damage (double poisoned)
+Toxic_DoublePoisonEffect: ; 2c994 (b:4994)
+ call DoublePoisonEffect
+ ret
+; 0x2c998
+
+ INCROM $2c998, $30000
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 40a1f85..ff07a17 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -4453,11 +4453,11 @@ Func_16f6: ; 16f6 (0:16f6)
xor a
ld [wccec], a
ld [wEffectFunctionsFeedbackIndex], a
- ld [wcced], a
+ ld [wEffectFailed], a
ld [wIsDamageToSelf], a
ld [wccef], a
ld [wccf0], a
- ld [wccf1], a
+ ld [wNoEffectFromStatus], a
bank1call ClearNonTurnTemporaryDuelvars_CopyStatus
ret
@@ -5175,10 +5175,10 @@ Func_1bb4: ; 1bb4 (0:1bb4)
call ExchangeRNG
ret
-; prints one of the ThereWasNoEffectFrom*Text if wcced contains $1,
-; and WasUnsuccessfulText if wcced contains $2
+; prints one of the ThereWasNoEffectFrom*Text if wEffectFailed contains EFFECT_FAILED_NO_EFFECT,
+; and prints WasUnsuccessfulText if wEffectFailed contains EFFECT_FAILED_UNSUCCESSFUL
Func_1bca: ; 1bca (0:1bca)
- ld a, [wcced]
+ ld a, [wEffectFailed]
or a
ret z
cp $1
@@ -9303,16 +9303,22 @@ Func_30a6: ; 30a6 (0:30a6)
call BankswitchROM
ret
-DrawYourOrOppPlayArea: ; 30bc (0:30bc)
+; loads tiles and icons to display Your Play Area / Opp. Play Area screen,
+; and draws the screen according to the turn player
+; input: h -> [wCheckMenuPlayAreaWhichDuelist] and l -> [wCheckMenuPlayAreaWhichLayout]
+; similar to DrawYourOrOppPlayArea (bank 2) except it also draws a wide text box.
+; this is because bank 2's DrawYourOrOppPlayArea is supposed to come from the Check Menu,
+; so the text box is always already there.
+DrawYourOrOppPlayAreaScreen_Bank0: ; 30bc (0:30bc)
ld a, h
- ld [wTurnHolder1], a
+ ld [wCheckMenuPlayAreaWhichDuelist], a
ld a, l
- ld [wTurnHolder2], a
+ ld [wCheckMenuPlayAreaWhichLayout], a
ldh a, [hBankROM]
push af
- ld a, BANK(_DrawYourOrOppPlayArea)
+ ld a, BANK(_DrawYourOrOppPlayAreaScreen)
call BankswitchROM
- call _DrawYourOrOppPlayArea
+ call _DrawYourOrOppPlayAreaScreen
call DrawWideTextBox
pop af
call BankswitchROM
diff --git a/src/text/text1.asm b/src/text/text1.asm
index e7b0fe4..8789758 100644
--- a/src/text/text1.asm
+++ b/src/text/text1.asm
@@ -1093,7 +1093,7 @@ Text00e8: ; 37d92 (d:7d92)
line "10 damage for each Heads!!!"
done
-Text00e9: ; 37dc9 (d:7dc9)
+IfHeadPlus10IfTails10ToYourselfText: ; 37dc9 (d:7dc9)
text "If Heads, + 10 damage!"
line "If Tails, +10 damage to yourself!"
done
@@ -1142,12 +1142,12 @@ Text00f2: ; 37f9a (d:7f9a)
text "Damage check"
done
-Text00f3: ; 37fa8 (d:7fa8)
+DamageCheckIfHeadsPlusDamageText: ; 37fa8 (d:7fa8)
text "Damage check!"
line "If Heads, +<RAMNUM> damage!!"
done
-Text00f4: ; 37fcd (d:7fcd)
+DamageCheckIfHeadsXDamageText: ; 37fcd (d:7fcd)
text "Damage check!"
line "If Heads, x <RAMNUM> damage!!"
done
diff --git a/src/text/text2.asm b/src/text/text2.asm
index 78fb6f9..8dac791 100644
--- a/src/text/text2.asm
+++ b/src/text/text2.asm
@@ -22,7 +22,7 @@ PokemonsSleepCheckText: ; 380db (e:40db)
text "<RAMTEXT>'s Sleep check."
done
-Text00fa: ; 380ed (e:40ed)
+PoisonedIfHeadsConfusedIfTailsText: ; 380ed (e:40ed)
text "Opponent is Poisoned if Heads,"
line "and Confused if Tails."
done
diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm
index f1ca193..6e03ba2 100644
--- a/src/text/text_offsets.asm
+++ b/src/text/text_offsets.asm
@@ -234,7 +234,7 @@ TextOffsets:: ; 34000 (d:4000)
textpointer Text00e6 ; 0x00e6
textpointer Text00e7 ; 0x00e7
textpointer Text00e8 ; 0x00e8
- textpointer Text00e9 ; 0x00e9
+ textpointer IfHeadPlus10IfTails10ToYourselfText ; 0x00e9
textpointer Text00ea ; 0x00ea
textpointer Text00eb ; 0x00eb
textpointer Text00ec ; 0x00ec
@@ -244,14 +244,14 @@ TextOffsets:: ; 34000 (d:4000)
textpointer Text00f0 ; 0x00f0
textpointer IfHeadsNoDamageNextTurnText ; 0x00f1
textpointer Text00f2 ; 0x00f2
- textpointer Text00f3 ; 0x00f3
- textpointer Text00f4 ; 0x00f4
+ textpointer DamageCheckIfHeadsPlusDamageText ; 0x00f3
+ textpointer DamageCheckIfHeadsXDamageText ; 0x00f4
textpointer AcidCheckText ; 0x00f5
textpointer TransparencyCheckText ; 0x00f6
textpointer ConfusionCheckDamageText ; 0x00f7
textpointer ConfusionCheckRetreatText ; 0x00f8
textpointer PokemonsSleepCheckText ; 0x00f9
- textpointer Text00fa ; 0x00fa
+ textpointer PoisonedIfHeadsConfusedIfTailsText ; 0x00fa
textpointer Text00fb ; 0x00fb
textpointer Text00fc ; 0x00fc
textpointer AttackUnsuccessfulText ; 0x00fd
diff --git a/src/wram.asm b/src/wram.asm
index a06be8c..caba9d1 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -190,9 +190,7 @@ wPlayerArenaCardDisabledMoveIndex:: ; c2f2
; damage taken the last time the opponent attacked (0 if no damage)
wPlayerArenaCardLastTurnDamage:: ; c2f3
- ds $1
-
- ds $1
+ ds $2
; status condition received the last time the opponent attacked (0 if none)
wPlayerArenaCardLastTurnStatus:: ; c2f5
@@ -333,9 +331,7 @@ wOpponentArenaCardDisabledMoveIndex:: ; c3f2
ds $1
wOpponentArenaCardLastTurnDamage:: ; c3f3
- ds $1
-
- ds $1
+ ds $2
wOpponentArenaCardLastTurnStatus:: ; c3f5
ds $1
@@ -919,24 +915,25 @@ wLoadedMove:: ; cca6
move_data_struct wLoadedMove
; the damage field of an used move is loaded here
+; doubles as "wAIAverageDamage" when complementing wAIMinDamage and wAIMaxDamage
+; little-endian
wDamage:: ; ccb9
ds $2
-; wccbb and wccbc appear to be used for AI scoring
-wccbb:: ; ccbb
+; wAIMinDamage and wAIMaxDamage appear to be used for AI scoring
+; they are updated with the minimum (or floor) damage of the current move
+; and with the maximum (or ceiling) damage of the current move
+wAIMinDamage:: ; ccbb
ds $1
-wccbc:: ; ccbc
+wAIMaxDamage:: ; ccbc
ds $1
ds $2
; damage dealt by an attack to a target
wDealtDamage:: ; ccbf
- ds $1
-
-wccc0:: ; ccc0
- ds $1
+ ds $2
; WEAKNESS and RESISTANCE flags for a damaging attack
wDamageEffectiveness:: ; ccc1
@@ -999,16 +996,15 @@ 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
+; in order print the appropriate text
+wEffectFailed:: ; 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
+; flag to determine whether DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE
+; gets zeroed or gets updated with wDealtDamage
wccef:: ; ccef
ds $1
@@ -1017,7 +1013,7 @@ wccf0:: ; ccf0
; 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
+wNoEffectFromStatus:: ; ccf1
ds $1
; when non-0, allows the player to skip some delays during a duel by pressing B.
@@ -1301,12 +1297,16 @@ wTextBoxLabel:: ; ce4c
wCoinTossScreenTextID:: ; ce4e
ds $2
-; these hold either player or opponent turn
-; for temporary calculations
-wTurnHolder1:: ; ce50
+; set to PLAYER_TURN in the "Your Play Area" screen
+; set to OPPONENT_TURN in the "Opp Play Area" screen
+; alternates when drawing the "In Play Area" screen
+wCheckMenuPlayAreaWhichDuelist:: ; ce50
ds $1
-wTurnHolder2:: ; ce51
+; apparently complements wCheckMenuPlayAreaWhichDuelist to be able to combine
+; the usual player or opponent layout with the opposite duelist information
+; appears not to be relevant in the "In Play Area" screen
+wCheckMenuPlayAreaWhichLayout:: ; ce51
ds $1
; holds the position of the cursor
@@ -1470,7 +1470,7 @@ wceb4:: ; ceb4
wceb5:: ; ceb5
ds $1
-; used to store the tens digit and
+; used to store the tens digit and
; ones digit of a value for printing
; the ones digit is added $20
; ceb6 = ones digit (+ $20)