summaryrefslogtreecommitdiff
path: root/engine/battle
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-05-20 19:40:33 -0500
committerdannye <33dannye@gmail.com>2020-05-20 20:02:53 -0500
commit10f9559eab8c93b94abb8ae8d1083704ad4e169a (patch)
tree7dbe7b152dde8a6e9b56664b5b8cdfc0d6be1253 /engine/battle
parentb8954732a3eaa3a784a6e3eaaa68977a9ccd9816 (diff)
Sync with pokered
Diffstat (limited to 'engine/battle')
-rwxr-xr-xengine/battle/animations.asm168
-rw-r--r--engine/battle/bank3d_battle.asm2
-rw-r--r--engine/battle/battle_transitions.asm30
-rw-r--r--engine/battle/common_text.asm4
-rwxr-xr-xengine/battle/core.asm1943
-rw-r--r--engine/battle/decrement_pp.asm8
-rw-r--r--engine/battle/display_effectiveness.asm4
-rw-r--r--engine/battle/draw_hud_pokeball_gfx.asm2
-rwxr-xr-xengine/battle/end_of_battle.asm2
-rw-r--r--engine/battle/experience.asm8
-rw-r--r--engine/battle/init_battle_variables.asm2
-rw-r--r--engine/battle/moveEffects/conversion_effect.asm2
-rw-r--r--engine/battle/moveEffects/focus_energy_effect.asm6
-rw-r--r--engine/battle/moveEffects/haze_effect.asm10
-rw-r--r--engine/battle/moveEffects/heal_effect.asm2
-rw-r--r--engine/battle/moveEffects/leech_seed_effect.asm4
-rw-r--r--engine/battle/moveEffects/mist_effect.asm4
-rw-r--r--engine/battle/moveEffects/recoil_effect.asm2
-rw-r--r--engine/battle/moveEffects/reflect_light_screen_effect.asm8
-rw-r--r--engine/battle/moveEffects/substitute_effect.asm8
-rw-r--r--engine/battle/moveEffects/transform_effect.asm6
-rwxr-xr-xengine/battle/read_trainer_party.asm80
-rwxr-xr-xengine/battle/safari_zone.asm2
-rw-r--r--engine/battle/save_trainer_name.asm26
-rw-r--r--engine/battle/trainer_ai.asm338
25 files changed, 1335 insertions, 1336 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 629aa8cd..de1e67b9 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -115,7 +115,7 @@ DrawFrameBlock:
.flipHorizontalTranslateDown
ld a, [wBaseCoordY]
add [hl]
- add a, 40 ; translate Y coordinate downwards
+ add 40 ; translate Y coordinate downwards
ld [de], a ; store Y
inc hl
inc de
@@ -134,7 +134,7 @@ DrawFrameBlock:
inc hl
inc de
ld a, [hli]
- add a, $31 ; base tile ID for battle animations
+ add $31 ; base tile ID for battle animations
ld [de], a ; store tile ID
inc de
ld a, [hli]
@@ -159,18 +159,18 @@ DrawFrameBlock:
jp nz, .loop ; go back up if there are more tiles to draw
.afterDrawingTiles
ld a, [wFBMode]
- cp a, 2
+ cp 2
jr z, .advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer
ld a, [wSubAnimFrameDelay]
ld c, a
call DelayFrames
ld a, [wFBMode]
- cp a, 3
+ cp 3
jr z, .advanceFrameBlockDestAddr ; skip cleaning OAM buffer
- cp a, 4
+ cp 4
jr z, .done ; skip cleaning OAM buffer and don't advance the frame block destination address
ld a, [wAnimationID]
- cp a, GROWL
+ cp GROWL
jr z, .resetFrameBlockDestAddr
call AnimationCleanOAM
.resetFrameBlockDestAddr
@@ -204,9 +204,9 @@ PlayAnimation:
ld l, a
.animationLoop
ld a, [hli]
- cp a, $FF
+ cp $FF
jr z, .AnimationOver
- cp a, $C0 ; is this subanimation or a special effect?
+ cp $C0 ; is this subanimation or a special effect?
jr c, .playSubanimation
.doSpecialEffect
ld c, a
@@ -221,7 +221,7 @@ PlayAnimation:
jr .searchSpecialEffectTableLoop
.foundMatch
ld a, [hli]
- cp a, $FF ; is there a sound to play?
+ cp $FF ; is there a sound to play?
jr z, .skipPlayingSound
ld [wAnimSoundID], a ; store sound
push hl
@@ -243,7 +243,7 @@ PlayAnimation:
jp hl ; jump to special effect function
.playSubanimation
ld c, a
- and a, %00111111
+ and %00111111
ld [wSubAnimFrameDelay], a
xor a
sla c
@@ -296,11 +296,11 @@ LoadSubanimation:
ld d, a ; de = address of subanimation
ld a, [de]
ld b, a
- and a, 31
+ and 31
ld [wSubAnimCounter], a ; number of frame blocks
ld a, b
- and a, %11100000
- cp a, 5 << 5 ; is subanimation type 5?
+ and %11100000
+ cp 5 << 5 ; is subanimation type 5?
jr nz, .isNotType5
.isType5
call GetSubanimationTransform2
@@ -312,7 +312,7 @@ LoadSubanimation:
srl a
swap a
ld [wSubAnimTransform], a
- cp a, 4 ; is the animation reversed?
+ cp 4 ; is the animation reversed?
ld hl, 0
jr nz, .storeSubentryAddr
; if the animation is reversed, then place the initial subentry address at the end of the list of subentries
@@ -410,7 +410,7 @@ MoveAnimation:
jr z, .animationFinished
; if throwing a Poké Ball, skip the regular animation code
- cp a, TOSS_ANIM
+ cp TOSS_ANIM
jr nz, .moveAnimation
ld de, .animationFinished
push de
@@ -453,11 +453,11 @@ ShareMoveAnimations:
ld a, [wAnimationID]
- cp a, AMNESIA
+ cp AMNESIA
ld b, CONF_ANIM
jr z, .replaceAnim
- cp a, REST
+ cp REST
ld b, SLP_ANIM
ret nz
@@ -596,7 +596,7 @@ WriteLowerByteOfBGMapAndEnableBGTransfer:
PlaySubanimation:
ld a, [wAnimSoundID]
- cp a, $FF
+ cp $FF
jr z, .skipPlayingSound
call GetMoveSound
call PlaySound
@@ -648,7 +648,7 @@ PlaySubanimation:
ld a, [wSubAnimSubEntryAddr]
ld l, a
ld a, [wSubAnimTransform]
- cp a, 4 ; is the animation reversed?
+ cp 4 ; is the animation reversed?
ld bc, 3
jr nz, .nextSubanimationSubentry
ld bc, -3
@@ -775,34 +775,34 @@ AnimationIdSpecialEffects:
DoBallTossSpecialEffects:
ld a, [wcf91]
- cp a, 3 ; is it a Master Ball or Ultra Ball?
+ cp 3 ; is it a Master Ball or Ultra Ball?
jr nc, .skipFlashingEffect
.flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball
ld a, [rOBP0]
- xor a, %00111100 ; complement colors 1 and 2
+ xor %00111100 ; complement colors 1 and 2
ld [rOBP0], a
call UpdateGBCPal_OBP0
.skipFlashingEffect
ld a, [wSubAnimCounter]
- cp a, 11 ; is it the beginning of the subanimation?
+ cp 11 ; is it the beginning of the subanimation?
jr nz, .skipPlayingSound
; if it is the beginning of the subanimation, play a sound
ld a, SFX_BALL_TOSS
call PlaySound
.skipPlayingSound
ld a, [wIsInBattle]
- cp a, 02 ; is it a trainer battle?
+ cp 02 ; is it a trainer battle?
jr z, .isTrainerBattle
ld a, [wd11e]
- cp a, $10 ; is the enemy pokemon the Ghost Marowak?
+ cp $10 ; is the enemy pokemon the Ghost Marowak?
ret nz
; if the enemy pokemon is the Ghost Marowak, make it dodge during the last 3 frames
ld a, [wSubAnimCounter]
- cp a, 3
+ cp 3
jr z, .moveGhostMarowakLeft
- cp a, 2
+ cp 2
jr z, .moveGhostMarowakLeft
- cp a, 1
+ cp 1
ret nz
.moveGhostMarowakLeft
coord hl, 17, 0
@@ -822,7 +822,7 @@ DoBallTossSpecialEffects:
ret
.isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame
ld a, [wSubAnimCounter]
- cp a, 3
+ cp 3
ret nz
dec a
ld [wSubAnimCounter], a
@@ -830,7 +830,7 @@ DoBallTossSpecialEffects:
DoBallShakeSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 4 ; is it the beginning of a shake?
+ cp 4 ; is it the beginning of a shake?
jr nz, .skipPlayingSound
; if it is the beginning of a shake, play a sound and wait 2/3 of a second
ld a, SFX_TINK
@@ -864,21 +864,21 @@ DoBallShakeSpecialEffects:
; plays a sound after the second frame of the poof animation
DoPoofSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 5
+ cp 5
ret nz
ld a, SFX_BALL_POOF
jp PlaySound
DoRockSlideSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 12
+ cp 12
ret nc
- cp a, 8
+ cp 8
jr nc, .shakeScreen
- cp a, 1
+ cp 1
jp z, AnimationFlashScreen ; if it's the end of the subanimation, flash the screen
ret
-; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically
+; if the subanimation counter is between 8 and 11, shake the screen horizontally and vertically
.shakeScreen
ld b, 1
predef PredefShakeScreenHorizontally ; shake horizontally
@@ -887,21 +887,21 @@ DoRockSlideSpecialEffects:
FlashScreenEveryEightFrameBlocks:
ld a, [wSubAnimCounter]
- and a, 7 ; is the subanimation counter exactly 8?
+ and 7 ; is the subanimation counter exactly 8?
call z, AnimationFlashScreen ; if so, flash the screen
ret
; flashes the screen if the subanimation counter is divisible by 4
FlashScreenEveryFourFrameBlocks:
ld a, [wSubAnimCounter]
- and a, 3
+ and 3
call z, AnimationFlashScreen
ret
; used for Explosion and Selfdestruct
DoExplodeSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 1 ; is it the end of the subanimation?
+ cp 1 ; is it the end of the subanimation?
jr nz, FlashScreenEveryFourFrameBlocks
; if it's the end of the subanimation, make the attacking pokemon disappear
coord hl, 1, 5
@@ -910,13 +910,13 @@ DoExplodeSpecialEffects:
; flashes the screen when subanimation counter is 1 modulo 4
DoBlizzardSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 13
+ cp 13
jp z, AnimationFlashScreen
- cp a, 9
+ cp 9
jp z, AnimationFlashScreen
- cp a, 5
+ cp 5
jp z, AnimationFlashScreen
- cp a, 1
+ cp 1
jp z, AnimationFlashScreen
ret
@@ -924,18 +924,18 @@ DoBlizzardSpecialEffects:
; unused
FlashScreenUnused:
ld a, [wSubAnimCounter]
- cp a, 14
+ cp 14
jp z, AnimationFlashScreen
- cp a, 9
+ cp 9
jp z, AnimationFlashScreen
- cp a, 2
+ cp 2
jp z, AnimationFlashScreen
ret
; function to make the pokemon disappear at the beginning of the animation
TradeHidePokemon:
ld a, [wSubAnimCounter]
- cp a, 6
+ cp 6
ret nz
ld a, 2 * SCREEN_WIDTH + 7
jp ClearMonPicFromTileMap ; make pokemon disappear
@@ -943,7 +943,7 @@ TradeHidePokemon:
; function to make a shaking pokeball jump up at the end of the animation
TradeShakePokeball:
ld a, [wSubAnimCounter]
- cp a, 1
+ cp 1
ret nz
; if it's the end of the animation, make the ball jump up
ld de, BallMoveDistances1
@@ -952,13 +952,13 @@ TradeShakePokeball:
ld bc, 4
.innerLoop
ld a, [de]
- cp a, $ff
+ cp $ff
jr z, .done
add [hl] ; add to Y value of OAM entry
ld [hl], a
add hl, bc
ld a, l
- cp a, 4 * 4 ; there are 4 entries, each 4 bytes
+ cp 4 * 4 ; there are 4 entries, each 4 bytes
jr nz, .innerLoop
inc de
push bc
@@ -982,20 +982,20 @@ TradeJumpPokeball:
ld bc, 4
.innerLoop
ld a, [de]
- cp a, $ff
+ cp $ff
jp z, ClearScreen
add [hl]
ld [hl], a
add hl, bc
ld a, l
- cp a, 4 * 4 ; there are 4 entries, each 4 bytes
+ cp 4 * 4 ; there are 4 entries, each 4 bytes
jr nz, .innerLoop
inc de
push de
ld a, [de]
- cp a, 12
+ cp 12
jr z, .playSound
- cp a, $ff
+ cp $ff
jr nz, .skipPlayingSound
.playSound ; play sound if next move distance is 12 or this is the last one
ld a, SFX_BATTLE_18
@@ -1006,7 +1006,7 @@ TradeJumpPokeball:
call DelayFrames
pop bc
ld a, [hSCX] ; background scroll X
- sub a, 8 ; scroll to the left
+ sub 8 ; scroll to the left
ld [hSCX], a
pop de
jr .loop
@@ -1125,7 +1125,7 @@ AnimationDelay10:
CallWithTurnFlipped:
ld a, [H_WHOSETURN]
push af
- xor a, 1
+ xor 1
ld [H_WHOSETURN], a
ld de, .returnAddress
push de
@@ -1148,7 +1148,7 @@ AnimationFlashScreenLong:
push hl
.innerLoop
ld a, [hli]
- cp a, $01 ; is it the end of the palettes?
+ cp $01 ; is it the end of the palettes?
jr z, .endOfPalettes
ld [rBGP], a
call UpdateGBCPal_BGP
@@ -1198,13 +1198,13 @@ FlashScreenLongSGB:
; causes a delay of 1 frame for the second and third cycles
FlashScreenLongDelay:
ld a, [wFlashScreenLongCounter]
- cp a, 4 ; never true since [wFlashScreenLongCounter] starts at 3
+ cp 4 ; never true since [wFlashScreenLongCounter] starts at 3
ld c, 4
jr z, .delayFrames
- cp a, 3
+ cp 3
ld c, 2
jr z, .delayFrames
- cp a, 2 ; nothing is done with this
+ cp 2 ; nothing is done with this
ld c, 1
.delayFrames
jp DelayFrames
@@ -1599,7 +1599,7 @@ AnimationShowMonPic:
jp Delay3
AnimationShowEnemyMonPic:
-; Shows the emenmy mon's front sprite. Used in animations like Seismic Toss
+; Shows the enemy mon's front sprite. Used in animations like Seismic Toss
; to make the mon's sprite reappear after disappears offscreen.
ld hl, AnimationShowMonPic
jp CallWithTurnFlipped
@@ -2201,7 +2201,7 @@ HideSubstituteShowMonAnim:
push de
push bc
; if the substitute broke, slide it down, else slide it offscreen horizontally
- bit HasSubstituteUp, a
+ bit HAS_SUBSTITUTE_UP, a
jr nz, .substituteStillUp
call AnimationSlideMonDown
jr .next2
@@ -2211,7 +2211,7 @@ HideSubstituteShowMonAnim:
pop bc
pop de
ld a, [de]
- bit Invulnerable, a
+ bit INVULNERABLE, a
pop hl
jr nz, .invulnerable
ld a, [bc]
@@ -2524,9 +2524,9 @@ GetMoveSound:
IsCryMove:
; set carry if the move animation involves playing a monster cry
ld a, [wAnimationID]
- cp a, GROWL
+ cp GROWL
jr z, .CryMove
- cp a, ROAR
+ cp ROAR
jr z, .CryMove
and a ; clear carry
ret
@@ -2589,12 +2589,12 @@ MoveSoundTable:
db SFX_BATTLE_2A, $80, $c0 ; ACID
db SFX_BATTLE_19, $10, $a0 ; EMBER
db SFX_BATTLE_19, $21, $e0 ; FLAMETHROWER
- db SFX_EARTHQUAKE, $00, $80 ; MIST
+ db SFX_BATTLE_29, $00, $80 ; MIST
db SFX_BATTLE_24, $20, $60 ; WATER_GUN
db SFX_BATTLE_2A, $00, $80 ; HYDRO_PUMP
db SFX_BATTLE_2C, $00, $80 ; SURF
db SFX_BATTLE_28, $40, $80 ; ICE_BEAM
- db SFX_EARTHQUAKE, $f0, $e0 ; BLIZZARD
+ db SFX_BATTLE_29, $f0, $e0 ; BLIZZARD
db SFX_PSYBEAM, $00, $80 ; PSYBEAM
db SFX_BATTLE_2A, $f0, $60 ; BUBBLEBEAM
db SFX_BATTLE_28, $00, $80 ; AURORA_BEAM
@@ -2617,15 +2617,15 @@ MoveSoundTable:
db SFX_BATTLE_1C, $01, $c0 ; SLEEP_POWDER
db SFX_BATTLE_13, $14, $c0 ; PETAL_DANCE
db SFX_BATTLE_1B, $02, $a0 ; STRING_SHOT
- db SFX_EARTHQUAKE, $f0, $80 ; DRAGON_RAGE
- db SFX_EARTHQUAKE, $20, $c0 ; FIRE_SPIN
- db SFX_THUNDERBOLT, $00, $20 ; THUNDERSHOCK
- db SFX_THUNDERBOLT, $20, $80 ; THUNDERBOLT
+ db SFX_BATTLE_29, $f0, $80 ; DRAGON_RAGE
+ db SFX_BATTLE_29, $20, $c0 ; FIRE_SPIN
+ db SFX_BATTLE_2F, $00, $20 ; THUNDERSHOCK
+ db SFX_BATTLE_2F, $20, $80 ; THUNDERBOLT
db SFX_BATTLE_2E, $12, $60 ; THUNDER_WAVE
db SFX_BATTLE_26, $00, $80 ; THUNDER
db SFX_BATTLE_14, $01, $e0 ; ROCK_THROW
- db SFX_EARTHQUAKE, $0f, $e0 ; EARTHQUAKE
- db SFX_EARTHQUAKE, $11, $20 ; FISSURE
+ db SFX_BATTLE_29, $0f, $e0 ; EARTHQUAKE
+ db SFX_BATTLE_29, $11, $20 ; FISSURE
db SFX_DAMAGE, $10, $40 ; DIG
db SFX_BATTLE_0F, $10, $c0 ; TOXIC
db SFX_BATTLE_14, $00, $20 ; CONFUSION
@@ -2661,7 +2661,7 @@ MoveSoundTable:
db SFX_NOT_VERY_EFFECTIVE, $10, $ff ; SMOG
db SFX_BATTLE_2A, $20, $20 ; SLUDGE
db SFX_BATTLE_32, $00, $80 ; BONE_CLUB
- db SFX_EARTHQUAKE, $1f, $20 ; FIRE_BLAST
+ db SFX_BATTLE_29, $1f, $20 ; FIRE_BLAST
db SFX_BATTLE_25, $2f, $80 ; WATERFALL
db SFX_BATTLE_0F, $1f, $ff ; CLAMP
db SFX_BATTLE_2B, $1f, $60 ; SWIFT
@@ -2696,7 +2696,7 @@ MoveSoundTable:
db SFX_BATTLE_1E, $12, $ff ; HYPER_FANG
db SFX_BATTLE_31, $80, $04 ; SHARPEN
db SFX_BATTLE_33, $f0, $10 ; CONVERSION
- db SFX_EARTHQUAKE, $f8, $ff ; TRI_ATTACK
+ db SFX_BATTLE_29, $f8, $ff ; TRI_ATTACK
db SFX_BATTLE_26, $f0, $ff ; SUPER_FANG
db SFX_NOT_VERY_EFFECTIVE, $01, $ff ; SLASH
db SFX_BATTLE_2C, $d8, $04 ; SUBSTITUTE
@@ -2765,11 +2765,11 @@ TileIDListPointerTable:
dn 5, 7
dw DownscaledMonTiles_3x7
dn 3, 7
- dw DownscaledMonTiles_79ce9
+ dw GengarIntroTiles1
dn 7, 7
- dw DownscaledMonTiles_79d1a
+ dw GengarIntroTiles2
dn 7, 7
- dw DownscaledMonTiles_79d4b
+ dw GengarIntroTiles3
dn 7, 7
dw DownscaledMonTiles_79d7c
dn 8, 6
@@ -2809,7 +2809,7 @@ DownscaledMonTiles_3x7:
db $02, $09, $10, $17, $1E, $25, $2C
db $04, $0B, $12, $19, $20, $27, $2E
-DownscaledMonTiles_79ce9:
+GengarIntroTiles1:
db $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $19, $00
db $02, $06, $0B, $10, $14, $1A, $00
@@ -2818,7 +2818,7 @@ DownscaledMonTiles_79ce9:
db $04, $09, $0E, $13, $17, $1D, $1F
db $05, $0A, $0F, $01, $18, $1E, $20
-DownscaledMonTiles_79d1a:
+GengarIntroTiles2:
db $00, $00, $00, $30, $00, $37, $00
db $00, $00, $2B, $31, $34, $38, $3D
db $21, $26, $2C, $01, $35, $39, $3E
@@ -2827,7 +2827,7 @@ DownscaledMonTiles_79d1a:
db $24, $29, $2F, $01, $01, $3B, $00
db $25, $2A, $01, $01, $01, $3C, $00
-DownscaledMonTiles_79d4b:
+GengarIntroTiles3:
db $00, $00, $00, $00, $00, $00, $00
db $00, $00, $47, $4D, $00, $00, $00
db $00, $00, $48, $4E, $52, $56, $5B
@@ -3158,30 +3158,30 @@ BattleAnimCopyTileMapToVRAM:
TossBallAnimation:
ld a, [wIsInBattle]
- cp a, 2
+ cp 2
jr z, .BlockBall ; if in trainer battle, play different animation
ld a, [wPokeBallAnimData]
ld b, a
; upper nybble: how many animations (from PokeBallAnimations) to play
; this will be 4 for successful capture, 6 for breakout
- and a, $F0
+ and $F0
swap a
ld c, a
; lower nybble: number of shakes
; store these for later
ld a, b
- and a, $F
+ and $F
ld [wNumShakes], a
ld hl, .PokeBallAnimations
; choose which toss animation to use
ld a, [wcf91]
- cp a, POKE_BALL
+ cp POKE_BALL
ld b, TOSS_ANIM
jr z, .done
- cp a, GREAT_BALL
+ cp GREAT_BALL
ld b, GREATTOSS_ANIM
jr z, .done
ld b, ULTRATOSS_ANIM
diff --git a/engine/battle/bank3d_battle.asm b/engine/battle/bank3d_battle.asm
index 740fc71a..0cf24fe1 100644
--- a/engine/battle/bank3d_battle.asm
+++ b/engine/battle/bank3d_battle.asm
@@ -30,7 +30,7 @@ asm_f601d:
res 1, [hl]
call InitBattleVariables
ld a, [wEnemyMonSpecies2]
- sub $c8
+ sub OPP_ID_OFFSET
jp c, InitWildBattle
ld [wTrainerClass], a
call GetTrainerInformation
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index ec95a5d9..e4392a01 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -82,7 +82,7 @@ BattleTransitions:
GetBattleTransitionID_WildOrTrainer:
ld a, [wCurOpponent]
- cp 200
+ cp OPP_ID_OFFSET
jr nc, .trainer
res 0, c
ret
@@ -118,8 +118,8 @@ GetBattleTransitionID_CompareLevels:
ld [wBattleTransitionSpiralDirection], a
ret
-; fails to recognize VICTORY_ROAD_2, VICTORY_ROAD_3, all ROCKET_HIDEOUT maps,
-; MANSION_1, SEAFOAM_ISLANDS_[2-5], POWER_PLANT, DIGLETTS_CAVE
+; fails to recognize VICTORY_ROAD_2F, VICTORY_ROAD_3F, all ROCKET_HIDEOUT maps,
+; POKEMON_MANSION_1F, SEAFOAM_ISLANDS_[B1F-B4F], POWER_PLANT, DIGLETTS_CAVE
; and SILPH_CO_[9-11]F as dungeon maps
GetBattleTransitionID_IsDungeonMap:
ld a, [wCurMap]
@@ -155,30 +155,30 @@ GetBattleTransitionID_IsDungeonMap:
; is equal to one of these maps
DungeonMaps1:
db VIRIDIAN_FOREST
- db ROCK_TUNNEL_1
- db SEAFOAM_ISLANDS_1
- db ROCK_TUNNEL_2
+ db ROCK_TUNNEL_1F
+ db SEAFOAM_ISLANDS_1F
+ db ROCK_TUNNEL_B1F
db $FF
; GetBattleTransitionID_IsDungeonMap checks if wCurMap
; is in between or equal to each pair of maps
DungeonMaps2:
; all MT_MOON maps
- db MT_MOON_1
- db MT_MOON_3
+ db MT_MOON_1F
+ db MT_MOON_B2F
- ; all SS_ANNE maps, VICTORY_ROAD_1, LANCES_ROOM, and HALL_OF_FAME
- db SS_ANNE_1
+ ; all SS_ANNE maps, VICTORY_ROAD_1F, LANCES_ROOM, and HALL_OF_FAME
+ db SS_ANNE_1F
db HALL_OF_FAME
- ; all POKEMONTOWER maps and Lavender Town buildings
+ ; all POKEMON_TOWER maps and Lavender Town buildings
db LAVENDER_POKECENTER
- db LAVENDER_HOUSE_2
+ db LAVENDER_CUBONE_HOUSE
- ; SILPH_CO_[2-8]F, MANSION[2-4], SAFARI_ZONE, and UNKNOWN_DUNGEON maps,
- ; except for SILPH_CO_1F
+ ; SILPH_CO_[2-8]F, POKEMON_MANSION[2F-B1F], SAFARI_ZONE, and
+ ; CERULEAN_CAVE maps, except for SILPH_CO_1F
db SILPH_CO_2F
- db UNKNOWN_DUNGEON_1
+ db CERULEAN_CAVE_1F
db $FF
LoadBattleTransitionTile:
diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm
index d84d0300..e8f4f002 100644
--- a/engine/battle/common_text.asm
+++ b/engine/battle/common_text.asm
@@ -3,9 +3,9 @@ PrintBeginningBattleText:
dec a
jr nz, .trainerBattle
ld a, [wCurMap]
- cp POKEMONTOWER_3
+ cp POKEMON_TOWER_3F
jr c, .notPokemonTower
- cp LAVENDER_HOUSE_1
+ cp MR_FUJIS_HOUSE
jr c, .pokemonTower
.notPokemonTower
ld a,[wBattleType]
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index f23dd649..60146902 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -390,15 +390,15 @@ MainInBattleLoop:
xor a
ld [wFirstMonsNotOutYet], a
ld a, [wPlayerBattleStatus2]
- and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge
+ and (1 << NEEDS_TO_RECHARGE) | (1 << USING_RAGE) ; check if the player is using Rage or needs to recharge
jr nz, .selectEnemyMove
; the player is not using Rage and doesn't need to recharge
ld hl, wEnemyBattleStatus1
- res Flinched, [hl] ; reset flinch bit
+ res FLINCHED, [hl] ; reset flinch bit
ld hl, wPlayerBattleStatus1
- res Flinched, [hl] ; reset flinch bit
+ res FLINCHED, [hl] ; reset flinch bit
ld a, [hl]
- and (1 << ThrashingAbout) | (1 << ChargingUp) ; check if the player is thrashing about or charging for an attack
+ and (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) ; check if the player is thrashing about or charging for an attack
jr nz, .selectEnemyMove ; if so, jump
; the player is neither thrashing about nor charging for an attack
call DisplayBattleMenu ; show battle menu
@@ -410,12 +410,12 @@ MainInBattleLoop:
and (1 << FRZ) | SLP ; is mon frozen or asleep?
jr nz, .selectEnemyMove ; if so, jump
ld a, [wPlayerBattleStatus1]
- and (1 << StoringEnergy) | (1 << UsingTrappingMove) ; check player is using Bide or using a multi-turn attack like wrap
+ and (1 << STORING_ENERGY) | (1 << USING_TRAPPING_MOVE) ; check player is using Bide or using a multi-turn attack like wrap
jr nz, .selectEnemyMove ; if so, jump
ld a, [wEnemyBattleStatus1]
- bit UsingTrappingMove, a ; check if enemy is using a multi-turn attack like wrap
+ bit USING_TRAPPING_MOVE, a ; check if enemy is using a multi-turn attack like wrap
jr z, .selectPlayerMove ; if not, jump
-; enemy is using a mult-turn attack like wrap, so player is trapped and cannot execute a move
+; enemy is using a multi-turn attack like wrap, so player is trapped and cannot execute a move
ld a, $ff
ld [wPlayerSelectedMove], a
jr .selectEnemyMove
@@ -441,17 +441,17 @@ MainInBattleLoop:
jr nz, .noLinkBattle
; link battle
ld a, [wSerialExchangeNybbleReceiveData]
- cp $f
+ cp LINKBATTLE_RUN
jp z, EnemyRan
- cp $e
+ cp LINKBATTLE_STRUGGLE
jr z, .noLinkBattle
- cp $d
+ cp LINKBATTLE_NO_ACTION
jr z, .noLinkBattle
- sub $4
+ sub 4
jr c, .noLinkBattle
; the link battle enemy has switched mons
ld a, [wPlayerBattleStatus1]
- bit UsingTrappingMove, a ; check if using multi-turn move like Wrap
+ bit USING_TRAPPING_MOVE, a ; check if using multi-turn move like Wrap
jr z, .specialMoveNotUsed
ld a, [wPlayerMoveListIndex]
ld hl, wBattleMonMoves
@@ -497,8 +497,8 @@ MainInBattleLoop:
jr nc, .playerMovesFirst ; if player is faster
jr .enemyMovesFirst ; if enemy is faster
.speedEqual ; 50/50 chance for both players
- ld a, [$ffaa]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr z, .invertOutcome
call BattleRandom
cp $80
@@ -588,7 +588,7 @@ HandlePoisonBurnLeechSeed:
call PrintText
xor a
ld [wAnimationType], a
- ld a,BURN_PSN_ANIM
+ ld a, BURN_PSN_ANIM
call PlayMoveAnimation ; play burn/poison animation
pop hl
call HandlePoisonBurnLeechSeed_DecreaseOwnHP
@@ -609,7 +609,7 @@ HandlePoisonBurnLeechSeed:
ld [H_WHOSETURN], a
xor a
ld [wAnimationType], a
- ld a,ABSORB
+ ld a, ABSORB
call PlayMoveAnimation ; play leech seed animation (from opposing mon)
pop af
ld [H_WHOSETURN], a
@@ -676,7 +676,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP:
ld hl, wEnemyBattleStatus3
ld de, wEnemyToxicCounter
.playersTurn
- bit BadlyPoisoned, [hl]
+ bit BADLY_POISONED, [hl]
jr z, .noToxic
ld a, [de] ; increment toxic counter
inc a
@@ -713,7 +713,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP:
ret
; adds bc to enemy HP
-; bc isn't updated if HP substracted was capped to prevent overkill
+; bc isn't updated if HP subtracted was capped to prevent overkill
HandlePoisonBurnLeechSeed_IncreaseEnemyHP:
push hl
ld hl, wEnemyMonMaxHP
@@ -785,14 +785,14 @@ CheckNumAttacksLeft:
jr nz, .checkEnemy
; player has 0 attacks left
ld hl, wPlayerBattleStatus1
- res UsingTrappingMove, [hl] ; player not using multi-turn attack like wrap any more
+ res USING_TRAPPING_MOVE, [hl] ; player not using multi-turn attack like wrap any more
.checkEnemy
ld a, [wEnemyNumAttacksLeft]
and a
ret nz
; enemy has 0 attacks left
ld hl, wEnemyBattleStatus1
- res UsingTrappingMove, [hl] ; enemy not using multi-turn attack like wrap any more
+ res USING_TRAPPING_MOVE, [hl] ; enemy not using multi-turn attack like wrap any more
ret
HandleEnemyMonFainted:
@@ -842,7 +842,7 @@ FaintEnemyPokemon:
ld [hl], a
.wild
ld hl, wPlayerBattleStatus1
- res AttackingMultipleTimes, [hl]
+ res ATTACKING_MULTIPLE_TIMES, [hl]
; 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
@@ -881,7 +881,7 @@ FaintEnemyPokemon:
ld a, SFX_FAINT_FALL
call PlaySoundWaitForCurrent
.sfxwait
- ld a, [wChannelSoundIDs + CH4]
+ ld a, [wChannelSoundIDs + Ch5]
cp SFX_FAINT_FALL
jr z, .sfxwait
ld a, SFX_FAINT_THUD
@@ -965,7 +965,7 @@ EndLowHealthAlarm:
; the low health alarm and prevents it from reactivating until the next battle.
xor a
ld [wLowHealthAlarm], a ; turn off low health alarm
- ld [wChannelSoundIDs + CH4], a
+ ld [wChannelSoundIDs + Ch5], a
inc a
ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating
ret
@@ -1004,7 +1004,7 @@ ReplaceFaintedEnemyMon:
; link battle
call LinkBattleExchangeData
ld a, [wSerialExchangeNybbleReceiveData]
- cp $f
+ cp LINKBATTLE_RUN
ret z
call LoadScreenTilesFromBuffer1
.notLinkBattle
@@ -1257,7 +1257,7 @@ ChooseNextMon:
ret
; called when player is out of usable mons.
-; prints approriate lose message, sets carry flag if player blacked out (special case for initial rival fight)
+; prints appropriate lose message, sets carry flag if player blacked out (special case for initial rival fight)
HandlePlayerBlackOut:
ld a, [wLinkState]
cp LINK_STATE_BATTLING
@@ -1402,138 +1402,138 @@ SlideTrainerPicOffScreen:
; send out a trainer's mon
EnemySendOut:
- ld hl,wPartyGainExpFlags
+ ld hl, wPartyGainExpFlags
xor a
- ld [hl],a
- ld a,[wPlayerMonNumber]
- ld c,a
- ld b,FLAG_SET
+ ld [hl], a
+ ld a, [wPlayerMonNumber]
+ ld c, a
+ ld b, FLAG_SET
push bc
predef FlagActionPredef
- ld hl,wPartyFoughtCurrentEnemyFlags
+ ld hl, wPartyFoughtCurrentEnemyFlags
xor a
- ld [hl],a
+ ld [hl], a
pop bc
predef FlagActionPredef
; don't change wPartyGainExpFlags or wPartyFoughtCurrentEnemyFlags
EnemySendOutFirstMon:
xor a
- ld hl,wEnemyStatsToDouble ; clear enemy statuses
- ld [hli],a
- ld [hli],a
- ld [hli],a
- ld [hli],a
- ld [hl],a
- ld [wEnemyDisabledMove],a
- ld [wEnemyDisabledMoveNumber],a
- ld [wEnemyMonMinimized],a
- ld hl,wPlayerUsedMove
- ld [hli],a
- ld [hl],a
+ ld hl, wEnemyStatsToDouble ; clear enemy statuses
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld [wEnemyDisabledMove], a
+ ld [wEnemyDisabledMoveNumber], a
+ ld [wEnemyMonMinimized], a
+ ld hl, wPlayerUsedMove
+ ld [hli], a
+ ld [hl], a
dec a
- ld [wAICount],a
- ld hl,wPlayerBattleStatus1
- res 5,[hl]
+ ld [wAICount], a
+ ld hl, wPlayerBattleStatus1
+ res 5, [hl]
coord hl, 18, 0
- ld a,8
+ ld a, 8
call SlideTrainerPicOffScreen
call PrintEmptyString
call SaveScreenTilesToBuffer1
- ld a,[wLinkState]
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
- jr nz,.next
- ld a,[wSerialExchangeNybbleReceiveData]
+ jr nz, .next
+ ld a, [wSerialExchangeNybbleReceiveData]
sub 4
- ld [wWhichPokemon],a
+ ld [wWhichPokemon], a
jr .next3
.next
- ld b,$FF
+ ld b, $FF
.next2
inc b
- ld a,[wEnemyMonPartyPos]
+ ld a, [wEnemyMonPartyPos]
cp b
- jr z,.next2
- ld hl,wEnemyMon1
- ld a,b
- ld [wWhichPokemon],a
+ jr z, .next2
+ ld hl, wEnemyMon1
+ ld a, b
+ ld [wWhichPokemon], a
push bc
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
pop bc
inc hl
- ld a,[hli]
- ld c,a
- ld a,[hl]
+ ld a, [hli]
+ ld c, a
+ ld a, [hl]
or c
- jr z,.next2
+ jr z, .next2
.next3
- ld a,[wWhichPokemon]
- ld hl,wEnemyMon1Level
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld a, [wWhichPokemon]
+ ld hl, wEnemyMon1Level
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
- ld a,[hl]
- ld [wCurEnemyLVL],a
- ld a,[wWhichPokemon]
+ ld a, [hl]
+ ld [wCurEnemyLVL], a
+ ld a, [wWhichPokemon]
inc a
- ld hl,wEnemyPartyCount
- ld c,a
- ld b,0
- add hl,bc
- ld a,[hl]
- ld [wEnemyMonSpecies2],a
- ld [wcf91],a
+ ld hl, wEnemyPartyCount
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ ld [wEnemyMonSpecies2], a
+ ld [wcf91], a
call LoadEnemyMonData
- ld hl,wEnemyMonHP
- ld a,[hli]
- ld [wLastSwitchInEnemyMonHP],a
- ld a,[hl]
- ld [wLastSwitchInEnemyMonHP + 1],a
- ld a,1
- ld [wCurrentMenuItem],a
- ld a,[wFirstMonsNotOutYet]
+ ld hl, wEnemyMonHP
+ ld a, [hli]
+ ld [wLastSwitchInEnemyMonHP], a
+ ld a, [hl]
+ ld [wLastSwitchInEnemyMonHP + 1], a
+ ld a, 1
+ ld [wCurrentMenuItem], a
+ ld a, [wFirstMonsNotOutYet]
dec a
- jr z,.next4
- ld a,[wPartyCount]
+ jr z, .next4
+ ld a, [wPartyCount]
dec a
- jr z,.next4
- ld a,[wLinkState]
+ jr z, .next4
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
- jr z,.next4
- ld a,[wOptions]
- bit 6,a
- jr nz,.next4
+ jr z, .next4
+ ld a, [wOptions]
+ bit 6, a
+ jr nz, .next4
ld hl, TrainerAboutToUseText
call PrintText
coord hl, 0, 7
lb bc, 8, 1
- ld a,TWO_OPTION_MENU
- ld [wTextBoxID],a
+ ld a, TWO_OPTION_MENU
+ ld [wTextBoxID], a
call DisplayTextBoxID
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
and a
- jr nz,.next4
- ld a,BATTLE_PARTY_MENU
- ld [wPartyMenuTypeOrMessageID],a
+ jr nz, .next4
+ ld a, BATTLE_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
call DisplayPartyMenu
.next9
- ld a,1
- ld [wCurrentMenuItem],a
- jr c,.next7
- ld hl,wPlayerMonNumber
- ld a,[wWhichPokemon]
+ ld a, 1
+ ld [wCurrentMenuItem], a
+ jr c, .next7
+ ld hl, wPlayerMonNumber
+ ld a, [wWhichPokemon]
cp [hl]
- jr nz,.next6
- ld hl,AlreadyOutText
+ jr nz, .next6
+ ld hl, AlreadyOutText
call PrintText
.next8
call GoBackToPartyMenu
jr .next9
.next6
call HasMonFainted
- jr z,.next8
+ jr z, .next8
xor a
- ld [wCurrentMenuItem],a
+ ld [wCurrentMenuItem], a
.next7
call GBPalWhiteOut
call LoadHudTilePatterns
@@ -1546,27 +1546,27 @@ EnemySendOutFirstMon:
ld b, SET_PAL_BATTLE
call RunPaletteCommand
call GBPalNormal
- ld hl,TrainerSentOutText
+ ld hl, TrainerSentOutText
call PrintText
- ld a,[wEnemyMonSpecies2]
- ld [wcf91],a
- ld [wd0b5],a
+ ld a, [wEnemyMonSpecies2]
+ ld [wcf91], a
+ ld [wd0b5], a
call GetMonHeader
- ld de,vFrontPic
+ ld de, vFrontPic
call LoadMonFrontSprite
- ld a,-$31
- ld [hStartTileID],a
+ ld a, -$31
+ ld [hStartTileID], a
coord hl, 15, 6
predef AnimateSendingOutMon
- ld a,[wEnemyMonSpecies2]
+ ld a, [wEnemyMonSpecies2]
call PlayCry
call DrawEnemyHUDAndHPBar
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
and a
ret nz
xor a
- ld [wPartyGainExpFlags],a
- ld [wPartyFoughtCurrentEnemyFlags],a
+ ld [wPartyGainExpFlags], a
+ ld [wPartyFoughtCurrentEnemyFlags], a
call SaveScreenTilesToBuffer1
jp SwitchPlayerMon
@@ -1720,12 +1720,12 @@ TryRunningFromBattle:
call SaveScreenTilesToBuffer1
xor a
ld [wActionResultOrTookBattleTurn], a
- ld a, $f
+ ld a, LINKBATTLE_RUN
ld [wPlayerMoveListIndex], a
call LinkBattleExchangeData
call LoadScreenTilesFromBuffer1
ld a, [wSerialExchangeNybbleReceiveData]
- cp $f
+ cp LINKBATTLE_RUN
ld a, $2
jr z, .playSound
dec a
@@ -1883,7 +1883,7 @@ SendOutMon:
ld b, SET_PAL_BATTLE
call RunPaletteCommand
ld hl, wEnemyBattleStatus1
- res UsingTrappingMove, [hl]
+ res USING_TRAPPING_MOVE, [hl]
callab IsThisPartymonStarterPikachu
jr c, .starterPikachu
ld a, $1
@@ -2029,7 +2029,7 @@ DrawPlayerHUDAndHPBar:
ld [hl], $0
ret z
xor a
- ld [wChannelSoundIDs + CH4], a
+ ld [wChannelSoundIDs + Ch5], a
ret
.setLowHealthAlarm
ld hl, wLowHealthAlarm
@@ -2215,7 +2215,7 @@ DisplayBattleMenu:
ld [hl], "▶"
ld c, 20
call DelayFrames
- ld [hl], $ec
+ ld [hl], "▷"
ld a, $2 ; select the "ITEM" menu
jp .upperLeftMenuItemWasNotSelected
.oldManName
@@ -2449,13 +2449,13 @@ UseBagItem:
jp z, BagWasSelected ; if not, go back to the bag menu
ld a, [wPlayerBattleStatus1]
- bit UsingTrappingMove, a ; is the player using a multi-turn move like wrap?
+ bit USING_TRAPPING_MOVE, a ; is the player using a multi-turn move like wrap?
jr z, .checkIfMonCaptured
ld hl, wPlayerNumAttacksLeft
dec [hl]
jr nz, .checkIfMonCaptured
ld hl, wPlayerBattleStatus1
- res UsingTrappingMove, [hl] ; not using multi-turn move any more
+ res USING_TRAPPING_MOVE, [hl] ; not using multi-turn move any more
.checkIfMonCaptured
ld a, [wCapturedMonSpecies]
@@ -2564,7 +2564,7 @@ PartyMenuOrRockOrRun:
ld a, 1
ld [H_WHOSETURN], a
ld a, [wEnemyBattleStatus2]
- bit HasSubstituteUp, a ; does the enemy mon have a substitute?
+ bit HAS_SUBSTITUTE_UP, a ; does the enemy mon have a substitute?
ld hl, AnimationSubstitute
jr nz, .doEnemyMonAnimation
; enemy mon doesn't have substitute
@@ -2786,7 +2786,7 @@ SelectMenuItem:
dec a
ld bc, SCREEN_WIDTH
call AddNTimes
- ld [hl], $ec
+ ld [hl], "▷"
.select
ld hl, hFlags_0xFFFA
set 1, [hl]
@@ -2994,7 +2994,7 @@ NoMovesLeftText:
SwapMovesInMenu:
ld a, [wPlayerBattleStatus3]
- bit Transformed, a
+ bit TRANSFORMED, a
jp nz, MoveSelectionMenu
ld a, [wMenuItemToSwap]
and a
@@ -3156,35 +3156,35 @@ SelectEnemyMove:
call LinkBattleExchangeData
call LoadScreenTilesFromBuffer1
ld a, [wSerialExchangeNybbleReceiveData]
- cp $e
+ cp LINKBATTLE_STRUGGLE
jp z, .linkedOpponentUsedStruggle
- cp $d
+ cp LINKBATTLE_NO_ACTION
jr z, .unableToSelectMove
- cp $4
+ cp 4
ret nc
ld [wEnemyMoveListIndex], a
ld c, a
ld hl, wEnemyMonMoves
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
jr .done
.noLinkBattle
ld a, [wEnemyBattleStatus2]
- and (1 << NeedsToRecharge) | (1 << UsingRage) ; need to recharge or using rage
+ and (1 << NEEDS_TO_RECHARGE) | (1 << USING_RAGE) ; need to recharge or using rage
ret nz
ld hl, wEnemyBattleStatus1
ld a, [hl]
- and (1 << ChargingUp) | (1 << ThrashingAbout) ; using a charging move or thrash/petal dance
+ and (1 << CHARGING_UP) | (1 << THRASHING_ABOUT) ; using a charging move or thrash/petal dance
ret nz
ld a, [wEnemyMonStatus]
and SLP | 1 << FRZ ; sleeping or frozen
ret nz
ld a, [wEnemyBattleStatus1]
- and (1 << UsingTrappingMove) | (1 << StoringEnergy) ; using a trapping move like wrap or bide
+ and (1 << USING_TRAPPING_MOVE) | (1 << STORING_ENERGY) ; using a trapping move like wrap or bide
ret nz
ld a, [wPlayerBattleStatus1]
- bit UsingTrappingMove, a ; caught in player's trapping move (e.g. wrap)
+ bit USING_TRAPPING_MOVE, a ; caught in player's trapping move (e.g. wrap)
jr z, .canSelectMove
.unableToSelectMove
ld a, $ff
@@ -3244,7 +3244,7 @@ LinkBattleExchangeData:
ld a, $ff
ld [wSerialExchangeNybbleReceiveData], a
ld a, [wPlayerMoveListIndex]
- cp $f ; is the player running from battle?
+ cp LINKBATTLE_RUN ; is the player running from battle?
jr z, .doExchange
ld a, [wActionResultOrTookBattleTurn]
and a ; is the player switching in another mon?
@@ -3252,10 +3252,10 @@ LinkBattleExchangeData:
; the player used a move
ld a, [wPlayerSelectedMove]
cp STRUGGLE
- ld b, $e
+ ld b, LINKBATTLE_STRUGGLE
jr z, .next
- dec b
- inc a
+ dec b ; LINKBATTLE_NO_ACTION
+ inc a ; does move equal -1 (i.e. no action)?
jr z, .next
ld a, [wPlayerMoveListIndex]
jr .doExchange
@@ -3311,7 +3311,7 @@ ExecutePlayerMove:
.playerHasNoSpecialCondition
call GetCurrentMove
ld hl, wPlayerBattleStatus1
- bit ChargingUp, [hl] ; charging up for attack
+ bit CHARGING_UP, [hl] ; charging up for attack
jr nz, PlayerCanExecuteChargingMove
call CheckForDisobedience
jp z, ExecutePlayerMoveDone
@@ -3326,160 +3326,160 @@ CheckIfPlayerNeedsToChargeUp:
; in-battle stuff
PlayerCanExecuteChargingMove:
- ld hl,wPlayerBattleStatus1
- res ChargingUp,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack
+ ld hl, wPlayerBattleStatus1
+ res CHARGING_UP, [hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack
; being fully paralyzed or hurting oneself in confusion removes charging up status
; resulting in the Pokemon being invulnerable for the whole battle
- res Invulnerable,[hl]
+ res INVULNERABLE, [hl]
PlayerCanExecuteMove:
call PrintMonName1Text
- ld hl,DecrementPP
- ld de,wPlayerSelectedMove ; pointer to the move just used
- ld b,BANK(DecrementPP)
+ ld hl, DecrementPP
+ ld de, wPlayerSelectedMove ; pointer to the move just used
+ ld b, BANK(DecrementPP)
call Bankswitch
- ld a,[wPlayerMoveEffect] ; effect of the move just used
- ld hl,ResidualEffects1
- ld de,1
+ ld a, [wPlayerMoveEffect] ; effect of the move just used
+ ld hl, ResidualEffects1
+ ld de, 1
call IsInArray
- jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests
+ jp c, JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests
; unless executed as part of their exclusive effect functions
- ld a,[wPlayerMoveEffect]
- ld hl,SpecialEffectsCont
- ld de,1
+ ld a, [wPlayerMoveEffect]
+ 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:
- ld a,[wPlayerMoveEffect]
- ld hl,SetDamageEffects
- ld de,1
+ ld a, [wPlayerMoveEffect]
+ ld hl, SetDamageEffects
+ ld de, 1
call IsInArray
- jp c,.moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation
+ jp c, .moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation
call CriticalHitTest
call HandleCounterMove
- jr z,handleIfPlayerMoveMissed
+ jr z, handleIfPlayerMoveMissed
call GetDamageVarsForPlayerAttack
call CalculateDamage
- jp z,playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
+ jp z, playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
; for these moves, accuracy tests will only occur if they are called as part of the effect itself
call AdjustDamageForMoveType
call RandomizeDamage
.moveHitTest
call MoveHitTest
handleIfPlayerMoveMissed:
- ld a,[wMoveMissed]
+ ld a, [wMoveMissed]
and a
- jr z,getPlayerAnimationType
- ld a,[wPlayerMoveEffect]
- sub a,EXPLODE_EFFECT
- jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
+ jr z, getPlayerAnimationType
+ ld a, [wPlayerMoveEffect]
+ sub EXPLODE_EFFECT
+ jr z, playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
jr playerCheckIfFlyOrChargeEffect
getPlayerAnimationType:
- ld a,[wPlayerMoveEffect]
+ ld a, [wPlayerMoveEffect]
and a
- ld a,4 ; move has no effect other than dealing damage
- jr z,playPlayerMoveAnimation
- ld a,5 ; move has effect
+ ld a, 4 ; move has no effect other than dealing damage
+ jr z, playPlayerMoveAnimation
+ ld a, 5 ; move has effect
playPlayerMoveAnimation:
push af
- ld a,[wPlayerBattleStatus2]
- bit HasSubstituteUp,a
- ld hl,HideSubstituteShowMonAnim
- ld b,BANK(HideSubstituteShowMonAnim)
- call nz,Bankswitch
+ ld a, [wPlayerBattleStatus2]
+ bit HAS_SUBSTITUTE_UP, a
+ ld hl, HideSubstituteShowMonAnim
+ ld b, BANK(HideSubstituteShowMonAnim)
+ call nz, Bankswitch
pop af
- ld [wAnimationType],a
- ld a,[wPlayerMoveNum]
+ ld [wAnimationType], a
+ ld a, [wPlayerMoveNum]
call PlayMoveAnimation
call HandleExplodingAnimation
call DrawPlayerHUDAndHPBar
- ld a,[wPlayerBattleStatus2]
- bit HasSubstituteUp,a
- ld hl,ReshowSubstituteAnim
- ld b,BANK(ReshowSubstituteAnim)
- call nz,Bankswitch
+ ld a, [wPlayerBattleStatus2]
+ bit HAS_SUBSTITUTE_UP, a
+ ld hl, ReshowSubstituteAnim
+ ld b, BANK(ReshowSubstituteAnim)
+ call nz, Bankswitch
jr MirrorMoveCheck
playerCheckIfFlyOrChargeEffect:
- ld c,30
+ ld c, 30
call DelayFrames
- ld a,[wPlayerMoveEffect]
- cp a,FLY_EFFECT
- jr z,.playAnim
- cp a,CHARGE_EFFECT
- jr z,.playAnim
+ ld a, [wPlayerMoveEffect]
+ cp FLY_EFFECT
+ jr z, .playAnim
+ cp CHARGE_EFFECT
+ jr z, .playAnim
jr MirrorMoveCheck
.playAnim
xor a
- ld [wAnimationType],a
- ld a,STATUS_AFFECTED_ANIM
+ ld [wAnimationType], a
+ ld a, STATUS_AFFECTED_ANIM
call PlayMoveAnimation
MirrorMoveCheck:
- ld a,[wPlayerMoveEffect]
- cp a,MIRROR_MOVE_EFFECT
- jr nz,.metronomeCheck
+ ld a, [wPlayerMoveEffect]
+ cp MIRROR_MOVE_EFFECT
+ jr nz, .metronomeCheck
call MirrorMoveCopyMove
- jp z,ExecutePlayerMoveDone
+ jp z, ExecutePlayerMoveDone
xor a
- ld [wMonIsDisobedient],a
+ ld [wMonIsDisobedient], a
jp CheckIfPlayerNeedsToChargeUp ; if Mirror Move was successful go back to damage calculation for copied move
.metronomeCheck
- cp a,METRONOME_EFFECT
- jr nz,.next
+ cp METRONOME_EFFECT
+ jr nz, .next
call MetronomePickMove
jp CheckIfPlayerNeedsToChargeUp ; Go back to damage calculation for the move picked by Metronome
.next
- ld a,[wPlayerMoveEffect]
- ld hl,ResidualEffects2
- ld de,1
+ ld a, [wPlayerMoveEffect]
+ ld hl, ResidualEffects2
+ ld de, 1
call IsInArray
- jp c,JumpMoveEffect ; done here after executing effects of ResidualEffects2
- ld a,[wMoveMissed]
+ jp c, JumpMoveEffect ; done here after executing effects of ResidualEffects2
+ ld a, [wMoveMissed]
and a
- jr z,.moveDidNotMiss
+ jr z, .moveDidNotMiss
call PrintMoveFailureText
- ld a,[wPlayerMoveEffect]
- cp a,EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated
- jr z,.notDone
+ ld a, [wPlayerMoveEffect]
+ cp EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated
+ jr z, .notDone
jp ExecutePlayerMoveDone ; otherwise, we're done if the move missed
.moveDidNotMiss
call ApplyAttackToEnemyPokemon
call PrintCriticalOHKOText
callab DisplayEffectiveness
- ld a,1
- ld [wMoveDidntMiss],a
+ ld a, 1
+ ld [wMoveDidntMiss], a
.notDone
- ld a,[wPlayerMoveEffect]
- ld hl,AlwaysHappenSideEffects
- ld de,1
+ ld a, [wPlayerMoveEffect]
+ ld hl, AlwaysHappenSideEffects
+ ld de, 1
call IsInArray
- call c,JumpMoveEffect ; not done after executing effects of AlwaysHappenSideEffects
- ld hl,wEnemyMonHP
- ld a,[hli]
- ld b,[hl]
+ call c, JumpMoveEffect ; not done after executing effects of AlwaysHappenSideEffects
+ ld hl, wEnemyMonHP
+ ld a, [hli]
+ ld b, [hl]
or b
ret z ; don't do anything else if the enemy fainted
call HandleBuildingRage
- ld hl,wPlayerBattleStatus1
- bit AttackingMultipleTimes,[hl]
- jr z,.executeOtherEffects
- ld a,[wPlayerNumAttacksLeft]
+ ld hl, wPlayerBattleStatus1
+ bit ATTACKING_MULTIPLE_TIMES, [hl]
+ jr z, .executeOtherEffects
+ 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.
+ ld [wPlayerNumAttacksLeft], a
+ 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
+ res ATTACKING_MULTIPLE_TIMES, [hl] ; clear attacking multiple times status when all attacks are over
+ ld hl, MultiHitText
call PrintText
xor a
- ld [wPlayerNumHits],a
+ ld [wPlayerNumHits], a
.executeOtherEffects
- ld a,[wPlayerMoveEffect]
+ ld a, [wPlayerMoveEffect]
and a
- jp z,ExecutePlayerMoveDone
- ld hl,SpecialEffects
- ld de,1
+ jp z, ExecutePlayerMoveDone
+ ld hl, SpecialEffects
+ ld de, 1
call IsInArray
- call nc,JumpMoveEffect ; move effects not included in SpecialEffects or in either of the ResidualEffect arrays,
+ call nc, JumpMoveEffect ; move effects not included in SpecialEffects or in either of the ResidualEffect arrays,
; which are the effects not covered yet. Rage effect will be executed for a second time (though it's irrelevant).
; Includes side effects that only need to be called if the target didn't faint.
; Responsible for executing Twineedle's second side effect (poison).
@@ -3491,26 +3491,26 @@ MultiHitText:
ExecutePlayerMoveDone:
xor a
- ld [wActionResultOrTookBattleTurn],a
- ld b,1
+ ld [wActionResultOrTookBattleTurn], a
+ ld b, 1
ret
PrintGhostText:
; print the ghost battle messages
call IsGhostBattle
ret nz
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
- jr nz,.Ghost
- ld a,[wBattleMonStatus] ; player’s turn
- and a,SLP | (1 << FRZ)
+ jr nz, .Ghost
+ ld a, [wBattleMonStatus] ; player’s turn
+ and SLP | (1 << FRZ)
ret nz
- ld hl,ScaredText
+ ld hl, ScaredText
call PrintText
xor a
ret
.Ghost ; ghost’s turn
- ld hl,GetOutText
+ ld hl, GetOutText
call PrintText
xor a
ret
@@ -3524,266 +3524,266 @@ GetOutText:
db "@"
IsGhostBattle:
- ld a,[wIsInBattle]
+ ld a, [wIsInBattle]
dec a
ret nz
- ld a,[wCurMap]
- cp a,POKEMONTOWER_1
- jr c,.next
- cp a,LAVENDER_HOUSE_1
- jr nc,.next
- ld b,SILPH_SCOPE
+ ld a, [wCurMap]
+ cp POKEMON_TOWER_1F
+ jr c, .next
+ cp MR_FUJIS_HOUSE
+ jr nc, .next
+ ld b, SILPH_SCOPE
call IsItemInBag
ret z
.next
- ld a,1
+ ld a, 1
and a
ret
; checks for various status conditions affecting the player mon
; stores whether the mon cannot use a move this turn in Z flag
CheckPlayerStatusConditions:
- ld hl,wBattleMonStatus
- ld a,[hl]
- and a,SLP ; sleep mask
- jr z,.FrozenCheck
+ ld hl, wBattleMonStatus
+ ld a, [hl]
+ and SLP ; sleep mask
+ jr z, .FrozenCheck
; sleeping
dec a
- ld [wBattleMonStatus],a ; decrement number of turns left
+ ld [wBattleMonStatus], a ; decrement number of turns left
and a
- jr z,.WakeUp ; if the number of turns hit 0, wake up
+ jr z, .WakeUp ; if the number of turns hit 0, wake up
; fast asleep
xor a
- ld [wAnimationType],a
- ld a,SLP_ANIM - 1
+ ld [wAnimationType], a
+ ld a, SLP_ANIM - 1
call PlayMoveAnimation
- ld hl,FastAsleepText
+ ld hl, FastAsleepText
call PrintText
jr .sleepDone
.WakeUp
- ld hl,WokeUpText
+ ld hl, WokeUpText
call PrintText
.sleepDone
xor a
- ld [wPlayerUsedMove],a
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld [wPlayerUsedMove], a
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.FrozenCheck
- bit FRZ,[hl] ; frozen?
- jr z,.HeldInPlaceCheck
- ld hl,IsFrozenText
+ bit FRZ, [hl] ; frozen?
+ jr z, .HeldInPlaceCheck
+ ld hl, IsFrozenText
call PrintText
xor a
- ld [wPlayerUsedMove],a
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld [wPlayerUsedMove], a
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.HeldInPlaceCheck
- ld a,[wEnemyBattleStatus1]
- bit UsingTrappingMove,a ; is enemy using a mult-turn move like wrap?
- jp z,.FlinchedCheck
- ld hl,CantMoveText
+ ld a, [wEnemyBattleStatus1]
+ bit USING_TRAPPING_MOVE, a ; is enemy using a mult-turn move like wrap?
+ jp z, .FlinchedCheck
+ ld hl, CantMoveText
call PrintText
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.FlinchedCheck
- ld hl,wPlayerBattleStatus1
- bit Flinched,[hl]
- jp z,.HyperBeamCheck
- res Flinched,[hl] ; reset player's flinch status
- ld hl,FlinchedText
+ ld hl, wPlayerBattleStatus1
+ bit FLINCHED, [hl]
+ jp z, .HyperBeamCheck
+ res FLINCHED, [hl] ; reset player's flinch status
+ ld hl, FlinchedText
call PrintText
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.HyperBeamCheck
- ld hl,wPlayerBattleStatus2
- bit NeedsToRecharge,[hl]
- jr z,.AnyMoveDisabledCheck
- res NeedsToRecharge,[hl] ; reset player's recharge status
- ld hl,MustRechargeText
+ ld hl, wPlayerBattleStatus2
+ bit NEEDS_TO_RECHARGE, [hl]
+ jr z, .AnyMoveDisabledCheck
+ res NEEDS_TO_RECHARGE, [hl] ; reset player's recharge status
+ ld hl, MustRechargeText
call PrintText
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.AnyMoveDisabledCheck
- ld hl,wPlayerDisabledMove
- ld a,[hl]
+ ld hl, wPlayerDisabledMove
+ ld a, [hl]
and a
- jr z,.ConfusedCheck
+ jr z, .ConfusedCheck
dec a
- ld [hl],a
+ ld [hl], a
and $f ; did Disable counter hit 0?
- jr nz,.ConfusedCheck
- ld [hl],a
- ld [wPlayerDisabledMoveNumber],a
- ld hl,DisabledNoMoreText
+ jr nz, .ConfusedCheck
+ ld [hl], a
+ ld [wPlayerDisabledMoveNumber], a
+ ld hl, DisabledNoMoreText
call PrintText
.ConfusedCheck
- ld a,[wPlayerBattleStatus1]
+ ld a, [wPlayerBattleStatus1]
add a ; is player confused?
- jr nc,.TriedToUseDisabledMoveCheck
- ld hl,wPlayerConfusedCounter
+ jr nc, .TriedToUseDisabledMoveCheck
+ ld hl, wPlayerConfusedCounter
dec [hl]
- jr nz,.IsConfused
- ld hl,wPlayerBattleStatus1
- res Confused,[hl] ; if confused counter hit 0, reset confusion status
- ld hl,ConfusedNoMoreText
+ jr nz, .IsConfused
+ ld hl, wPlayerBattleStatus1
+ res CONFUSED, [hl] ; if confused counter hit 0, reset confusion status
+ ld hl, ConfusedNoMoreText
call PrintText
jr .TriedToUseDisabledMoveCheck
.IsConfused
- ld hl,IsConfusedText
+ ld hl, IsConfusedText
call PrintText
xor a
- ld [wAnimationType],a
- ld a,CONF_ANIM - 1
+ ld [wAnimationType], a
+ ld a, CONF_ANIM - 1
call PlayMoveAnimation
call BattleRandom
- cp a,$80 ; 50% chance to hurt itself
- jr c,.TriedToUseDisabledMoveCheck
- ld hl,wPlayerBattleStatus1
- ld a,[hl]
- and a, 1 << Confused ; if mon hurts itself, clear every other status from wPlayerBattleStatus1
- ld [hl],a
+ cp $80 ; 50% chance to hurt itself
+ jr c, .TriedToUseDisabledMoveCheck
+ ld hl, wPlayerBattleStatus1
+ ld a, [hl]
+ and 1 << CONFUSED ; if mon hurts itself, clear every other status from wPlayerBattleStatus1
+ ld [hl], a
call HandleSelfConfusionDamage
jr .MonHurtItselfOrFullyParalysed
.TriedToUseDisabledMoveCheck
; prevents a disabled move that was selected before being disabled from being used
- ld a,[wPlayerDisabledMoveNumber]
+ ld a, [wPlayerDisabledMoveNumber]
and a
- jr z,.ParalysisCheck
- ld hl,wPlayerSelectedMove
+ jr z, .ParalysisCheck
+ ld hl, wPlayerSelectedMove
cp [hl]
- jr nz,.ParalysisCheck
+ jr nz, .ParalysisCheck
call PrintMoveIsDisabledText
- ld hl,ExecutePlayerMoveDone ; if a disabled move was somehow selected, player can't move this turn
+ ld hl, ExecutePlayerMoveDone ; if a disabled move was somehow selected, player can't move this turn
jp .returnToHL
.ParalysisCheck
- ld hl,wBattleMonStatus
- bit PAR,[hl]
- jr z,.BideCheck
+ ld hl, wBattleMonStatus
+ bit PAR, [hl]
+ jr z, .BideCheck
call BattleRandom
- cp a,$3F ; 25% to be fully paralyzed
- jr nc,.BideCheck
- ld hl,FullyParalyzedText
+ cp $3F ; 25% to be fully paralyzed
+ jr nc, .BideCheck
+ ld hl, FullyParalyzedText
call PrintText
.MonHurtItselfOrFullyParalysed
- ld hl,wPlayerBattleStatus1
- ld a,[hl]
+ ld hl, wPlayerBattleStatus1
+ 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))
- ld [hl],a
- ld a,[wPlayerMoveEffect]
- cp a,FLY_EFFECT
- jr z,.FlyOrChargeEffect
- cp a,CHARGE_EFFECT
- jr z,.FlyOrChargeEffect
+ and $ff ^ ((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE))
+ ld [hl], a
+ ld a, [wPlayerMoveEffect]
+ cp FLY_EFFECT
+ jr z, .FlyOrChargeEffect
+ cp CHARGE_EFFECT
+ jr z, .FlyOrChargeEffect
jr .NotFlyOrChargeEffect
.FlyOrChargeEffect
xor a
- ld [wAnimationType],a
- ld a,STATUS_AFFECTED_ANIM
+ ld [wAnimationType], a
+ ld a, STATUS_AFFECTED_ANIM
call PlayMoveAnimation
.NotFlyOrChargeEffect
- ld hl,ExecutePlayerMoveDone
+ ld hl, ExecutePlayerMoveDone
jp .returnToHL ; if using a two-turn move, we need to recharge the first turn
.BideCheck
- ld hl,wPlayerBattleStatus1
- bit StoringEnergy,[hl] ; is mon using bide?
- jr z,.ThrashingAboutCheck
- xor a
- ld [wPlayerMoveNum],a
- ld hl,wDamage
- ld a,[hli]
- ld b,a
- ld c,[hl]
- ld hl,wPlayerBideAccumulatedDamage + 1
- ld a,[hl]
- add c ; acumulate damage taken
- ld [hld],a
- ld a,[hl]
+ ld hl, wPlayerBattleStatus1
+ bit STORING_ENERGY, [hl] ; is mon using bide?
+ jr z, .ThrashingAboutCheck
+ xor a
+ ld [wPlayerMoveNum], a
+ ld hl, wDamage
+ ld a, [hli]
+ ld b, a
+ ld c, [hl]
+ ld hl, wPlayerBideAccumulatedDamage + 1
+ ld a, [hl]
+ add c ; accumulate damage taken
+ ld [hld], a
+ ld a, [hl]
adc b
- ld [hl],a
- ld hl,wPlayerNumAttacksLeft
+ ld [hl], a
+ ld hl, wPlayerNumAttacksLeft
dec [hl] ; did Bide counter hit 0?
- jr z,.UnleashEnergy
- ld hl,ExecutePlayerMoveDone
+ jr z, .UnleashEnergy
+ ld hl, ExecutePlayerMoveDone
jp .returnToHL ; unless mon unleashes energy, can't move this turn
.UnleashEnergy
- ld hl,wPlayerBattleStatus1
- res StoringEnergy,[hl] ; not using bide any more
- ld hl,UnleashedEnergyText
+ ld hl, wPlayerBattleStatus1
+ res STORING_ENERGY, [hl] ; not using bide any more
+ ld hl, UnleashedEnergyText
call PrintText
- ld a,1
- ld [wPlayerMovePower],a
- ld hl,wPlayerBideAccumulatedDamage + 1
- ld a,[hld]
+ ld a, 1
+ ld [wPlayerMovePower], a
+ ld hl, wPlayerBideAccumulatedDamage + 1
+ ld a, [hld]
add a
- ld b,a
- ld [wDamage + 1],a
- ld a,[hl]
+ ld b, a
+ ld [wDamage + 1], a
+ ld a, [hl]
rl a ; double the damage
- ld [wDamage],a
+ ld [wDamage], a
or b
- jr nz,.next
- ld a,1
- ld [wMoveMissed],a
+ jr nz, .next
+ ld a, 1
+ ld [wMoveMissed], a
.next
xor a
- ld [hli],a
- ld [hl],a
- ld a,BIDE
- ld [wPlayerMoveNum],a
- ld hl,handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
+ ld [hli], a
+ ld [hl], a
+ ld a, BIDE
+ ld [wPlayerMoveNum], a
+ ld hl, handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .returnToHL
.ThrashingAboutCheck
- bit ThrashingAbout,[hl] ; is mon using thrash or petal dance?
- jr z,.MultiturnMoveCheck
- ld a,THRASH
- ld [wPlayerMoveNum],a
- ld hl,ThrashingAboutText
+ bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance?
+ jr z, .MultiturnMoveCheck
+ ld a, THRASH
+ ld [wPlayerMoveNum], a
+ ld hl, ThrashingAboutText
call PrintText
- ld hl,wPlayerNumAttacksLeft
+ ld hl, wPlayerNumAttacksLeft
dec [hl] ; did Thrashing About counter hit 0?
- ld hl,PlayerCalcMoveDamage ; skip DecrementPP
- jp nz,.returnToHL
+ ld hl, PlayerCalcMoveDamage ; skip DecrementPP
+ jp nz, .returnToHL
push hl
- ld hl,wPlayerBattleStatus1
- res ThrashingAbout,[hl] ; no longer thrashing about
- set Confused,[hl] ; confused
+ ld hl, wPlayerBattleStatus1
+ res THRASHING_ABOUT, [hl] ; no longer thrashing about
+ set CONFUSED, [hl] ; confused
call BattleRandom
- and a,3
+ and 3
inc a
inc a ; confused for 2-5 turns
- ld [wPlayerConfusedCounter],a
+ ld [wPlayerConfusedCounter], a
pop hl ; skip DecrementPP
jp .returnToHL
.MultiturnMoveCheck
- bit UsingTrappingMove,[hl] ; is mon using multi-turn move?
- jp z,.RageCheck
- ld hl,AttackContinuesText
+ bit USING_TRAPPING_MOVE, [hl] ; is mon using multi-turn move?
+ jp z, .RageCheck
+ ld hl, AttackContinuesText
call PrintText
- ld a,[wPlayerNumAttacksLeft]
+ 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 [wPlayerNumAttacksLeft], a
+ ld hl, getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
; DecrementPP and MoveHitTest
- jp nz,.returnToHL
+ jp nz, .returnToHL
jp .returnToHL
.RageCheck
ld a, [wPlayerBattleStatus2]
- bit UsingRage, a ; is mon using rage?
+ bit USING_RAGE, a ; is mon using rage?
jp z, .checkPlayerStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE
ld [wd11e], a
@@ -3873,7 +3873,7 @@ PrintMoveIsDisabledText:
ld de, wEnemyBattleStatus1
.removeChargingUp
ld a, [de]
- res ChargingUp, a ; end the pokemon's
+ res CHARGING_UP, a ; end the pokemon's
ld [de], a
ld a, [hl]
ld [wd11e], a
@@ -4409,7 +4409,7 @@ GetDamageVarsForPlayerAttack:
ld b, a
ld c, [hl] ; bc = enemy defense
ld a, [wEnemyBattleStatus3]
- bit HasReflectUp, a ; check for Reflect
+ bit HAS_REFLECT_UP, a ; check for Reflect
jr z, .physicalAttackCritCheck
; if the enemy has used Reflect, double the enemy's defense
sla c
@@ -4439,13 +4439,13 @@ GetDamageVarsForPlayerAttack:
ld b, a
ld c, [hl] ; bc = enemy special
ld a, [wEnemyBattleStatus3]
- bit HasLightScreenUp, a ; check for Light Screen
+ bit HAS_LIGHT_SCREEN_UP, a ; check for Light Screen
jr z, .specialAttackCritCheck
; if the enemy has used Light Screen, double the enemy's special
sla c
rl b
; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if
-; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen
+; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
.specialAttackCritCheck
ld hl, wBattleMonSpecial
ld a, [wCriticalHitOrOHKO]
@@ -4522,7 +4522,7 @@ GetDamageVarsForEnemyAttack:
ld b, a
ld c, [hl] ; bc = player defense
ld a, [wPlayerBattleStatus3]
- bit HasReflectUp, a ; check for Reflect
+ bit HAS_REFLECT_UP, a ; check for Reflect
jr z, .physicalAttackCritCheck
; if the player has used Reflect, double the player's defense
sla c
@@ -4552,13 +4552,13 @@ GetDamageVarsForEnemyAttack:
ld b, a
ld c, [hl]
ld a, [wPlayerBattleStatus3]
- bit HasLightScreenUp, a ; check for Light Screen
+ bit HAS_LIGHT_SCREEN_UP, a ; check for Light Screen
jr z, .specialAttackCritCheck
; if the player has used Light Screen, double the player's special
sla c
rl b
; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if
-; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen
+; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
.specialAttackCritCheck
ld hl, wEnemyMonSpecial
ld a, [wCriticalHitOrOHKO]
@@ -4661,10 +4661,10 @@ GetEnemyMonStat:
CalculateDamage:
; input:
-; b: attack
-; c: opponent defense
-; d: base power
-; e: level
+; b: attack
+; c: opponent defense
+; d: base power
+; e: level
ld a, [H_WHOSETURN] ; whose turn?
and a
@@ -4674,7 +4674,7 @@ CalculateDamage:
.effect
; EXPLODE_EFFECT halves defense.
- cp a, EXPLODE_EFFECT
+ cp EXPLODE_EFFECT
jr nz, .ok
srl c
jr nz, .ok
@@ -4682,13 +4682,13 @@ CalculateDamage:
.ok
; Multi-hit attacks may or may not have 0 bp.
- cp a, TWO_TO_FIVE_ATTACKS_EFFECT
+ cp TWO_TO_FIVE_ATTACKS_EFFECT
jr z, .skipbp
- cp a, $1e
+ cp $1e
jr z, .skipbp
; Calculate OHKO damage based on remaining HP.
- cp a, OHKO_EFFECT
+ cp OHKO_EFFECT
jp z, JumpToOHKOMoveEffect
; Don't calculate damage for moves that don't do any.
@@ -4866,7 +4866,7 @@ CriticalHitTest:
dec hl
ld c, [hl] ; read move id
ld a, [de]
- bit GettingPumped, a ; test for focus energy
+ bit GETTING_PUMPED, a ; test for focus energy
jr nz, .focusEnergyUsed ; bug: using focus energy causes a shift to the right instead of left,
; resulting in 1/4 the usual crit chance
sla b ; (effective (base speed/2)*2)
@@ -4921,297 +4921,297 @@ HandleCounterMove:
; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon.
; This might also lead to desync glitches in link battles.
- ld a,[H_WHOSETURN] ; whose turn
+ ld a, [H_WHOSETURN] ; whose turn
and a
; player's turn
- ld hl,wEnemySelectedMove
- ld de,wEnemyMovePower
- ld a,[wPlayerSelectedMove]
- jr z,.next
+ ld hl, wEnemySelectedMove
+ ld de, wEnemyMovePower
+ ld a, [wPlayerSelectedMove]
+ jr z, .next
; enemy's turn
- ld hl,wPlayerSelectedMove
- ld de,wPlayerMovePower
- ld a,[wEnemySelectedMove]
+ ld hl, wPlayerSelectedMove
+ ld de, wPlayerMovePower
+ ld a, [wEnemySelectedMove]
.next
- cp a,COUNTER
+ cp COUNTER
ret nz ; return if not using Counter
- ld a,$01
- ld [wMoveMissed],a ; initialize the move missed variable to true (it is set to false below if the move hits)
- ld a,[hl]
- cp a,COUNTER
+ ld a, $01
+ ld [wMoveMissed], a ; initialize the move missed variable to true (it is set to false below if the move hits)
+ ld a, [hl]
+ cp COUNTER
ret z ; miss if the opponent's last selected move is Counter.
- ld a,[de]
+ ld a, [de]
and a
ret z ; miss if the opponent's last selected move's Base Power is 0.
; check if the move the target last selected was Normal or Fighting type
inc de
- ld a,[de]
+ ld a, [de]
and a ; normal type
- jr z,.counterableType
- cp a,FIGHTING
- jr z,.counterableType
+ jr z, .counterableType
+ cp FIGHTING
+ jr z, .counterableType
; if the move wasn't Normal or Fighting type, miss
xor a
ret
.counterableType
- ld hl,wDamage
- ld a,[hli]
+ ld hl, wDamage
+ 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.
; wDamage 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]
+ ld a, [hl]
add a
- ldd [hl],a
- ld a,[hl]
+ ldd [hl], a
+ ld a, [hl]
adc a
- ld [hl],a
- jr nc,.noCarry
+ ld [hl], a
+ jr nc, .noCarry
; damage is capped at 0xFFFF
- ld a,$ff
- ld [hli],a
- ld [hl],a
+ ld a, $ff
+ ld [hli], a
+ ld [hl], a
.noCarry
xor a
- ld [wMoveMissed],a
+ ld [wMoveMissed], a
call MoveHitTest ; do the normal move hit test in addition to Counter's special rules
xor a
ret
ApplyAttackToEnemyPokemon:
- ld a,[wPlayerMoveEffect]
- cp a,OHKO_EFFECT
- jr z,ApplyDamageToEnemyPokemon
- cp a,SUPER_FANG_EFFECT
- jr z,.superFangEffect
- cp a,SPECIAL_DAMAGE_EFFECT
- jr z,.specialDamage
- ld a,[wPlayerMovePower]
- and a
- jp z,ApplyAttackToEnemyPokemonDone ; no attack to apply if base power is 0
+ ld a, [wPlayerMoveEffect]
+ cp OHKO_EFFECT
+ jr z, ApplyDamageToEnemyPokemon
+ cp SUPER_FANG_EFFECT
+ jr z, .superFangEffect
+ cp SPECIAL_DAMAGE_EFFECT
+ jr z, .specialDamage
+ ld a, [wPlayerMovePower]
+ and a
+ jp z, ApplyAttackToEnemyPokemonDone ; no attack to apply if base power is 0
jr ApplyDamageToEnemyPokemon
.superFangEffect
; set the damage to half the target's HP
- ld hl,wEnemyMonHP
- ld de,wDamage
- ld a,[hli]
+ ld hl, wEnemyMonHP
+ ld de, wDamage
+ ld a, [hli]
srl a
- ld [de],a
+ ld [de], a
inc de
- ld b,a
- ld a,[hl]
+ ld b, a
+ ld a, [hl]
rr a
- ld [de],a
+ ld [de], a
or b
- jr nz,ApplyDamageToEnemyPokemon
+ jr nz, ApplyDamageToEnemyPokemon
; make sure Super Fang's damage is always at least 1
- ld a,$01
- ld [de],a
+ ld a, $01
+ ld [de], a
jr ApplyDamageToEnemyPokemon
.specialDamage
- ld hl,wBattleMonLevel
- ld a,[hl]
- ld b,a ; Seismic Toss deals damage equal to the user's level
- ld a,[wPlayerMoveNum]
- cp a,SEISMIC_TOSS
- jr z,.storeDamage
- cp a,NIGHT_SHADE
- jr z,.storeDamage
- ld b,SONICBOOM_DAMAGE ; 20
- cp a,SONICBOOM
- jr z,.storeDamage
- ld b,DRAGON_RAGE_DAMAGE ; 40
- cp a,DRAGON_RAGE
- jr z,.storeDamage
+ ld hl, wBattleMonLevel
+ ld a, [hl]
+ ld b, a ; Seismic Toss deals damage equal to the user's level
+ ld a, [wPlayerMoveNum]
+ cp SEISMIC_TOSS
+ jr z, .storeDamage
+ cp NIGHT_SHADE
+ jr z, .storeDamage
+ ld b, SONICBOOM_DAMAGE ; 20
+ cp SONICBOOM
+ jr z, .storeDamage
+ ld b, DRAGON_RAGE_DAMAGE ; 40
+ cp DRAGON_RAGE
+ jr z, .storeDamage
; Psywave
- ld a,[hl]
- ld b,a
+ ld a, [hl]
+ ld b, a
srl a
add b
- ld b,a ; b = level * 1.5
+ ld b, a ; b = level * 1.5
; loop until a random number in the range [1, b) is found
.loop
call BattleRandom
and a
- jr z,.loop
+ jr z, .loop
cp b
- jr nc,.loop
- ld b,a
+ jr nc, .loop
+ ld b, a
.storeDamage ; store damage value at b
- ld hl,wDamage
+ ld hl, wDamage
xor a
- ld [hli],a
- ld a,b
- ld [hl],a
+ ld [hli], a
+ ld a, b
+ ld [hl], a
ApplyDamageToEnemyPokemon:
- ld hl,wDamage
- ld a,[hli]
- ld b,a
- ld a,[hl]
+ ld hl, wDamage
+ ld a, [hli]
+ ld b, a
+ ld a, [hl]
or b
- jr z,ApplyAttackToEnemyPokemonDone ; we're done if damage is 0
- ld a,[wEnemyBattleStatus2]
- bit HasSubstituteUp,a ; does the enemy have a substitute?
- jp nz,AttackSubstitute
+ jr z, ApplyAttackToEnemyPokemonDone ; we're done if damage is 0
+ ld a, [wEnemyBattleStatus2]
+ bit HAS_SUBSTITUTE_UP, a ; does the enemy have a substitute?
+ jp nz, AttackSubstitute
; subtract the damage from the pokemon's current HP
; also, save the current HP at wHPBarOldHP
- ld a,[hld]
- ld b,a
- ld a,[wEnemyMonHP + 1]
- ld [wHPBarOldHP],a
+ ld a, [hld]
+ ld b, a
+ ld a, [wEnemyMonHP + 1]
+ ld [wHPBarOldHP], a
sub b
- ld [wEnemyMonHP + 1],a
- ld a,[hl]
- ld b,a
- ld a,[wEnemyMonHP]
- ld [wHPBarOldHP+1],a
+ ld [wEnemyMonHP + 1], a
+ ld a, [hl]
+ ld b, a
+ ld a, [wEnemyMonHP]
+ ld [wHPBarOldHP+1], a
sbc b
- ld [wEnemyMonHP],a
- jr nc,.animateHpBar
+ ld [wEnemyMonHP], a
+ jr nc, .animateHpBar
; if more damage was done than the current HP, zero the HP and set the damage (wDamage)
; equal to how much HP the pokemon had before the attack
- ld a,[wHPBarOldHP+1]
- ld [hli],a
- ld a,[wHPBarOldHP]
- ld [hl],a
- xor a
- ld hl,wEnemyMonHP
- ld [hli],a
- ld [hl],a
+ ld a, [wHPBarOldHP+1]
+ ld [hli], a
+ ld a, [wHPBarOldHP]
+ ld [hl], a
+ xor a
+ ld hl, wEnemyMonHP
+ ld [hli], a
+ ld [hl], a
.animateHpBar
- ld hl,wEnemyMonMaxHP
- ld a,[hli]
- ld [wHPBarMaxHP+1],a
- ld a,[hl]
- ld [wHPBarMaxHP],a
- ld hl,wEnemyMonHP
- ld a,[hli]
- ld [wHPBarNewHP+1],a
- ld a,[hl]
- ld [wHPBarNewHP],a
+ ld hl, wEnemyMonMaxHP
+ ld a, [hli]
+ ld [wHPBarMaxHP+1], a
+ ld a, [hl]
+ ld [wHPBarMaxHP], a
+ ld hl, wEnemyMonHP
+ ld a, [hli]
+ ld [wHPBarNewHP+1], a
+ ld a, [hl]
+ ld [wHPBarNewHP], a
coord hl, 2, 2
xor a
- ld [wHPBarType],a
+ ld [wHPBarType], a
predef UpdateHPBar2 ; animate the HP bar shortening
ApplyAttackToEnemyPokemonDone:
jp DrawHUDsAndHPBars
ApplyAttackToPlayerPokemon:
- ld a,[wEnemyMoveEffect]
- cp a,OHKO_EFFECT
- jr z,ApplyDamageToPlayerPokemon
- cp a,SUPER_FANG_EFFECT
- jr z,.superFangEffect
- cp a,SPECIAL_DAMAGE_EFFECT
- jr z,.specialDamage
- ld a,[wEnemyMovePower]
- and a
- jp z,ApplyAttackToPlayerPokemonDone
+ ld a, [wEnemyMoveEffect]
+ cp OHKO_EFFECT
+ jr z, ApplyDamageToPlayerPokemon
+ cp SUPER_FANG_EFFECT
+ jr z, .superFangEffect
+ cp SPECIAL_DAMAGE_EFFECT
+ jr z, .specialDamage
+ ld a, [wEnemyMovePower]
+ and a
+ jp z, ApplyAttackToPlayerPokemonDone
jr ApplyDamageToPlayerPokemon
.superFangEffect
; set the damage to half the target's HP
- ld hl,wBattleMonHP
- ld de,wDamage
- ld a,[hli]
+ ld hl, wBattleMonHP
+ ld de, wDamage
+ ld a, [hli]
srl a
- ld [de],a
+ ld [de], a
inc de
- ld b,a
- ld a,[hl]
+ ld b, a
+ ld a, [hl]
rr a
- ld [de],a
+ ld [de], a
or b
- jr nz,ApplyDamageToPlayerPokemon
+ jr nz, ApplyDamageToPlayerPokemon
; make sure Super Fang's damage is always at least 1
- ld a,$01
- ld [de],a
+ ld a, $01
+ ld [de], a
jr ApplyDamageToPlayerPokemon
.specialDamage
- ld hl,wEnemyMonLevel
- ld a,[hl]
- ld b,a
- ld a,[wEnemyMoveNum]
- cp a,SEISMIC_TOSS
- jr z,.storeDamage
- cp a,NIGHT_SHADE
- jr z,.storeDamage
- ld b,SONICBOOM_DAMAGE
- cp a,SONICBOOM
- jr z,.storeDamage
- ld b,DRAGON_RAGE_DAMAGE
- cp a,DRAGON_RAGE
- jr z,.storeDamage
+ ld hl, wEnemyMonLevel
+ ld a, [hl]
+ ld b, a
+ ld a, [wEnemyMoveNum]
+ cp SEISMIC_TOSS
+ jr z, .storeDamage
+ cp NIGHT_SHADE
+ jr z, .storeDamage
+ ld b, SONICBOOM_DAMAGE
+ cp SONICBOOM
+ jr z, .storeDamage
+ ld b, DRAGON_RAGE_DAMAGE
+ cp DRAGON_RAGE
+ jr z, .storeDamage
; Psywave
- ld a,[hl]
- ld b,a
+ ld a, [hl]
+ ld b, a
srl a
add b
- ld b,a ; b = attacker's level * 1.5
+ ld b, a ; b = attacker's level * 1.5
; loop until a random number in the range [0, b) is found
; this differs from the range when the player attacks, which is [1, b)
; it's possible for the enemy to do 0 damage with Psywave, but the player always does at least 1 damage
.loop
call BattleRandom
cp b
- jr nc,.loop
- ld b,a
+ jr nc, .loop
+ ld b, a
.storeDamage
- ld hl,wDamage
+ ld hl, wDamage
xor a
- ld [hli],a
- ld a,b
- ld [hl],a
+ ld [hli], a
+ ld a, b
+ ld [hl], a
ApplyDamageToPlayerPokemon:
- ld hl,wDamage
- ld a,[hli]
- ld b,a
- ld a,[hl]
+ ld hl, wDamage
+ ld a, [hli]
+ ld b, a
+ ld a, [hl]
or b
- jr z,ApplyAttackToPlayerPokemonDone ; we're done if damage is 0
- ld a,[wPlayerBattleStatus2]
- bit HasSubstituteUp,a ; does the player have a substitute?
- jp nz,AttackSubstitute
+ jr z, ApplyAttackToPlayerPokemonDone ; we're done if damage is 0
+ ld a, [wPlayerBattleStatus2]
+ bit HAS_SUBSTITUTE_UP, a ; does the player have a substitute?
+ jp nz, AttackSubstitute
; subtract the damage from the pokemon's current HP
; also, save the current HP at wHPBarOldHP and the new HP at wHPBarNewHP
- ld a,[hld]
- ld b,a
- ld a,[wBattleMonHP + 1]
- ld [wHPBarOldHP],a
+ ld a, [hld]
+ ld b, a
+ ld a, [wBattleMonHP + 1]
+ ld [wHPBarOldHP], a
sub b
- ld [wBattleMonHP + 1],a
- ld [wHPBarNewHP],a
- ld b,[hl]
- ld a,[wBattleMonHP]
- ld [wHPBarOldHP+1],a
+ ld [wBattleMonHP + 1], a
+ ld [wHPBarNewHP], a
+ ld b, [hl]
+ ld a, [wBattleMonHP]
+ ld [wHPBarOldHP+1], a
sbc b
- ld [wBattleMonHP],a
- ld [wHPBarNewHP+1],a
- jr nc,.animateHpBar
+ ld [wBattleMonHP], a
+ ld [wHPBarNewHP+1], a
+ jr nc, .animateHpBar
; if more damage was done than the current HP, zero the HP and set the damage (wDamage)
; equal to how much HP the pokemon had before the attack
- ld a,[wHPBarOldHP+1]
- ld [hli],a
- ld a,[wHPBarOldHP]
- ld [hl],a
- xor a
- ld hl,wBattleMonHP
- ld [hli],a
- ld [hl],a
- ld hl,wHPBarNewHP
- ld [hli],a
- ld [hl],a
+ ld a, [wHPBarOldHP+1]
+ ld [hli], a
+ ld a, [wHPBarOldHP]
+ ld [hl], a
+ xor a
+ ld hl, wBattleMonHP
+ ld [hli], a
+ ld [hl], a
+ ld hl, wHPBarNewHP
+ ld [hli], a
+ ld [hl], a
.animateHpBar
- ld hl,wBattleMonMaxHP
- ld a,[hli]
- ld [wHPBarMaxHP+1],a
- ld a,[hl]
- ld [wHPBarMaxHP],a
+ ld hl, wBattleMonMaxHP
+ ld a, [hli]
+ ld [wHPBarMaxHP+1], a
+ ld a, [hl]
+ ld [wHPBarMaxHP], a
coord hl, 10, 9
- ld a,$01
- ld [wHPBarType],a
+ ld a, $01
+ ld [wHPBarType], a
predef UpdateHPBar2 ; animate the HP bar shortening
ApplyAttackToPlayerPokemonDone:
jp DrawHUDsAndHPBars
@@ -5224,51 +5224,51 @@ AttackSubstitute:
; 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
+ ld hl, SubstituteTookDamageText
call PrintText
; values for player turn
- ld de,wEnemySubstituteHP
- ld bc,wEnemyBattleStatus2
- ld a,[H_WHOSETURN]
+ ld de, wEnemySubstituteHP
+ ld bc, wEnemyBattleStatus2
+ ld a, [H_WHOSETURN]
and a
- jr z,.applyDamageToSubstitute
+ jr z, .applyDamageToSubstitute
; values for enemy turn
- ld de,wPlayerSubstituteHP
- ld bc,wPlayerBattleStatus2
+ ld de, wPlayerSubstituteHP
+ ld bc, wPlayerBattleStatus2
.applyDamageToSubstitute
- ld hl,wDamage
- ld a,[hli]
+ ld hl, wDamage
+ ld a, [hli]
and a
- jr nz,.substituteBroke ; damage > 0xFF always breaks substitutes
+ jr nz, .substituteBroke ; damage > 0xFF always breaks substitutes
; subtract damage from HP of substitute
- ld a,[de]
+ ld a, [de]
sub [hl]
- ld [de],a
+ ld [de], a
ret nc
.substituteBroke
; If the target's Substitute breaks, wDamage isn't updated with the amount of HP
; the Substitute had before being attacked.
- ld h,b
- ld l,c
- res HasSubstituteUp,[hl] ; unset the substitute bit
- ld hl,SubstituteBrokeText
+ ld h, b
+ ld l, c
+ res HAS_SUBSTITUTE_UP, [hl] ; unset the substitute bit
+ ld hl, SubstituteBrokeText
call PrintText
; flip whose turn it is for the next function call
- ld a,[H_WHOSETURN]
- xor a,$01
- ld [H_WHOSETURN],a
+ ld a, [H_WHOSETURN]
+ xor $01
+ ld [H_WHOSETURN], a
callab Func_79929 ; animate the substitute breaking
; flip the turn back to the way it was
- ld a,[H_WHOSETURN]
- xor a,$01
- ld [H_WHOSETURN],a
- ld hl,wPlayerMoveEffect ; value for player's turn
+ ld a, [H_WHOSETURN]
+ xor $01
+ ld [H_WHOSETURN], a
+ ld hl, wPlayerMoveEffect ; value for player's turn
and a
- jr z,.nullifyEffect
- ld hl,wEnemyMoveEffect ; value for enemy's turn
+ jr z, .nullifyEffect
+ ld hl, wEnemyMoveEffect ; value for enemy's turn
.nullifyEffect
xor a
- ld [hl],a ; zero the effect of the attacker's move
+ ld [hl], a ; zero the effect of the attacker's move
jp DrawHUDsAndHPBars
SubstituteTookDamageText:
@@ -5282,44 +5282,44 @@ SubstituteBrokeText:
; this function raises the attack modifier of a pokemon using Rage when that pokemon is attacked
HandleBuildingRage:
; values for the player turn
- ld hl,wEnemyBattleStatus2
- ld de,wEnemyMonStatMods
- ld bc,wEnemyMoveNum
- ld a,[H_WHOSETURN]
+ ld hl, wEnemyBattleStatus2
+ ld de, wEnemyMonStatMods
+ ld bc, wEnemyMoveNum
+ ld a, [H_WHOSETURN]
and a
- jr z,.next
+ jr z, .next
; values for the enemy turn
- ld hl,wPlayerBattleStatus2
- ld de,wPlayerMonStatMods
- ld bc,wPlayerMoveNum
+ ld hl, wPlayerBattleStatus2
+ ld de, wPlayerMonStatMods
+ ld bc, wPlayerMoveNum
.next
- bit UsingRage,[hl] ; is the pokemon being attacked under the effect of Rage?
+ bit USING_RAGE, [hl] ; is the pokemon being attacked under the effect of Rage?
ret z ; return if not
- ld a,[de]
- cp a,$0d ; maximum stat modifier value
+ ld a, [de]
+ cp $0d ; maximum stat modifier value
ret z ; return if attack modifier is already maxed
- ld a,[H_WHOSETURN]
- xor a,$01 ; flip turn for the stat modifier raising function
- ld [H_WHOSETURN],a
+ ld a, [H_WHOSETURN]
+ xor $01 ; flip turn for the stat modifier raising function
+ ld [H_WHOSETURN], a
; temporarily change the target pokemon's move to $00 and the effect to the one
; that causes the attack modifier to go up one stage
- ld h,b
- ld l,c
- ld [hl],$00 ; null move number
+ ld h, b
+ ld l, c
+ ld [hl], $00 ; null move number
inc hl
- ld [hl],ATTACK_UP1_EFFECT
+ ld [hl], ATTACK_UP1_EFFECT
push hl
- ld hl,BuildingRageText
+ ld hl, BuildingRageText
call PrintText
call StatModifierUpEffect ; stat modifier raising function
pop hl
xor a
- ldd [hl],a ; null move effect
- ld a,RAGE
- ld [hl],a ; restore the target pokemon's move number to Rage
- ld a,[H_WHOSETURN]
- xor a,$01 ; flip turn back to the way it was
- ld [H_WHOSETURN],a
+ ldd [hl], a ; null move effect
+ ld a, RAGE
+ ld [hl], a ; restore the target pokemon's move number to Rage
+ ld a, [H_WHOSETURN]
+ xor $01 ; flip turn back to the way it was
+ ld [H_WHOSETURN], a
ret
BuildingRageText:
@@ -5335,25 +5335,25 @@ MirrorMoveCopyMove:
; ccf1 is also set to 0 whenever the player is fast asleep or frozen solid.
; ccf2 is also set to 0 whenever the enemy is fast asleep or frozen solid.
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
; values for player turn
- ld a,[wEnemyUsedMove]
- ld hl,wPlayerSelectedMove
- ld de,wPlayerMoveNum
- jr z,.next
+ ld a, [wEnemyUsedMove]
+ ld hl, wPlayerSelectedMove
+ ld de, wPlayerMoveNum
+ jr z, .next
; values for enemy turn
- ld a,[wPlayerUsedMove]
- ld de,wEnemyMoveNum
- ld hl,wEnemySelectedMove
+ ld a, [wPlayerUsedMove]
+ ld de, wEnemyMoveNum
+ ld hl, wEnemySelectedMove
.next
- ld [hl],a
- cp a,MIRROR_MOVE ; did the target Pokemon last use Mirror Move, and miss?
- jr z,.mirrorMoveFailed
+ ld [hl], a
+ cp MIRROR_MOVE ; did the target Pokemon last use Mirror Move, and miss?
+ jr z, .mirrorMoveFailed
and a ; has the target selected any move yet?
- jr nz,ReloadMoveData
+ jr nz, ReloadMoveData
.mirrorMoveFailed
- ld hl,MirrorMoveFailedText
+ ld hl, MirrorMoveFailedText
call PrintText
xor a
ret
@@ -5364,78 +5364,78 @@ MirrorMoveFailedText:
; function used to reload move data for moves like Mirror Move and Metronome
ReloadMoveData:
- ld [wd11e],a
+ ld [wd11e], a
dec a
- ld hl,Moves
- ld bc,MoveEnd - Moves
+ ld hl, Moves
+ ld bc, MoveEnd - Moves
call AddNTimes
- ld a,BANK(Moves)
+ ld a, BANK(Moves)
call FarCopyData ; copy the move's stats
call IncrementMovePP
; the follow two function calls are used to reload the move name
call GetMoveName
call CopyStringToCF4B
- ld a,$01
+ ld a, $01
and a
ret
; function that picks a random move for metronome
MetronomePickMove:
xor a
- ld [wAnimationType],a
- ld a,METRONOME
+ ld [wAnimationType], a
+ ld a, METRONOME
call PlayMoveAnimation ; play Metronome's animation
; values for player turn
- ld de,wPlayerMoveNum
- ld hl,wPlayerSelectedMove
- ld a,[H_WHOSETURN]
+ ld de, wPlayerMoveNum
+ ld hl, wPlayerSelectedMove
+ ld a, [H_WHOSETURN]
and a
- jr z,.pickMoveLoop
+ jr z, .pickMoveLoop
; values for enemy turn
- ld de,wEnemyMoveNum
- ld hl,wEnemySelectedMove
+ ld de, wEnemyMoveNum
+ ld hl, wEnemySelectedMove
; loop to pick a random number in the range [1, $a5) to be the move used by Metronome
.pickMoveLoop
call BattleRandom
and a
- jr z,.pickMoveLoop
- cp a,NUM_ATTACKS + 1 ; max normal move number + 1 (this is Struggle's move number)
- jr nc,.pickMoveLoop
- cp a,METRONOME
- jr z,.pickMoveLoop
- ld [hl],a
+ jr z, .pickMoveLoop
+ cp NUM_ATTACKS + 1 ; max normal move number + 1 (this is Struggle's move number)
+ jr nc, .pickMoveLoop
+ cp METRONOME
+ jr z, .pickMoveLoop
+ ld [hl], a
jr ReloadMoveData
; this function increments the current move's PP
; it's used to prevent moves that run another move within the same turn
; (like Mirror Move and Metronome) from losing 2 PP
IncrementMovePP:
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
; values for player turn
- ld hl,wBattleMonPP
- ld de,wPartyMon1PP
- ld a,[wPlayerMoveListIndex]
- jr z,.next
+ ld hl, wBattleMonPP
+ ld de, wPartyMon1PP
+ ld a, [wPlayerMoveListIndex]
+ jr z, .next
; values for enemy turn
- ld hl,wEnemyMonPP
- ld de,wEnemyMon1PP
- ld a,[wEnemyMoveListIndex]
+ ld hl, wEnemyMonPP
+ ld de, wEnemyMon1PP
+ ld a, [wEnemyMoveListIndex]
.next
- ld b,$00
- ld c,a
- add hl,bc
+ ld b, $00
+ ld c, a
+ add hl, bc
inc [hl] ; increment PP in the currently battling pokemon memory location
- ld h,d
- ld l,e
- add hl,bc
- ld a,[H_WHOSETURN]
- and a
- ld a,[wPlayerMonNumber] ; value for player turn
- jr z,.updatePP
- ld a,[wEnemyMonPartyPos] ; value for enemy turn
+ ld h, d
+ ld l, e
+ add hl, bc
+ ld a, [H_WHOSETURN]
+ and a
+ ld a, [wPlayerMonNumber] ; value for player turn
+ jr z, .updatePP
+ ld a, [wEnemyMonPartyPos] ; value for enemy turn
.updatePP
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
inc [hl] ; increment PP in the party memory location
ret
@@ -5443,107 +5443,107 @@ IncrementMovePP:
; function to adjust the base damage of an attack to account for type effectiveness
AdjustDamageForMoveType:
; values for player turn
- ld hl,wBattleMonType
- ld a,[hli]
- ld b,a ; b = type 1 of attacker
- ld c,[hl] ; c = type 2 of attacker
- ld hl,wEnemyMonType
- ld a,[hli]
- ld d,a ; d = type 1 of defender
- ld e,[hl] ; e = type 2 of defender
- ld a,[wPlayerMoveType]
- ld [wMoveType],a
- ld a,[H_WHOSETURN]
- and a
- jr z,.next
+ ld hl, wBattleMonType
+ ld a, [hli]
+ ld b, a ; b = type 1 of attacker
+ ld c, [hl] ; c = type 2 of attacker
+ ld hl, wEnemyMonType
+ ld a, [hli]
+ ld d, a ; d = type 1 of defender
+ ld e, [hl] ; e = type 2 of defender
+ ld a, [wPlayerMoveType]
+ ld [wMoveType], a
+ ld a, [H_WHOSETURN]
+ and a
+ jr z, .next
; values for enemy turn
- ld hl,wEnemyMonType
- ld a,[hli]
- ld b,a ; b = type 1 of attacker
- ld c,[hl] ; c = type 2 of attacker
- ld hl,wBattleMonType
- ld a,[hli]
- ld d,a ; d = type 1 of defender
- ld e,[hl] ; e = type 2 of defender
- ld a,[wEnemyMoveType]
- ld [wMoveType],a
+ ld hl, wEnemyMonType
+ ld a, [hli]
+ ld b, a ; b = type 1 of attacker
+ ld c, [hl] ; c = type 2 of attacker
+ ld hl, wBattleMonType
+ ld a, [hli]
+ ld d, a ; d = type 1 of defender
+ ld e, [hl] ; e = type 2 of defender
+ ld a, [wEnemyMoveType]
+ ld [wMoveType], a
.next
- ld a,[wMoveType]
+ ld a, [wMoveType]
cp b ; does the move type match type 1 of the attacker?
- jr z,.sameTypeAttackBonus
+ jr z, .sameTypeAttackBonus
cp c ; does the move type match type 2 of the attacker?
- jr z,.sameTypeAttackBonus
+ jr z, .sameTypeAttackBonus
jr .skipSameTypeAttackBonus
.sameTypeAttackBonus
; if the move type matches one of the attacker's types
- ld hl,wDamage + 1
- ld a,[hld]
- ld h,[hl]
- ld l,a ; hl = damage
- ld b,h
- ld c,l ; bc = damage
+ ld hl, wDamage + 1
+ ld a, [hld]
+ ld h, [hl]
+ ld l, a ; hl = damage
+ ld b, h
+ ld c, l ; bc = damage
srl b
rr c ; bc = floor(0.5 * damage)
- add hl,bc ; hl = floor(1.5 * damage)
+ add hl, bc ; hl = floor(1.5 * damage)
; store damage
- ld a,h
- ld [wDamage],a
- ld a,l
- ld [wDamage + 1],a
- ld hl,wDamageMultipliers
- set 7,[hl]
+ ld a, h
+ ld [wDamage], a
+ ld a, l
+ ld [wDamage + 1], a
+ ld hl, wDamageMultipliers
+ set 7, [hl]
.skipSameTypeAttackBonus
- ld a,[wMoveType]
- ld b,a
- ld hl,TypeEffects
+ ld a, [wMoveType]
+ ld b, a
+ ld hl, TypeEffects
.loop
- ld a,[hli] ; a = "attacking type" of the current type pair
- cp a,$ff
- jr z,.done
+ ld a, [hli] ; a = "attacking type" of the current type pair
+ cp $ff
+ jr z, .done
cp b ; does move type match "attacking type"?
- jr nz,.nextTypePair
- ld a,[hl] ; a = "defending type" of the current type pair
+ jr nz, .nextTypePair
+ ld a, [hl] ; a = "defending type" of the current type pair
cp d ; does type 1 of defender match "defending type"?
- jr z,.matchingPairFound
+ jr z, .matchingPairFound
cp e ; does type 2 of defender match "defending type"?
- jr z,.matchingPairFound
+ jr z, .matchingPairFound
jr .nextTypePair
.matchingPairFound
; if the move type matches the "attacking type" and one of the defender's types matches the "defending type"
push hl
push bc
inc hl
- ld a,[wDamageMultipliers]
- and a,$80
- ld b,a
- ld a,[hl] ; a = damage multiplier
- ld [H_MULTIPLIER],a
+ ld a, [wDamageMultipliers]
+ and $80
+ ld b, a
+ ld a, [hl] ; a = damage multiplier
+ ld [H_MULTIPLIER], a
add b
- ld [wDamageMultipliers],a
- xor a
- ld [H_MULTIPLICAND],a
- ld hl,wDamage
- ld a,[hli]
- ld [H_MULTIPLICAND + 1],a
- ld a,[hld]
- ld [H_MULTIPLICAND + 2],a
+ ld [wDamageMultipliers], a
+ xor a
+ ld [H_MULTIPLICAND], a
+ ld hl, wDamage
+ ld a, [hli]
+ ld [H_MULTIPLICAND + 1], a
+ ld a, [hld]
+ ld [H_MULTIPLICAND + 2], a
call Multiply
- ld a,10
- ld [H_DIVISOR],a
- ld b,$04
+ ld a, 10
+ ld [H_DIVISOR], a
+ ld b, $04
call Divide
- ld a,[H_QUOTIENT + 2]
- ld [hli],a
- ld b,a
- ld a,[H_QUOTIENT + 3]
- ld [hl],a
+ ld a, [H_QUOTIENT + 2]
+ ld [hli], a
+ ld b, a
+ ld a, [H_QUOTIENT + 3]
+ ld [hl], a
or b ; is damage 0?
- jr nz,.skipTypeImmunity
+ jr nz, .skipTypeImmunity
.typeImmunity
; if damage is 0, make the move miss
; this only occurs if a move that would do 2 or 3 damage is 0.25x effective against the target
inc a
- ld [wMoveMissed],a
+ ld [wMoveMissed], a
.skipTypeImmunity
pop bc
pop hl
@@ -5555,26 +5555,26 @@ AdjustDamageForMoveType:
ret
AIGetTypeEffectiveness:
- ld a,[wEnemyMoveType]
- ld d,a ; d = type of enemy move
- ld hl,wBattleMonType
- ld b,[hl] ; b = type 1 of player's pokemon
+ ld a, [wEnemyMoveType]
+ ld d, a ; d = type of enemy move
+ ld hl, wBattleMonType
+ ld b, [hl] ; b = type 1 of player's pokemon
inc hl
- ld c,[hl] ; c = type 2 of player's pokemon
- ld a,$10
- ld [wd11e],a ; initialize [wd11e] to neutral effectiveness
- ld hl,TypeEffects
+ ld c, [hl] ; c = type 2 of player's pokemon
+ ld a, $10
+ ld [wd11e], a ; initialize [wd11e] to neutral effectiveness
+ ld hl, TypeEffects
.loop
- ld a,[hli]
- cp a,$ff
+ ld a, [hli]
+ cp $ff
ret z
cp d ; match the type of the move
- jr nz,.nextTypePair1
- ld a,[hli]
+ jr nz, .nextTypePair1
+ ld a, [hli]
cp b ; match with type 1 of pokemon
- jr z,.done
+ jr z, .done
cp c ; or match with type 2 of pokemon
- jr z,.done
+ jr z, .done
jr .nextTypePair2
.nextTypePair1
inc hl
@@ -5594,8 +5594,8 @@ AIGetTypeEffectiveness:
ret c
.ok
- ld a,[hl]
- ld [wd11e],a ; store damage multiplier
+ ld a, [hl]
+ ld [wd11e], a ; store damage multiplier
ret
INCLUDE "data/type_effects.asm"
@@ -5603,52 +5603,52 @@ INCLUDE "data/type_effects.asm"
; some tests that need to pass for a move to hit
MoveHitTest:
; player's turn
- ld hl,wEnemyBattleStatus1
- ld de,wPlayerMoveEffect
- ld bc,wEnemyMonStatus
- ld a,[H_WHOSETURN]
+ ld hl, wEnemyBattleStatus1
+ ld de, wPlayerMoveEffect
+ ld bc, wEnemyMonStatus
+ ld a, [H_WHOSETURN]
and a
- jr z,.dreamEaterCheck
+ jr z, .dreamEaterCheck
; enemy's turn
- ld hl,wPlayerBattleStatus1
- ld de,wEnemyMoveEffect
- ld bc,wBattleMonStatus
+ ld hl, wPlayerBattleStatus1
+ ld de, wEnemyMoveEffect
+ ld bc, wBattleMonStatus
.dreamEaterCheck
- ld a,[de]
- cp a,DREAM_EATER_EFFECT
- jr nz,.swiftCheck
- ld a,[bc]
- and a,SLP ; is the target pokemon sleeping?
- jp z,.moveMissed
+ ld a, [de]
+ cp DREAM_EATER_EFFECT
+ jr nz, .swiftCheck
+ ld a, [bc]
+ and SLP ; is the target pokemon sleeping?
+ jp z, .moveMissed
.swiftCheck
- ld a,[de]
- cp a,SWIFT_EFFECT
+ ld a, [de]
+ cp SWIFT_EFFECT
ret z ; Swift never misses (interestingly, Azure Heights lists this is a myth, but it appears to be true)
call CheckTargetSubstitute ; substitute check (note that this overwrites a)
- jr z,.checkForDigOrFlyStatus
+ jr z, .checkForDigOrFlyStatus
; this code is buggy. it's supposed to prevent HP draining moves from working on substitutes.
; since $7b79 overwrites a with either $00 or $01, it never works.
- cp a,DRAIN_HP_EFFECT
- jp z,.moveMissed
- cp a,DREAM_EATER_EFFECT
- jp z,.moveMissed
+ cp DRAIN_HP_EFFECT
+ jp z, .moveMissed
+ cp DREAM_EATER_EFFECT
+ jp z, .moveMissed
.checkForDigOrFlyStatus
- bit Invulnerable,[hl]
- jp nz,.moveMissed
- ld a,[H_WHOSETURN]
+ bit INVULNERABLE, [hl]
+ jp nz, .moveMissed
+ ld a, [H_WHOSETURN]
and a
- jr nz,.enemyTurn
+ jr nz, .enemyTurn
.playerTurn
; this checks if the move effect is disallowed by mist
- ld a,[wPlayerMoveEffect]
- cp a,ATTACK_DOWN1_EFFECT
- jr c,.skipEnemyMistCheck
- cp a,HAZE_EFFECT + 1
- jr c,.enemyMistCheck
- cp a,ATTACK_DOWN2_EFFECT
- jr c,.skipEnemyMistCheck
- cp a,REFLECT_EFFECT + 1
- jr c,.enemyMistCheck
+ ld a, [wPlayerMoveEffect]
+ cp ATTACK_DOWN1_EFFECT
+ jr c, .skipEnemyMistCheck
+ cp HAZE_EFFECT + 1
+ jr c, .enemyMistCheck
+ cp ATTACK_DOWN2_EFFECT
+ jr c, .skipEnemyMistCheck
+ cp REFLECT_EFFECT + 1
+ jr c, .enemyMistCheck
jr .skipEnemyMistCheck
.enemyMistCheck
; if move effect is from $12 to $19 inclusive or $3a to $41 inclusive
@@ -5657,98 +5657,98 @@ MoveHitTest:
; FLASH, CONVERSION*, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT*
; the moves that are marked with an asterisk are not affected since this
; function is not called when those moves are used
- ld a,[wEnemyBattleStatus2]
- bit ProtectedByMist,a ; is mon protected by mist?
- jp nz,.moveMissed
+ ld a, [wEnemyBattleStatus2]
+ bit PROTECTED_BY_MIST, a ; is mon protected by mist?
+ jp nz, .moveMissed
.skipEnemyMistCheck
- ld a,[wPlayerBattleStatus2]
- bit UsingXAccuracy,a ; is the player using X Accuracy?
+ ld a, [wPlayerBattleStatus2]
+ bit USING_X_ACCURACY, a ; is the player using X Accuracy?
ret nz ; if so, always hit regardless of accuracy/evasion
jr .calcHitChance
.enemyTurn
- ld a,[wEnemyMoveEffect]
- cp a,ATTACK_DOWN1_EFFECT
- jr c,.skipPlayerMistCheck
- cp a,HAZE_EFFECT + 1
- jr c,.playerMistCheck
- cp a,ATTACK_DOWN2_EFFECT
- jr c,.skipPlayerMistCheck
- cp a,REFLECT_EFFECT + 1
- jr c,.playerMistCheck
+ ld a, [wEnemyMoveEffect]
+ cp ATTACK_DOWN1_EFFECT
+ jr c, .skipPlayerMistCheck
+ cp HAZE_EFFECT + 1
+ jr c, .playerMistCheck
+ cp ATTACK_DOWN2_EFFECT
+ jr c, .skipPlayerMistCheck
+ cp REFLECT_EFFECT + 1
+ jr c, .playerMistCheck
jr .skipPlayerMistCheck
.playerMistCheck
; similar to enemy mist check
- ld a,[wPlayerBattleStatus2]
- bit ProtectedByMist,a ; is mon protected by mist?
- jp nz,.moveMissed
+ ld a, [wPlayerBattleStatus2]
+ bit PROTECTED_BY_MIST, a ; is mon protected by mist?
+ jp nz, .moveMissed
.skipPlayerMistCheck
- ld a,[wEnemyBattleStatus2]
- bit UsingXAccuracy,a ; is the enemy using X Accuracy?
+ ld a, [wEnemyBattleStatus2]
+ bit USING_X_ACCURACY, a ; is the enemy using X Accuracy?
ret nz ; if so, always hit regardless of accuracy/evasion
.calcHitChance
call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion
- ld a,[wPlayerMoveAccuracy]
- ld b,a
- ld a,[H_WHOSETURN]
+ ld a, [wPlayerMoveAccuracy]
+ ld b, a
+ ld a, [H_WHOSETURN]
and a
- jr z,.doAccuracyCheck
- ld a,[wEnemyMoveAccuracy]
- ld b,a
+ jr z, .doAccuracyCheck
+ ld a, [wEnemyMoveAccuracy]
+ ld b, a
.doAccuracyCheck
; if the random number generated is greater than or equal to the scaled accuracy, the move misses
; note that this means that even the highest accuracy is still just a 255/256 chance, not 100%
call BattleRandom
cp b
- jr nc,.moveMissed
+ jr nc, .moveMissed
ret
.moveMissed
xor a
- ld hl,wDamage ; zero the damage
- ld [hli],a
- ld [hl],a
+ ld hl, wDamage ; zero the damage
+ ld [hli], a
+ ld [hl], a
inc a
- ld [wMoveMissed],a
- ld a,[H_WHOSETURN]
+ ld [wMoveMissed], a
+ ld a, [H_WHOSETURN]
and a
- jr z,.playerTurn2
+ jr z, .playerTurn2
.enemyTurn2
- ld hl,wEnemyBattleStatus1
- res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap
+ ld hl, wEnemyBattleStatus1
+ res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap
ret
.playerTurn2
- ld hl,wPlayerBattleStatus1
- res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap
+ ld hl, wPlayerBattleStatus1
+ res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap
ret
; values for player turn
CalcHitChance:
- ld hl,wPlayerMoveAccuracy
- ld a,[H_WHOSETURN]
- and a
- ld a,[wPlayerMonAccuracyMod]
- ld b,a
- ld a,[wEnemyMonEvasionMod]
- ld c,a
- jr z,.next
+ ld hl, wPlayerMoveAccuracy
+ ld a, [H_WHOSETURN]
+ and a
+ ld a, [wPlayerMonAccuracyMod]
+ ld b, a
+ ld a, [wEnemyMonEvasionMod]
+ ld c, a
+ jr z, .next
; values for enemy turn
- ld hl,wEnemyMoveAccuracy
- ld a,[wEnemyMonAccuracyMod]
- ld b,a
- ld a,[wPlayerMonEvasionMod]
- ld c,a
+ ld hl, wEnemyMoveAccuracy
+ ld a, [wEnemyMonAccuracyMod]
+ ld b, a
+ ld a, [wPlayerMonEvasionMod]
+ ld c, a
.next
- ld a,$0e
+ ld a, $0e
sub c
- ld c,a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion
+ ld c, a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion
; decreases the hit chance instead of increasing the hit chance)
; zero the high bytes of the multiplicand
xor a
- ld [H_MULTIPLICAND],a
- ld [H_MULTIPLICAND + 1],a
- ld a,[hl]
- ld [H_MULTIPLICAND + 2],a ; set multiplicand to move accuracy
+ ld [H_MULTIPLICAND], a
+ ld [H_MULTIPLICAND + 1], a
+ ld a, [hl]
+ ld [H_MULTIPLICAND + 2], a ; set multiplicand to move accuracy
push hl
- ld d,$02 ; loop has two iterations
+ ld d, $02 ; loop has two iterations
; loop to do the calculations, the first iteration multiplies by the accuracy ratio and
; the second iteration multiplies by the evasion ratio
.loop
@@ -5756,40 +5756,40 @@ CalcHitChance:
ld hl, StatModifierRatios ; stat modifier ratios
dec b
sla b
- ld c,b
- ld b,$00
- add hl,bc ; hl = address of stat modifier ratio
+ ld c, b
+ ld b, $00
+ add hl, bc ; hl = address of stat modifier ratio
pop bc
- ld a,[hli]
- ld [H_MULTIPLIER],a ; set multiplier to the numerator of the ratio
+ ld a, [hli]
+ ld [H_MULTIPLIER], a ; set multiplier to the numerator of the ratio
call Multiply
- ld a,[hl]
- ld [H_DIVISOR],a ; set divisor to the the denominator of the ratio
+ ld a, [hl]
+ ld [H_DIVISOR], a ; set divisor to the the denominator of the ratio
; (the dividend is the product of the previous multiplication)
- ld b,$04 ; number of bytes in the dividend
+ ld b, $04 ; number of bytes in the dividend
call Divide
- ld a,[H_QUOTIENT + 3]
- ld b,a
- ld a,[H_QUOTIENT + 2]
+ ld a, [H_QUOTIENT + 3]
+ ld b, a
+ ld a, [H_QUOTIENT + 2]
or b
- jp nz,.nextCalculation
+ jp nz, .nextCalculation
; make sure the result is always at least one
- ld [H_QUOTIENT + 2],a
- ld a,$01
- ld [H_QUOTIENT + 3],a
+ ld [H_QUOTIENT + 2], a
+ ld a, $01
+ ld [H_QUOTIENT + 3], a
.nextCalculation
- ld b,c
+ ld b, c
dec d
- jr nz,.loop
- ld a,[H_QUOTIENT + 2]
+ jr nz, .loop
+ ld a, [H_QUOTIENT + 2]
and a ; is the calculated hit chance over 0xFF?
- ld a,[H_QUOTIENT + 3]
- jr z,.storeAccuracy
+ ld a, [H_QUOTIENT + 3]
+ jr z, .storeAccuracy
; if calculated hit chance over 0xFF
- ld a,$ff ; set the hit chance to 0xFF
+ ld a, $ff ; set the hit chance to 0xFF
.storeAccuracy
pop hl
- ld [hl],a ; store the hit chance in the move accuracy variable
+ ld [hl], a ; store the hit chance in the move accuracy variable
ret
; multiplies damage by a random percentage from ~85% to 100%
@@ -5841,9 +5841,9 @@ ExecuteEnemyMove:
jr nz, .executeEnemyMove
ld b, $1
ld a, [wSerialExchangeNybbleReceiveData]
- cp $e
+ cp LINKBATTLE_STRUGGLE
jr z, .executeEnemyMove
- cp $4
+ cp 4
ret nc
.executeEnemyMove
ld hl, wAILayer2Encouragement
@@ -5858,7 +5858,7 @@ ExecuteEnemyMove:
jp hl
.enemyHasNoSpecialConditions
ld hl, wEnemyBattleStatus1
- bit ChargingUp, [hl] ; is the enemy charging up for attack?
+ bit CHARGING_UP, [hl] ; is the enemy charging up for attack?
jr nz, EnemyCanExecuteChargingMove ; if so, jump
call GetCurrentMove
@@ -5871,8 +5871,8 @@ CheckIfEnemyNeedsToChargeUp:
jr EnemyCanExecuteMove
EnemyCanExecuteChargingMove:
ld hl, wEnemyBattleStatus1
- res ChargingUp, [hl] ; no longer charging up for attack
- res Invulnerable, [hl] ; no longer invulnerable to typical attacks
+ res CHARGING_UP, [hl] ; no longer charging up for attack
+ res INVULNERABLE, [hl] ; no longer invulnerable to typical attacks
ld a, [wEnemyMoveNum]
ld [wd0b5], a
ld a, BANK(MoveNames)
@@ -5940,7 +5940,7 @@ handleExplosionMiss:
playEnemyMoveAnimation:
push af
ld a, [wEnemyBattleStatus2]
- bit HasSubstituteUp, a ; does mon have a substitute?
+ bit HAS_SUBSTITUTE_UP, a ; does mon have a substitute?
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
@@ -5951,7 +5951,7 @@ playEnemyMoveAnimation:
call HandleExplodingAnimation
call DrawEnemyHUDAndHPBar
ld a, [wEnemyBattleStatus2]
- bit HasSubstituteUp, a ; does mon have a substitute?
+ bit HAS_SUBSTITUTE_UP, a ; does mon have a substitute?
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch ; slide the substitute's sprite out
@@ -5970,7 +5970,7 @@ EnemyCheckIfFlyOrChargeEffect:
.playAnim
xor a
ld [wAnimationType], a
- ld a,STATUS_AFFECTED_ANIM
+ ld a, STATUS_AFFECTED_ANIM
call PlayMoveAnimation
EnemyCheckIfMirrorMoveEffect:
ld a, [wEnemyMoveEffect]
@@ -6017,14 +6017,14 @@ EnemyCheckIfMirrorMoveEffect:
ret z
call HandleBuildingRage
ld hl, wEnemyBattleStatus1
- bit AttackingMultipleTimes, [hl] ; is mon hitting multiple times? (example: double kick)
+ bit ATTACKING_MULTIPLE_TIMES, [hl] ; is mon hitting multiple times? (example: double kick)
jr z, .notMultiHitMove
push hl
ld hl, wEnemyNumAttacksLeft
dec [hl]
pop hl
jp nz, GetEnemyAnimationType
- res AttackingMultipleTimes, [hl] ; mon is no longer hitting multiple times
+ res ATTACKING_MULTIPLE_TIMES, [hl] ; mon is no longer hitting multiple times
ld hl, HitXTimesText
call PrintText
xor a
@@ -6062,7 +6062,7 @@ CheckEnemyStatusConditions:
call PrintText
xor a
ld [wAnimationType], a
- ld a,SLP_ANIM
+ ld a, SLP_ANIM
call PlayMoveAnimation
jr .sleepDone
.wokeUp
@@ -6084,7 +6084,7 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL
.checkIfTrapped
ld a, [wPlayerBattleStatus1]
- bit UsingTrappingMove, a ; is the player using a multi-turn attack like warp
+ bit USING_TRAPPING_MOVE, a ; is the player using a multi-turn attack like warp
jp z, .checkIfFlinched
ld hl, CantMoveText
call PrintText
@@ -6092,18 +6092,18 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL
.checkIfFlinched
ld hl, wEnemyBattleStatus1
- bit Flinched, [hl] ; check if enemy mon flinched
+ bit FLINCHED, [hl] ; check if enemy mon flinched
jp z, .checkIfMustRecharge
- res Flinched, [hl]
+ res FLINCHED, [hl]
ld hl, FlinchedText
call PrintText
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL
.checkIfMustRecharge
ld hl, wEnemyBattleStatus2
- bit NeedsToRecharge, [hl] ; check if enemy mon has to recharge after using a move
+ bit NEEDS_TO_RECHARGE, [hl] ; check if enemy mon has to recharge after using a move
jr z, .checkIfAnyMoveDisabled
- res NeedsToRecharge, [hl]
+ res NEEDS_TO_RECHARGE, [hl]
ld hl, MustRechargeText
call PrintText
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
@@ -6129,7 +6129,7 @@ CheckEnemyStatusConditions:
dec [hl]
jr nz, .isConfused
ld hl, wEnemyBattleStatus1
- res Confused, [hl] ; if confused counter hit 0, reset confusion status
+ res CONFUSED, [hl] ; if confused counter hit 0, reset confusion status
ld hl, ConfusedNoMoreText
call PrintText
jp .checkIfTriedToUseDisabledMove
@@ -6138,14 +6138,14 @@ CheckEnemyStatusConditions:
call PrintText
xor a
ld [wAnimationType], a
- ld a,CONF_ANIM
+ ld a, CONF_ANIM
call PlayMoveAnimation
call BattleRandom
cp $80
jr c, .checkIfTriedToUseDisabledMove
ld hl, wEnemyBattleStatus1
ld a, [hl]
- and 1 << Confused ; if mon hurts itself, clear every other status from wEnemyBattleStatus1
+ and 1 << CONFUSED ; if mon hurts itself, clear every other status from wEnemyBattleStatus1
ld [hl], a
ld hl, HurtItselfText
call PrintText
@@ -6212,7 +6212,7 @@ CheckEnemyStatusConditions:
ld hl, wEnemyBattleStatus1
ld a, [hl]
; clear bide, thrashing about, charging up, and multi-turn moves such as warp
- and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
+ and $ff ^ ((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE))
ld [hl], a
ld a, [wEnemyMoveEffect]
cp FLY_EFFECT
@@ -6230,7 +6230,7 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL ; if using a two-turn move, enemy needs to recharge the first turn
.checkIfUsingBide
ld hl, wEnemyBattleStatus1
- bit StoringEnergy, [hl] ; is mon using bide?
+ bit STORING_ENERGY, [hl] ; is mon using bide?
jr z, .checkIfThrashingAbout
xor a
ld [wEnemyMoveNum], a
@@ -6252,7 +6252,7 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL ; unless mon unleashes energy, can't move this turn
.unleashEnergy
ld hl, wEnemyBattleStatus1
- res StoringEnergy, [hl] ; not using bide any more
+ res STORING_ENERGY, [hl] ; not using bide any more
ld hl, UnleashedEnergyText
call PrintText
ld a, $1
@@ -6279,7 +6279,7 @@ CheckEnemyStatusConditions:
ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .enemyReturnToHL
.checkIfThrashingAbout
- bit ThrashingAbout, [hl] ; is mon using thrash or petal dance?
+ bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance?
jr z, .checkIfUsingMultiturnMove
ld a, THRASH
ld [wEnemyMoveNum], a
@@ -6291,8 +6291,8 @@ CheckEnemyStatusConditions:
jp nz, .enemyReturnToHL
push hl
ld hl, wEnemyBattleStatus1
- res ThrashingAbout, [hl] ; mon is no longer using thrash or petal dance
- set Confused, [hl] ; mon is now confused
+ res THRASHING_ABOUT, [hl] ; mon is no longer using thrash or petal dance
+ set CONFUSED, [hl] ; mon is now confused
call BattleRandom
and $3
inc a
@@ -6301,7 +6301,7 @@ CheckEnemyStatusConditions:
pop hl ; skip DecrementPP
jp .enemyReturnToHL
.checkIfUsingMultiturnMove
- bit UsingTrappingMove, [hl] ; is mon using multi-turn move?
+ bit USING_TRAPPING_MOVE, [hl] ; is mon using multi-turn move?
jp z, .checkIfUsingRage
ld hl, AttackContinuesText
call PrintText
@@ -6313,7 +6313,7 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL
.checkIfUsingRage
ld a, [wEnemyBattleStatus2]
- bit UsingRage, a ; is mon using rage?
+ bit USING_RAGE, a ; is mon using rage?
jp z, .checkEnemyStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE
ld [wd11e], a
@@ -6371,7 +6371,7 @@ LoadEnemyMonData:
ld [wd0b5], a
call GetMonHeader
ld a, [wEnemyBattleStatus3]
- bit Transformed, a ; is enemy mon transformed?
+ bit TRANSFORMED, a ; is enemy mon transformed?
ld hl, wTransformedEnemyMonOriginalDVs ; original DVs before transforming
ld a, [hli]
ld b, [hl]
@@ -6403,7 +6403,7 @@ LoadEnemyMonData:
cp $2 ; is it a trainer battle?
jr z, .copyHPAndStatusFromPartyData
ld a, [wEnemyBattleStatus3]
- bit Transformed, a ; is enemy mon transformed?
+ bit TRANSFORMED, a ; is enemy mon transformed?
jr nz, .copyTypes ; if transformed, jump
; if it's a wild mon and not transformed, init the current HP to max HP and the status to 0
ld a, [wEnemyMonMaxHP]
@@ -6982,7 +6982,7 @@ HandleExplodingAnimation:
ret nz
.isExplodingMove
ld a, [de]
- bit Invulnerable, a ; fly/dig
+ bit INVULNERABLE, a ; fly/dig
ret nz
ld a, [hli]
cp GHOST
@@ -6997,7 +6997,7 @@ HandleExplodingAnimation:
ld [wAnimationType], a
PlayMoveAnimation:
- ld [wAnimationID],a
+ ld [wAnimationID], a
call Delay3
predef MoveAnimation
callab Func_78e98
@@ -7125,8 +7125,8 @@ SleepEffect:
.sleepEffect
ld a, [bc]
- bit NeedsToRecharge, a ; does the target need to recharge? (hyper beam)
- res NeedsToRecharge, a ; target no longer needs to recharge
+ bit NEEDS_TO_RECHARGE, a ; does the target need to recharge? (hyper beam)
+ res NEEDS_TO_RECHARGE, a ; target no longer needs to recharge
ld [bc], a
jr nz, .setSleepCounter ; if the target had to recharge, all hit tests will be skipped
; including the event where the target already has another status
@@ -7186,16 +7186,16 @@ PoisonEffect:
ld de, wEnemyMoveEffect
.poisonEffect
call CheckTargetSubstitute
- jr nz, .noEffect ; can't posion a substitute target
+ jr nz, .noEffect ; can't poison a substitute target
ld a, [hli]
ld b, a
and a
jr nz, .noEffect ; miss if target is already statused
ld a, [hli]
- cp POISON ; can't posion a poison-type target
+ cp POISON ; can't poison a poison-type target
jr z, .noEffect
ld a, [hld]
- cp POISON ; can't posion a poison-type target
+ cp POISON ; can't poison a poison-type target
jr z, .noEffect
ld a, [de]
cp POISON_SIDE_EFFECT1
@@ -7235,7 +7235,7 @@ PoisonEffect:
.ok
cp TOXIC
jr nz, .normalPoison ; done if move is not Toxic
- set BadlyPoisoned, [hl] ; else set Toxic battstatus
+ set BADLY_POISONED, [hl] ; else set Toxic battstatus
xor a
ld [de], a
ld hl, BadlyPoisonedText
@@ -7288,7 +7288,7 @@ ExplodeEffect:
inc hl
ld [hl], a ; set mon's status to 0
ld a, [de]
- res Seeded, a ; clear mon's leech seed status
+ res SEEDED, a ; clear mon's leech seed status
ld [de], a
ret
@@ -7326,7 +7326,7 @@ FreezeBurnParalyzeEffect:
ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance
jr c, .next1 ; branch ahead if this is a 10% chance effect..
ld b, $4d ; else use 0x4D/0x100 or 77/256 = 30.1%~ chance
- sub a, $1e ; subtract $1E to map to equivalent 10% chance effects
+ sub $1e ; subtract $1E to map to equivalent 10% chance effects
.next1
push af
call BattleRandom ; get random 8bit value for probability test
@@ -7334,9 +7334,9 @@ FreezeBurnParalyzeEffect:
pop bc
ret nc ; do nothing if random value is >= 1A or 4D [no status applied]
ld a, b ; what type of effect is this?
- cp a, BURN_SIDE_EFFECT1
+ cp BURN_SIDE_EFFECT1
jr z, .burn1
- cp a, FREEZE_SIDE_EFFECT
+ cp FREEZE_SIDE_EFFECT
jr z, .freeze1
; .paralyze
ld a, 1 << PAR
@@ -7388,7 +7388,7 @@ FreezeBurnParalyzeEffect:
ld b, $1a
jr c, .next2
ld b, $4d
- sub a, $1e
+ sub $1e
.next2
push af
call BattleRandom
@@ -7396,9 +7396,9 @@ FreezeBurnParalyzeEffect:
pop bc
ret nc
ld a, b
- cp a, BURN_SIDE_EFFECT1
+ cp BURN_SIDE_EFFECT1
jr z, .burn2
- cp a, FREEZE_SIDE_EFFECT
+ cp FREEZE_SIDE_EFFECT
jr z, .freeze2
ld a, 1 << PAR
ld [wBattleMonStatus], a
@@ -7433,16 +7433,16 @@ FrozenText:
CheckDefrost:
; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target
- and a, 1 << FRZ ; are they frozen?
+ and 1 << FRZ ; are they frozen?
ret z ; return if so
ld a, [H_WHOSETURN]
and a
jr nz, .opponent
;player [attacker]
ld a, [wPlayerMoveType]
- sub a, FIRE
+ sub FIRE
ret nz ; return if type of move used isn't fire
- ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster]
+ ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster]
ld hl, wEnemyMon1Status
ld a, [wEnemyMonPartyPos]
ld bc, wEnemyMon2 - wEnemyMon1
@@ -7452,8 +7452,8 @@ CheckDefrost:
ld hl, FireDefrostedText
jr .common
.opponent
- ld a, [wEnemyMoveType] ; same as above with addresses swapped
- sub a, FIRE
+ ld a, [wEnemyMoveType] ; same as above with addresses swapped
+ sub FIRE
ret nz
ld [wBattleMonStatus], a
ld hl, wPartyMon1Status
@@ -7594,7 +7594,7 @@ UpdateStatDone:
jr nz, .notMinimize
; if a substitute is up, slide off the substitute and show the mon pic before
; playing the minimize animation
- bit HasSubstituteUp, [hl]
+ bit HAS_SUBSTITUTE_UP, [hl]
push af
push bc
push de
@@ -7650,7 +7650,7 @@ MonsStatsRoseText:
ret
GreatlyRoseText:
- db $0a
+ TX_DELAY
TX_FAR _GreatlyRoseText
; fallthrough
RoseText:
@@ -7697,11 +7697,11 @@ StatModifierDownEffect:
and a
jp nz, MoveMissed
ld a, [bc]
- bit Invulnerable, a ; fly/dig
+ bit INVULNERABLE, a ; fly/dig
jp nz, MoveMissed
ld a, [de]
sub ATTACK_DOWN1_EFFECT
- cp EVASION_DOWN1_EFFECT + $3 - ATTACK_DOWN1_EFFECT ; covers al -1 effects
+ cp EVASION_DOWN1_EFFECT + $3 - ATTACK_DOWN1_EFFECT ; covers all -1 effects
jr c, .decrementStatMod
sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map -2 effects to corresponding -1 effect
.decrementStatMod
@@ -7855,7 +7855,7 @@ MonsStatsFellText:
ret
GreatlyFellText:
- db $0a
+ TX_DELAY
TX_FAR _GreatlyFellText
; fallthrough
FellText:
@@ -7913,7 +7913,7 @@ BideEffect:
ld de, wEnemyBideAccumulatedDamage
ld bc, wEnemyNumAttacksLeft
.bideEffect
- set StoringEnergy, [hl] ; mon is now using bide
+ set STORING_ENERGY, [hl] ; mon is now using bide
xor a
ld [de], a
inc de
@@ -7938,7 +7938,7 @@ ThrashPetalDanceEffect:
ld hl, wEnemyBattleStatus1
ld de, wEnemyNumAttacksLeft
.thrashPetalDanceEffect
- set ThrashingAbout, [hl] ; mon is now using thrash/petal dance
+ set THRASHING_ABOUT, [hl] ; mon is now using thrash/petal dance
call BattleRandom
and $1
inc a
@@ -7968,9 +7968,8 @@ SwitchAndTeleportEffect:
cp c ; get a random number between 0 and c
jr nc, .rejectionSampleLoop1
srl b
- srl b ; b = enemy level * 4
-; bug: does not account for overflow, so levels above 63 can lead to erroneousness results
- cp b ; is rand[0, playerLevel + enemyLevel] > enemyLevel?
+ srl b ; b = enemyLevel / 4
+ cp b ; is rand[0, playerLevel + enemyLevel) >= (enemyLevel / 4)?
jr nc, .playerMoveWasSuccessful ; if so, allow teleporting
ld c, 50
call DelayFrames
@@ -8075,9 +8074,9 @@ TwoToFiveAttacksEffect:
ld de, wEnemyNumAttacksLeft
ld bc, wEnemyNumHits
.twoToFiveAttacksEffect
- bit AttackingMultipleTimes, [hl] ; is mon attacking multiple times?
+ bit ATTACKING_MULTIPLE_TIMES, [hl] ; is mon attacking multiple times?
ret nz
- set AttackingMultipleTimes, [hl] ; mon is now attacking multiple times
+ set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times
ld hl, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
@@ -8133,7 +8132,7 @@ FlinchSideEffect:
call BattleRandom
cp b
ret nc
- set Flinched, [hl] ; set mon's status to flinching
+ set FLINCHED, [hl] ; set mon's status to flinching
call ClearHyperBeam
ret
@@ -8151,18 +8150,18 @@ ChargeEffect:
ld de, wEnemyMoveEffect
ld b, ANIM_AF
.chargeEffect
- set ChargingUp, [hl]
+ set CHARGING_UP, [hl]
ld a, [de]
dec de ; de contains enemy or player MOVENUM
cp FLY_EFFECT
jr nz, .notFly
- set Invulnerable, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
+ set INVULNERABLE, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
ld b, TELEPORT ; load Teleport's animation
.notFly
ld a, [de]
cp DIG
jr nz, .notDigOrFly
- set Invulnerable, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
+ set INVULNERABLE, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
ld b, ANIM_C0
.notDigOrFly
push de
@@ -8170,7 +8169,7 @@ ChargeEffect:
inc hl ; battle status 2
push hl
ld a, [hl]
- bit HasSubstituteUp, a
+ bit HAS_SUBSTITUTE_UP, a
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
@@ -8181,7 +8180,7 @@ ChargeEffect:
ld a, b
call PlayBattleAnimation
ld a, [hl]
- bit HasSubstituteUp, a
+ bit HAS_SUBSTITUTE_UP, a
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch
@@ -8248,11 +8247,11 @@ TrappingEffect:
ld hl, wEnemyBattleStatus1
ld de, wEnemyNumAttacksLeft
.trappingEffect
- bit UsingTrappingMove, [hl]
+ bit USING_TRAPPING_MOVE, [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
- set UsingTrappingMove, [hl] ; mon is now using a trapping move
+ set USING_TRAPPING_MOVE, [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
cp $2
@@ -8298,9 +8297,9 @@ ConfusionSideEffectSuccess:
ld bc, wPlayerConfusedCounter
ld a, [wEnemyMoveEffect]
.confuseTarget
- bit Confused, [hl] ; is mon confused?
+ bit CONFUSED, [hl] ; is mon confused?
jr nz, ConfusionEffectFailed
- set Confused, [hl] ; mon is now confused
+ set CONFUSED, [hl] ; mon is now confused
push af
call BattleRandom
and $3
@@ -8337,7 +8336,7 @@ HyperBeamEffect:
jr z, .hyperBeamEffect
ld hl, wEnemyBattleStatus2
.hyperBeamEffect
- set NeedsToRecharge, [hl] ; mon now needs to recharge
+ set NEEDS_TO_RECHARGE, [hl] ; mon now needs to recharge
ret
ClearHyperBeam:
@@ -8348,7 +8347,7 @@ ClearHyperBeam:
jr z, .playerTurn
ld hl, wPlayerBattleStatus2
.playerTurn
- res NeedsToRecharge, [hl] ; mon no longer needs to recharge
+ res NEEDS_TO_RECHARGE, [hl] ; mon no longer needs to recharge
pop hl
ret
@@ -8359,7 +8358,7 @@ RageEffect:
jr z, .player
ld hl, wEnemyBattleStatus2
.player
- set UsingRage, [hl] ; mon is now in "rage" mode
+ set USING_RAGE, [hl] ; mon is now in "rage" mode
ret
MimicEffect:
@@ -8380,7 +8379,7 @@ MimicEffect:
ld hl, wEnemyMonMoves
ld a, [wEnemyBattleStatus1]
.enemyTurn
- bit Invulnerable, a
+ bit INVULNERABLE, a
jr nz, .mimicMissed
.getRandomMove
push hl
@@ -8404,7 +8403,7 @@ MimicEffect:
jr .playerTurn
.letPlayerChooseMove
ld a, [wEnemyBattleStatus1]
- bit Invulnerable, a
+ bit INVULNERABLE, a
jr nz, .mimicMissed
ld a, [wCurrentMenuItem]
push af
@@ -8603,7 +8602,7 @@ CheckTargetSubstitute:
jr z, .next1
ld hl, wPlayerBattleStatus2
.next1
- bit HasSubstituteUp, [hl]
+ bit HAS_SUBSTITUTE_UP, [hl]
pop hl
ret
diff --git a/engine/battle/decrement_pp.asm b/engine/battle/decrement_pp.asm
index e23a85ba..b7c428f7 100644
--- a/engine/battle/decrement_pp.asm
+++ b/engine/battle/decrement_pp.asm
@@ -1,15 +1,15 @@
DecrementPP:
; after using a move, decrement pp in battle and (if not transformed?) in party
ld a, [de]
- cp a, STRUGGLE
+ cp STRUGGLE
ret z ; if the pokemon is using "struggle", there's nothing to do
; we don't decrement PP for "struggle"
ld hl, wPlayerBattleStatus1
ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the
; wPlayerBattleStatus2 status flags later
- and a, (1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << AttackingMultipleTimes)
+ and (1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << ATTACKING_MULTIPLE_TIMES)
ret nz ; if any of these statuses are true, don't decrement PP
- bit UsingRage, [hl]
+ bit USING_RAGE, [hl]
ret nz ; don't decrement PP either if Pokemon is using Rage
ld hl, wBattleMonPP ; PP of first move (in battle)
@@ -18,7 +18,7 @@ DecrementPP:
; decrement PP in the party struct
ld a, [wPlayerBattleStatus3]
- bit Transformed, a
+ bit TRANSFORMED, a
ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP
; separately from the "Pokemon in your party's" PP. This is
; duplication -- in all cases *other* than Pokemon with Transform.
diff --git a/engine/battle/display_effectiveness.asm b/engine/battle/display_effectiveness.asm
index 85f2bc3e..1bf14460 100644
--- a/engine/battle/display_effectiveness.asm
+++ b/engine/battle/display_effectiveness.asm
@@ -1,7 +1,7 @@
DisplayEffectiveness:
ld a, [wDamageMultipliers]
- and a, $7F
- cp a, $0A
+ and $7F
+ cp $0A
ret z
ld hl, SuperEffectiveText
jr nc, .done
diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm
index 8f9dce46..96294774 100644
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -194,7 +194,7 @@ SetupPlayerAndEnemyPokeballs:
ld hl, wOAMBuffer + $18
jp WritePokeballOAMData
-; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon)
+; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (fainted) and pokeball slot (no mon)
PokeballTileGraphics::
INCBIN "gfx/pokeball.2bpp"
PokeballTileGraphicsEnd:
diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm
index 47c9fa5d..5c0c3991 100755
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -50,7 +50,7 @@ EndOfBattle:
.resetVariables
xor a
ld [wLowHealthAlarm], a ;disable low health alarm
- ld [wChannelSoundIDs + CH4], a
+ ld [wChannelSoundIDs + Ch5], a
ld [wIsInBattle], a
ld [wBattleType], a
ld [wMoveMissed], a
diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm
index 9946c6c6..722685c2 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -119,11 +119,11 @@ GainExperience:
ld d, MAX_LEVEL
callab CalcExperience ; get max exp
; compare max exp with current exp
- ld a, [$ff96]
+ ld a, [hExperience]
ld b, a
- ld a, [$ff97]
+ ld a, [hExperience + 1]
ld c, a
- ld a, [$ff98]
+ ld a, [hExperience + 2]
ld d, a
pop hl
ld a, [hld]
@@ -378,5 +378,5 @@ ExpPointsText:
GrewLevelText:
TX_FAR _GrewLevelText
- db $0b
+ TX_SFX_LEVEL_UP
db "@"
diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm
index bdd5d8f4..7bc912d2 100644
--- a/engine/battle/init_battle_variables.asm
+++ b/engine/battle/init_battle_variables.asm
@@ -30,7 +30,7 @@ InitBattleVariables:
ld a, [wCurMap]
cp SAFARI_ZONE_EAST
jr c, .notSafariBattle
- cp SAFARI_ZONE_REST_HOUSE_1
+ cp SAFARI_ZONE_CENTER_REST_HOUSE
jr nc, .notSafariBattle
ld a, BATTLE_TYPE_SAFARI
ld [wBattleType], a
diff --git a/engine/battle/moveEffects/conversion_effect.asm b/engine/battle/moveEffects/conversion_effect.asm
index 9c347876..f23c3d70 100644
--- a/engine/battle/moveEffects/conversion_effect.asm
+++ b/engine/battle/moveEffects/conversion_effect.asm
@@ -11,7 +11,7 @@ ConversionEffect_:
pop de
ld a, [wPlayerBattleStatus1]
.conversionEffect
- bit Invulnerable, a ; is mon immune to typical attacks (dig/fly)
+ bit INVULNERABLE, a ; is mon immune to typical attacks (dig/fly)
jr nz, PrintButItFailedText
; copy target's types to user
ld a, [hli]
diff --git a/engine/battle/moveEffects/focus_energy_effect.asm b/engine/battle/moveEffects/focus_energy_effect.asm
index 9ba0ade0..16dad7bb 100644
--- a/engine/battle/moveEffects/focus_energy_effect.asm
+++ b/engine/battle/moveEffects/focus_energy_effect.asm
@@ -5,9 +5,9 @@ FocusEnergyEffect_:
jr z, .notEnemy
ld hl, wEnemyBattleStatus2
.notEnemy
- bit GettingPumped, [hl] ; is mon already using focus energy?
+ bit GETTING_PUMPED, [hl] ; is mon already using focus energy?
jr nz, .alreadyUsing
- set GettingPumped, [hl] ; mon is now using focus energy
+ set GETTING_PUMPED, [hl] ; mon is now using focus energy
callab PlayCurrentMoveAnimation
ld hl, GettingPumpedText
jp PrintText
@@ -17,6 +17,6 @@ FocusEnergyEffect_:
jpab PrintButItFailedText_
GettingPumpedText:
- db $0a
+ TX_DELAY
TX_FAR _GettingPumpedText
db "@"
diff --git a/engine/battle/moveEffects/haze_effect.asm b/engine/battle/moveEffects/haze_effect.asm
index bd20f231..47723ba2 100644
--- a/engine/battle/moveEffects/haze_effect.asm
+++ b/engine/battle/moveEffects/haze_effect.asm
@@ -12,6 +12,7 @@ HazeEffect_:
ld hl, wEnemyMonUnmodifiedAttack
ld de, wEnemyMonAttack
call ResetStats
+; cure non-volatile status, but only for the target
ld hl, wEnemyMonStatus
ld de, wEnemySelectedMove
ld a, [H_WHOSETURN]
@@ -46,15 +47,14 @@ HazeEffect_:
jp PrintText
CureVolatileStatuses:
-; only cures statuses of the Pokemon not using Haze
- res Confused, [hl]
+ res CONFUSED, [hl]
inc hl ; BATTSTATUS2
ld a, [hl]
- ; clear UsingXAccuracy, ProtectedByMist, GettingPumped, and Seeded statuses
- and $ff ^((1 << UsingXAccuracy) | (1 << ProtectedByMist) | (1 << GettingPumped) | (1 << Seeded))
+ ; clear USING_X_ACCURACY, PROTECTED_BY_MIST, GETTING_PUMPED, and SEEDED statuses
+ and $ff ^((1 << USING_X_ACCURACY) | (1 << PROTECTED_BY_MIST) | (1 << GETTING_PUMPED) | (1 << SEEDED))
ld [hli], a ; BATTSTATUS3
ld a, [hl]
- and %11110000 | (1 << Transformed) ; clear Bad Poison, Reflect and Light Screen statuses
+ and %11110000 | (1 << TRANSFORMED) ; clear Bad Poison, Reflect and Light Screen statuses
ld [hl], a
ret
diff --git a/engine/battle/moveEffects/heal_effect.asm b/engine/battle/moveEffects/heal_effect.asm
index 377c14c4..97afa394 100644
--- a/engine/battle/moveEffects/heal_effect.asm
+++ b/engine/battle/moveEffects/heal_effect.asm
@@ -76,7 +76,7 @@ HealEffect_:
ld a, [de]
sbc [hl]
jr c, .playAnim
-; copy max HP to current HP if an overflow ocurred
+; copy max HP to current HP if an overflow occurred
ld a, [hli]
ld [de], a
ld [wHPBarNewHP+1], a
diff --git a/engine/battle/moveEffects/leech_seed_effect.asm b/engine/battle/moveEffects/leech_seed_effect.asm
index 0f3a2666..f4d3ee9c 100644
--- a/engine/battle/moveEffects/leech_seed_effect.asm
+++ b/engine/battle/moveEffects/leech_seed_effect.asm
@@ -19,9 +19,9 @@ LeechSeedEffect_:
ld a, [de]
cp GRASS
jr z, .moveMissed
- bit Seeded, [hl]
+ bit SEEDED, [hl]
jr nz, .moveMissed
- set Seeded, [hl]
+ set SEEDED, [hl]
callab PlayCurrentMoveAnimation
ld hl, WasSeededText
jp PrintText
diff --git a/engine/battle/moveEffects/mist_effect.asm b/engine/battle/moveEffects/mist_effect.asm
index b92777de..65070a3e 100644
--- a/engine/battle/moveEffects/mist_effect.asm
+++ b/engine/battle/moveEffects/mist_effect.asm
@@ -5,9 +5,9 @@ MistEffect_:
jr z, .mistEffect
ld hl, wEnemyBattleStatus2
.mistEffect
- bit ProtectedByMist, [hl] ; is mon protected by mist?
+ bit PROTECTED_BY_MIST, [hl] ; is mon protected by mist?
jr nz, .mistAlreadyInUse
- set ProtectedByMist, [hl] ; mon is now protected by mist
+ set PROTECTED_BY_MIST, [hl] ; mon is now protected by mist
callab PlayCurrentMoveAnimation
ld hl, ShroudedInMistText
jp PrintText
diff --git a/engine/battle/moveEffects/recoil_effect.asm b/engine/battle/moveEffects/recoil_effect.asm
index 7fc90c44..0f2f087b 100644
--- a/engine/battle/moveEffects/recoil_effect.asm
+++ b/engine/battle/moveEffects/recoil_effect.asm
@@ -25,7 +25,7 @@ RecoilEffect_:
jr nz, .updateHP
inc c ; minimum recoil damage is 1
.updateHP
-; substract HP from user due to the recoil damage
+; subtract HP from user due to the recoil damage
ld a, [hli]
ld [wHPBarMaxHP+1], a
ld a, [hl]
diff --git a/engine/battle/moveEffects/reflect_light_screen_effect.asm b/engine/battle/moveEffects/reflect_light_screen_effect.asm
index f2165956..e5748b19 100644
--- a/engine/battle/moveEffects/reflect_light_screen_effect.asm
+++ b/engine/battle/moveEffects/reflect_light_screen_effect.asm
@@ -10,15 +10,15 @@ ReflectLightScreenEffect_:
ld a, [de]
cp LIGHT_SCREEN_EFFECT
jr nz, .reflect
- bit HasLightScreenUp, [hl] ; is mon already protected by light screen?
+ bit HAS_LIGHT_SCREEN_UP, [hl] ; is mon already protected by light screen?
jr nz, .moveFailed
- set HasLightScreenUp, [hl] ; mon is now protected by light screen
+ set HAS_LIGHT_SCREEN_UP, [hl] ; mon is now protected by light screen
ld hl, LightScreenProtectedText
jr .playAnim
.reflect
- bit HasReflectUp, [hl] ; is mon already protected by reflect?
+ bit HAS_REFLECT_UP, [hl] ; is mon already protected by reflect?
jr nz, .moveFailed
- set HasReflectUp, [hl] ; mon is now protected by reflect
+ set HAS_REFLECT_UP, [hl] ; mon is now protected by reflect
ld hl, ReflectGainedArmorText
.playAnim
push hl
diff --git a/engine/battle/moveEffects/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm
index 03314ebf..b5d006fc 100644
--- a/engine/battle/moveEffects/substitute_effect.asm
+++ b/engine/battle/moveEffects/substitute_effect.asm
@@ -12,7 +12,7 @@ SubstituteEffect_:
ld bc, wEnemyBattleStatus2
.notEnemy
ld a, [bc]
- bit HasSubstituteUp, a ; user already has substitute?
+ bit HAS_SUBSTITUTE_UP, a ; user already has substitute?
jr nz, .alreadyHasSubstitute
; quarter health to remove from user
; assumes max HP is 1023 or lower
@@ -37,13 +37,13 @@ SubstituteEffect_:
sbc 0
pop bc
jr c, .notEnoughHP ; underflow means user would be left with negative health
- ; bug: since it only brances on carry, it will possibly leave user with 0 HP
+ ; bug: since it only branches on carry, it will possibly leave user with 0 HP
.userHasZeroOrMoreHP
- ldi [hl], a ; save resulting HP after substraction into current HP
+ ldi [hl], a ; save resulting HP after subtraction into current HP
ld [hl], d
ld h, b
ld l, c
- set HasSubstituteUp, [hl]
+ set HAS_SUBSTITUTE_UP, [hl]
ld a, [wOptions]
bit 7, a ; battle animation is enabled?
ld hl, PlayCurrentMoveAnimation
diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm
index 2906de11..ec07b303 100644
--- a/engine/battle/moveEffects/transform_effect.asm
+++ b/engine/battle/moveEffects/transform_effect.asm
@@ -12,7 +12,7 @@ TransformEffect_:
ld [wPlayerMoveListIndex], a
ld a, [wPlayerBattleStatus1]
.hitTest
- bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig)
+ bit INVULNERABLE, a ; is mon invulnerable to typical attacks? (fly/dig)
jp nz, .failed
push hl
push de
@@ -24,7 +24,7 @@ TransformEffect_:
ld hl, wEnemyBattleStatus2
.transformEffect
; animation(s) played are different if target has Substitute up
- bit HasSubstituteUp, [hl]
+ bit HAS_SUBSTITUTE_UP, [hl]
push af
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
@@ -44,7 +44,7 @@ TransformEffect_:
call nz, Bankswitch
pop bc
ld a, [bc]
- set Transformed, a ; mon is now Transformed
+ set TRANSFORMED, a ; mon is now transformed
ld [bc], a
pop de
pop hl
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 3f10a85d..b4ee46a0 100755
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -1,43 +1,43 @@
ReadTrainer:
; don't change any moves in a link battle
- ld a,[wLinkState]
+ ld a, [wLinkState]
and a
ret nz
; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF
; XXX first is total enemy pokemon?
; XXX second is species of first pokemon?
- ld hl,wEnemyPartyCount
+ ld hl, wEnemyPartyCount
xor a
- ld [hli],a
+ ld [hli], a
dec a
- ld [hl],a
+ ld [hl], a
; get the pointer to trainer data for this class
- ld a,[wTrainerClass] ; get trainer class
+ ld a, [wTrainerClass] ; get trainer class
dec a
add a
- ld hl,TrainerDataPointers
- ld c,a
- ld b,0
- add hl,bc ; hl points to trainer class
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld a,[wTrainerNo]
- ld b,a
+ ld hl, TrainerDataPointers
+ ld c, a
+ ld b, 0
+ add hl, bc ; hl points to trainer class
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wTrainerNo]
+ ld b, a
; At this point b contains the trainer number,
; and hl points to the trainer class.
; Our next task is to iterate through the trainers,
; decrementing b each time, until we get to the right one.
.outer
dec b
- jr z,.IterateTrainer
+ jr z, .IterateTrainer
.inner
- ld a,[hli]
+ ld a, [hli]
and a
- jr nz,.inner
+ jr nz, .inner
jr .outer
; if the first byte of trainer data is FF,
@@ -46,17 +46,17 @@ ReadTrainer:
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
; else the first byte is the level of every pokemon on the team
.IterateTrainer
- ld a,[hli]
+ ld a, [hli]
cp $FF ; is the trainer special?
- jr z,.SpecialTrainer ; if so, check for special moves
- ld [wCurEnemyLVL],a
+ jr z, .SpecialTrainer ; if so, check for special moves
+ ld [wCurEnemyLVL], a
.LoopTrainerData
- ld a,[hli]
+ ld a, [hli]
and a ; have we reached the end of the trainer data?
jp z, .AddAdditionalMoveData
- ld [wcf91],a ; write species somewhere (XXX why?)
- ld a,ENEMY_PARTY_DATA
- ld [wMonDataLocation],a
+ ld [wcf91], a ; write species somewhere (XXX why?)
+ ld a, ENEMY_PARTY_DATA
+ ld [wMonDataLocation], a
push hl
call AddPartyMon
pop hl
@@ -66,14 +66,14 @@ ReadTrainer:
; - each pokemon has a specific level
; (as opposed to the whole team being of the same level)
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
- ld a,[hli]
+ ld a, [hli]
and a ; have we reached the end of the trainer data?
- jr z,.AddAdditionalMoveData
- ld [wCurEnemyLVL],a
- ld a,[hli]
- ld [wcf91],a
- ld a,ENEMY_PARTY_DATA
- ld [wMonDataLocation],a
+ jr z, .AddAdditionalMoveData
+ ld [wCurEnemyLVL], a
+ ld a, [hli]
+ ld [wcf91], a
+ ld a, ENEMY_PARTY_DATA
+ ld [wMonDataLocation], a
push hl
call AddPartyMon
pop hl
@@ -123,23 +123,23 @@ ReadTrainer:
.FinishUp
; clear wAmountMoneyWon addresses
xor a
- ld de,wAmountMoneyWon
- ld [de],a
+ ld de, wAmountMoneyWon
+ ld [de], a
inc de
- ld [de],a
+ ld [de], a
inc de
- ld [de],a
- ld a,[wCurEnemyLVL]
- ld b,a
+ ld [de], a
+ ld a, [wCurEnemyLVL]
+ ld b, a
.LastLoop
; update wAmountMoneyWon addresses (money to win) based on enemy's level
- ld hl,wTrainerBaseMoney + 1
- ld c,2 ; wAmountMoneyWon is a 3-byte number
+ ld hl, wTrainerBaseMoney + 1
+ ld c, 2 ; wAmountMoneyWon is a 3-byte number
push bc
predef AddBCDPredef
pop bc
inc de
inc de
dec b
- jr nz,.LastLoop ; repeat wCurEnemyLVL times
+ jr nz, .LastLoop ; repeat wCurEnemyLVL times
ret
diff --git a/engine/battle/safari_zone.asm b/engine/battle/safari_zone.asm
index c6c0fa80..88064f9a 100755
--- a/engine/battle/safari_zone.asm
+++ b/engine/battle/safari_zone.asm
@@ -19,7 +19,7 @@ PrintSafariZoneBattleText:
ld [wd0b5], a
call GetMonHeader
ld a, [wMonHCatchRate]
- ld [wEnemyMonCatchRate], a
+ ld [wEnemyMonActualCatchRate], a
pop hl
.asm_4138
push hl
diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm
index 7e2c911c..49d0429f 100644
--- a/engine/battle/save_trainer_name.asm
+++ b/engine/battle/save_trainer_name.asm
@@ -1,21 +1,21 @@
SaveTrainerName:
- ld hl,TrainerNamePointers
- ld a,[wTrainerClass]
+ ld hl, TrainerNamePointers
+ ld a, [wTrainerClass]
dec a
- ld c,a
- ld b,0
- add hl,bc
- add hl,bc
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld de,wcd6d
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wcd6d
.CopyCharacter
- ld a,[hli]
- ld [de],a
+ ld a, [hli]
+ ld [de], a
inc de
cp "@"
- jr nz,.CopyCharacter
+ jr nz, .CopyCharacter
ret
TrainerNamePointers:
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index ddaf1350..c8fdfb29 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -51,7 +51,7 @@ AIEnemyTrainerChooseMoves:
ld l, a
ld de, .nextMoveChoiceModification ; set return address
push de
- jp hl ; execute modification function
+ jp hl ; execute modification function
.loopFindMinimumEntries ; all entries will be decremented sequentially until one of them is zero
ld hl, wBuffer ; temp move selection array
ld de, wEnemyMonMoves ; enemy moves
@@ -114,7 +114,7 @@ AIMoveChoiceModification1:
ld a, [wBattleMonStatus]
and a
ret z ; return if no status ailment on player's mon
- ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest)
+ ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
ld de, wEnemyMonMoves ; enemy moves
ld b, NUM_MOVES + 1
.nextMove
@@ -154,7 +154,7 @@ StatusAilmentMoveEffects:
; slightly encourage moves with specific effects.
; in particular, stat-modifying moves and other move effects
-; that fall in-bewteen
+; that fall in-between
AIMoveChoiceModification2:
ld a, [wAILayer2Encouragement]
cp $1
@@ -212,7 +212,7 @@ AIMoveChoiceModification3:
cp $10
jr z, .nextMove
jr c, .notEffectiveMove
- dec [hl] ; sligthly encourage this move
+ dec [hl] ; slightly encourage this move
jr .nextMove
.notEffectiveMove ; discourages non-effective moves if better moves are available
push hl
@@ -253,7 +253,7 @@ AIMoveChoiceModification3:
pop hl
and a
jr z, .nextMove
- inc [hl] ; sligthly discourage this move
+ inc [hl] ; slightly discourage this move
jr .nextMove
AIMoveChoiceModification4:
ret
@@ -263,10 +263,10 @@ ReadMove:
push de
push bc
dec a
- ld hl,Moves
- ld bc,MoveEnd - Moves
+ ld hl, Moves
+ ld bc, MoveEnd - Moves
call AddNTimes
- ld de,wEnemyMoveNum
+ ld de, wEnemyMoveNum
call CopyData
pop bc
pop de
@@ -337,40 +337,40 @@ INCLUDE "data/trainer_moves.asm"
INCLUDE "data/trainer_parties.asm"
TrainerAI:
- ld a,[wIsInBattle]
+ ld a, [wIsInBattle]
dec a
jr z, .done ; if not a trainer, we're done here
- ld a,[wLinkState]
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .done ; if in a link battle, we're done as well
ld a, [wEnemyBattleStatus1]
- and 1 << ChargingUp | 1 << ThrashingAbout | 1 << StoringEnergy ; %10011
+ and 1 << CHARGING_UP | 1 << THRASHING_ABOUT | 1 << STORING_ENERGY ; %10011
jr nz, .done ; don't follow trainer ai if opponent is in a locked state
ld a, [wEnemyBattleStatus2]
- and 1 << UsingRage ; %1000000
+ and 1 << USING_RAGE ; %1000000
jr nz, .done ; don't follow trainer ai if opponent is locked in rage
; note that this doesn't check for hyper beam recharge which can cause problems
ld a,[wTrainerClass] ; what trainer class is this?
dec a
- ld c,a
- ld b,0
- ld hl,TrainerAIPointers
- add hl,bc
- add hl,bc
- add hl,bc
- ld a,[wAICount]
+ ld c, a
+ ld b, 0
+ ld hl, TrainerAIPointers
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ ld a, [wAICount]
and a
jr z, .done; if no AI uses left, we're done here
inc hl
inc a
- jr nz,.getpointer
+ jr nz, .getpointer
dec hl
- ld a,[hli]
- ld [wAICount],a
+ ld a, [hli]
+ ld [wAICount], a
.getpointer
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
call Random
jp hl
.done
@@ -451,17 +451,17 @@ CooltrainerMAI:
CooltrainerFAI:
cp 25 percent + 1
- ld a,10
+ ld a, 10
call AICheckIfHPBelowFraction
- jp c,AIUseHyperPotion
- ld a,5
+ jp c, AIUseHyperPotion
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AISwitchIfEnoughMons
BrockAI:
; if his active monster has a status condition, use a full heal
- ld a,[wEnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and a
ret z
jp AIUseFullHeal
@@ -479,7 +479,7 @@ LtSurgeAI:
ErikaAI:
cp 50 percent + 1
ret nc
- ld a,10
+ ld a, 10
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -492,7 +492,7 @@ KogaAI:
BlaineAI:
cp 25 percent + 1
ret nc
- ld a,10
+ ld a, 10
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -505,7 +505,7 @@ SabrinaAI:
Sony2AI:
cp 13 percent - 1
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUsePotion
@@ -513,7 +513,7 @@ Sony2AI:
Sony3AI:
cp 13 percent - 1
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseFullRestore
@@ -521,7 +521,7 @@ Sony3AI:
LoreleiAI:
cp 50 percent + 1
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -533,10 +533,10 @@ BrunoAI:
AgathaAI:
cp 8 percent
- jp c,AISwitchIfEnoughMons
+ jp c, AISwitchIfEnoughMons
cp 50 percent + 1
ret nc
- ld a,4
+ ld a, 4
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -544,7 +544,7 @@ AgathaAI:
LanceAI:
cp 50 percent + 1
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseHyperPotion
@@ -556,133 +556,133 @@ GenericAI:
; end of individual trainer AI routines
DecrementAICount:
- ld hl,wAICount
+ ld hl, wAICount
dec [hl]
scf
ret
AIPlayRestoringSFX:
- ld a,SFX_HEAL_AILMENT
+ ld a, SFX_HEAL_AILMENT
jp PlaySoundWaitForCurrent
AIUseFullRestore:
call AICureStatus
- ld a,FULL_RESTORE
- ld [wAIItem],a
- ld de,wHPBarOldHP
- ld hl,wEnemyMonHP + 1
- ld a,[hld]
- ld [de],a
+ ld a, FULL_RESTORE
+ ld [wAIItem], a
+ ld de, wHPBarOldHP
+ ld hl, wEnemyMonHP + 1
+ ld a, [hld]
+ ld [de], a
inc de
- ld a,[hl]
- ld [de],a
+ ld a, [hl]
+ ld [de], a
inc de
- ld hl,wEnemyMonMaxHP + 1
- ld a,[hld]
- ld [de],a
+ ld hl, wEnemyMonMaxHP + 1
+ ld a, [hld]
+ ld [de], a
inc de
- ld [wHPBarMaxHP],a
- ld [wEnemyMonHP + 1],a
- ld a,[hl]
- ld [de],a
- ld [wHPBarMaxHP+1],a
- ld [wEnemyMonHP],a
+ ld [wHPBarMaxHP], a
+ ld [wEnemyMonHP + 1], a
+ ld a, [hl]
+ ld [de], a
+ ld [wHPBarMaxHP+1], a
+ ld [wEnemyMonHP], a
jr AIPrintItemUseAndUpdateHPBar
AIUsePotion:
; enemy trainer heals his monster with a potion
- ld a,POTION
- ld b,20
+ ld a, POTION
+ ld b, 20
jr AIRecoverHP
AIUseSuperPotion:
; enemy trainer heals his monster with a super potion
- ld a,SUPER_POTION
- ld b,50
+ ld a, SUPER_POTION
+ ld b, 50
jr AIRecoverHP
AIUseHyperPotion:
; enemy trainer heals his monster with a hyper potion
- ld a,HYPER_POTION
- ld b,200
+ ld a, HYPER_POTION
+ ld b, 200
; fallthrough
AIRecoverHP:
; heal b HP and print "trainer used $(a) on pokemon!"
- ld [wAIItem],a
- ld hl,wEnemyMonHP + 1
- ld a,[hl]
- ld [wHPBarOldHP],a
+ ld [wAIItem], a
+ ld hl, wEnemyMonHP + 1
+ ld a, [hl]
+ ld [wHPBarOldHP], a
add b
- ld [hld],a
- ld [wHPBarNewHP],a
- ld a,[hl]
- ld [wHPBarOldHP+1],a
- ld [wHPBarNewHP+1],a
- jr nc,.next
+ ld [hld], a
+ ld [wHPBarNewHP], a
+ ld a, [hl]
+ ld [wHPBarOldHP+1], a
+ ld [wHPBarNewHP+1], a
+ jr nc, .next
inc a
- ld [hl],a
- ld [wHPBarNewHP+1],a
+ ld [hl], a
+ ld [wHPBarNewHP+1], a
.next
inc hl
- ld a,[hld]
- ld b,a
- ld de,wEnemyMonMaxHP + 1
- ld a,[de]
+ ld a, [hld]
+ ld b, a
+ ld de, wEnemyMonMaxHP + 1
+ ld a, [de]
dec de
- ld [wHPBarMaxHP],a
+ ld [wHPBarMaxHP], a
sub b
- ld a,[hli]
- ld b,a
- ld a,[de]
- ld [wHPBarMaxHP+1],a
+ ld a, [hli]
+ ld b, a
+ ld a, [de]
+ ld [wHPBarMaxHP+1], a
sbc b
- jr nc,AIPrintItemUseAndUpdateHPBar
+ jr nc, AIPrintItemUseAndUpdateHPBar
inc de
- ld a,[de]
+ ld a, [de]
dec de
- ld [hld],a
- ld [wHPBarNewHP],a
- ld a,[de]
- ld [hl],a
- ld [wHPBarNewHP+1],a
+ ld [hld], a
+ ld [wHPBarNewHP], a
+ ld a, [de]
+ ld [hl], a
+ ld [wHPBarNewHP+1], a
; fallthrough
AIPrintItemUseAndUpdateHPBar:
call AIPrintItemUse_
coord hl, 2, 2
xor a
- ld [wHPBarType],a
+ ld [wHPBarType], a
predef UpdateHPBar2
jp DecrementAICount
AISwitchIfEnoughMons:
; enemy trainer switches if there are 3 or more unfainted mons in party
- ld a,[wEnemyPartyCount]
- ld c,a
- ld hl,wEnemyMon1HP
+ ld a, [wEnemyPartyCount]
+ ld c, a
+ ld hl, wEnemyMon1HP
- ld d,0 ; keep count of unfainted monsters
+ ld d, 0 ; keep count of unfainted monsters
; count how many monsters haven't fainted yet
.loop
- ld a,[hli]
- ld b,a
- ld a,[hld]
+ ld a, [hli]
+ ld b, a
+ ld a, [hld]
or b
- jr z,.Fainted ; has monster fainted?
+ jr z, .Fainted ; has monster fainted?
inc d
.Fainted
push bc
ld bc, wEnemyMon2 - wEnemyMon1
- add hl,bc
+ add hl, bc
pop bc
dec c
- jr nz,.loop
+ jr nz, .loop
- ld a,d ; how many available monsters are there?
+ ld a, d ; how many available monsters are there?
cp 2 ; don't bother if only 1 or 2
- jp nc,SwitchEnemyMon
+ jp nc, SwitchEnemyMon
and a
ret
@@ -690,14 +690,14 @@ SwitchEnemyMon:
; prepare to withdraw the active monster: copy hp, number, and status to roster
- ld a,[wEnemyMonPartyPos]
- ld hl,wEnemyMon1HP
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld a, [wEnemyMonPartyPos]
+ ld hl, wEnemyMon1HP
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
- ld d,h
- ld e,l
- ld hl,wEnemyMonHP
- ld bc,4
+ ld d, h
+ ld e, l
+ ld hl, wEnemyMonHP
+ ld bc, 4
call CopyData
ld hl, AIBattleWithdrawText
@@ -705,13 +705,13 @@ SwitchEnemyMon:
; This wFirstMonsNotOutYet variable is abused to prevent the player from
; switching in a new mon in response to this switch.
- ld a,1
- ld [wFirstMonsNotOutYet],a
+ ld a, 1
+ ld [wFirstMonsNotOutYet], a
callab EnemySendOut
xor a
- ld [wFirstMonsNotOutYet],a
+ ld [wFirstMonsNotOutYet], a
- ld a,[wLinkState]
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z
scf
@@ -724,120 +724,120 @@ AIBattleWithdrawText:
AIUseFullHeal:
call AIPlayRestoringSFX
call AICureStatus
- ld a,FULL_HEAL
+ ld a, FULL_HEAL
jp AIPrintItemUse
AICureStatus:
; cures the status of enemy's active pokemon
- ld a,[wEnemyMonPartyPos]
- ld hl,wEnemyMon1Status
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld a, [wEnemyMonPartyPos]
+ ld hl, wEnemyMon1Status
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
xor a
- ld [hl],a ; clear status in enemy team roster
- ld [wEnemyMonStatus],a ; clear status of active enemy
- ld hl,wEnemyBattleStatus3
- res 0,[hl]
+ ld [hl], a ; clear status in enemy team roster
+ ld [wEnemyMonStatus], a ; clear status of active enemy
+ ld hl, wEnemyBattleStatus3
+ res 0, [hl]
ret
AIUseXAccuracy: ; unused
call AIPlayRestoringSFX
- ld hl,wEnemyBattleStatus2
- set 0,[hl]
- ld a,X_ACCURACY
+ ld hl, wEnemyBattleStatus2
+ set 0, [hl]
+ ld a, X_ACCURACY
jp AIPrintItemUse
AIUseGuardSpec:
call AIPlayRestoringSFX
- ld hl,wEnemyBattleStatus2
- set 1,[hl]
- ld a,GUARD_SPEC
+ ld hl, wEnemyBattleStatus2
+ set 1, [hl]
+ ld a, GUARD_SPEC
jp AIPrintItemUse
AIUseDireHit: ; unused
call AIPlayRestoringSFX
- ld hl,wEnemyBattleStatus2
- set 2,[hl]
- ld a,DIRE_HIT
+ ld hl, wEnemyBattleStatus2
+ set 2, [hl]
+ ld a, DIRE_HIT
jp AIPrintItemUse
AICheckIfHPBelowFraction:
; return carry if enemy trainer's current HP is below 1 / a of the maximum
- ld [H_DIVISOR],a
- ld hl,wEnemyMonMaxHP
- ld a,[hli]
- ld [H_DIVIDEND],a
- ld a,[hl]
- ld [H_DIVIDEND + 1],a
- ld b,2
+ ld [H_DIVISOR], a
+ ld hl, wEnemyMonMaxHP
+ ld a, [hli]
+ ld [H_DIVIDEND], a
+ ld a, [hl]
+ ld [H_DIVIDEND + 1], a
+ ld b, 2
call Divide
- ld a,[H_QUOTIENT + 3]
- ld c,a
- ld a,[H_QUOTIENT + 2]
- ld b,a
- ld hl,wEnemyMonHP + 1
- ld a,[hld]
- ld e,a
- ld a,[hl]
- ld d,a
- ld a,d
+ ld a, [H_QUOTIENT + 3]
+ ld c, a
+ ld a, [H_QUOTIENT + 2]
+ ld b, a
+ ld hl, wEnemyMonHP + 1
+ ld a, [hld]
+ ld e, a
+ ld a, [hl]
+ ld d, a
+ ld a, d
sub b
ret nz
- ld a,e
+ ld a, e
sub c
ret
AIUseXAttack:
- ld b,$A
- ld a,X_ATTACK
+ ld b, $A
+ ld a, X_ATTACK
jr AIIncreaseStat
AIUseXDefend:
- ld b,$B
- ld a,X_DEFEND
+ ld b, $B
+ ld a, X_DEFEND
jr AIIncreaseStat
AIUseXSpeed:
- ld b,$C
- ld a,X_SPEED
+ ld b, $C
+ ld a, X_SPEED
jr AIIncreaseStat
AIUseXSpecial:
- ld b,$D
- ld a,X_SPECIAL
+ ld b, $D
+ ld a, X_SPECIAL
; fallthrough
AIIncreaseStat:
- ld [wAIItem],a
+ ld [wAIItem], a
push bc
call AIPrintItemUse_
pop bc
- ld hl,wEnemyMoveEffect
- ld a,[hld]
+ ld hl, wEnemyMoveEffect
+ ld a, [hld]
push af
- ld a,[hl]
+ ld a, [hl]
push af
push hl
- ld a,ANIM_AF
- ld [hli],a
- ld [hl],b
+ ld a, ANIM_AF
+ ld [hli], a
+ ld [hl], b
callab StatModifierUpEffect
pop hl
pop af
- ld [hli],a
+ ld [hli], a
pop af
- ld [hl],a
+ ld [hl], a
jp DecrementAICount
AIPrintItemUse:
- ld [wAIItem],a
+ ld [wAIItem], a
call AIPrintItemUse_
jp DecrementAICount
AIPrintItemUse_:
; print "x used [wAIItem] on z!"
- ld a,[wAIItem]
- ld [wd11e],a
+ ld a, [wAIItem]
+ ld [wd11e], a
call GetItemName
ld hl, AIBattleUseItemText
jp PrintText