summaryrefslogtreecommitdiff
path: root/engine/battle/core.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/core.asm')
-rwxr-xr-xengine/battle/core.asm997
1 files changed, 496 insertions, 501 deletions
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 1b8203b1..8a46c705 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -101,8 +101,8 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c)
ld a, MESSAGE_BOX ; the usual text box at the bottom of the screen
ld [wTextBoxID], a
call DisplayTextBoxID
- hlCoord 1, 5
- ld bc, $307
+ coord hl, 1, 5
+ lb bc, 3, 7
call ClearScreenArea
call DisableLCD
call LoadFontTilePatterns
@@ -110,14 +110,14 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c)
ld hl, vBGMap0
ld bc, $400
.clearBackgroundLoop
- ld a, $7f
+ ld a, " "
ld [hli], a
dec bc
ld a, b
or c
jr nz, .clearBackgroundLoop
; copy the work RAM tile map to VRAM
- ld hl, wTileMap
+ coord hl, 0, 0
ld de, vBGMap0
ld b, 18 ; number of rows
.copyRowLoop
@@ -175,21 +175,19 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c)
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, $31
- ld [$ffe1], a
- hlCoord 1, 5
- predef Func_3f0c6
+ ld [hStartTileID], a
+ coord hl, 1, 5
+ predef CopyUncompressedPicToTilemap
xor a
ld [hWY], a
ld [rWY], a
inc a
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
- ld b, $1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
call HideSprites
- ld hl, PrintBeginningBattleText
- ld b, BANK(PrintBeginningBattleText)
- jp Bankswitch
+ jpab PrintBeginningBattleText
; when a battle is starting, silhouettes of the player's pic and the enemy's pic are slid onto the screen
; the lower of the player's pic (his body) is part of the background, but his head is a sprite
@@ -225,9 +223,9 @@ StartBattle: ; 3c11e (f:411e)
xor a
ld [wPartyGainExpFlags], a
ld [wPartyFoughtCurrentEnemyFlags], a
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
inc a
- ld [wd11d], a
+ ld [wFirstMonsNotOutYet], a
ld hl, wEnemyMon1HP
ld bc, wEnemyMon2 - wEnemyMon1 - 1
ld d, $3
@@ -260,7 +258,7 @@ StartBattle: ; 3c11e (f:411e)
.displaySafariZoneBattleMenu
call DisplayBattleMenu
ret c ; return if the player ran from battle
- ld a, [wcd6a]
+ ld a, [wActionResultOrTookBattleTurn]
and a ; was the item used successfully?
jr z, .displaySafariZoneBattleMenu ; if not, display the menu again; XXX does this ever jump?
ld a, [W_NUMSAFARIBALLS]
@@ -324,13 +322,13 @@ StartBattle: ; 3c11e (f:411e)
ld [wcf91], a
ld [wBattleMonSpecies2], a
call LoadScreenTilesFromBuffer1
- hlCoord 1, 5
+ coord hl, 1, 5
ld a, $9
call SlideTrainerPicOffScreen
call SaveScreenTilesToBuffer1
ld a, [wWhichPokemon]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
push bc
ld hl, wPartyGainExpFlags
predef FlagActionPredef
@@ -355,13 +353,11 @@ EnemyRan: ; 3c202 (f:4202)
ld hl, EnemyRanText
.printText
call PrintText
- ld a, (SFX_08_44 - SFX_Headers_08) / 3
+ ld a, SFX_RUN
call PlaySoundWaitForCurrent
xor a
ld [H_WHOSETURN], a
- ld hl, AnimationSlideEnemyMonOut
- ld b, BANK(AnimationSlideEnemyMonOut)
- jp Bankswitch
+ jpab AnimationSlideEnemyMonOff
WildRanText: ; 3c229 (f:4229)
TX_FAR _WildRanText
@@ -383,7 +379,7 @@ MainInBattleLoop: ; 3c233 (f:4233)
jp z, HandleEnemyMonFainted ; if enemy mon HP is 0, jump
call SaveScreenTilesToBuffer1
xor a
- ld [wd11d], a
+ ld [wFirstMonsNotOutYet], a
ld a, [W_PLAYERBATTSTATUS2]
and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge
jr nz, .selectEnemyMove
@@ -415,8 +411,8 @@ MainInBattleLoop: ; 3c233 (f:4233)
ld [wPlayerSelectedMove], a
jr .selectEnemyMove
.selectPlayerMove
- ld a, [wcd6a]
- and a
+ ld a, [wActionResultOrTookBattleTurn]
+ and a ; has the player already used the turn (e.g. by using an item, trying to run or switching pokemon)
jr nz, .selectEnemyMove
ld [wMoveMenuType], a
inc a
@@ -620,7 +616,7 @@ HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd)
or [hl]
ret nz ; test if fainted
call DrawHUDsAndHPBars
- ld c, $14
+ ld c, 20
call DelayFrames
xor a
ret
@@ -721,8 +717,8 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3)
ld [wHPBarMaxHP+1], a
ld a, [hl]
ld [wHPBarMaxHP], a
- ld de, $fff2
- add hl, de ; skip back fomr max hp to current hp
+ ld de, wBattleMonHP - wBattleMonMaxHP
+ add hl, de ; skip back from max hp to current hp
ld a, [hl]
ld [wHPBarOldHP], a ; add bc to current HP
add c
@@ -760,12 +756,12 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3)
ret
UpdateCurMonHPBar: ; 3c4f6 (f:44f6)
- hlCoord 10, 9 ; tile pointer to player HP bar
+ coord hl, 10, 9 ; tile pointer to player HP bar
ld a, [H_WHOSETURN]
and a
ld a, $1
jr z, .playersTurn
- hlCoord 2, 2 ; tile pointer to enemy HP bar
+ coord hl, 2, 2 ; tile pointer to enemy HP bar
xor a
.playersTurn
push bc
@@ -792,7 +788,7 @@ CheckNumAttacksLeft: ; 3c50f (f:450f)
HandleEnemyMonFainted: ; 3c525 (f:4525)
xor a
- ld [wccf0], a
+ ld [wInHandlePlayerMonFainted], a
call FaintEnemyPokemon
call AnyPartyAlive
ld a, d
@@ -816,14 +812,14 @@ HandleEnemyMonFainted: ; 3c525 (f:4525)
call ChooseNextMon
.skipReplacingBattleMon
ld a, $1
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
call ReplaceFaintedEnemyMon
jp z, EnemyRan
xor a
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
jp MainInBattleLoop
-FaintEnemyPokemon ; 0x3c567
+FaintEnemyPokemon: ; 0x3c567
call ReadPlayerMonCurHPAndStatus
ld a, [W_ISINBATTLE]
dec a
@@ -838,8 +834,17 @@ FaintEnemyPokemon ; 0x3c567
.wild
ld hl, W_PLAYERBATTSTATUS1
res AttackingMultipleTimes, [hl]
- xor a
- ld [wPlayerNumHits], a
+; Bug. This only zeroes the high byte of the player's accumulated damage,
+; setting the accumulated damage to itself mod 256 instead of 0 as was probably
+; intended. That alone is problematic, but this mistake has another more severe
+; effect. This function's counterpart for when the player mon faints,
+; RemoveFaintedPlayerMon, zeroes both the high byte and the low byte. In a link
+; battle, the other player's Game Boy will call that function in response to
+; the enemy mon (the player mon from the other side's perspective) fainting,
+; and the states of the two Game Boys will go out of sync unless the damage
+; was congruent to 0 modulo 256.
+ xor a
+ ld [wPlayerBideAccumulatedDamage], a
ld hl, wEnemyStatsToDouble ; clear enemy statuses
ld [hli], a
ld [hli], a
@@ -848,29 +853,29 @@ FaintEnemyPokemon ; 0x3c567
ld [hl], a
ld [W_ENEMYDISABLEDMOVE], a
ld [wEnemyDisabledMoveNumber], a
- ld [wccf3], a
+ ld [wEnemyMonMinimized], a
ld hl, wPlayerUsedMove
ld [hli], a
ld [hl], a
- hlCoord 12, 5
- deCoord 12, 6
+ coord hl, 12, 5
+ coord de, 12, 6
call SlideDownFaintedMonPic
- ld hl, wTileMap
- ld bc, $40b
+ coord hl, 0, 0
+ lb bc, 4, 11
call ClearScreenArea
ld a, [W_ISINBATTLE]
dec a
jr z, .wild_win
xor a
- ld [wc0f1], a
- ld [wc0f2], a
- ld a, (SFX_08_48 - SFX_Headers_08) / 3 ; SFX_FALL?
+ ld [wFrequencyModifier], a
+ ld [wTempoModifier], a
+ ld a, SFX_FAINT_FALL
call PlaySoundWaitForCurrent
.sfxwait
- ld a, [wc02a]
- cp (SFX_08_48 - SFX_Headers_08) / 3
+ ld a, [wChannelSoundIDs + CH4]
+ cp SFX_FAINT_FALL
jr z, .sfxwait
- ld a, (SFX_08_43 - SFX_Headers_08) / 3 ; SFX_DROP
+ ld a, SFX_FAINT_THUD
call PlaySound
call WaitForSoundToFinish
jr .sfxplayed
@@ -883,9 +888,9 @@ FaintEnemyPokemon ; 0x3c567
ld a, [hli]
or [hl]
jr nz, .playermonnotfaint
- ld a, [wccf0]
- and a
- jr nz, .playermonnotfaint
+ ld a, [wInHandlePlayerMonFainted]
+ and a ; was this called by HandlePlayerMonFainted?
+ jr nz, .playermonnotfaint ; if so, don't call RemoveFaintedPlayerMon twice
call RemoveFaintedPlayerMon
.playermonnotfaint
call AnyPartyAlive
@@ -938,20 +943,20 @@ FaintEnemyPokemon ; 0x3c567
jr nz, .gainExpFlagsLoop
ld a, b
ld [wPartyGainExpFlags], a
- ld hl, GainExperience
- ld b, BANK(GainExperience)
- jp Bankswitch
+ jpab GainExperience
EnemyMonFaintedText: ; 0x3c63e
TX_FAR _EnemyMonFaintedText
db "@"
EndLowHealthAlarm: ; 3c643 (f:4643)
+; This function is called when the player has the won the battle. It turns off
+; the low health alarm and prevents it from reactivating until the next battle.
xor a
- ld [wLowHealthAlarm], a ;disable low health alarm
- ld [wc02a], a
+ ld [wLowHealthAlarm], a ; turn off low health alarm
+ ld [wChannelSoundIDs + CH4], a
inc a
- ld [wccf6], a
+ ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating
ret
AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f)
@@ -973,7 +978,7 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f)
; stores whether enemy ran in Z flag
ReplaceFaintedEnemyMon: ; 3c664 (f:4664)
- ld hl, wcf1e
+ ld hl, wEnemyHPBarColor
ld e, $30
call GetBattleHealthBarColor
callab DrawEnemyPokeballs
@@ -990,7 +995,7 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664)
call EnemySendOut
xor a
ld [W_ENEMYMOVENUM], a
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
ld [wAILayer2Encouragement], a
inc a ; reset Z flag
ret
@@ -1020,10 +1025,10 @@ TrainerBattleVictory: ; 3c696 (f:4696)
cp LINK_STATE_BATTLING
ret z
call ScrollTrainerPicAfterBattle
- ld c, $28
+ ld c, 40
call DelayFrames
call PrintEndBattleText
-; win money
+; win money
ld hl, MoneyForWinningText
call PrintText
ld de, wPlayerMoney + 2
@@ -1042,7 +1047,7 @@ TrainerDefeatedText: ; 3c6e9 (f:46e9)
PlayBattleVictoryMusic: ; 3c6ee (f:46ee)
push af
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySoundWaitForCurrent
ld c, BANK(Music_DefeatedTrainer)
pop af
@@ -1050,8 +1055,8 @@ PlayBattleVictoryMusic: ; 3c6ee (f:46ee)
jp Delay3
HandlePlayerMonFainted: ; 3c700 (f:4700)
- ld a, $1
- ld [wccf0], a
+ ld a, 1
+ ld [wInHandlePlayerMonFainted], a
call RemoveFaintedPlayerMon
call AnyPartyAlive ; test if any more mons are alive
ld a, d
@@ -1075,11 +1080,11 @@ HandlePlayerMonFainted: ; 3c700 (f:4700)
jp nz, MainInBattleLoop ; if the enemy mon has more than 0 HP, go back to battle loop
; the enemy mon has 0 HP
ld a, $1
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
call ReplaceFaintedEnemyMon
jp z, EnemyRan ; if enemy ran from battle rather than sending out another mon, jump
xor a
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
jp MainInBattleLoop
; resets flags, slides mon's pic down, plays cry, and prints fainted message
@@ -1087,7 +1092,7 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741)
ld a, [wPlayerMonNumber]
ld c, a
ld hl, wPartyGainExpFlags
- ld b, $0
+ ld b, FLAG_RESET
predef FlagActionPredef ; clear gain exp flag for fainted mon
ld hl, W_ENEMYBATTSTATUS1
res 2, [hl] ; reset "attacking multiple times" flag
@@ -1098,24 +1103,29 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741)
ld [wLowHealthAlarm], a ;disable low health alarm
call WaitForSoundToFinish
.skipWaitForSound
-; bug? if the player mon faints while the enemy mon is using bide,
-; the accumulated damage is overwritten. xxx what values can [wLowHealthAlarm] have here?
+; a is 0, so this zeroes the enemy's accumulated damage.
ld hl, wEnemyBideAccumulatedDamage
ld [hli], a
ld [hl], a
ld [wBattleMonStatus], a
call ReadPlayerMonCurHPAndStatus
- hlCoord 9, 7
- ld bc, $50b
+ coord hl, 9, 7
+ lb bc, 5, 11
call ClearScreenArea
- hlCoord 1, 10
- deCoord 1, 11
+ coord hl, 1, 10
+ coord de, 1, 11
call SlideDownFaintedMonPic
ld a, $1
ld [wBattleResult], a
- ld a, [wccf0]
- and a
- ret z
+
+; When the player mon and enemy mon faint at the same time and the fact that the
+; enemy mon has fainted is detected first (e.g. when the player mon knocks out
+; the enemy mon using a move with recoil and faints due to the recoil), don't
+; play the player mon's cry or show the "[player mon] fainted!" message.
+ ld a, [wInHandlePlayerMonFainted]
+ and a ; was this called by HandleEnemyMonFainted?
+ ret z ; if so, return
+
ld a, [wBattleMonSpecies]
call PlayCry
ld hl, PlayerMonFaintedText
@@ -1137,13 +1147,13 @@ DoUseNextMonDialogue: ; 3c79b (f:479b)
ld hl, UseNextMonText
call PrintText
.displayYesNoBox
- hlCoord 13, 9
- ld bc, $a0e
+ coord hl, 13, 9
+ lb bc, 10, 14
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call DisplayTextBoxID
- ld a, [wd12e]
- cp $2 ; did the player choose NO?
+ ld a, [wMenuExitMethod]
+ cp CHOSE_SECOND_ITEM ; did the player choose NO?
jr z, .tryRunning ; if the player chose NO, try running
and a ; reset carry
ret
@@ -1162,8 +1172,8 @@ UseNextMonText: ; 3c7d3 (f:47d3)
; choose next player mon to send out
; stores whether enemy mon has no HP left in Z flag
ChooseNextMon: ; 3c7d8 (f:47d8)
- ld a, $2
- ld [wd07d], a
+ ld a, BATTLE_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
call DisplayPartyMenu
.checkIfMonChosen
jr nc, .monChosen
@@ -1177,17 +1187,17 @@ ChooseNextMon: ; 3c7d8 (f:47d8)
cp LINK_STATE_BATTLING
jr nz, .notLinkBattle
inc a
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
call LinkBattleExchangeData
.notLinkBattle
xor a
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
call ClearSprites
ld a, [wWhichPokemon]
ld [wPlayerMonNumber], a
ld c, a
ld hl, wPartyGainExpFlags
- ld b, $1
+ ld b, FLAG_SET
push bc
predef FlagActionPredef
pop bc
@@ -1197,7 +1207,7 @@ ChooseNextMon: ; 3c7d8 (f:47d8)
call GBPalWhiteOut
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer1
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
call SendOutMon
ld hl, wEnemyMonHP
@@ -1212,13 +1222,13 @@ HandlePlayerBlackOut: ; 3c837 (f:4837)
cp LINK_STATE_BATTLING
jr z, .notSony1Battle
ld a, [W_CUROPPONENT]
- cp $c8 + SONY1
+ cp OPP_SONY1
jr nz, .notSony1Battle
- ld hl, wTileMap ; sony 1 battle
- ld bc, $815
+ coord hl, 0, 0 ; sony 1 battle
+ lb bc, 8, 21
call ClearScreenArea
call ScrollTrainerPicAfterBattle
- ld c, $28
+ ld c, 40
call DelayFrames
ld hl, Sony1WinText
call PrintText
@@ -1226,8 +1236,8 @@ HandlePlayerBlackOut: ; 3c837 (f:4837)
cp OAKS_LAB
ret z ; starter battle in oak's lab: don't black out
.notSony1Battle
- ld b, $0
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE_BLACK
+ call RunPaletteCommand
ld hl, PlayerBlackedOutText2
ld a, [wLinkState]
cp LINK_STATE_BATTLING
@@ -1310,7 +1320,7 @@ SevenSpacesText: ; 3c8d7 (f:48d7)
; if a is 8, the slide is to the right, else it is to the left
; bug: when this is called, [H_AUTOBGTRANSFERENABLED] is non-zero, so there is screen tearing
SlideTrainerPicOffScreen: ; 3c8df (f:48df)
- ld [$FF8B], a
+ ld [hSlideAmount], a
ld c, a
.slideStepLoop ; each iteration, the trainer pic is slid one tile left/right
push bc
@@ -1318,10 +1328,10 @@ SlideTrainerPicOffScreen: ; 3c8df (f:48df)
ld b, 7 ; number of rows
.rowLoop
push hl
- ld a, [$FF8B]
+ ld a, [hSlideAmount]
ld c, a
.columnLoop
- ld a, [$FF8B]
+ ld a, [hSlideAmount]
cp 8
jr z, .slideRight
.slideLeft ; slide player sprite off screen
@@ -1356,7 +1366,7 @@ EnemySendOut: ; 3c90e (f:490e)
ld [hl],a
ld a,[wPlayerMonNumber]
ld c,a
- ld b,1
+ ld b,FLAG_SET
push bc
predef FlagActionPredef
ld hl,wPartyFoughtCurrentEnemyFlags
@@ -1376,7 +1386,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld [hl],a
ld [W_ENEMYDISABLEDMOVE],a
ld [wEnemyDisabledMoveNumber],a
- ld [wccf3],a
+ ld [wEnemyMonMinimized],a
ld hl,wPlayerUsedMove
ld [hli],a
ld [hl],a
@@ -1384,7 +1394,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld [wAICount],a
ld hl,W_PLAYERBATTSTATUS1
res 5,[hl]
- hlCoord 18, 0
+ coord hl, 18, 0
ld a,8
call SlideTrainerPicOffScreen
call PrintEmptyString
@@ -1435,12 +1445,12 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
call LoadEnemyMonData
ld hl,wEnemyMonHP
ld a,[hli]
- ld [wcce3],a
+ ld [wLastSwitchInEnemyMonHP],a
ld a,[hl]
- ld [wcce4],a
+ ld [wLastSwitchInEnemyMonHP + 1],a
ld a,1
ld [wCurrentMenuItem],a
- ld a,[wd11d]
+ ld a,[wFirstMonsNotOutYet]
dec a
jr z,.next4
ld a,[wPartyCount]
@@ -1454,16 +1464,16 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
jr nz,.next4
ld hl, TrainerAboutToUseText
call PrintText
- hlCoord 0, 7
- ld bc,$0801
+ coord hl, 0, 7
+ lb bc, 8, 1
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID
ld a,[wCurrentMenuItem]
and a
jr nz,.next4
- ld a,2
- ld [wd07d],a
+ ld a,BATTLE_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
.next9
ld a,1
@@ -1489,11 +1499,11 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
call LoadScreenTilesFromBuffer1
.next4
call ClearSprites
- ld hl,wTileMap
- ld bc,$040B
+ coord hl, 0, 0
+ lb bc, 4, 11
call ClearScreenArea
- ld b,1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
call GBPalNormal
ld hl,TrainerSentOutText
call PrintText
@@ -1503,10 +1513,10 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
call GetMonHeader
ld de,vFrontPic
call LoadMonFrontSprite
- ld a,$CF
- ld [$FFE1],a
- hlCoord 15, 6
- predef Func_3f073
+ ld a,-$31
+ ld [hStartTileID],a
+ coord hl, 15, 6
+ predef AnimateSendingOutMon
ld a,[wEnemyMonSpecies2]
call PlayCry
call DrawEnemyHUDAndHPBar
@@ -1555,7 +1565,7 @@ HasMonFainted: ; 3ca97 (f:4a97)
ld a, [hli]
or [hl]
ret nz
- ld a, [wd11d]
+ ld a, [wFirstMonsNotOutYet]
and a
jr nz, .done
ld hl, NoWillText
@@ -1590,14 +1600,14 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9)
ld a, [hl]
ld [H_MULTIPLICAND + 2], a
ld a, [de]
- ld [$ff8d], a
+ ld [hEnemySpeed], a
inc de
ld a, [de]
- ld [$ff8e], a
+ ld [hEnemySpeed + 1], a
call LoadScreenTilesFromBuffer1
ld de, H_MULTIPLICAND + 1
- ld hl, $ff8d
- ld c, $2
+ ld hl, hEnemySpeed
+ ld c, 2
call StringCmp
jr nc, .canEscape ; jump if player speed greater than enemy speed
xor a
@@ -1609,9 +1619,9 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9)
ld [H_DIVIDEND], a
ld a, [H_PRODUCT + 3]
ld [H_DIVIDEND + 1], a
- ld a, [$ff8d]
+ ld a, [hEnemySpeed]
ld b, a
- ld a, [$ff8e]
+ ld a, [hEnemySpeed + 1]
; divide enemy speed by 4
srl b
rr a
@@ -1642,19 +1652,19 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9)
ld b, a
ld a, [H_QUOTIENT + 3]
cp b
- jr nc, .canEscape ; if the random value was less than or equal to the quotient
+ jr nc, .canEscape ; if the random value was less than or equal to the quotient
; plus 30 times the number of attempts, the player can escape
; can't escape
ld a, $1
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a ; you lose your turn when you can't escape
ld hl, CantEscapeText
jr .printCantEscapeOrNoRunningText
.trainerBattle
ld hl, NoRunningText
.printCantEscapeOrNoRunningText
call PrintText
- ld a, $1
- ld [wd11f], a
+ ld a, 1
+ ld [wForcePlayerToChooseMon], a
call SaveScreenTilesToBuffer1
and a ; reset carry
ret
@@ -1666,7 +1676,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9)
; link battle
call SaveScreenTilesToBuffer1
xor a
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
ld a, $f
ld [wPlayerMoveListIndex], a
call LinkBattleExchangeData
@@ -1678,7 +1688,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9)
dec a
.playSound
ld [wBattleResult], a
- ld a, (SFX_08_44 - SFX_Headers_08) / 3
+ ld a, SFX_RUN
call PlaySoundWaitForCurrent
ld hl, GotAwayText
call PrintText
@@ -1702,19 +1712,19 @@ GotAwayText: ; 3cba1 (f:4ba1)
; copies from party data to battle mon data when sending out a new player mon
LoadBattleMonFromParty: ; 3cba6 (f:4ba6)
ld a, [wWhichPokemon]
- ld bc, $2c
+ ld bc, wPartyMon2 - wPartyMon1
ld hl, wPartyMon1Species
call AddNTimes
ld de, wBattleMonSpecies
- ld bc, $c
+ ld bc, wBattleMonDVs - wBattleMonSpecies
call CopyData
- ld bc, $f
+ ld bc, wPartyMon1DVs - wPartyMon1OTID
add hl, bc
ld de, wBattleMonDVs
- ld bc, $2
+ ld bc, NUM_DVS
call CopyData
ld de, wBattleMonPP
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyData
ld de, wBattleMonLevel
ld bc, $b
@@ -1726,16 +1736,16 @@ LoadBattleMonFromParty: ; 3cba6 (f:4ba6)
ld a, [wPlayerMonNumber]
call SkipFixedLengthTextEntries
ld de, wBattleMonNick
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wBattleMonLevel
ld de, wPlayerMonUnmodifiedLevel ; block of memory used for unmodified stats
- ld bc, $b
+ ld bc, 1 + NUM_STATS * 2
call CopyData
call ApplyBurnAndParalysisPenaltiesToPlayer
call ApplyBadgeStatBoosts
ld a, $7 ; default stat modifier
- ld b, $8
+ ld b, NUM_STAT_MODS
ld hl, wPlayerMonAttackMod
.statModLoop
ld [hli], a
@@ -1746,19 +1756,19 @@ LoadBattleMonFromParty: ; 3cba6 (f:4ba6)
; copies from enemy party data to current enemy mon data when sending out a new enemy mon
LoadEnemyMonFromParty: ; 3cc13 (f:4c13)
ld a, [wWhichPokemon]
- ld bc, $2c
+ ld bc, wEnemyMon2 - wEnemyMon1
ld hl, wEnemyMons
call AddNTimes
ld de, wEnemyMonSpecies
- ld bc, $c
+ ld bc, wEnemyMonDVs - wEnemyMonSpecies
call CopyData
- ld bc, $f
+ ld bc, wEnemyMon1DVs - wEnemyMon1OTID
add hl, bc
ld de, wEnemyMonDVs
- ld bc, $2
+ ld bc, NUM_DVS
call CopyData
ld de, wEnemyMonPP
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyData
ld de, wEnemyMonLevel
ld bc, $b
@@ -1770,16 +1780,16 @@ LoadEnemyMonFromParty: ; 3cc13 (f:4c13)
ld a, [wWhichPokemon]
call SkipFixedLengthTextEntries
ld de, wEnemyMonNick
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wEnemyMonLevel
ld de, wEnemyMonUnmodifiedLevel ; block of memory used for unmodified stats
- ld bc, $b
+ ld bc, 1 + NUM_STATS * 2
call CopyData
call ApplyBurnAndParalysisPenaltiesToEnemy
ld hl, W_MONHBASESTATS
ld de, wEnemyMonBaseStats
- ld b, $5
+ ld b, NUM_STATS
.copyBaseStatsLoop
ld a, [hli]
ld [de], a
@@ -1787,7 +1797,7 @@ LoadEnemyMonFromParty: ; 3cc13 (f:4c13)
dec b
jr nz, .copyBaseStatsLoop
ld a, $7 ; default stat modifier
- ld b, $8
+ ld b, NUM_STAT_MODS
ld hl, wEnemyMonStatMods
.statModLoop
ld [hli], a
@@ -1808,8 +1818,8 @@ SendOutMon: ; 3cc91 (f:4c91)
call DrawPlayerHUDAndHPBar
predef LoadMonBackPic
xor a
- ld [$ffe1], a
- ld hl, wcc2d
+ ld [hStartTileID], a
+ ld hl, wBattleAndStartSavedMenuItem
ld [hli], a
ld [hl], a
ld [wBoostExpByExpAll], a
@@ -1826,50 +1836,50 @@ SendOutMon: ; 3cc91 (f:4c91)
ld [hl], a
ld [W_PLAYERDISABLEDMOVE], a
ld [wPlayerDisabledMoveNumber], a
- ld [wccf7], a
- ld b, $1
- call GoPAL_SET
+ ld [wPlayerMonMinimized], a
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
ld hl, W_ENEMYBATTSTATUS1
res UsingTrappingMove, [hl]
ld a, $1
ld [H_WHOSETURN], a
ld a, POOF_ANIM
call PlayMoveAnimation
- hlCoord 4, 11
- predef Func_3f073
+ coord hl, 4, 11
+ predef AnimateSendingOutMon
ld a, [wcf91]
call PlayCry
call PrintEmptyString
jp SaveScreenTilesToBuffer1
-; show 2 stages of the player getting smaller before disappearing
+; show 2 stages of the player mon getting smaller before disappearing
AnimateRetreatingPlayerMon: ; 3ccfa (f:4cfa)
- hlCoord 1, 5
- ld bc, $707
+ coord hl, 1, 5
+ lb bc, 7, 7
call ClearScreenArea
- hlCoord 3, 7
- ld bc, $505
+ coord hl, 3, 7
+ lb bc, 5, 5
xor a
- ld [wcd6c], a
- ld [H_DOWNARROWBLINKCNT1], a
- predef Func_79aba
- ld c, $4
+ ld [wDownscaledMonSize], a
+ ld [hBaseTileID], a
+ predef CopyDownscaledMonTiles
+ ld c, 4
call DelayFrames
call .clearScreenArea
- hlCoord 4, 9
- ld bc, $303
- ld a, $1
- ld [wcd6c], a
+ coord hl, 4, 9
+ lb bc, 3, 3
+ ld a, 1
+ ld [wDownscaledMonSize], a
xor a
- ld [H_DOWNARROWBLINKCNT1], a
- predef Func_79aba
+ ld [hBaseTileID], a
+ predef CopyDownscaledMonTiles
call Delay3
call .clearScreenArea
ld a, $4c
Coorda 5, 11
.clearScreenArea
- hlCoord 1, 5
- ld bc, $707
+ coord hl, 1, 5
+ lb bc, 7, 7
jp ClearScreenArea
; reads player's current mon's HP into wBattleMonHP
@@ -1891,14 +1901,14 @@ DrawHUDsAndHPBars: ; 3cd5a (f:4d5a)
DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
- hlCoord 9, 7
- ld bc, $50b
+ coord hl, 9, 7
+ lb bc, 5, 11
call ClearScreenArea
callab PlacePlayerHUDTiles
- hlCoord 18, 9
+ coord hl, 18, 9
ld [hl], $73
ld de, wBattleMonNick
- hlCoord 10, 7
+ coord hl, 10, 7
call CenterMonName
call PlaceString
ld hl, wBattleMonSpecies
@@ -1909,7 +1919,7 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
ld de, wLoadedMonLevel
ld bc, $b
call CopyData
- hlCoord 14, 8
+ coord hl, 14, 8
push hl
inc hl
ld de, wLoadedMonStatus
@@ -1920,21 +1930,21 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
.asm_3cdae
ld a, [wLoadedMonSpecies]
ld [wcf91], a
- hlCoord 10, 9
+ coord hl, 10, 9
predef DrawHP
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
- ld hl, wcf1d
+ ld hl, wPlayerHPBarColor
call GetBattleHealthBarColor
ld hl, wBattleMonHP
ld a, [hli]
or [hl]
jr z, .asm_3cdd9
- ld a, [wccf6]
- and a
- ret nz
- ld a, [wcf1d]
- cp $2
+ ld a, [wLowHealthAlarmDisabled]
+ and a ; has the alarm been disabled because the player has already won?
+ ret nz ; if so, return
+ ld a, [wPlayerHPBarColor]
+ cp HP_BAR_RED
jr z, .asm_3cde6
.asm_3cdd9
ld hl, wLowHealthAlarm
@@ -1942,7 +1952,7 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
ld [hl], $0
ret z
xor a
- ld [wc02a], a
+ ld [wChannelSoundIDs + CH4], a
ret
.asm_3cde6
ld hl, wLowHealthAlarm
@@ -1952,15 +1962,15 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
- ld hl, wTileMap
- ld bc, $40c
+ coord hl, 0, 0
+ lb bc, 4, 12
call ClearScreenArea
callab PlaceEnemyHUDTiles
ld de, wEnemyMonNick
- hlCoord 1, 0
+ coord hl, 1, 0
call CenterMonName
call PlaceString
- hlCoord 4, 1
+ coord hl, 4, 1
push hl
inc hl
ld de, wEnemyMonStatus
@@ -2033,11 +2043,11 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec)
.drawHPBar
xor a
ld [wHPBarType], a
- hlCoord 2, 2
+ coord hl, 2, 2
call DrawHPBar
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
- ld hl, wcf1e
+ ld hl, wEnemyHPBarColor
GetBattleHealthBarColor: ; 3ce90 (f:4e90)
ld b, [hl]
@@ -2045,8 +2055,8 @@ GetBattleHealthBarColor: ; 3ce90 (f:4e90)
ld a, [hl]
cp b
ret z
- ld b, $1
- jp GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ jp RunPaletteCommand
; center's mon's name on the battle screen
; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual
@@ -2061,11 +2071,11 @@ CenterMonName: ; 3ce9c (f:4e9c)
.loop
inc de
ld a, [de]
- cp $50
+ cp "@"
jr z, .done
inc de
ld a, [de]
- cp $50
+ cp "@"
jr z, .done
dec hl
dec b
@@ -2097,7 +2107,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
; the following happens for the old man tutorial
ld hl, wPlayerName
ld de, W_GRASSRATE
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData ; temporarily save the player name in unused space,
; which is supposed to get overwritten when entering a
; map with wild Pokémon. Due to an oversight, the data
@@ -2105,17 +2115,17 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
; Missingno. glitch can show up.
ld hl, .oldManName
ld de, wPlayerName
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
; the following simulates the keystrokes by drawing menus on screen
- hlCoord 9, 14
+ coord hl, 9, 14
ld [hl], "▶"
- ld c, $50
+ ld c, 80
call DelayFrames
- ld [hl], $7f
- hlCoord 9, 16
+ ld [hl], " "
+ coord hl, 9, 16
ld [hl], "▶"
- ld c, $32
+ ld c, 50
call DelayFrames
ld [hl], $ec
ld a, $2 ; select the "ITEM" menu
@@ -2123,7 +2133,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
.oldManName
db "OLD MAN@"
.handleBattleMenuInput
- ld a, [wcc2d]
+ ld a, [wBattleAndStartSavedMenuItem]
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
sub 2 ; check if the cursor is in the left column
@@ -2145,9 +2155,9 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
.safariLeftColumn
Coorda 13, 14
Coorda 13, 16
- hlCoord 7, 14
+ coord hl, 7, 14
ld de, W_NUMSAFARIBALLS
- ld bc, $102
+ lb bc, 1, 2
call PrintNumber
ld b, $1 ; top menu item X
.leftColumn_WaitForInput
@@ -2178,9 +2188,9 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
.safariRightColumn
Coorda 1, 14 ; clear upper cursor position in left column
Coorda 1, 16 ; clear lower cursor position in left column
- hlCoord 7, 14
+ coord hl, 7, 14
ld de, W_NUMSAFARIBALLS
- ld bc, $102
+ lb bc, 1, 2
call PrintNumber
ld b, $d ; top menu item X
.rightColumn_WaitForInput
@@ -2206,7 +2216,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
ld a, [W_BATTLETYPE]
cp $2 ; is it a Safari battle?
ld a, [wCurrentMenuItem]
- ld [wcc2d], a
+ ld [wBattleAndStartSavedMenuItem], a
jr z, .handleMenuSelection
; not Safari battle
; swap the IDs of the item menu and party menu (this is probably because they swapped the positions
@@ -2276,9 +2286,9 @@ BagWasSelected:
jr nz, DisplayPlayerBag ; no, it is a normal battle
ld hl, OldManItemList
ld a, l
- ld [wList], a
+ ld [wListPointer], a
ld a, h
- ld [wList + 1], a
+ ld [wListPointer + 1], a
jr DisplayBagMenu
OldManItemList:
@@ -2290,22 +2300,22 @@ DisplayPlayerBag:
; get the pointer to player's bag when in a normal battle
ld hl, wNumBagItems
ld a, l
- ld [wList], a
+ ld [wListPointer], a
ld a, h
- ld [wList + 1], a
+ ld [wListPointer + 1], a
DisplayBagMenu:
xor a
- ld [wcf93], a
+ ld [wPrintItemPrices], a
ld a, ITEMLISTMENU
ld [wListMenuID], a
- ld a, [wcc2c]
+ ld a, [wBagSavedMenuItem]
ld [wCurrentMenuItem], a
call DisplayListMenuID
ld a, [wCurrentMenuItem]
- ld [wcc2c], a
+ ld [wBagSavedMenuItem], a
ld a, $0
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld [wMenuItemToSwap], a
jp c, DisplayBattleMenu ; go back to battle menu if an item was not selected
@@ -2316,7 +2326,7 @@ UseBagItem:
call GetItemName
call CopyStringToCF4B ; copy name
xor a
- ld [wd152], a
+ ld [wPseudoItemID], a
call UseItem
call LoadHudTilePatterns
call ClearSprites
@@ -2326,7 +2336,7 @@ UseBagItem:
cp $2 ; is it a safari battle?
jr z, .checkIfMonCaptured
- ld a, [wcd6a]
+ ld a, [wActionResultOrTookBattleTurn]
and a ; was the item used successfully?
jp z, BagWasSelected ; if not, go back to the bag menu
@@ -2340,7 +2350,7 @@ UseBagItem:
res UsingTrappingMove, [hl] ; not using multi-turn move any more
.checkIfMonCaptured
- ld a, [wd11c]
+ ld a, [wCapturedMonSpecies]
and a ; was the enemy mon captured with a ball?
jr nz, .returnAfterCapturingMon
@@ -2360,7 +2370,7 @@ UseBagItem:
.returnAfterCapturingMon
call GBPalNormal
xor a
- ld [wd11c], a
+ ld [wCapturedMonSpecies], a
ld a, $2
ld [wBattleResult], a
scf ; set carry
@@ -2384,8 +2394,8 @@ PartyMenuOrRockOrRun:
jp UseBagItem
.partyMenuWasSelected
call LoadScreenTilesFromBuffer1
- xor a
- ld [wd07d], a
+ xor a ; NORMAL_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
.checkIfPartyMonWasSelected
@@ -2395,16 +2405,16 @@ PartyMenuOrRockOrRun:
call GBPalWhiteOut
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer2
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
jp DisplayBattleMenu
.partyMonDeselected
- hlCoord 11, 11
- ld bc, $81
- ld a, $7f
+ coord hl, 11, 11
+ ld bc, 6 * SCREEN_WIDTH + 9
+ ld a, " "
call FillMemory
- xor a
- ld [wd07d], a
+ xor a ; NORMAL_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
call GoBackToPartyMenu
jr .checkIfPartyMonWasSelected
.partyMonWasSelected
@@ -2435,8 +2445,8 @@ PartyMenuOrRockOrRun:
and a ; was Switch selected?
jr z, .switchMon ; if so, jump
; Stats was selected
- xor a
- ld [wcc49], a
+ xor a ; PLAYER_PARTY_DATA
+ ld [wMonDataLocation], a
ld hl, wPartyMon1
call ClearSprites
; display the two status screens
@@ -2448,7 +2458,7 @@ PartyMenuOrRockOrRun:
ld hl, AnimationSubstitute
jr nz, .doEnemyMonAnimation
; enemy mon doesn't have substitute
- ld a, [wccf3]
+ ld a, [wEnemyMonMinimized]
and a ; has the enemy mon used Minimise?
ld hl, AnimationMinimizeMon
jr nz, .doEnemyMonAnimation
@@ -2479,24 +2489,24 @@ PartyMenuOrRockOrRun:
call HasMonFainted
jp z, .partyMonDeselected ; can't switch to fainted mon
ld a, $1
- ld [wcd6a], a
+ ld [wActionResultOrTookBattleTurn], a
call GBPalWhiteOut
call ClearSprites
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer1
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
; fall through to SwitchPlayerMon
SwitchPlayerMon: ; 3d1ba (f:51ba)
callab RetreatMon
- ld c, $32
+ ld c, 50
call DelayFrames
call AnimateRetreatingPlayerMon
ld a, [wWhichPokemon]
ld [wPlayerMonNumber], a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
push bc
ld hl, wPartyGainExpFlags
predef FlagActionPredef
@@ -2522,12 +2532,12 @@ BattleMenu_RunWasSelected: ; 3d1fa (f:51fa)
ld hl, wBattleMonSpeed
ld de, wEnemyMonSpeed
call TryRunningFromBattle
- ld a, $0
- ld [wd11f], a
+ ld a, 0
+ ld [wForcePlayerToChooseMon], a
ret c
- ld a, [wcd6a]
+ ld a, [wActionResultOrTookBattleTurn]
and a
- ret nz
+ ret nz ; return if the player couldn't escape
jp DisplayBattleMenu
MoveSelectionMenu: ; 3d219 (f:5219)
@@ -2561,17 +2571,17 @@ MoveSelectionMenu: ; 3d219 (f:5219)
ret z
ld hl, wBattleMonMoves
call .loadmoves
- hlCoord 4, 12
+ coord hl, 4, 12
ld b, $4
ld c, $e
di
call TextBoxBorder
- hlCoord 4, 12
+ coord hl, 4, 12
ld [hl], $7a
- hlCoord 10, 12
+ coord hl, 10, 12
ld [hl], $7e
ei
- hlCoord 6, 13
+ coord hl, 6, 13
call .writemoves
ld b, $5
ld a, $c
@@ -2579,11 +2589,11 @@ MoveSelectionMenu: ; 3d219 (f:5219)
.mimicmenu
ld hl, wEnemyMonMoves
call .loadmoves
- hlCoord 0, 7
+ coord hl, 0, 7
ld b, $4
ld c, $e
call TextBoxBorder
- hlCoord 2, 8
+ coord hl, 2, 8
call .writemoves
ld b, $1
ld a, $7
@@ -2591,22 +2601,22 @@ MoveSelectionMenu: ; 3d219 (f:5219)
.relearnmenu
ld a, [wWhichPokemon]
ld hl, wPartyMon1Moves
- ld bc, $2c
+ ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
call .loadmoves
- hlCoord 4, 7
+ coord hl, 4, 7
ld b, $4
ld c, $e
call TextBoxBorder
- hlCoord 6, 8
+ coord hl, 6, 8
call .writemoves
ld b, $5
ld a, $7
.menuset
ld hl, wTopMenuItemY
- ld [hli], a
+ ld [hli], a ; wTopMenuItemY
ld a, b
- ld [hli], a
+ ld [hli], a ; wTopMenuItemX
ld a, [wMoveMenuType]
cp $1
jr z, .selectedmoveknown
@@ -2615,30 +2625,30 @@ MoveSelectionMenu: ; 3d219 (f:5219)
ld a, [wPlayerMoveListIndex]
inc a
.selectedmoveknown
- ld [hli], a
+ ld [hli], a ; wCurrentMenuItem
inc hl ; wTileBehindCursor untouched
- ld a, [wcd6c]
+ ld a, [wNumMovesMinusOne]
inc a
inc a
- ld [hli], a
+ ld [hli], a ; wMaxMenuItem
ld a, [wMoveMenuType]
dec a
- ld b, $c1 ; can't use B
+ ld b, D_UP | D_DOWN | A_BUTTON
jr z, .matchedkeyspicked
dec a
- ld b, $c3
+ ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON
jr z, .matchedkeyspicked
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .matchedkeyspicked
ld a, [W_FLAGS_D733]
- bit 0, a
- ld b, $c7
+ bit BIT_TEST_BATTLE, a
+ ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT
jr z, .matchedkeyspicked
ld b, $ff
.matchedkeyspicked
ld a, b
- ld [hli], a
+ ld [hli], a ; wMenuWatchedKeys
ld a, [wMoveMenuType]
cp $1
jr z, .movelistindex1
@@ -2654,21 +2664,21 @@ SelectMenuItem: ; 3d2fe (f:52fe)
jr z, .battleselect
dec a
jr nz, .select
- hlCoord 1, 14
+ coord hl, 1, 14
ld de, WhichTechniqueString
call PlaceString
jr .select
.battleselect
ld a, [W_FLAGS_D733]
- bit 0, a
+ bit BIT_TEST_BATTLE, a
jr nz, .select
call PrintMenuItem
ld a, [wMenuItemToSwap]
and a
jr z, .select
- hlCoord 5, 13
+ coord hl, 5, 13
dec a
- ld bc, $14
+ ld bc, SCREEN_WIDTH
call AddNTimes
ld [hl], $ec
.select
@@ -2759,7 +2769,7 @@ CursorUp: ; 3d3c9 (f:53c9)
and a
jp nz, SelectMenuItem
call EraseMenuCursor
- ld a, [wcd6c]
+ ld a, [wNumMovesMinusOne]
inc a
ld [wCurrentMenuItem], a
jp SelectMenuItem
@@ -2767,7 +2777,7 @@ CursorUp: ; 3d3c9 (f:53c9)
CursorDown: ; 3d3dd (f:53dd)
ld a, [wCurrentMenuItem]
ld b, a
- ld a, [wcd6c]
+ ld a, [wNumMovesMinusOne]
inc a
inc a
cp b
@@ -2815,7 +2825,7 @@ AnyMoveToSelect: ; 3d3f5 (f:53f5)
.asm_3d423
ld hl, NoMovesLeftText
call PrintText
- ld c, $3c
+ ld c, 60
call DelayFrames
xor a
ret
@@ -2868,7 +2878,7 @@ SwapMovesInMenu: ; 3d435 (f:5435)
push hl
call .swapBytes ; swap moves
pop hl
- ld bc, $15
+ ld bc, wPartyMon1PP - wPartyMon1Moves
add hl, bc
call .swapBytes ; swap move PP
xor a
@@ -2903,7 +2913,7 @@ SwapMovesInMenu: ; 3d435 (f:5435)
PrintMenuItem: ; 3d4b6 (f:54b6)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
- hlCoord 0, 8
+ coord hl, 0, 8
ld b, $3
ld c, $9
call TextBoxBorder
@@ -2916,7 +2926,7 @@ PrintMenuItem: ; 3d4b6 (f:54b6)
ld a, [wCurrentMenuItem]
cp b
jr nz, .notDisabled
- hlCoord 1, 10
+ coord hl, 1, 10
ld de, DisabledText
call PlaceString
jr .moveDisabled
@@ -2930,13 +2940,13 @@ PrintMenuItem: ; 3d4b6 (f:54b6)
ld c, a
ld b, $0 ; which item in the menu is the cursor pointing to? (0-3)
add hl, bc ; point to the item (move) in memory
- ld a, [hl]
- ld [wPlayerSelectedMove], a ; update wPlayerSelectedMove even if the move
+ ld a, [hl]
+ ld [wPlayerSelectedMove], a ; update wPlayerSelectedMove even if the move
; isn't actually selected (just pointed to by the cursor)
ld a, [wPlayerMonNumber]
ld [wWhichPokemon], a
- ld a, $4
- ld [wcc49], a
+ ld a, BATTLE_MON_DATA
+ ld [wMonDataLocation], a
callab GetMaxPP
ld hl, wCurrentMenuItem
ld c, [hl]
@@ -2947,24 +2957,24 @@ PrintMenuItem: ; 3d4b6 (f:54b6)
ld a, [hl]
and $3f
ld [wcd6d], a
-; print TYPE/<type> and <curPP>/<maxPP>
- hlCoord 1, 9
+; print TYPE/<type> and <curPP>/<maxPP>
+ coord hl, 1, 9
ld de, TypeText
call PlaceString
- hlCoord 7, 11
+ coord hl, 7, 11
ld [hl], "/"
- hlCoord 5, 9
+ coord hl, 5, 9
ld [hl], "/"
- hlCoord 5, 11
+ coord hl, 5, 11
ld de, wcd6d
- ld bc, $102
+ lb bc, 1, 2
call PrintNumber
- hlCoord 8, 11
- ld de, wd11e
- ld bc, $102
+ coord hl, 8, 11
+ ld de, wMaxPP
+ lb bc, 1, 2
call PrintNumber
- call GetCurrentMove
- hlCoord 2, 10
+ call GetCurrentMove
+ coord hl, 2, 10
predef PrintMoveType
.moveDisabled
ld a, $1
@@ -2979,7 +2989,7 @@ TypeText: ; 3d55f (f:555f)
SelectEnemyMove: ; 3d564 (f:5564)
ld a, [wLinkState]
- sub $4
+ sub LINK_STATE_BATTLING
jr nz, .noLinkBattle
; link battle
call SaveScreenTilesToBuffer1
@@ -3037,18 +3047,18 @@ SelectEnemyMove: ; 3d564 (f:5564)
push hl
call BattleRandom
ld b, $1
- cp $3f ; select move 1 in [0,3e] (63/256 chance)
+ cp $3f ; select move 1, [0,3e] (63/256 chance)
jr c, .moveChosen
inc hl
inc b
- cp $7f ; select move 1 in [3f,7e] (64/256 chance)
+ cp $7f ; select move 2, [3f,7e] (64/256 chance)
jr c, .moveChosen
inc hl
inc b
- cp $be ; select move 1 in [7f,bd] (63/256 chance)
+ cp $be ; select move 3, [7f,bd] (63/256 chance)
jr c, .moveChosen
inc hl
- inc b ; select move 4 in [be,ff] (66/256 chance)
+ inc b ; select move 4, [be,ff] (66/256 chance)
.moveChosen
ld a, b
dec a
@@ -3075,46 +3085,47 @@ LinkBattleExchangeData: ; 3d605 (f:5605)
ld [wSerialExchangeNybbleReceiveData], a
ld a, [wPlayerMoveListIndex]
cp $f ; is the player running from battle?
- jr z, .asm_3d630
- ld a, [wcd6a]
- and a
- jr nz, .asm_3d629
+ jr z, .doExchange
+ ld a, [wActionResultOrTookBattleTurn]
+ and a ; is the player switching in another mon?
+ jr nz, .switching
+; the player used a move
ld a, [wPlayerSelectedMove]
cp STRUGGLE
ld b, $e
- jr z, .asm_3d62f
+ jr z, .next
dec b
inc a
- jr z, .asm_3d62f
+ jr z, .next
ld a, [wPlayerMoveListIndex]
- jr .asm_3d630
-.asm_3d629
+ jr .doExchange
+.switching
ld a, [wWhichPokemon]
- add $4
+ add 4
ld b, a
-.asm_3d62f
+.next
ld a, b
-.asm_3d630
+.doExchange
ld [wSerialExchangeNybbleSendData], a
callab PrintWaitingText
-.asm_3d63b
+.syncLoop1
call Serial_ExchangeNybble
call DelayFrame
ld a, [wSerialExchangeNybbleReceiveData]
inc a
- jr z, .asm_3d63b
- ld b, $a
-.asm_3d649
+ jr z, .syncLoop1
+ ld b, 10
+.syncLoop2
call DelayFrame
call Serial_ExchangeNybble
dec b
- jr nz, .asm_3d649
- ld b, $a
-.asm_3d654
+ jr nz, .syncLoop2
+ ld b, 10
+.syncLoop3
call DelayFrame
call Serial_SendZeroByte
dec b
- jr nz, .asm_3d654
+ jr nz, .syncLoop3
ret
ExecutePlayerMove: ; 3d65e (f:565e)
@@ -3129,8 +3140,8 @@ ExecutePlayerMove: ; 3d65e (f:565e)
ld [wMoveDidntMiss], a
ld a, $a
ld [wDamageMultipliers], a
- ld a, [wcd6a]
- and a
+ ld a, [wActionResultOrTookBattleTurn]
+ and a ; has the player already used the turn (e.g. by using an item, trying to run or switching pokemon)
jp nz, ExecutePlayerMoveDone
call PrintGhostText
jp z, ExecutePlayerMoveDone
@@ -3170,13 +3181,13 @@ PlayerCanExecuteMove: ; 3d6b0 (f:56b0)
ld hl,ResidualEffects1
ld de,1
call IsInArray
- jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests
- ; unless executed as part of their exclusive effect functions
+ jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests
+ ; unless executed as part of their exclusive effect functions
ld a,[W_PLAYERMOVEEFFECT]
ld hl,SpecialEffectsCont
ld de,1
call IsInArray
- call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything
+ call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything
PlayerCalcMoveDamage: ; 3d6dc (f:56dc)
ld a,[W_PLAYERMOVEEFFECT]
ld hl,SetDamageEffects
@@ -3199,7 +3210,7 @@ handleIfPlayerMoveMissed
and a
jr z,getPlayerAnimationType
ld a,[W_PLAYERMOVEEFFECT]
- sub a,EXPLODE_EFFECT
+ sub a,EXPLODE_EFFECT
jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
jr playerCheckIfFlyOrChargeEffect
getPlayerAnimationType
@@ -3211,9 +3222,9 @@ getPlayerAnimationType
playPlayerMoveAnimation
push af
ld a,[W_PLAYERBATTSTATUS2]
- bit 4,a
- ld hl,Func_79747
- ld b,BANK(Func_79747)
+ bit HasSubstituteUp,a
+ ld hl,HideSubstituteShowMonAnim
+ ld b,BANK(HideSubstituteShowMonAnim)
call nz,Bankswitch
pop af
ld [wAnimationType],a
@@ -3222,13 +3233,13 @@ playPlayerMoveAnimation
call HandleExplodingAnimation
call DrawPlayerHUDAndHPBar
ld a,[W_PLAYERBATTSTATUS2]
- bit 4,a
- ld hl,Func_79771
- ld b,BANK(Func_79771)
+ bit HasSubstituteUp,a
+ ld hl,ReshowSubstituteAnim
+ ld b,BANK(ReshowSubstituteAnim)
call nz,Bankswitch
jr MirrorMoveCheck
playerCheckIfFlyOrChargeEffect
- ld c,$1E
+ ld c,30
call DelayFrames
ld a,[W_PLAYERMOVEEFFECT]
cp a,FLY_EFFECT
@@ -3294,7 +3305,7 @@ MirrorMoveCheck
ld a,[wPlayerNumAttacksLeft]
dec a
ld [wPlayerNumAttacksLeft],a
- jp nz,getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
+ jp nz,getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
; damage calculation and accuracy tests only happen for the first hit
res AttackingMultipleTimes,[hl] ; clear attacking multiple times status when all attacks are over
ld hl,MultiHitText
@@ -3320,7 +3331,7 @@ MultiHitText: ; 3d805 (f:5805)
ExecutePlayerMoveDone: ; 3d80a (f:580a)
xor a
- ld [wcd6a],a
+ ld [wActionResultOrTookBattleTurn],a
ld b,1
ret
@@ -3505,8 +3516,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
.MonHurtItselfOrFullyParalysed
ld hl,W_PLAYERBATTSTATUS1
ld a,[hl]
- ; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage)
- and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
+ ; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage)
+ and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
ld [hl],a
ld a,[W_PLAYERMOVEEFFECT]
cp a,FLY_EFFECT
@@ -3584,7 +3595,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
ld hl,wPlayerNumAttacksLeft
dec [hl] ; did Thrashing About counter hit 0?
ld hl,PlayerCalcMoveDamage ; skip DecrementPP
- jp nz,.returnToHL
+ jp nz,.returnToHL
push hl
ld hl,W_PLAYERBATTSTATUS1
res ThrashingAbout,[hl] ; no longer thrashing about
@@ -3605,7 +3616,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
ld a,[wPlayerNumAttacksLeft]
dec a ; did multi-turn move end?
ld [wPlayerNumAttacksLeft],a
- ld hl,getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
+ ld hl,getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
; DecrementPP and MoveHitTest
jp nz,.returnToHL
jp .returnToHL
@@ -3702,7 +3713,7 @@ PrintMoveIsDisabledText: ; 3da88 (f:5a88)
ld de, W_ENEMYBATTSTATUS1
.removeChargingUp
ld a, [de]
- res ChargingUp, a ; end the pokemon's
+ res ChargingUp, a ; end the pokemon's
ld [de], a
ld a, [hl]
ld [wd11e], a
@@ -3762,9 +3773,14 @@ PrintMonName1Text: ; 3daf5 (f:5af5)
ld hl, MonName1Text
jp PrintText
+; this function wastes time calling DetermineExclamationPointTextNum
+; and choosing between Used1Text and Used2Text, even though
+; those text strings are identical and both continue at PrintInsteadText
+; this likely had to do with Japanese grammar that got translated,
+; but the functionality didn't get removed
MonName1Text: ; 3dafb (f:5afb)
TX_FAR _MonName1Text
- db $08 ; asm
+ TX_ASM
ld a, [H_WHOSETURN]
and a
ld a, [W_PLAYERMOVENUM]
@@ -3775,7 +3791,7 @@ MonName1Text: ; 3dafb (f:5afb)
.asm_3db11
ld [hl], a
ld [wd11e], a
- call Func_3db85
+ call DetermineExclamationPointTextNum
ld a, [wMonIsDisobedient]
and a
ld hl, Used2Text
@@ -3789,33 +3805,35 @@ MonName1Text: ; 3dafb (f:5afb)
Used1Text: ; 3db2d (f:5b2d)
TX_FAR _Used1Text
- db $08 ; asm
+ TX_ASM
jr PrintInsteadText
Used2Text: ; 3db34 (f:5b34)
TX_FAR _Used2Text
- db $08 ; asm
+ TX_ASM
+ ; fall through
PrintInsteadText: ; 3db39 (f:5b39)
ld a, [wMonIsDisobedient]
and a
- jr z, PrintCF4BText
+ jr z, PrintMoveName
ld hl, InsteadText
ret
InsteadText: ; 3db43 (f:5b43)
TX_FAR _InsteadText
- db $08 ; asm
+ TX_ASM
+ ; fall through
-PrintCF4BText: ; 3db48 (f:5b48)
- ld hl, CF4BText
+PrintMoveName: ; 3db48 (f:5b48)
+ ld hl, _PrintMoveName
ret
-CF4BText: ; 3db4c (f:5b4c)
+_PrintMoveName: ; 3db4c (f:5b4c)
TX_FAR _CF4BText
- db $08 ; asm
+ TX_ASM
ld hl, ExclamationPointPointerTable
- ld a, [wd11e]
+ ld a, [wd11e] ; exclamation point num
add a
push bc
ld b, $0
@@ -3854,29 +3872,36 @@ ExclamationPoint5Text: ; 3db80 (f:5b80)
TX_FAR _ExclamationPoint5Text
db "@"
-Func_3db85: ; 3db85 (f:5b85)
+; this function does nothing useful
+; if the move being used is in set [1-4] from ExclamationPointMoveSets,
+; use ExclamationPoint[1-4]Text
+; otherwise, use ExclamationPoint5Text
+; but all five text strings are identical
+; this likely had to do with Japanese grammar that got translated,
+; but the functionality didn't get removed
+DetermineExclamationPointTextNum: ; 3db85 (f:5b85)
push bc
- ld a, [wd11e] ; move number
+ ld a, [wd11e] ; move ID
ld c, a
ld b, $0
- ld hl, UnknownMovesList_3dba3
-.asm_3db8f
+ ld hl, ExclamationPointMoveSets
+.loop
ld a, [hli]
cp $ff
- jr z, .asm_3db9d
+ jr z, .done
cp c
- jr z, .asm_3db9d
+ jr z, .done
and a
- jr nz, .asm_3db8f
+ jr nz, .loop
inc b
- jr .asm_3db8f
-.asm_3db9d
+ jr .loop
+.done
ld a, b
- ld [wd11e], a
+ ld [wd11e], a ; exclamation point num
pop bc
ret
-UnknownMovesList_3dba3: ; 3dba3 (f:5ba3)
+ExclamationPointMoveSets: ; 3dba3 (f:5ba3)
db SWORDS_DANCE, GROWTH
db $00
db RECOVER, BIDE, SELFDESTRUCT, AMNESIA
@@ -3919,7 +3944,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2)
; if you get here, the mon used jump kick or hi jump kick and missed
ld hl, W_DAMAGE ; since the move missed, W_DAMAGE will always contain 0 at this point.
- ; Thus, recoil damage will always be equal to 1
+ ; Thus, recoil damage will always be equal to 1
; even if it was intended to be potential damage/8.
ld a, [hli]
ld b, [hl]
@@ -3940,7 +3965,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2)
ld hl, KeptGoingAndCrashedText
call PrintText
ld b, $4
- predef Func_48125
+ predef PredefShakeScreenHorizontally
ld a, [H_WHOSETURN]
and a
jr nz, .enemyTurn
@@ -3986,7 +4011,7 @@ PrintCriticalOHKOText: ; 3dc5c (f:5c5c)
xor a
ld [wCriticalHitOrOHKO], a
.done
- ld c, $14
+ ld c, 20
jp DelayFrames
CriticalOHKOTextPointers: ; 3dc7a (f:5c7a)
@@ -4673,7 +4698,7 @@ CriticalHitTest: ; 3e023 (f:6023)
jr z, .calcCriticalHitProbability
ld hl, W_ENEMYMOVEPOWER
ld de, W_ENEMYBATTSTATUS2
-.calcCriticalHitProbability ; 0x3e04f
+.calcCriticalHitProbability
ld a, [hld] ; read base power from RAM
and a
ret z ; do nothing if zero
@@ -4772,7 +4797,7 @@ HandleCounterMove: ; 3e093 (f:6093)
ld a,[hli]
or [hl]
ret z ; If we made it here, Counter still misses if the last move used in battle did no damage to its target.
- ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself
+ ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself
; if the conditions meet, even though 99% of the times damage will come from the target.
; if it did damage, double it
ld a,[hl]
@@ -4905,7 +4930,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142)
ld [wHPBarNewHP+1],a
ld a,[hl]
ld [wHPBarNewHP],a
- hlCoord 2, 2
+ coord hl, 2, 2
xor a
ld [wHPBarType],a
predef UpdateHPBar2 ; animate the HP bar shortening
@@ -5023,7 +5048,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200)
ld [wHPBarMaxHP+1],a
ld a,[hl]
ld [wHPBarMaxHP],a
- hlCoord 10, 9
+ coord hl, 10, 9
ld a,$01
ld [wHPBarType],a
predef UpdateHPBar2 ; animate the HP bar shortening
@@ -5033,9 +5058,9 @@ ApplyAttackToPlayerPokemonDone
AttackSubstitute: ; 3e25e (f:625e)
; Unlike the two ApplyAttackToPokemon functions, Attack Substitute is shared by player and enemy.
; Self-confusion damage as well as Hi-Jump Kick and Jump Kick recoil cause a momentary turn swap before being applied.
-; If the user has a Substitute up and would take damage because of that,
+; If the user has a Substitute up and would take damage because of that,
; damage will be applied to the other player's Substitute.
-; Normal recoil such as from Double-Edge isn't affected by this glitch,
+; Normal recoil such as from Double-Edge isn't affected by this glitch,
; because this function is never called in that case.
ld hl,SubstituteTookDamageText
@@ -5060,7 +5085,7 @@ AttackSubstitute: ; 3e25e (f:625e)
ld [de],a
ret nc
.substituteBroke
-; If the target's Substitute breaks, W_DAMAGE isn't updated with the amount of HP
+; If the target's Substitute breaks, W_DAMAGE isn't updated with the amount of HP
; the Substitute had before being attacked.
ld h,b
ld l,c
@@ -5071,7 +5096,7 @@ AttackSubstitute: ; 3e25e (f:625e)
ld a,[H_WHOSETURN]
xor a,$01
ld [H_WHOSETURN],a
- callab Func_79747 ; animate the substitute breaking
+ callab HideSubstituteShowMonAnim ; animate the substitute breaking
; flip the turn back to the way it was
ld a,[H_WHOSETURN]
xor a,$01
@@ -5181,7 +5206,7 @@ ReloadMoveData: ; 3e329 (f:6329)
ld [wd11e],a
dec a
ld hl,Moves
- ld bc,$0006
+ ld bc,MoveEnd - Moves
call AddNTimes
ld a,BANK(Moves)
call FarCopyData ; copy the move's stats
@@ -5266,7 +5291,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld d,a ; d = type 1 of defender
ld e,[hl] ; e = type 2 of defender
ld a,[W_PLAYERMOVETYPE]
- ld [wd11e],a
+ ld [wMoveType],a
ld a,[H_WHOSETURN]
and a
jr z,.next
@@ -5280,9 +5305,9 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld d,a ; d = type 1 of defender
ld e,[hl] ; e = type 2 of defender
ld a,[W_ENEMYMOVETYPE]
- ld [wd11e],a
+ ld [wMoveType],a
.next
- ld a,[wd11e] ; move type
+ ld a,[wMoveType]
cp b ; does the move type match type 1 of the attacker?
jr z,.sameTypeAttackBonus
cp c ; does the move type match type 2 of the attacker?
@@ -5307,8 +5332,8 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld hl,wDamageMultipliers
set 7,[hl]
.skipSameTypeAttackBonus
- ld a,[wd11e]
- ld b,a ; b = move type
+ ld a,[wMoveType]
+ ld b,a
ld hl,TypeEffects
.loop
ld a,[hli] ; a = "attacking type" of the current type pair
@@ -5371,29 +5396,29 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
; function to tell how effective the type of an enemy attack is on the player's current pokemon
; this doesn't take into account the effects that dual types can have
; (e.g. 4x weakness / resistance, weaknesses and resistances canceling)
-; the result is stored in [wd11e]
+; the result is stored in [wTypeEffectiveness]
; ($05 is not very effective, $10 is neutral, $14 is super effective)
; as far is can tell, this is only used once in some AI code to help decide which move to use
AIGetTypeEffectiveness: ; 3e449 (f:6449)
ld a,[W_ENEMYMOVETYPE]
- ld d,a ; d = type of enemy move
+ ld d,a ; d = type of enemy move
ld hl,wBattleMonType
- ld b,[hl] ; b = type 1 of player's pokemon
+ ld b,[hl] ; b = type 1 of player's pokemon
inc hl
- ld c,[hl] ; c = type 2 of player's pokemon
+ ld c,[hl] ; c = type 2 of player's pokemon
ld a,$10
- ld [wd11e],a ; initialize [wd11e] to neutral effectiveness
+ ld [wTypeEffectiveness],a ; initialize to neutral effectiveness
ld hl,TypeEffects
.loop
ld a,[hli]
cp a,$ff
ret z
- cp d ; match the type of the move
+ cp d ; match the type of the move
jr nz,.nextTypePair1
ld a,[hli]
- cp b ; match with type 1 of pokemon
+ cp b ; match with type 1 of pokemon
jr z,.done
- cp c ; or match with type 2 of pokemon
+ cp c ; or match with type 2 of pokemon
jr z,.done
jr .nextTypePair2
.nextTypePair1
@@ -5403,7 +5428,7 @@ AIGetTypeEffectiveness: ; 3e449 (f:6449)
jr .loop
.done
ld a,[hl]
- ld [wd11e],a ; store damage multiplier
+ ld [wTypeEffectiveness],a ; store damage multiplier
ret
INCLUDE "data/type_effects.asm"
@@ -5561,7 +5586,7 @@ CalcHitChance: ; 3e624 (f:6624)
; the second iteration multiplies by the evasion ratio
.loop
push bc
- ld hl, StatModifierRatios ; $76cb ; stat modifier ratios
+ ld hl, StatModifierRatios ; stat modifier ratios
dec b
sla b
ld c,b
@@ -5749,8 +5774,8 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4)
push af
ld a, [W_ENEMYBATTSTATUS2]
bit HasSubstituteUp, a ; does mon have a substitute?
- ld hl, Func_79747
- ld b, BANK(Func_79747)
+ ld hl, HideSubstituteShowMonAnim
+ ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
pop af
ld [wAnimationType], a
@@ -5760,14 +5785,14 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4)
call DrawEnemyHUDAndHPBar
ld a, [W_ENEMYBATTSTATUS2]
bit HasSubstituteUp, a ; does mon have a substitute?
- ld hl, Func_79771
- ld b, BANK(Func_79771)
+ ld hl, ReshowSubstituteAnim
+ ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch ; slide the substitute's sprite out
jr EnemyCheckIfMirrorMoveEffect
EnemyCheckIfFlyOrChargeEffect: ; 3e7d1 (f:67d1)
call SwapPlayerAndEnemyLevels
- ld c, $1e
+ ld c, 30
call DelayFrames
ld a, [W_ENEMYMOVEEFFECT]
cp FLY_EFFECT
@@ -6019,7 +6044,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
.monHurtItselfOrFullyParalysed
ld hl, W_ENEMYBATTSTATUS1
ld a, [hl]
- ; clear bide, thrashing about, charging up, and multi-turn moves such as warp
+ ; clear bide, thrashing about, charging up, and multi-turn moves such as warp
and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
ld [hl], a
ld a, [W_ENEMYMOVEEFFECT]
@@ -6115,7 +6140,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call PrintText
ld hl, wEnemyNumAttacksLeft
dec [hl] ; did multi-turn move end?
- ld hl, GetEnemyAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
+ ld hl, GetEnemyAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
; DecrementPP and MoveHitTest
jp nz, .enemyReturnToHL
jp .enemyReturnToHL
@@ -6149,15 +6174,15 @@ GetCurrentMove: ; 3eabe (f:6abe)
.player
ld de, W_PLAYERMOVENUM
ld a, [W_FLAGS_D733]
- bit 0, a
- ld a, [wccd9]
+ bit BIT_TEST_BATTLE, a
+ ld a, [wTestBattlePlayerSelectedMove]
jr nz, .selected
ld a, [wPlayerSelectedMove]
.selected
ld [wd0b5], a
dec a
ld hl, Moves
- ld bc, $6
+ ld bc, MoveEnd - Moves
call AddNTimes
ld a, BANK(Moves)
call FarCopyData
@@ -6180,7 +6205,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
call GetMonHeader
ld a, [W_ENEMYBATTSTATUS3]
bit Transformed, a ; is enemy mon transformed?
- ld hl, wcceb ; copied DVs from when it used Transform
+ ld hl, wTransformedEnemyMonOriginalDVs ; original DVs before transforming
ld a, [hli]
ld b, [hl]
jr nz, .storeDVs
@@ -6279,15 +6304,15 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
dec de
dec de
xor a
- ld [wHPBarMaxHP], a
+ ld [wLearningMovesFromDayCare], a
predef WriteMonMoves ; get moves based on current level
.loadMovePPs
ld hl, wEnemyMonMoves
- ld de, wEnemyMonSpecial + 1
+ ld de, wEnemyMonPP - 1
predef LoadMovePPs
ld hl, W_MONHBASESTATS
ld de, wEnemyMonBaseStats
- ld b, $5
+ ld b, NUM_STATS
.copyBaseStatsLoop
ld a, [hli]
ld [de], a
@@ -6305,7 +6330,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
call GetMonName
ld hl, wcd6d
ld de, wEnemyMonNick
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wEnemyMonSpecies2]
ld [wd11e], a
@@ -6313,15 +6338,15 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
ld a, [wd11e]
dec a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, wPokedexSeen
predef FlagActionPredef ; mark this mon as seen in the pokedex
ld hl, wEnemyMonLevel
ld de, wEnemyMonUnmodifiedLevel
- ld bc, $b
+ ld bc, 1 + NUM_STATS * 2
call CopyData
ld a, $7 ; default stat mod
- ld b, $8 ; number of stat mods
+ ld b, NUM_STAT_MODS ; number of stat mods
ld hl, wEnemyMonStatMods
.statModLoop
ld [hli], a
@@ -6392,7 +6417,7 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92)
predef ScaleSpriteByTwo
ld hl, wOAMBuffer
xor a
- ld [$FF8B], a ; initial tile number
+ ld [hOAMTile], a ; initial tile number
ld b, $7 ; 7 columns
ld e, $a0 ; X for the left-most column
.loop ; each loop iteration writes 3 OAM entries in a vertical column
@@ -6406,16 +6431,16 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92)
add d ; increase Y by height of tile
ld d, a
inc hl
- ld a, [$FF8B]
+ ld a, [hOAMTile]
ld [hli], a ; OAM tile number
inc a ; increment tile number
- ld [$FF8B], a
+ ld [hOAMTile], a
inc hl
dec c
jr nz, .innerLoop
- ld a, [$FF8B]
+ ld a, [hOAMTile]
add $4 ; increase tile number by 4
- ld [$FF8B], a
+ ld [hOAMTile], a
ld a, $8 ; width of tile
add e ; increase X by width of tile
ld e, a
@@ -6436,21 +6461,17 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92)
xor a
ld [$0], a
ld a, $31
- ld [$ffe1], a
- hlCoord 1, 5
- predef_jump Func_3f0c6
+ ld [hStartTileID], a
+ coord hl, 1, 5
+ predef_jump CopyUncompressedPicToTilemap
; does nothing since no stats are ever selected (barring glitches)
DoubleOrHalveSelectedStats: ; 3ed02 (f:6d02)
callab DoubleSelectedStats
- ld hl, HalveSelectedStats
- ld b, BANK(HalveSelectedStats)
- jp Bankswitch
+ jpab HalveSelectedStats
ScrollTrainerPicAfterBattle: ; 3ed12 (f:6d12)
- ld hl, _ScrollTrainerPicAfterBattle
- ld b, BANK(_ScrollTrainerPicAfterBattle)
- jp Bankswitch
+ jpab _ScrollTrainerPicAfterBattle
ApplyBurnAndParalysisPenaltiesToPlayer: ; 3ed1a (f:6d1a)
ld a, $1
@@ -6552,7 +6573,7 @@ CalculateModifiedStats: ; 3ed99 (f:6d99)
call CalculateModifiedStat
inc c
ld a, c
- cp 4
+ cp NUM_STATS - 1
jr nz, .loop
ret
@@ -6560,12 +6581,12 @@ CalculateModifiedStats: ; 3ed99 (f:6d99)
CalculateModifiedStat: ; 3eda5 (f:6da5)
push bc
push bc
- ld a, [wd11e]
+ ld a, [wCalculateWhoseStats]
and a
ld a, c
ld hl, wBattleMonAttack
ld de, wPlayerMonUnmodifiedAttack
- ld bc, wPlayerMonAttackMod
+ ld bc, wPlayerMonStatMods
jr z, .next
ld hl, wEnemyMonAttack
ld de, wEnemyMonUnmodifiedAttack
@@ -6698,22 +6719,22 @@ LoadHudTilePatterns: ; 3ee5b (f:6e5b)
.lcdDisabled
ld hl, BattleHudTiles1
ld de, vChars2 + $6d0
- ld bc, $18
+ ld bc, BattleHudTiles1End - BattleHudTiles1
ld a, BANK(BattleHudTiles1)
call FarCopyDataDouble
ld hl, BattleHudTiles2
ld de, vChars2 + $730
- ld bc, $30
+ ld bc, BattleHudTiles3End - BattleHudTiles2
ld a, BANK(BattleHudTiles2)
jp FarCopyDataDouble
.lcdEnabled
ld de, BattleHudTiles1
ld hl, vChars2 + $6d0
- ld bc, (BANK(BattleHudTiles1) << 8) + $03
+ lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8
call CopyVideoDataDouble
ld de, BattleHudTiles2
ld hl, vChars2 + $730
- ld bc, (BANK(BattleHudTiles2) << 8) + $06
+ lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8
jp CopyVideoDataDouble
PrintEmptyString: ; 3ee94 (f:6e94)
@@ -6749,8 +6770,8 @@ BattleRandom:
push hl
push bc
push af
-
-; point to seed 0 so we pick the first number the next time
+
+; point to seed 0 so we pick the first number the next time
xor a
ld [wLinkBattleRandomNumberListIndex], a
@@ -6759,11 +6780,11 @@ BattleRandom:
.loop
ld a, [hl]
ld c, a
-; multiply by 5
+; multiply by 5
add a
add a
add c
-; add 1
+; add 1
inc a
ld [hli], a
dec b
@@ -6778,11 +6799,11 @@ BattleRandom:
HandleExplodingAnimation: ; 3eed3 (f:6ed3)
ld a, [H_WHOSETURN]
and a
- ld hl, wEnemyMonType1 ; wcfea
+ ld hl, wEnemyMonType1
ld de, W_ENEMYBATTSTATUS1
ld a, [W_PLAYERMOVENUM]
jr z, .asm_3eeea
- ld hl, wBattleMonType1 ; wd019
+ ld hl, wBattleMonType1
ld de, W_ENEMYBATTSTATUS1
ld a, [W_ENEMYMOVENUM]
.asm_3eeea
@@ -6812,10 +6833,10 @@ PlayMoveAnimation: ; 3ef07 (f:6f07)
predef_jump MoveAnimation
; unreferenced
-Func_3f069: ; 3f069 (f:7069)
+ResetCryModifiers: ; 3f069 (f:7069)
xor a
- ld [wc0f1], a
- ld [wc0f2], a
+ ld [wFrequencyModifier], a
+ ld [wTempoModifier], a
jp PlaySound
JumpMoveEffect: ; 3f132 (f:7132)
@@ -7063,7 +7084,7 @@ PoisonEffect: ; 3f24f (f:724f)
cp POISON_EFFECT
ret nz
.didntAffect
- ld c, $32
+ ld c, 50
call DelayFrames
jp PrintDidntAffectText
@@ -7076,9 +7097,7 @@ BadlyPoisonedText: ; 3f2e4 (f:72e4)
db "@"
DrainHPEffect: ; 3f2e9 (f:72e9)
- ld hl, DrainHPEffect_
- ld b, BANK(DrainHPEffect_)
- jp Bankswitch
+ jpab DrainHPEffect_
ExplodeEffect: ; 3f2f1 (f:72f1)
ld hl, wBattleMonHP
@@ -7325,17 +7344,17 @@ StatModifierUpEffect: ; 3f428 (f:7428)
add hl, bc
pop bc
xor a
- ld [H_MULTIPLICAND], a
+ ld [H_MULTIPLICAND], a
ld a, [de]
ld [H_MULTIPLICAND + 1], a
inc de
ld a, [de]
ld [H_MULTIPLICAND + 2], a
ld a, [hli]
- ld [H_MULTIPLIER], a
+ ld [H_MULTIPLIER], a
call Multiply
ld a, [hl]
- ld [H_DIVISOR], a
+ ld [H_DIVISOR], a
ld b, $4
call Divide
pop hl
@@ -7359,27 +7378,29 @@ UpdateStat: ; 3f4c3 (f:74c3)
UpdateStatDone: ; 3f4ca (f:74ca)
ld b, c
inc b
- call Func_3f688
+ call PrintStatText
ld hl, W_PLAYERBATTSTATUS2
ld de, W_PLAYERMOVENUM
- ld bc, wccf7
+ ld bc, wPlayerMonMinimized
ld a, [H_WHOSETURN]
and a
jr z, .asm_3f4e6
ld hl, W_ENEMYBATTSTATUS2
ld de, W_ENEMYMOVENUM
- ld bc, wccf3
+ ld bc, wEnemyMonMinimized
.asm_3f4e6
ld a, [de]
cp MINIMIZE
jr nz, .asm_3f4f9
- bit HasSubstituteUp, [hl] ; substitute
+ ; if a substitute is up, slide off the substitute and show the mon pic before
+ ; playing the minimize animation
+ bit HasSubstituteUp, [hl]
push af
push bc
- ld hl, Func_79747
- ld b, BANK(Func_79747)
+ ld hl, HideSubstituteShowMonAnim
+ ld b, BANK(HideSubstituteShowMonAnim)
push de
- call nz, Bankswitch ; play Minimize animation unless there's Substitute involved
+ call nz, Bankswitch
pop de
.asm_3f4f9
call PlayCurrentMoveAnimation
@@ -7389,8 +7410,8 @@ UpdateStatDone: ; 3f4ca (f:74ca)
pop bc
ld a, $1
ld [bc], a
- ld hl, Func_79771
- ld b, BANK(Func_79771)
+ ld hl, ReshowSubstituteAnim
+ ld b, BANK(ReshowSubstituteAnim)
pop af
call nz, Bankswitch
.applyBadgeBoostsAndStatusPenalties
@@ -7415,7 +7436,7 @@ PrintNothingHappenedText: ; 3f522 (f:7522)
MonsStatsRoseText: ; 3f528 (f:7528)
TX_FAR _MonsStatsRoseText
- db $08 ; asm
+ TX_ASM
ld hl, GreatlyRoseText
ld a, [H_WHOSETURN]
and a
@@ -7529,7 +7550,7 @@ StatModifierDownEffect: ; 3f54c (f:754c)
jr nz, .recalculateStat
ld a, [hl]
and a
- jp z, Func_3f64d
+ jp z, CantLowerAnymore_Pop
.recalculateStat
; recalculate affected stat
; paralysis and burn penalties, as well as badge boosts are ignored
@@ -7543,17 +7564,17 @@ StatModifierDownEffect: ; 3f54c (f:754c)
add hl, bc
pop bc
xor a
- ld [H_MULTIPLICAND], a
+ ld [H_MULTIPLICAND], a
ld a, [de]
ld [H_MULTIPLICAND + 1], a
inc de
ld a, [de]
ld [H_MULTIPLICAND + 2], a
ld a, [hli]
- ld [H_MULTIPLIER], a
+ ld [H_MULTIPLIER], a
call Multiply
ld a, [hl]
- ld [H_DIVISOR], a
+ ld [H_DIVISOR], a
ld b, $4
call Divide
pop hl
@@ -7577,7 +7598,7 @@ UpdateLoweredStatDone: ; 3f62c (f:762c)
ld b, c
inc b
push de
- call Func_3f688
+ call PrintStatText
pop de
ld a, [de]
cp $44
@@ -7597,7 +7618,7 @@ UpdateLoweredStatDone: ; 3f62c (f:762c)
call QuarterSpeedDueToParalysis
jp HalveAttackDueToBurn
-Func_3f64d: ; 3f64d (f:764d)
+CantLowerAnymore_Pop: ; 3f64d (f:764d)
pop de
pop hl
inc [hl]
@@ -7617,7 +7638,7 @@ MoveMissed: ; 3f65a (f:765a)
MonsStatsFellText: ; 3f661 (f:7661)
TX_FAR _MonsStatsFellText
- db $08 ; asm
+ TX_ASM
ld hl, FellText
ld a, [H_WHOSETURN]
and a
@@ -7640,9 +7661,9 @@ FellText: ; 3f683 (f:7683)
TX_FAR _FellText
db "@"
-Func_3f688: ; 3f688 (f:7688)
+PrintStatText: ; 3f688 (f:7688)
ld hl, StatsTextStrings
- ld c, $50
+ ld c, "@"
.asm_3f68d
dec b
jr z, .asm_3f696
@@ -7749,7 +7770,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
srl b
cp b
jr nc, .asm_3f76e
- ld c, $32
+ ld c, 50
call DelayFrames
ld a, [W_PLAYERMOVENUM]
cp TELEPORT
@@ -7764,7 +7785,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
ld a, [W_PLAYERMOVENUM]
jr .asm_3f7e4
.asm_3f77e
- ld c, $32
+ ld c, 50
call DelayFrames
ld hl, IsUnaffectedText
ld a, [W_PLAYERMOVENUM]
@@ -7791,7 +7812,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
srl b
cp b
jr nc, .asm_3f7c1
- ld c, $32
+ ld c, 50
call DelayFrames
ld a, [W_ENEMYMOVENUM]
cp TELEPORT
@@ -7806,7 +7827,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
ld a, [W_ENEMYMOVENUM]
jr .asm_3f7e4
.asm_3f7d1
- ld c, $32
+ ld c, 50
call DelayFrames
ld hl, IsUnaffectedText
ld a, [W_ENEMYMOVENUM]
@@ -7816,7 +7837,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
.asm_3f7e4
push af
call PlayBattleAnimation
- ld c, $14
+ ld c, 20
call DelayFrames
pop af
ld hl, RanFromBattleText
@@ -7911,9 +7932,7 @@ FlinchSideEffect: ; 3f85b (f:785b)
ret
OneHitKOEffect: ; 3f884 (f:7884)
- ld hl, OneHitKOEffect_
- ld b, BANK(OneHitKOEffect_)
- jp Bankswitch
+ jpab OneHitKOEffect_
ChargeEffect: ; 3f88c (f:788c)
ld hl, W_PLAYERBATTSTATUS1
@@ -7945,14 +7964,14 @@ ChargeEffect: ; 3f88c (f:788c)
ld a, b
call PlayBattleAnimation
ld a, [de]
- ld [wWhichTrade], a
+ ld [wChargeMoveNum], a
ld hl, ChargeMoveEffectText
jp PrintText
ChargeMoveEffectText: ; 3f8c8 (f:78c8)
TX_FAR _ChargeMoveEffectText
- db $08 ; asm
- ld a, [wWhichTrade]
+ TX_ASM
+ ld a, [wChargeMoveNum]
cp RAZOR_WIND
ld hl, MadeWhirlwindText
jr z, .asm_3f8f8
@@ -8008,8 +8027,8 @@ TrappingEffect: ; 3f917 (f:7917)
.trappingEffect
bit UsingTrappingMove, [hl]
ret nz
- call ClearHyperBeam ; since this effect is called before testing whether the move will hit,
- ; the target won't need to recharge even if the trapping move missed
+ call ClearHyperBeam ; since this effect is called before testing whether the move will hit,
+ ; the target won't need to recharge even if the trapping move missed
set UsingTrappingMove, [hl] ; mon is now using a trapping move
call BattleRandom ; 3/8 chance for 2 and 3 attacks, and 1/8 chance for 4 and 5 attacks
and $3
@@ -8023,19 +8042,13 @@ TrappingEffect: ; 3f917 (f:7917)
ret
MistEffect: ; 3f941 (f:7941)
- ld hl, MistEffect_
- ld b, BANK(MistEffect_)
- jp Bankswitch
+ jpab MistEffect_
FocusEnergyEffect: ; 3f949 (f:7949)
- ld hl, FocusEnergyEffect_
- ld b, BANK(FocusEnergyEffect_)
- jp Bankswitch
+ jpab FocusEnergyEffect_
RecoilEffect: ; 3f951 (f:7951)
- ld hl, RecoilEffect_
- ld b, BANK(RecoilEffect_)
- jp Bankswitch
+ jpab RecoilEffect_
ConfusionSideEffect: ; 3f959 (f:7959)
call BattleRandom
@@ -8067,7 +8080,7 @@ ConfusionSideEffectSuccess: ; 3f96f (f:796f)
set Confused, [hl] ; mon is now confused
push af
call BattleRandom
- and $3
+ and $3
inc a
inc a
ld [bc], a ; confusion status will last 2-5 turns
@@ -8084,19 +8097,15 @@ BecameConfusedText: ; 3f9a1 (f:79a1)
ConfusionEffectFailed: ; 3f9a6 (f:79a6)
cp CONFUSION_SIDE_EFFECT
ret z
- ld c, $32
+ ld c, 50
call DelayFrames
jp ConditionalPrintButItFailed
ParalyzeEffect: ; 3f9b1 (f:79b1)
- ld hl, ParalyzeEffect_
- ld b, BANK(ParalyzeEffect_)
- jp Bankswitch
+ jpab ParalyzeEffect_
SubstituteEffect: ; 3f9b9 (f:79b9)
- ld hl, SubstituteEffect_
- ld b, BANK(SubstituteEffect_)
- jp Bankswitch
+ jpab SubstituteEffect_
HyperBeamEffect: ; 3f9c1 (f:79c1)
ld hl, W_PLAYERBATTSTATUS2
@@ -8131,7 +8140,7 @@ RageEffect: ; 3f9df (f:79df)
ret
MimicEffect: ; 3f9ed (f:79ed)
- ld c, $32
+ ld c, 50
call DelayFrames
call MoveHitTest
ld a, [W_MOVEMISSED]
@@ -8207,9 +8216,7 @@ MimicLearnedMoveText: ; 3fa77 (f:7a77)
db "@"
LeechSeedEffect: ; 3fa7c (f:7a7c)
- ld hl, LeechSeedEffect_
- ld b, BANK(LeechSeedEffect_)
- jp Bankswitch
+ jpab LeechSeedEffect_
SplashEffect: ; 3fa84 (f:7a84)
call PlayCurrentMoveAnimation
@@ -8248,12 +8255,12 @@ DisableEffect: ; 3fa8a (f:7a8a)
ld a, [H_WHOSETURN]
and a
ld hl, wBattleMonPP
- jr nz, .enemyTurn
+ jr nz, .enemyTurn
ld a, [wLinkState]
cp LINK_STATE_BATTLING
pop hl ; wEnemyMonMoves
jr nz, .playerTurnNotLinkBattle
-; .playerTurnLinkBattle
+; .playerTurnLinkBattle
push hl
ld hl, wEnemyMonPP
.enemyTurn
@@ -8278,7 +8285,7 @@ DisableEffect: ; 3fa8a (f:7a8a)
and $7
inc a ; 1-8 turns disabled
inc c ; move 1-4 will be disabled
- swap c
+ swap c
add c ; map disabled move to high nibble of W_ENEMYDISABLEDMOVE / W_PLAYERDISABLEDMOVE
ld [de], a
call PlayCurrentMoveAnimation2
@@ -8289,7 +8296,7 @@ DisableEffect: ; 3fa8a (f:7a8a)
inc hl ; wEnemyDisabledMoveNumber
.printDisableText
ld a, [wd11e] ; move number
- ld [hl], a
+ ld [hl], a
call GetMoveName
ld hl, MoveWasDisabledText
jp PrintText
@@ -8303,34 +8310,22 @@ MoveWasDisabledText: ; 3fb09 (f:7b09)
db "@"
PayDayEffect: ; 3fb0e (f:7b0e)
- ld hl, PayDayEffect_
- ld b, BANK(PayDayEffect_)
- jp Bankswitch
+ jpab PayDayEffect_
ConversionEffect: ; 3fb16 (f:7b16)
- ld hl, ConversionEffect_
- ld b, BANK(ConversionEffect_)
- jp Bankswitch
+ jpab ConversionEffect_
HazeEffect: ; 3fb1e (f:7b1e)
- ld hl, HazeEffect_
- ld b, BANK(HazeEffect_)
- jp Bankswitch
+ jpab HazeEffect_
HealEffect: ; 3fb26 (f:7b26)
- ld hl, HealEffect_
- ld b, BANK(HealEffect_)
- jp Bankswitch
+ jpab HealEffect_
TransformEffect: ; 3fb2e (f:7b2e)
- ld hl, TransformEffect_
- ld b, BANK(TransformEffect_)
- jp Bankswitch
+ jpab TransformEffect_
ReflectLightScreenEffect: ; 3fb36 (f:7b36)
- ld hl, ReflectLightScreenEffect_
- ld b, BANK(ReflectLightScreenEffect_)
- jp Bankswitch
+ jpab ReflectLightScreenEffect_
NothingHappenedText: ; 3fb3e (f:7b3e)
TX_FAR _NothingHappenedText
@@ -8380,12 +8375,12 @@ ParalyzedMayNotAttackText: ; 3fb74 (f:7b74)
CheckTargetSubstitute: ; 3fb79 (f:7b79)
push hl
ld hl, W_ENEMYBATTSTATUS2
- ld a, [H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
jr z, .next1
ld hl, W_PLAYERBATTSTATUS2
.next1
- bit HasSubstituteUp, [hl]
+ bit HasSubstituteUp, [hl]
pop hl
ret