summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxCrystal <rgr.crystal@gmail.com>2016-03-04 21:38:39 +0100
committerxCrystal <rgr.crystal@gmail.com>2016-03-05 00:21:05 +0100
commitce16914bb06788557b8ca19132008c34ddb38894 (patch)
treeba46bab7c584284cfb6a80a27ebebc2fe738a36c /src
parentfb524eaa51f02a4a1fbd54962132dd3c67989ee6 (diff)
start dissasembling move effect functions
and plenty of other duel related stuff
Diffstat (limited to 'src')
-rw-r--r--src/constants/duel_constants.asm11
-rw-r--r--src/data/effect_commands.asm105
-rwxr-xr-xsrc/engine/bank1.asm216
-rw-r--r--src/engine/effect_functions.asm95
-rwxr-xr-xsrc/engine/home.asm132
-rwxr-xr-xsrc/macros.asm8
-rwxr-xr-xsrc/main.asm2
-rwxr-xr-xsrc/text/text1.asm14
-rwxr-xr-xsrc/text/text_offsets.asm14
-rwxr-xr-xsrc/wram.asm15
10 files changed, 462 insertions, 150 deletions
diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm
index 849a671..0ba6715 100644
--- a/src/constants/duel_constants.asm
+++ b/src/constants/duel_constants.asm
@@ -38,7 +38,10 @@ CARD_LOCATION_BENCH_4 EQU $14
CARD_LOCATION_BENCH_5 EQU $15
; status condition constants
-CARD_NOSTATUS EQU $00
-CARD_CONFUSED EQU $01
-CARD_ASLEEP EQU $02
-CARD_PARALYZED EQU $03
+; two statuses can be combined if they are identified by a different nybble
+CARD_NOSTATUS EQU $00
+CARD_CONFUSED EQU $01
+CARD_ASLEEP EQU $02
+CARD_PARALYZED EQU $03
+CARD_POISONED EQU $80
+CARD_DOUBLE_POISONED EQU $c0
diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm
index 103abfd..5d4754f 100644
--- a/src/data/effect_commands.asm
+++ b/src/data/effect_commands.asm
@@ -13,7 +13,6 @@ EffectCommands: ; 186f7 (6:46f7)
; Similar move effects of different Pokemon cards all point to a different command list,
; even though in some cases their commands and function pointers match.
-; xxx use <TrainerCardName>EffectCommands or <EnergyCardName>EffectCommands for these types of cards.
EkansSpitPoisonEffectCommands:
dbw $03, $46f8
@@ -21,7 +20,7 @@ EkansSpitPoisonEffectCommands:
db $00
EkansWrapEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
ArbokTerrorStrikeEffectCommands:
@@ -31,12 +30,12 @@ ArbokTerrorStrikeEffectCommands:
db $00
ArbokPoisonFangEffectCommands:
- dbw $03, $4007
+ dbw $03, PoisonEffect
dbw $09, $4730
db $00
WeepinbellPoisonPowderEffectCommands:
- dbw $03, $4000
+ dbw $03, Poison50PercentEffect
dbw $09, $4738
db $00
@@ -52,15 +51,15 @@ VictreebelAcidEffectCommands:
db $00
PinsirIronGripEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
CaterpieStringShotEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
GloomPoisonPowderEffectCommands:
- dbw $03, $4007
+ dbw $03, PoisonEffect
dbw $09, $478b
db $00
@@ -73,7 +72,7 @@ KakunaStiffenEffectCommands:
db $00
KakunaPoisonPowderEffectCommands:
- dbw $03, $4000
+ dbw $03, Poison50PercentEffect
dbw $09, $47b4
db $00
@@ -82,7 +81,7 @@ GolbatLeechLifeEffectCommands:
db $00
VenonatStunSporeEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
VenonatLeechLifeEffectCommands:
@@ -107,12 +106,12 @@ BeedrillTwineedleEffectCommands:
db $00
BeedrillPoisonStingEffectCommands:
- dbw $03, $4000
+ dbw $03, Poison50PercentEffect
dbw $09, $480d
db $00
ExeggcuteHypnosisEffectCommands:
- dbw $03, $4030
+ dbw $03, SleepEffect
db $00
ExeggcuteLeechSeedEffectCommands:
@@ -129,11 +128,11 @@ MetapodStiffenEffectCommands:
db $00
MetapodStunSporeEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
OddishStunSporeEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
OddishSproutEffectCommands:
@@ -212,20 +211,20 @@ ButterfreeMegaDrainEffectCommands:
db $00
ParasSporeEffectCommands:
- dbw $03, $4030
+ dbw $03, SleepEffect
db $00
ParasectSporeEffectCommands:
- dbw $03, $4030
+ dbw $03, SleepEffect
db $00
WeedlePoisonStingEffectCommands:
- dbw $03, $4000
+ dbw $03, Poison50PercentEffect
dbw $09, $4b27
db $00
IvysaurPoisonPowderEffectCommands:
- dbw $03, $4007
+ dbw $03, PoisonEffect
dbw $09, $4b2f
db $00
@@ -241,7 +240,7 @@ VenusaurEnergyTransEffectCommands:
db $00
GrimerNastyGooEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
GrimerMinimizeEffectCommands:
@@ -253,7 +252,7 @@ MukToxicGasEffectCommands:
db $00
MukSludgeEffectCommands:
- dbw $03, $4000
+ dbw $03, Poison50PercentEffect
dbw $09, $4c38
db $00
@@ -265,7 +264,7 @@ BellsproutCallforFamilyEffectCommands:
db $00
WeezingSmogEffectCommands:
- dbw $03, $4000
+ dbw $03, Poison50PercentEffect
dbw $09, $4ce2
db $00
@@ -285,11 +284,11 @@ VenomothVenomPowderEffectCommands:
db $00
TangelaBindEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
TangelaPoisonPowderEffectCommands:
- dbw $03, $4007
+ dbw $03, PoisonEffect
dbw $09, $4da0
db $00
@@ -304,11 +303,11 @@ VileplumePetalDanceEffectCommands:
db $00
TangelaStunSporeEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
TangelaPoisonWhipEffectCommands:
- dbw $03, $4007
+ dbw $03, PoisonEffect
dbw $09, $4e4b
db $00
@@ -354,7 +353,7 @@ BlastoiseHydroPumpEffectCommands:
db $00
GyaradosBubblebeamEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
KinglerFlailEffectCommands:
@@ -384,7 +383,7 @@ PsyduckFurySweepesEffectCommands:
db $00
GolduckPsyshockEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
GolduckHyperBeamEffectCommands:
@@ -421,7 +420,7 @@ VaporeonWaterGunEffectCommands:
db $00
DewgongIceBeamEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
StarmieRecoverEffectCommands:
@@ -433,11 +432,11 @@ StarmieRecoverEffectCommands:
db $00
StarmieStarFreezeEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
SquirtleBubbleEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
SquirtleWithdrawEffectCommands:
@@ -453,7 +452,7 @@ TentacruelSupersonicEffectCommands:
db $00
TentacruelJellyfishStingEffectCommands:
- dbw $03, $4007
+ dbw $03, PoisonEffect
dbw $09, $5141
db $00
@@ -495,7 +494,7 @@ CloysterSpikeCannonEffectCommands:
db $00
ArticunoFreezeDryEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
ArticunoBlizzardEffectCommands:
@@ -515,7 +514,7 @@ LaprasWaterGunEffectCommands:
db $00
LaprasConfuseRayEffectCommands:
- dbw $03, $401d
+ dbw $03, Confusion50PercentEffect
db $00
ArticunoQuickfreezeEffectCommands:
@@ -624,7 +623,7 @@ MagmarSmokescreenEffectCommands:
db $00
MagmarSmogEffectCommands:
- dbw $03, $4000
+ dbw $03, Poison50PercentEffect
dbw $09, $559a
db $00
@@ -647,7 +646,7 @@ CharizardFireSpinEffectCommands:
db $00
VulpixConfuseRayEffectCommands:
- dbw $03, $401d
+ dbw $03, Confusion50PercentEffect
db $00
FlareonRageEffectCommands:
@@ -675,7 +674,7 @@ Moltres2DiveBombEffectCommands:
db $00
AbraPsyshockEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
GengarCurseEffectCommands:
@@ -703,7 +702,7 @@ GastlyDestinyBondEffectCommands:
db $00
GastlyLickEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
GastlyEnergyConversionEffectCommands:
@@ -714,7 +713,7 @@ GastlyEnergyConversionEffectCommands:
db $00
HaunterHypnosisEffectCommands:
- dbw $03, $4030
+ dbw $03, SleepEffect
db $00
HaunterDreamEaterEffectCommands:
@@ -726,7 +725,7 @@ HaunterTransparencyEffectCommands:
db $00
HaunterNightmareEffectCommands:
- dbw $03, $4030
+ dbw $03, SleepEffect
db $00
HypnoProphecyEffectCommands:
@@ -743,7 +742,7 @@ HypnoDarkMindEffectCommands:
db $00
DrowzeeConfuseRayEffectCommands:
- dbw $03, $401d
+ dbw $03, Confusion50PercentEffect
db $00
MrMimeInvisibleWallEffectCommands:
@@ -762,7 +761,7 @@ AlakazamDamageSwapEffectCommands:
db $00
AlakazamConfuseRayEffectCommands:
- dbw $03, $401d
+ dbw $03, Confusion50PercentEffect
db $00
MewPsywaveEffectCommands:
@@ -782,7 +781,7 @@ MewNeutralizingShieldEffectCommands:
db $00
MewPsyshockEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
MewtwoPsychicEffectCommands:
@@ -819,7 +818,7 @@ SlowbroStrangeBehaviorEffectCommands:
db $00
SlowbroPsyshockEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
SlowpokeSpacingOutEffectCommands:
@@ -985,7 +984,7 @@ MarowakWailEffectCommands:
db $00
ElectabuzzThundershockEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
ElectabuzzThunderpunchEffectCommands:
@@ -1004,7 +1003,7 @@ ElectabuzzQuickAttackEffectCommands:
db $00
MagnemiteThunderWaveEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
MagnemiteSelfdestructEffectCommands:
@@ -1035,7 +1034,7 @@ JolteonPinMissileEffectCommands:
db $00
FlyingPikachuThundershockEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
FlyingPikachuFlyEffectCommands:
@@ -1059,7 +1058,7 @@ Pikachu3GrowlEffectCommands:
db $00
Pikachu3ThundershockEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
Pikachu4GrowlEffectCommands:
@@ -1067,7 +1066,7 @@ Pikachu4GrowlEffectCommands:
db $00
Pikachu4ThundershockEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
ElectrodeChainLightningEffectCommands:
@@ -1090,7 +1089,7 @@ RaichuGigashockEffectCommands:
db $00
MagnetonThunderWaveEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
Magneton1SelfdestructEffectCommands:
@@ -1139,7 +1138,7 @@ JolteonDoubleKickEffectCommands:
db $00
JolteonStunNeedleEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
EeveeTailWagEffectCommands:
@@ -1180,7 +1179,7 @@ SnorlaxThickSkinnedEffectCommands:
db $00
SnorlaxBodySlamEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
FarfetchdLeekSlapEffectCommands:
@@ -1279,7 +1278,7 @@ ClefairyMetronomeEffectCommands:
db $00
WigglytuffLullabyEffectCommands:
- dbw $03, $4030
+ dbw $03, SleepEffect
db $00
WigglytuffDotheWaveEffectCommands:
@@ -1288,7 +1287,7 @@ WigglytuffDotheWaveEffectCommands:
db $00
JigglypuffLullabyEffectCommands:
- dbw $03, $4030
+ dbw $03, SleepEffect
db $00
JigglypuffFirstAidEffectCommands:
@@ -1305,7 +1304,7 @@ PersianPounceEffectCommands:
db $00
LickitungTongueWrapEffectCommands:
- dbw $03, $4011
+ dbw $03, Paralysis50PercentEffect
db $00
LickitungSupersonicEffectCommands:
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm
index 6ca20d2..7ab0b22 100755
--- a/src/engine/bank1.asm
+++ b/src/engine/bank1.asm
@@ -54,9 +54,9 @@ StartDuel: ; 409f (1:409f)
ld a, [$cc19]
ld [wOpponentDeckId], a
call LoadPlayerDeck
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call LoadOpponentDeck
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
jr .asm_40ca
ld a, MUSIC_DUELTHEME1
@@ -109,7 +109,7 @@ StartDuel: ; 409f (1:409f)
jr z, .asm_4126
.asm_4121
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
jr .mainDuelLoop
.asm_4126
@@ -258,9 +258,9 @@ Func_4225: ; 4225 (1:4225)
ld a, [$cc0d]
cp $00
jr z, Func_4262
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call Func_34e2
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call c, $4b2c
jr Func_426d
@@ -365,9 +365,9 @@ Func_4320: ; 4320 (1:4320)
jp Func_426d
Func_4329: ; 4329 (1:4329)
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call Func_4333
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ret
Func_4333: ; 4333 (1:4333)
@@ -375,9 +375,9 @@ Func_4333: ; 4333 (1:4333)
jp $6008
Func_4339: ; 4339 (1:4339)
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call $5550
- jp GetOpposingTurnDuelistVariable_SwapTurn
+ jp SwapTurn
Func_4342: ; 4342 (1:4342)
jp $5550
@@ -865,7 +865,7 @@ InitializeDuelVariables: ; 7107 (1:7107)
pop af
pop hl
ld [hl], a
- ld bc, DECK_SIZE ; lb bc, DUELVARS_CARD_LOCATIONS, DECK_SIZE
+ lb bc, DUELVARS_CARD_LOCATIONS, DECK_SIZE
ld l, DUELVARS_DECK_CARDS
.initDuelVariablesLoop
; zero card locations and cards in hand, and init order of cards in deck
@@ -889,7 +889,201 @@ InitializeDuelVariables: ; 7107 (1:7107)
ret
; 0x7133
-INCBIN "baserom.gbc",$7133,$7354 - $7133
+INCBIN "baserom.gbc",$7133,$71ad - $7133
+
+TossCoin: ; 71ad (1:71ad)
+ ld [$cd9c], a
+ ld a, [wcac2]
+ cp $6
+ jr z, .asm_71c1
+ xor a
+ ld [$cd9f], a
+ call Func_04a2
+ call $210f
+
+.asm_71c1
+ ld a, [$cd9f]
+ or a
+ jr nz, .asm_71ec
+ ld a, $6
+ ld [wcac2], a
+ ld de, $000c
+ ld bc, $1406
+ ld hl, $0000
+ call DrawLabeledTextBox
+ call EnableLCD
+ ld de, $010e
+ ld a, $13
+ call Func_22a6
+ ld hl, wCoinTossScreenTextId
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call PrintText
+
+.asm_71ec
+ ld hl, wCoinTossScreenTextId
+ xor a
+ ld [hli], a
+ ld [hl], a
+ call EnableLCD
+ ld a, $f1
+ call GetTurnDuelistVariable
+ ld [$cd9e], a
+ call Func_0f58
+ xor a
+ ld [$cd9d], a
+ ld a, [$cd9c]
+ cp $2
+ jr c, .asm_7223
+ ld bc, $0f0b
+ ld a, [$cd9f]
+ inc a
+ call $65b7
+ ld b, $11
+ ld a, $2e
+ call Func_06c3
+ inc b
+ ld a, [$cd9c]
+ call $65b7
+
+.asm_7223
+ call Func_3b21
+ ld a, $58
+ call Func_3b6a
+ ld a, [$cd9e]
+ or a
+ jr z, .asm_7236
+ call $7324
+ jr .asm_723c
+
+.asm_7236
+ call WaitForWideTextBoxInput
+ call $72ff
+
+.asm_723c
+ call Func_3b21
+ ld d, $5a
+ ld e, $0
+ call UpdateRNGSources
+ rra
+ jr c, .asm_724d
+ ld d, $59
+ ld e, $1
+
+.asm_724d
+ ld a, d
+ call Func_3b6a
+ ld a, [$cd9e]
+ or a
+ jr z, .asm_725e
+ ld a, e
+ call $7310
+ ld e, a
+ jr .asm_726c
+
+.asm_725e
+ push de
+ call DoFrame
+ call Func_3b52
+ pop de
+ jr c, .asm_725e
+ ld a, e
+ call $72ff
+
+.asm_726c
+ ld b, $5c
+ ld c, $34
+ ld a, e
+ or a
+ jr z, .asm_727c
+ ld b, $5b
+ ld c, $30
+ ld hl, $cd9d
+ inc [hl]
+
+.asm_727c
+ ld a, b
+ call Func_3b6a
+ ld a, [$cd9e]
+ or a
+ jr z, .asm_728a
+ ld a, $1
+ xor e
+ ld e, a
+
+.asm_728a
+ ld d, $54
+ ld a, e
+ or a
+ jr nz, .asm_7292
+ ld d, $55
+
+.asm_7292
+ ld a, d
+ call Func_3796
+ ld a, [$cd9c]
+ dec a
+ jr z, .asm_72b9
+ ld a, c
+ push af
+ ld e, $0
+ ld a, [$cd9f]
+.asm_72a3
+ cp $a
+ jr c, .asm_72ad
+ inc e
+ inc e
+ sub $a
+ jr .asm_72a3
+
+.asm_72ad
+ add a
+ ld d, a
+ ld bc, $0202
+ ld hl, $0102
+ pop af
+ call Func_1f5f
+
+.asm_72b9
+ ld hl, $cd9f
+ inc [hl]
+ ld a, [$cd9e]
+ or a
+ jr z, .asm_72dc
+ ld a, [hl]
+ ld hl, $cd9c
+ cp [hl]
+ call z, WaitForWideTextBoxInput
+ call $7324
+ ld a, [$cd9c]
+ ld hl, $cd9d
+ or [hl]
+ jr nz, .asm_72e2
+ call z, WaitForWideTextBoxInput
+ jr .asm_72e2
+
+.asm_72dc
+ call WaitForWideTextBoxInput
+ call $72ff
+
+.asm_72e2
+ call Func_3b31
+ ld a, [$cd9f]
+ ld hl, $cd9c
+ cp [hl]
+ jp c, $7204
+ call Func_0f58
+ call Func_3b31
+ call Func_3b21
+ ld a, [$cd9d]
+ or a
+ ret z
+ scf
+ ret
+; 0x72ff
+
+INCBIN "baserom.gbc",$72ff,$7354 - $72ff
BuildVersion: ; 7354 (1:7354)
db "VER 12/20 09:36",TX_END
diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm
new file mode 100644
index 0000000..84d3b0b
--- /dev/null
+++ b/src/engine/effect_functions.asm
@@ -0,0 +1,95 @@
+Poison50PercentEffect: ; 2c000 (b:4000)
+ text_de PoisonCheckText
+ call DisplayCoinTossScreen2_BankB
+ ret nc
+
+PoisonEffect: ; 2c007 (b:4007)
+ lb bc, $0f, CARD_POISONED
+ jr applyEffect
+
+ lb bc, $0f, CARD_DOUBLE_POISONED
+ jr applyEffect
+
+Paralysis50PercentEffect: ; 2c011 (b:4011)
+ text_de ParalysisCheckText
+ call DisplayCoinTossScreen2_BankB
+ ret nc
+ lb bc, $f0, CARD_PARALYZED
+ jr applyEffect
+
+Confusion50PercentEffect: ; 2c01d (b:401d)
+ text_de ConfusionCheckText
+ call DisplayCoinTossScreen2_BankB
+ ret nc
+ lb bc, $f0, CARD_CONFUSED
+ jr applyEffect
+
+ text_de SleepCheckText
+ call DisplayCoinTossScreen2_BankB
+ ret nc
+
+SleepEffect: ; 2c030 (b:4030)
+ lb bc, $f0, CARD_ASLEEP
+ jr applyEffect
+
+applyEffect
+ ld a, [$ff97]
+ ld hl, $cc05
+ cp [hl]
+ jr nz, .asm_2c061
+ ld a, [wccc4]
+ cp $cb
+ jr z, .asm_2c058
+ cp $cc
+ jr z, .asm_2c058
+ cp $be
+ jr nz, .asm_2c061
+ call SwapTurn
+ xor a
+ call Func_34f0
+ call SwapTurn
+ jr c, .asm_2c061
+
+.asm_2c058
+ ld a, c
+ ld [wccf1], a
+ call Func_2c09c
+ or a
+ ret
+
+.asm_2c061
+ ld hl, wcccd
+ push hl
+ ld e, [hl]
+ ld d, $0
+ ld hl, $ccce
+ add hl, de
+ call SwapTurn
+ ld a, [$ff97]
+ ld [hli], a
+ call SwapTurn
+ ld [hl], b
+ inc hl
+ ld [hl], c
+ pop hl
+ inc [hl]
+ inc [hl]
+ inc [hl]
+ scf
+ ret
+; 0x2c07e
+
+DisplayCoinTossScreen2_BankB: ; 2c07e (b:407e)
+ call DisplayCoinTossScreen2
+ ret
+; 0x2c082
+
+INCBIN "baserom.gbc",$2c082,$2c09c - $2c082
+
+Func_2c09c: ; 2c09c (b:409c)
+ ld a, $1
+ ld [wcced], a
+ ret
+; 0x2c0a2
+
+INCBIN "baserom.gbc",$2c0a2,$30000 - $2c0a2
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 5a10d44..3875ff7 100755
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -2180,13 +2180,13 @@ Func_100b: ; 100b (0:100b)
call LoadDeckCardToDE
ld a, e
ld [wccc3], a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
call LoadDeckCardToDE
ld a, e
ld [wccc4], a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
pop hl
push hl
call EnableExtRAM
@@ -2531,13 +2531,13 @@ Func_16f6: ; 16f6 (0:16f6)
call LoadDeckCardToDE
ld a, e
ld [wccc3], a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
call LoadDeckCardToDE
ld a, e
ld [wccc4], a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
xor a
ld [wccec], a
ld [wcccd], a
@@ -2595,9 +2595,9 @@ Func_1730: ; 1730 (0:1730)
ld a, [wccb1]
and $80
jr nz, .asm_17ad
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call Func_3432
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
.asm_17ad
xor a
ld [$ff9d], a
@@ -2749,11 +2749,11 @@ Func_189d: ; 189d (0:189d)
ret z
.asm_18b9
push de
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
xor a
ld [wcceb], a
call Func_348a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
pop de
ret nc
bank1call $4f9d
@@ -2775,7 +2775,7 @@ Func_18d7: ; 18d7 (0:18d7)
ret
.confused
ld de, $00f7
- call Func_307d
+ call DisplayCoinTossScreen2
jr c, .asm_18f7
ld a, $1
ld [wccc9], a
@@ -2846,9 +2846,9 @@ Func_1994: ; 1994 (0:1994)
call Func_36f7
call Func_1a0e
ld b, a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call Func_3730
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
and b
jr z, .asm_19dc
sla e
@@ -2856,9 +2856,9 @@ Func_1994: ; 1994 (0:1994)
ld hl, $ccc1
set 1, [hl]
.asm_19dc
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call Func_374a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
and b
jr z, .asm_19f3
ld hl, $ffe2
@@ -2870,7 +2870,7 @@ Func_1994: ; 1994 (0:1994)
.asm_19f3
ld b, CARD_LOCATION_ARENA
call ApplyAttachedPluspower
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ld b, CARD_LOCATION_ARENA
call ApplyAttachedDefender
call Func_3244
@@ -2878,7 +2878,7 @@ Func_1994: ; 1994 (0:1994)
jr z, .asm_1a0a
ld de, $0000
.asm_1a0a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ret
Func_1a0e: ; 1a0e (0:1a0e)
@@ -3103,10 +3103,11 @@ Func_1bca: ; 1bca (0:1bca)
INCBIN "baserom.gbc",$1c05,$1c72 - $1c05
-; returns [([hWhoseTurn] ^ $1) << 8 + a] in a
-; i.e. variable a of the player whose turn it is not
-; Also: [hWhoseTurn] <-- ([hWhoseTurn] ^ $1)
-GetOpposingTurnDuelistVariable_SwapTurn: ; 1c72 (0:1c72)
+; returns [hWhoseTurn] <-- ([hWhoseTurn] ^ $1)
+; As a side effect, this also returns a duelist variable in a similar manner to
+; GetOpposingTurnDuelistVariable, but this function appears to be
+; only called to swap the turn value.
+SwapTurn: ; 1c72 (0:1c72)
push af
push hl
call GetOpposingTurnDuelistVariable
@@ -3205,7 +3206,7 @@ AdjustCoordinatesForWindow: ; 1deb (0:1deb)
ret
; Draws a bxc text box at de printing a name in the left side of the top border.
-; The name's text offset must be at hl when this function is called.
+; The name's text id must be at hl when this function is called.
; Mostly used to print text boxes for talked-to NPCs, but occasionally used in duels as well.
DrawLabeledTextBox: ; 1e00 (0:1e00)
ld a, [wConsole]
@@ -4515,7 +4516,7 @@ Func_2a44: ; 2a44 (0:2a44)
pop hl
ld a, l
or h
- jp nz, Func_2e76
+ jp nz, PrintTextNoDelay
ld hl, $c590
jp Func_21c5
@@ -4528,7 +4529,7 @@ DrawWideTextBox_PrintText: ; 2a59 (0:2a59)
call Func_22a6
call EnableLCD
pop hl
- jp Func_2e41
+ jp PrintText
; draws a 12x6 text box aligned to the bottom left of the screen
DrawNarrowTextBox: ; 2a6f (0:2a6f)
@@ -4673,10 +4674,10 @@ LoadOpponentDeck: ; 2b78 (0:2b78)
.normalSamDuel
xor a
ld [wOpponentDeckId], a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ld a, PRACTICE_PLAYER_DECK
call LoadDeck
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ld hl, wRNG1
ld a, $57
ld [hli], a
@@ -4817,12 +4818,12 @@ Func_2c84: ; 2c84 (0:2c84)
call Func_2d15
call Func_2cc8
.asm_2c93
- ld a, [wce47]
+ ld a, [wTextSpeed]
ld c, a
inc c
jr .asm_2cac
.asm_2c9a
- ld a, [wce47]
+ ld a, [wTextSpeed]
cp $2
jr nc, .asm_2ca7
ld a, [$ff90]
@@ -5085,56 +5086,60 @@ Func_2e2c: ; 2e2c (0:2e2c)
pop hl
ret
-Func_2e41: ; 2e41 (0:2e41)
+; prints text with id at hl with letter delay in a textbox area
+PrintText: ; 2e41 (0:2e41)
ld a, l
or h
- jr z, .asm_2e53
+ jr z, .fromRAM
ldh a, [hBankROM]
push af
call ReadTextOffset
- call .asm_2e56
+ call .printText
pop af
call BankswitchHome
ret
-.asm_2e53
+.fromRAM
ld hl, $c590
-.asm_2e56
+.printText
call Func_2cc8
-.asm_2e59
+.nextTileLoop
ldh a, [hButtonsHeld]
ld b, a
- ld a, [wce47]
+ ld a, [wTextSpeed]
inc a
cp $3
- jr nc, .asm_2e6d
+ jr nc, .applyDelay
+ ; if text speed is 1, pressing b ignores it
bit 1, b
- jr nz, .asm_2e70
- jr .asm_2e6d
-.asm_2e6a
+ jr nz, .skipDelay
+ jr .applyDelay
+.textDelayLoop
+ ; wait a number of frames equal to wTextSpeed between printing each text tile
call DoFrame
-.asm_2e6d
+.applyDelay
dec a
- jr nz, .asm_2e6a
-.asm_2e70
+ jr nz, .textDelayLoop
+.skipDelay
call Func_2d43
- jr nc, .asm_2e59
+ jr nc, .nextTileLoop
ret
-Func_2e76: ; 2e76 (0:2e76)
+; prints text with id at hl without letter delay in a textbox area
+PrintTextNoDelay: ; 2e76 (0:2e76)
ldh a, [hBankROM]
push af
call ReadTextOffset
call Func_2cc8
-.asm_2e7f
+.nextTileLoop
call Func_2d43
- jr nc, .asm_2e7f
+ jr nc, .nextTileLoop
pop af
call BankswitchHome
ret
; Prints a name in the left side of the top border of a text box, usually to identify the talked-to NPC.
; input:
- ; hl: text offset
+ ; hl: text id
; de: where to print the name
PrintTextBoxBorderLabel: ; 2e89 (0:2e89)
ld a, l
@@ -5439,28 +5444,33 @@ Func_3061: ; 3061 (0:3061)
pop de
ret
-Func_3071: ; 3071 (0:3071)
+; function that executes a coin toss during a duel,
+; displaying the result ([O] or [X]) in the top left corner of the screen.
+; text at de is printed in a text box during the coin toss.
+; returns c if heads, nc if tails.
+DisplayCoinTossScreen1: ; 3071 (0:3071)
push hl
- ld hl, $ce4e
+ ld hl, wCoinTossScreenTextId
ld [hl], e
inc hl
ld [hl], d
rst $18
- xor l
- ld [hl], c
+ dw TossCoin
pop hl
ret
-Func_307d: ; 307d (0:307d)
+; function that executes a coin toss during a duel, without displaying the result.
+; text at de is printed in a text box during the coin toss.
+; returns c if heads, nc if tails.
+DisplayCoinTossScreen2: ; 307d (0:307d)
push hl
- ld hl, $ce4e
+ ld hl, wCoinTossScreenTextId
ld [hl], e
inc hl
ld [hl], d
ld a, $1
rst $18
- xor l
- ld [hl], c
+ dw TossCoin
ld hl, $cac2
ld [hl], $0
pop hl
@@ -5926,7 +5936,7 @@ Func_33e1: ; 33e1 (0:33e1)
Func_3400: ; 3400 (0:3400)
call Func_3414
ret nc
- call Func_307d
+ call DisplayCoinTossScreen2
ld [wcc0a], a
ccf
ret nc
@@ -5940,10 +5950,10 @@ Func_3414: ; 3414 (0:3414)
call GetTurnDuelistVariable
or a
ret z
- ld de, $00de
+ text_de SandAttackCheckText
cp $2
jr z, .asm_342b
- ld de, $00df
+ text_de SmokescreenCheckText
cp $1
jr z, .asm_342b
or a
@@ -6020,7 +6030,7 @@ Func_348a: ; 348a (0:348a)
xor a
ld [wcac2], a
ld de, $00f6
- call Func_307d
+ call DisplayCoinTossScreen2
ret nc
ld a, $4
ld [wccc7], a
@@ -6064,10 +6074,10 @@ Func_3509: ; 3509 (0:3509)
ld [wce7c], a
call Func_3525
ld c, a
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ld a, [wce7c]
call Func_3525
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
add c
or a
scf
@@ -6171,9 +6181,9 @@ Func_367b: ; 367b (0:367b)
ld a, [wccbf]
or a
ret z
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
call Func_34ef
- call GetOpposingTurnDuelistVariable_SwapTurn
+ call SwapTurn
ret c
ld hl, $000a
call Func_36a2
diff --git a/src/macros.asm b/src/macros.asm
index d7f05b1..22046c6 100755
--- a/src/macros.asm
+++ b/src/macros.asm
@@ -5,6 +5,10 @@ dbw: MACRO
dw \2
ENDM
+lb: MACRO ; r, hi, lo
+ ld \1, (\2) << 8 + ((\3) & $ff)
+ENDM
+
bank1call: MACRO
rst $18
dw \1
@@ -46,6 +50,10 @@ text_hl: MACRO
ld hl, \1_
ENDM
+text_de: MACRO
+ ld de, \1_
+ENDM
+
sgb: MACRO
db \1 * 8 + \2 ; sgb_command * 8 + length
ENDM
diff --git a/src/main.asm b/src/main.asm
index 3c678ed..697cce0 100755
--- a/src/main.asm
+++ b/src/main.asm
@@ -34,7 +34,7 @@ SECTION "bankA",ROMX,BANK[$A]
emptybank
SECTION "bankB",ROMX,BANK[$B]
-INCBIN "baserom.gbc",$2C000,$4000
+INCLUDE "engine/effect_functions.asm"
SECTION "bankC",ROMX,BANK[$C]
INCLUDE "data/decks.asm"
diff --git a/src/text/text1.asm b/src/text/text1.asm
index 93e19b7..74e8826 100755
--- a/src/text/text1.asm
+++ b/src/text/text1.asm
@@ -802,31 +802,31 @@ Text00dd: ; 37b5d (d:7b5d)
db "Please use a\n"
db "Game Boy Color.",TX_END
-Text00de: ; 37ba9 (d:7ba9)
+SandAttackCheckText: ; 37ba9 (d:7ba9)
db TX_START,"Sand-attack check!\n"
db "If Tails, Attack is unsuccessful.",TX_END
-Text00df: ; 37bdf (d:7bdf)
+SmokescreenCheckText: ; 37bdf (d:7bdf)
db TX_START,"Smokescreen check!\n"
db "If Tails, Attack is unsuccessful.",TX_END
-Text00e0: ; 37c15 (d:7c15)
+ParalysisCheckText: ; 37c15 (d:7c15)
db TX_START,"Paralysis check!\n"
db "If Heads, opponent is Paralyzed.",TX_END
-Text00e1: ; 37c48 (d:7c48)
+SleepCheckText: ; 37c48 (d:7c48)
db TX_START,"Sleep check!\n"
db "If Heads, opponent becomes Asleep.",TX_END
-Text00e2: ; 37c79 (d:7c79)
+PoisonCheckText: ; 37c79 (d:7c79)
db TX_START,"Poison check!\n"
db "If Heads, opponent is Poisoned.",TX_END
-Text00e3: ; 37ca8 (d:7ca8)
+ConfusionCheckText: ; 37ca8 (d:7ca8)
db TX_START,"Confusion check! If Heads,\n"
db "opponent becomes Confused.",TX_END
-Text00e4: ; 37cdf (d:7cdf)
+VenomPowderCheckText: ; 37cdf (d:7cdf)
db TX_START,"Venom Powder check! If Heads,\n"
db "opponent is Poisoned & Confused.",TX_END
diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm
index 1e6e14f..b906c99 100755
--- a/src/text/text_offsets.asm
+++ b/src/text/text_offsets.asm
@@ -224,13 +224,13 @@ TextOffsets:: ; 34000 (d:4000)
text Text00db
text Text00dc
text Text00dd
- text Text00de
- text Text00df
- text Text00e0
- text Text00e1
- text Text00e2
- text Text00e3
- text Text00e4
+ text SandAttackCheckText
+ text SmokescreenCheckText
+ text ParalysisCheckText
+ text SleepCheckText
+ text PoisonCheckText
+ text ConfusionCheckText
+ text VenomPowderCheckText
text Text00e5
text Text00e6
text Text00e7
diff --git a/src/wram.asm b/src/wram.asm
index 5b8399f..9b1d932 100755
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -65,10 +65,9 @@ wPlayerBench5CardHP:: ; c2cd
ds $1
ds $1a
-;The only known use of this is to store
-;when an attack causes a pokemon
-;to not be able to attack the following turn
-;for example: tail wag, leer
+; The only known use of this is to store when an attack
+; causes a pokemon to not be able to attack the following turn.
+; for example: tail wag, leer
wPlayerCantAttackStatus:: ; c2e8
ds $1
ds $3
@@ -578,7 +577,8 @@ wce43:: ; ce43
wce44:: ; ce44
ds $3
-wce47:: ; ce47
+; when printing text, number of frames to wait between each text tile
+wTextSpeed:: ; ce47
ds $1
wce48:: ; ce48
@@ -591,7 +591,10 @@ wce4a:: ; ce4a
ds $1
wce4b:: ; ce4b
- ds $5
+ ds $3
+
+wCoinTossScreenTextId:: ; ce4e
+ ds $2
wce50:: ; ce50
ds $1