summaryrefslogtreecommitdiff
path: root/engine/battle
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle')
-rwxr-xr-xengine/battle/animations.asm1002
-rwxr-xr-xengine/battle/core.asm1852
-rw-r--r--engine/battle/decrement_pp.asm8
-rw-r--r--engine/battle/display_effectiveness.asm4
-rw-r--r--engine/battle/moveEffects/conversion_effect.asm2
-rw-r--r--engine/battle/moveEffects/focus_energy_effect.asm4
-rw-r--r--engine/battle/moveEffects/haze_effect.asm8
-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/reflect_light_screen_effect.asm8
-rw-r--r--engine/battle/moveEffects/substitute_effect.asm4
-rw-r--r--engine/battle/moveEffects/transform_effect.asm6
-rwxr-xr-xengine/battle/read_trainer_party.asm148
-rw-r--r--engine/battle/save_trainer_name.asm26
-rw-r--r--engine/battle/trainer_ai.asm326
15 files changed, 1703 insertions, 1703 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 1e400aa5..76d4f464 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -1,202 +1,202 @@
; Draws a "frame block". Frame blocks are blocks of tiles that are put
; together to form frames in battle animations.
DrawFrameBlock:
- ld l,c
- ld h,b
- ld a,[hli]
- ld [wNumFBTiles],a
- ld a,[wFBDestAddr + 1]
- ld e,a
- ld a,[wFBDestAddr]
- ld d,a
+ ld l, c
+ ld h, b
+ ld a, [hli]
+ ld [wNumFBTiles], a
+ ld a, [wFBDestAddr + 1]
+ ld e, a
+ ld a, [wFBDestAddr]
+ ld d, a
xor a
- ld [wFBTileCounter],a ; loop counter
+ ld [wFBTileCounter], a ; loop counter
.loop
- ld a,[wFBTileCounter]
+ ld a, [wFBTileCounter]
inc a
- ld [wFBTileCounter],a
- ld a,[wSubAnimTransform]
+ ld [wFBTileCounter], a
+ ld a, [wSubAnimTransform]
dec a
- jr z,.flipHorizontalAndVertical ; 1
+ jr z, .flipHorizontalAndVertical ; 1
dec a
- jp z,.flipHorizontalTranslateDown ; 2
+ jp z, .flipHorizontalTranslateDown ; 2
dec a
- jr z,.flipBaseCoords ; 3
+ jr z, .flipBaseCoords ; 3
.noTransformation
- ld a,[wBaseCoordY]
+ ld a, [wBaseCoordY]
add [hl]
- ld [de],a ; store Y
+ ld [de], a ; store Y
inc hl
inc de
- ld a,[wBaseCoordX]
+ ld a, [wBaseCoordX]
jr .finishCopying
.flipBaseCoords
- ld a,[wBaseCoordY]
- ld b,a
- ld a,136
+ ld a, [wBaseCoordY]
+ ld b, a
+ ld a, 136
sub b ; flip Y base coordinate
add [hl] ; Y offset
- ld [de],a ; store Y
+ ld [de], a ; store Y
inc hl
inc de
- ld a,[wBaseCoordX]
- ld b,a
- ld a,168
+ ld a, [wBaseCoordX]
+ ld b, a
+ ld a, 168
sub b ; flip X base coordinate
.finishCopying ; finish copying values to OAM (when [wSubAnimTransform] not 1 or 2)
add [hl] ; X offset
- ld [de],a ; store X
+ ld [de], a ; store X
inc hl
inc de
- ld a,[hli]
- add a,$31 ; base tile ID for battle animations
- ld [de],a ; store tile ID
+ ld a, [hli]
+ add $31 ; base tile ID for battle animations
+ ld [de], a ; store tile ID
inc de
- ld a,[hli]
- ld [de],a ; store flags
+ ld a, [hli]
+ ld [de], a ; store flags
inc de
jp .nextTile
.flipHorizontalAndVertical
- ld a,[wBaseCoordY]
+ ld a, [wBaseCoordY]
add [hl] ; Y offset
- ld b,a
- ld a,136
+ ld b, a
+ ld a, 136
sub b ; flip Y coordinate
- ld [de],a ; store Y
+ ld [de], a ; store Y
inc hl
inc de
- ld a,[wBaseCoordX]
+ ld a, [wBaseCoordX]
add [hl] ; X offset
- ld b,a
- ld a,168
+ ld b, a
+ ld a, 168
sub b ; flip X coordinate
- ld [de],a ; store X
+ ld [de], a ; store X
inc hl
inc de
- ld a,[hli]
- add a,$31 ; base tile ID for battle animations
- ld [de],a ; store tile ID
+ ld a, [hli]
+ add $31 ; base tile ID for battle animations
+ ld [de], a ; store tile ID
inc de
; toggle horizontal and vertical flip
- ld a,[hli] ; flags
+ ld a, [hli] ; flags
and a
- ld b,OAM_VFLIP | OAM_HFLIP
- jr z,.storeFlags1
- cp a,OAM_HFLIP
- ld b,OAM_VFLIP
- jr z,.storeFlags1
- cp a,OAM_VFLIP
- ld b,OAM_HFLIP
- jr z,.storeFlags1
- ld b,0
+ ld b, OAM_VFLIP | OAM_HFLIP
+ jr z, .storeFlags1
+ cp OAM_HFLIP
+ ld b, OAM_VFLIP
+ jr z, .storeFlags1
+ cp OAM_VFLIP
+ ld b, OAM_HFLIP
+ jr z, .storeFlags1
+ ld b, 0
.storeFlags1
- ld a,b
- ld [de],a
+ ld a, b
+ ld [de], a
inc de
jp .nextTile
.flipHorizontalTranslateDown
- ld a,[wBaseCoordY]
+ ld a, [wBaseCoordY]
add [hl]
- add a,40 ; translate Y coordinate downwards
- ld [de],a ; store Y
+ add 40 ; translate Y coordinate downwards
+ ld [de], a ; store Y
inc hl
inc de
- ld a,[wBaseCoordX]
+ ld a, [wBaseCoordX]
add [hl]
- ld b,a
- ld a,168
+ ld b, a
+ ld a, 168
sub b ; flip X coordinate
- ld [de],a ; store X
+ ld [de], a ; store X
inc hl
inc de
- ld a,[hli]
- add a,$31 ; base tile ID for battle animations
- ld [de],a ; store tile ID
+ ld a, [hli]
+ add $31 ; base tile ID for battle animations
+ ld [de], a ; store tile ID
inc de
- ld a,[hli]
- bit 5,a ; is horizontal flip enabled?
- jr nz,.disableHorizontalFlip
+ ld a, [hli]
+ bit 5, a ; is horizontal flip enabled?
+ jr nz, .disableHorizontalFlip
.enableHorizontalFlip
- set 5,a
+ set 5, a
jr .storeFlags2
.disableHorizontalFlip
- res 5,a
+ res 5, a
.storeFlags2
- ld [de],a
+ ld [de], a
inc de
.nextTile
- ld a,[wFBTileCounter]
- ld c,a
- ld a,[wNumFBTiles]
+ ld a, [wFBTileCounter]
+ ld c, a
+ ld a, [wNumFBTiles]
cp c
- jp nz,.loop ; go back up if there are more tiles to draw
+ jp nz, .loop ; go back up if there are more tiles to draw
.afterDrawingTiles
- ld a,[wFBMode]
- cp a,2
- jr z,.advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer
- ld a,[wSubAnimFrameDelay]
- ld c,a
+ ld a, [wFBMode]
+ 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
- jr z,.advanceFrameBlockDestAddr ; skip cleaning OAM buffer
- cp a,4
- jr z,.done ; skip cleaning OAM buffer and don't advance the frame block destination address
- ld a,[wAnimationID]
- cp a,GROWL
- jr z,.resetFrameBlockDestAddr
+ ld a, [wFBMode]
+ cp 3
+ jr z, .advanceFrameBlockDestAddr ; skip cleaning OAM buffer
+ cp 4
+ jr z, .done ; skip cleaning OAM buffer and don't advance the frame block destination address
+ ld a, [wAnimationID]
+ cp GROWL
+ jr z, .resetFrameBlockDestAddr
call AnimationCleanOAM
.resetFrameBlockDestAddr
- ld hl,wOAMBuffer ; OAM buffer
- ld a,l
- ld [wFBDestAddr + 1],a
- ld a,h
- ld [wFBDestAddr],a ; set destination address to beginning of OAM buffer
+ ld hl, wOAMBuffer ; OAM buffer
+ ld a, l
+ ld [wFBDestAddr + 1], a
+ ld a, h
+ ld [wFBDestAddr], a ; set destination address to beginning of OAM buffer
ret
.advanceFrameBlockDestAddr
- ld a,e
- ld [wFBDestAddr + 1],a
- ld a,d
- ld [wFBDestAddr],a
+ ld a, e
+ ld [wFBDestAddr + 1], a
+ ld a, d
+ ld [wFBDestAddr], a
.done
ret
PlayAnimation:
xor a
- ld [$FF8B],a ; it looks like nothing reads this
- ld [wSubAnimTransform],a
- ld a,[wAnimationID] ; get animation number
+ ld [$FF8B], a ; it looks like nothing reads this
+ ld [wSubAnimTransform], a
+ ld a, [wAnimationID] ; get animation number
dec a
- ld l,a
- ld h,0
- add hl,hl
- ld de,AttackAnimationPointers ; animation command stream pointers
- add hl,de
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, AttackAnimationPointers ; animation command stream pointers
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
.animationLoop
- ld a,[hli]
- cp a,$FF
- jr z,.AnimationOver
- cp a,$C0 ; is this subanimation or a special effect?
- jr c,.playSubanimation
+ ld a, [hli]
+ cp $FF
+ jr z, .AnimationOver
+ cp $C0 ; is this subanimation or a special effect?
+ jr c, .playSubanimation
.doSpecialEffect
- ld c,a
- ld de,SpecialEffectPointers
+ ld c, a
+ ld de, SpecialEffectPointers
.searchSpecialEffectTableLoop
- ld a,[de]
+ ld a, [de]
cp c
- jr z,.foundMatch
+ jr z, .foundMatch
inc de
inc de
inc de
jr .searchSpecialEffectTableLoop
.foundMatch
- ld a,[hli]
- cp a,$FF ; is there a sound to play?
- jr z,.skipPlayingSound
- ld [wAnimSoundID],a ; store sound
+ ld a, [hli]
+ cp $FF ; is there a sound to play?
+ jr z, .skipPlayingSound
+ ld [wAnimSoundID], a ; store sound
push hl
push de
call GetMoveSound
@@ -206,50 +206,50 @@ PlayAnimation:
.skipPlayingSound
push hl
inc de
- ld a,[de]
- ld l,a
+ ld a, [de]
+ ld l, a
inc de
- ld a,[de]
- ld h,a
- ld de,.nextAnimationCommand
+ ld a, [de]
+ ld h, a
+ ld de, .nextAnimationCommand
push de
jp hl ; jump to special effect function
.playSubanimation
- ld c,a
- and a,%00111111
- ld [wSubAnimFrameDelay],a
+ ld c, a
+ and %00111111
+ ld [wSubAnimFrameDelay], a
xor a
sla c
rla
sla c
rla
- ld [wWhichBattleAnimTileset],a
- ld a,[hli] ; sound
- ld [wAnimSoundID],a ; store sound
- ld a,[hli] ; subanimation ID
- ld c,l
- ld b,h
- ld l,a
- ld h,0
- add hl,hl
- ld de,SubanimationPointers
- add hl,de
- ld a,l
- ld [wSubAnimAddrPtr],a
- ld a,h
- ld [wSubAnimAddrPtr + 1],a
- ld l,c
- ld h,b
+ ld [wWhichBattleAnimTileset], a
+ ld a, [hli] ; sound
+ ld [wAnimSoundID], a ; store sound
+ ld a, [hli] ; subanimation ID
+ ld c, l
+ ld b, h
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, SubanimationPointers
+ add hl, de
+ ld a, l
+ ld [wSubAnimAddrPtr], a
+ ld a, h
+ ld [wSubAnimAddrPtr + 1], a
+ ld l, c
+ ld h, b
push hl
- ld a,[rOBP0]
+ ld a, [rOBP0]
push af
- ld a,[wAnimPalette]
- ld [rOBP0],a
+ ld a, [wAnimPalette]
+ ld [rOBP0], a
call LoadAnimationTileset
call LoadSubanimation
call PlaySubanimation
pop af
- ld [rOBP0],a
+ ld [rOBP0], a
.nextAnimationCommand
pop hl
jr .animationLoop
@@ -257,22 +257,22 @@ PlayAnimation:
ret
LoadSubanimation:
- ld a,[wSubAnimAddrPtr + 1]
- ld h,a
- ld a,[wSubAnimAddrPtr]
- ld l,a
- ld a,[hli]
- ld e,a
- ld a,[hl]
- ld d,a ; de = address of subanimation
- ld a,[de]
- ld b,a
- and a,31
- ld [wSubAnimCounter],a ; number of frame blocks
- ld a,b
- and a,%11100000
- cp a,5 << 5 ; is subanimation type 5?
- jr nz,.isNotType5
+ ld a, [wSubAnimAddrPtr + 1]
+ ld h, a
+ ld a, [wSubAnimAddrPtr]
+ ld l, a
+ ld a, [hli]
+ ld e, a
+ ld a, [hl]
+ ld d, a ; de = address of subanimation
+ ld a, [de]
+ ld b, a
+ and 31
+ ld [wSubAnimCounter], a ; number of frame blocks
+ ld a, b
+ and %11100000
+ cp 5 << 5 ; is subanimation type 5?
+ jr nz, .isNotType5
.isType5
call GetSubanimationTransform2
jr .saveTransformation
@@ -282,35 +282,35 @@ LoadSubanimation:
; place the upper 3 bits of a into bits 0-2 of a before storing
srl a
swap a
- ld [wSubAnimTransform],a
- cp a,4 ; is the animation reversed?
- ld hl,0
- jr nz,.storeSubentryAddr
+ ld [wSubAnimTransform], a
+ 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
- ld a,[wSubAnimCounter]
+ ld a, [wSubAnimCounter]
dec a
- ld bc,3
+ ld bc, 3
.loop
- add hl,bc
+ add hl, bc
dec a
- jr nz,.loop
+ jr nz, .loop
.storeSubentryAddr
inc de
- add hl,de
- ld a,l
- ld [wSubAnimSubEntryAddr],a
- ld a,h
- ld [wSubAnimSubEntryAddr + 1],a
+ add hl, de
+ ld a, l
+ ld [wSubAnimSubEntryAddr], a
+ ld a, h
+ ld [wSubAnimSubEntryAddr + 1], a
ret
; called if the subanimation type is not 5
; sets the transform to 0 (i.e. no transform) if it's the player's turn
; sets the transform to the subanimation type if it's the enemy's turn
GetSubanimationTransform1:
- ld b,a
- ld a,[H_WHOSETURN]
+ ld b, a
+ ld a, [H_WHOSETURN]
and a
- ld a,b
+ ld a, b
ret nz
xor a
ret
@@ -319,32 +319,32 @@ GetSubanimationTransform1:
; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn
; sets the transform to 0 (i.e. no transform) if it's the enemy's turn
GetSubanimationTransform2:
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
- ld a,2 << 5
+ ld a, 2 << 5
ret z
xor a
ret
; loads tile patterns for battle animations
LoadAnimationTileset:
- ld a,[wWhichBattleAnimTileset]
+ ld a, [wWhichBattleAnimTileset]
add a
add a
- ld hl,AnimationTilesetPointers
- ld e,a
- ld d,0
- add hl,de
- ld a,[hli]
- ld [wTempTilesetNumTiles],a ; number of tiles
- ld a,[hli]
- ld e,a
- ld a,[hl]
- ld d,a ; de = address of tileset
- ld hl,vSprites + $310
+ ld hl, AnimationTilesetPointers
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld a, [hli]
+ ld [wTempTilesetNumTiles], a ; number of tiles
+ ld a, [hli]
+ ld e, a
+ ld a, [hl]
+ ld d, a ; de = address of tileset
+ ld hl, vSprites + $310
ld b, BANK(AnimationTileset1) ; ROM bank
- ld a,[wTempTilesetNumTiles]
- ld c,a ; number of tiles
+ ld a, [wTempTilesetNumTiles]
+ ld c, a ; number of tiles
jp CopyVideoData ; load tileset
AnimationTilesetPointers:
@@ -381,12 +381,12 @@ MoveAnimation:
push af
call WaitForSoundToFinish
call SetAnimationPalette
- ld a,[wAnimationID]
+ ld a, [wAnimationID]
and a
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
@@ -394,25 +394,25 @@ MoveAnimation:
.moveAnimation
; check if battle animations are disabled in the options
- ld a,[wOptions]
- bit 7,a
+ ld a, [wOptions]
+ bit 7, a
jr nz, .animationsDisabled
call ShareMoveAnimations
call PlayAnimation
jr .next4
.animationsDisabled
- ld c,30
+ ld c, 30
call DelayFrames
.next4
call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)
.animationFinished
call WaitForSoundToFinish
xor a
- ld [wSubAnimSubEntryAddr],a
- ld [wUnusedD09B],a
- ld [wSubAnimTransform],a
+ ld [wSubAnimSubEntryAddr], a
+ ld [wUnusedD09B], a
+ ld [wSubAnimTransform], a
dec a
- ld [wAnimSoundID],a
+ ld [wAnimSoundID], a
pop af
pop bc
pop de
@@ -421,42 +421,42 @@ MoveAnimation:
ShareMoveAnimations:
; some moves just reuse animations from status conditions
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
ret z
; opponent’s turn
- ld a,[wAnimationID]
+ ld a, [wAnimationID]
- cp a,AMNESIA
- ld b,CONF_ANIM
+ cp AMNESIA
+ ld b, CONF_ANIM
jr z, .replaceAnim
- cp a,REST
- ld b,SLP_ANIM
+ cp REST
+ ld b, SLP_ANIM
ret nz
.replaceAnim
- ld a,b
- ld [wAnimationID],a
+ ld a, b
+ ld [wAnimationID], a
ret
PlayApplyingAttackAnimation:
; Generic animation that shows after the move's individual animation
; Different animation depending on whether the move has an additional effect and on whose turn it is
- ld a,[wAnimationType]
+ ld a, [wAnimationType]
and a
ret z
dec a
add a
- ld c,a
- ld b,0
- ld hl,AnimationTypePointerTable
- add hl,bc
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld c, a
+ ld b, 0
+ ld hl, AnimationTypePointerTable
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
jp hl
AnimationTypePointerTable:
@@ -547,69 +547,69 @@ SetAnimationPalette:
ret
PlaySubanimation:
- ld a,[wAnimSoundID]
- cp a,$FF
- jr z,.skipPlayingSound
+ ld a, [wAnimSoundID]
+ cp $FF
+ jr z, .skipPlayingSound
call GetMoveSound
call PlaySound
.skipPlayingSound
- ld hl,wOAMBuffer ; base address of OAM buffer
- ld a,l
- ld [wFBDestAddr + 1],a
- ld a,h
- ld [wFBDestAddr],a
- ld a,[wSubAnimSubEntryAddr + 1]
- ld h,a
- ld a,[wSubAnimSubEntryAddr]
- ld l,a
+ ld hl, wOAMBuffer ; base address of OAM buffer
+ ld a, l
+ ld [wFBDestAddr + 1], a
+ ld a, h
+ ld [wFBDestAddr], a
+ ld a, [wSubAnimSubEntryAddr + 1]
+ ld h, a
+ ld a, [wSubAnimSubEntryAddr]
+ ld l, a
.loop
push hl
- ld c,[hl] ; frame block ID
- ld b,0
- ld hl,FrameBlockPointers
- add hl,bc
- add hl,bc
- ld a,[hli]
- ld c,a
- ld a,[hli]
- ld b,a
+ ld c, [hl] ; frame block ID
+ ld b, 0
+ ld hl, FrameBlockPointers
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld c, a
+ ld a, [hli]
+ ld b, a
pop hl
inc hl
push hl
- ld e,[hl] ; base coordinate ID
- ld d,0
- ld hl,FrameBlockBaseCoords ; base coordinate table
- add hl,de
- add hl,de
- ld a,[hli]
- ld [wBaseCoordY],a
- ld a,[hl]
- ld [wBaseCoordX],a
+ ld e, [hl] ; base coordinate ID
+ ld d, 0
+ ld hl, FrameBlockBaseCoords ; base coordinate table
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld [wBaseCoordY], a
+ ld a, [hl]
+ ld [wBaseCoordX], a
pop hl
inc hl
- ld a,[hl] ; frame block mode
- ld [wFBMode],a
+ ld a, [hl] ; frame block mode
+ ld [wFBMode], a
call DrawFrameBlock
call DoSpecialEffectByAnimationId ; run animation-specific function (if there is one)
- ld a,[wSubAnimCounter]
+ ld a, [wSubAnimCounter]
dec a
- ld [wSubAnimCounter],a
+ ld [wSubAnimCounter], a
ret z
- ld a,[wSubAnimSubEntryAddr + 1]
- ld h,a
- ld a,[wSubAnimSubEntryAddr]
- ld l,a
- ld a,[wSubAnimTransform]
- cp a,4 ; is the animation reversed?
- ld bc,3
- jr nz,.nextSubanimationSubentry
- ld bc,-3
+ ld a, [wSubAnimSubEntryAddr + 1]
+ ld h, a
+ ld a, [wSubAnimSubEntryAddr]
+ ld l, a
+ ld a, [wSubAnimTransform]
+ cp 4 ; is the animation reversed?
+ ld bc, 3
+ jr nz, .nextSubanimationSubentry
+ ld bc, -3
.nextSubanimationSubentry
- add hl,bc
- ld a,h
- ld [wSubAnimSubEntryAddr + 1],a
- ld a,l
- ld [wSubAnimSubEntryAddr],a
+ add hl, bc
+ ld a, h
+ ld [wSubAnimSubEntryAddr + 1], a
+ ld a, l
+ ld [wSubAnimSubEntryAddr], a
jp .loop
AnimationCleanOAM:
@@ -631,16 +631,16 @@ DoSpecialEffectByAnimationId:
push hl
push de
push bc
- ld a,[wAnimationID]
- ld hl,AnimationIdSpecialEffects
- ld de,3
+ ld a, [wAnimationID]
+ ld hl, AnimationIdSpecialEffects
+ ld de, 3
call IsInArray
- jr nc,.done
+ jr nc, .done
inc hl
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld de,.done
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, .done
push de
jp hl
.done
@@ -726,38 +726,38 @@ AnimationIdSpecialEffects:
db $FF ; terminator
DoBallTossSpecialEffects:
- ld a,[wcf91]
- cp a,3 ; is it a Master Ball or Ultra Ball?
- jr nc,.skipFlashingEffect
+ ld a, [wcf91]
+ 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
- ld [rOBP0],a
+ ld a, [rOBP0]
+ xor %00111100 ; complement colors 1 and 2
+ ld [rOBP0], a
.skipFlashingEffect
- ld a,[wSubAnimCounter]
- cp a,11 ; is it the beginning of the subanimation?
- jr nz,.skipPlayingSound
+ ld a, [wSubAnimCounter]
+ 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
+ ld a, SFX_BALL_TOSS
call PlaySound
.skipPlayingSound
- ld a,[wIsInBattle]
- cp a,02 ; is it a trainer battle?
- jr z,.isTrainerBattle
- ld a,[wd11e]
- cp a,$10 ; is the enemy pokemon the Ghost Marowak?
+ ld a, [wIsInBattle]
+ cp 02 ; is it a trainer battle?
+ jr z, .isTrainerBattle
+ ld a, [wd11e]
+ 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
- jr z,.moveGhostMarowakLeft
- cp a,2
- jr z,.moveGhostMarowakLeft
- cp a,1
+ ld a, [wSubAnimCounter]
+ cp 3
+ jr z, .moveGhostMarowakLeft
+ cp 2
+ jr z, .moveGhostMarowakLeft
+ cp 1
ret nz
.moveGhostMarowakLeft
coord hl, 17, 0
- ld de,20
+ ld de, 20
lb bc, 7, 7
.loop
push hl
@@ -765,152 +765,152 @@ DoBallTossSpecialEffects:
call AnimCopyRowRight ; move row of tiles left
pop bc
pop hl
- add hl,de
+ add hl, de
dec b
- jr nz,.loop
- ld a,%00001000
- ld [rNR10],a ; Channel 1 sweep register
+ jr nz, .loop
+ ld a, %00001000
+ ld [rNR10], a ; Channel 1 sweep register
ret
.isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame
- ld a,[wSubAnimCounter]
- cp a,3
+ ld a, [wSubAnimCounter]
+ cp 3
ret nz
dec a
- ld [wSubAnimCounter],a
+ ld [wSubAnimCounter], a
ret
DoBallShakeSpecialEffects:
- ld a,[wSubAnimCounter]
- cp a,4 ; is it the beginning of a shake?
- jr nz,.skipPlayingSound
+ ld a, [wSubAnimCounter]
+ 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
+ ld a, SFX_TINK
call PlaySound
- ld c,40
+ ld c, 40
call DelayFrames
.skipPlayingSound
- ld a,[wSubAnimCounter]
+ ld a, [wSubAnimCounter]
dec a
ret nz
; if it's the end of the ball shaking subanimation, check if more shakes are left and restart the subanimation
- ld a,[wNumShakes] ; number of shakes
+ ld a, [wNumShakes] ; number of shakes
dec a ; decrement number of shakes
- ld [wNumShakes],a
+ ld [wNumShakes], a
ret z
; if there are shakes left, restart the subanimation
- ld a,[wSubAnimSubEntryAddr]
- ld l,a
- ld a,[wSubAnimSubEntryAddr + 1]
- ld h,a
- ld de,-(4 * 3) ; 4 subentries and 3 bytes per subentry
- add hl,de
- ld a,l
- ld [wSubAnimSubEntryAddr],a
- ld a,h
- ld [wSubAnimSubEntryAddr + 1],a
- ld a,5 ; number of subentries in the ball shaking subanimation plus one
- ld [wSubAnimCounter],a
+ ld a, [wSubAnimSubEntryAddr]
+ ld l, a
+ ld a, [wSubAnimSubEntryAddr + 1]
+ ld h, a
+ ld de, -(4 * 3) ; 4 subentries and 3 bytes per subentry
+ add hl, de
+ ld a, l
+ ld [wSubAnimSubEntryAddr], a
+ ld a, h
+ ld [wSubAnimSubEntryAddr + 1], a
+ ld a, 5 ; number of subentries in the ball shaking subanimation plus one
+ ld [wSubAnimCounter], a
ret
; plays a sound after the second frame of the poof animation
DoPoofSpecialEffects:
- ld a,[wSubAnimCounter]
- cp a,5
+ ld a, [wSubAnimCounter]
+ cp 5
ret nz
- ld a,SFX_BALL_POOF
+ ld a, SFX_BALL_POOF
jp PlaySound
DoRockSlideSpecialEffects:
- ld a,[wSubAnimCounter]
- cp a,12
+ ld a, [wSubAnimCounter]
+ cp 12
ret nc
- cp a,8
- jr nc,.shakeScreen
- cp a,1
- jp z,AnimationFlashScreen ; if it's the end of the subanimation, flash the screen
+ cp 8
+ jr nc, .shakeScreen
+ cp 1
+ jp z, AnimationFlashScreen ; if it's the end of the subanimation, flash the screen
ret
; if the subanimation counter is between 8 and 11, shake the screen horizontally and vertically
.shakeScreen
- ld b,1
+ ld b, 1
predef PredefShakeScreenHorizontally ; shake horizontally
- ld b,1
+ ld b, 1
predef_jump PredefShakeScreenVertically ; shake vertically
FlashScreenEveryEightFrameBlocks:
- ld a,[wSubAnimCounter]
- and a,7 ; is the subanimation counter exactly 8?
- call z,AnimationFlashScreen ; if so, flash the screen
+ ld a, [wSubAnimCounter]
+ 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
- call z,AnimationFlashScreen
+ ld a, [wSubAnimCounter]
+ 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?
- jr nz,FlashScreenEveryFourFrameBlocks
+ ld a, [wSubAnimCounter]
+ 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
jp AnimationHideMonPic ; make pokemon disappear
; flashes the screen when subanimation counter is 1 modulo 4
DoBlizzardSpecialEffects:
- ld a,[wSubAnimCounter]
- cp a,13
- jp z,AnimationFlashScreen
- cp a,9
- jp z,AnimationFlashScreen
- cp a,5
- jp z,AnimationFlashScreen
- cp a,1
- jp z,AnimationFlashScreen
+ ld a, [wSubAnimCounter]
+ cp 13
+ jp z, AnimationFlashScreen
+ cp 9
+ jp z, AnimationFlashScreen
+ cp 5
+ jp z, AnimationFlashScreen
+ cp 1
+ jp z, AnimationFlashScreen
ret
; flashes the screen at 3 points in the subanimation
; unused
FlashScreenUnused:
- ld a,[wSubAnimCounter]
- cp a,14
- jp z,AnimationFlashScreen
- cp a,9
- jp z,AnimationFlashScreen
- cp a,2
- jp z,AnimationFlashScreen
+ ld a, [wSubAnimCounter]
+ cp 14
+ jp z, AnimationFlashScreen
+ cp 9
+ jp z, AnimationFlashScreen
+ 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
+ ld a, [wSubAnimCounter]
+ cp 6
ret nz
- ld a,2 * SCREEN_WIDTH + 7
+ ld a, 2 * SCREEN_WIDTH + 7
jp ClearMonPicFromTileMap ; make pokemon disappear
; function to make a shaking pokeball jump up at the end of the animation
TradeShakePokeball:
- ld a,[wSubAnimCounter]
- cp a,1
+ ld a, [wSubAnimCounter]
+ cp 1
ret nz
; if it's the end of the animation, make the ball jump up
- ld de,BallMoveDistances1
+ ld de, BallMoveDistances1
.loop
- ld hl,wOAMBuffer ; OAM buffer
- ld bc,4
+ ld hl, wOAMBuffer ; OAM buffer
+ ld bc, 4
.innerLoop
- ld a,[de]
- cp a,$ff
- jr z,.done
+ ld a, [de]
+ 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
- jr nz,.innerLoop
+ ld [hl], a
+ add hl, bc
+ ld a, l
+ cp 4 * 4 ; there are 4 entries, each 4 bytes
+ jr nz, .innerLoop
inc de
push bc
call Delay3
@@ -918,7 +918,7 @@ TradeShakePokeball:
jr .loop
.done
call AnimationCleanOAM
- ld a,SFX_TRADE_MACHINE
+ ld a, SFX_TRADE_MACHINE
jp PlaySound
BallMoveDistances1:
@@ -927,38 +927,38 @@ BallMoveDistances1:
; function to make the pokeball jump up
TradeJumpPokeball:
- ld de,BallMoveDistances2
+ ld de, BallMoveDistances2
.loop
- ld hl,wOAMBuffer ; OAM buffer
- ld bc,4
+ ld hl, wOAMBuffer ; OAM buffer
+ ld bc, 4
.innerLoop
- ld a,[de]
- cp a,$ff
- jp z,ClearScreen
+ ld a, [de]
+ 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
- jr nz,.innerLoop
+ ld [hl], a
+ add hl, bc
+ ld a, l
+ cp 4 * 4 ; there are 4 entries, each 4 bytes
+ jr nz, .innerLoop
inc de
push de
- ld a,[de]
- cp a,12
- jr z,.playSound
- cp a,$ff
- jr nz,.skipPlayingSound
+ ld a, [de]
+ cp 12
+ jr z, .playSound
+ 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
+ ld a, SFX_BATTLE_18
call PlaySound
.skipPlayingSound
push bc
- ld c,5
+ ld c, 5
call DelayFrames
pop bc
- ld a,[hSCX] ; background scroll X
- sub a,8 ; scroll to the left
- ld [hSCX],a
+ ld a, [hSCX] ; background scroll X
+ sub 8 ; scroll to the left
+ ld [hSCX], a
pop de
jr .loop
@@ -969,20 +969,20 @@ BallMoveDistances2:
; this function copies the current musical note graphic
; so that there are two musical notes flying towards the defending pokemon
DoGrowlSpecialEffects:
- ld hl,wOAMBuffer ; OAM buffer
- ld de,wOAMBuffer + $10
- ld bc,$10
+ ld hl, wOAMBuffer ; OAM buffer
+ ld de, wOAMBuffer + $10
+ ld bc, $10
call CopyData ; copy the musical note graphic
- ld a,[wSubAnimCounter]
+ ld a, [wSubAnimCounter]
dec a
- call z,AnimationCleanOAM ; clean up at the end of the subanimation
+ call z, AnimationCleanOAM ; clean up at the end of the subanimation
ret
; this is associated with Tail Whip, but Tail Whip doesn't use any subanimations
TailWhipAnimationUnused:
- ld a,1
- ld [wSubAnimCounter],a
- ld c,20
+ ld a, 1
+ ld [wSubAnimCounter], a
+ ld c, 20
jp DelayFrames
; Format: Special Effect ID (1 byte), Address (2 bytes)
@@ -1068,48 +1068,48 @@ SpecialEffectPointers:
db $FF
AnimationDelay10:
- ld c,10
+ ld c, 10
jp DelayFrames
; calls a function with the turn flipped from player to enemy or vice versa
; input - hl - address of function to call
CallWithTurnFlipped:
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
push af
- xor a,1
- ld [H_WHOSETURN],a
- ld de,.returnAddress
+ xor 1
+ ld [H_WHOSETURN], a
+ ld de, .returnAddress
push de
jp hl
.returnAddress
pop af
- ld [H_WHOSETURN],a
+ ld [H_WHOSETURN], a
ret
; flashes the screen for an extended period (48 frames)
AnimationFlashScreenLong:
- ld a,3 ; cycle through the palettes 3 times
- ld [wFlashScreenLongCounter],a
- ld a,[wOnSGB] ; running on SGB?
+ ld a, 3 ; cycle through the palettes 3 times
+ ld [wFlashScreenLongCounter], a
+ ld a, [wOnSGB] ; running on SGB?
and a
- ld hl,FlashScreenLongMonochrome
- jr z,.loop
- ld hl,FlashScreenLongSGB
+ ld hl, FlashScreenLongMonochrome
+ jr z, .loop
+ ld hl, FlashScreenLongSGB
.loop
push hl
.innerLoop
- ld a,[hli]
- cp a,$01 ; is it the end of the palettes?
- jr z,.endOfPalettes
- ld [rBGP],a
+ ld a, [hli]
+ cp $01 ; is it the end of the palettes?
+ jr z, .endOfPalettes
+ ld [rBGP], a
call FlashScreenLongDelay
jr .innerLoop
.endOfPalettes
- ld a,[wFlashScreenLongCounter]
+ ld a, [wFlashScreenLongCounter]
dec a
- ld [wFlashScreenLongCounter],a
+ ld [wFlashScreenLongCounter], a
pop hl
- jr nz,.loop
+ jr nz, .loop
ret
; BG palettes
@@ -1147,31 +1147,31 @@ FlashScreenLongSGB:
; causes a delay of 2 frames for the first cycle
; 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
- ld c,4
- jr z,.delayFrames
- cp a,3
- ld c,2
- jr z,.delayFrames
- cp a,2 ; nothing is done with this
- ld c,1
+ ld a, [wFlashScreenLongCounter]
+ cp 4 ; never true since [wFlashScreenLongCounter] starts at 3
+ ld c, 4
+ jr z, .delayFrames
+ cp 3
+ ld c, 2
+ jr z, .delayFrames
+ cp 2 ; nothing is done with this
+ ld c, 1
.delayFrames
jp DelayFrames
AnimationFlashScreen:
- ld a,[rBGP]
+ ld a, [rBGP]
push af ; save initial palette
- ld a,%00011011 ; 0, 1, 2, 3 (inverted colors)
- ld [rBGP],a
- ld c,2
+ ld a, %00011011 ; 0, 1, 2, 3 (inverted colors)
+ ld [rBGP], a
+ ld c, 2
call DelayFrames
xor a ; white out background
- ld [rBGP],a
- ld c,2
+ ld [rBGP], a
+ ld c, 2
call DelayFrames
pop af
- ld [rBGP],a ; restore initial palette
+ ld [rBGP], a ; restore initial palette
ret
AnimationDarkScreenPalette:
@@ -2101,7 +2101,7 @@ HideSubstituteShowMonAnim:
.next1
push hl
; 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
@@ -2310,52 +2310,52 @@ GetMoveSoundB:
ret
GetMoveSound:
- ld hl,MoveSoundTable
- ld e,a
- ld d,0
- add hl,de
- add hl,de
- add hl,de
- ld a,[hli]
- ld b,a
+ ld hl, MoveSoundTable
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld b, a
call IsCryMove
- jr nc,.NotCryMove
- ld a,[H_WHOSETURN]
+ jr nc, .NotCryMove
+ ld a, [H_WHOSETURN]
and a
- jr nz,.next
- ld a,[wBattleMonSpecies] ; get number of current monster
+ jr nz, .next
+ ld a, [wBattleMonSpecies] ; get number of current monster
jr .Continue
.next
- ld a,[wEnemyMonSpecies]
+ ld a, [wEnemyMonSpecies]
.Continue
push hl
call GetCryData
- ld b,a
+ ld b, a
pop hl
- ld a,[wFrequencyModifier]
+ ld a, [wFrequencyModifier]
add [hl]
- ld [wFrequencyModifier],a
+ ld [wFrequencyModifier], a
inc hl
- ld a,[wTempoModifier]
+ ld a, [wTempoModifier]
add [hl]
- ld [wTempoModifier],a
+ ld [wTempoModifier], a
jr .done
.NotCryMove
- ld a,[hli]
- ld [wFrequencyModifier],a
- ld a,[hli]
- ld [wTempoModifier],a
+ ld a, [hli]
+ ld [wFrequencyModifier], a
+ ld a, [hli]
+ ld [wTempoModifier], a
.done
- ld a,b
+ ld a, b
ret
IsCryMove:
; set carry if the move animation involves playing a monster cry
- ld a,[wAnimationID]
- cp a,GROWL
- jr z,.CryMove
- cp a,ROAR
- jr z,.CryMove
+ ld a, [wAnimationID]
+ cp GROWL
+ jr z, .CryMove
+ cp ROAR
+ jr z, .CryMove
and a ; clear carry
ret
.CryMove
@@ -2951,46 +2951,46 @@ BattleAnimCopyTileMapToVRAM:
jp Delay3
TossBallAnimation:
- ld a,[wIsInBattle]
- cp a,2
- jr z,.BlockBall ; if in trainer battle, play different animation
- ld a,[wPokeBallAnimData]
- ld b,a
+ ld a, [wIsInBattle]
+ 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
+ ld c, a
; lower nybble: number of shakes
; store these for later
- ld a,b
- and a,$F
- ld [wNumShakes],a
+ ld a, b
+ and $F
+ ld [wNumShakes], a
- ld hl,.PokeBallAnimations
+ ld hl, .PokeBallAnimations
; choose which toss animation to use
- ld a,[wcf91]
- cp a,POKE_BALL
- ld b,TOSS_ANIM
- jr z,.done
- cp a,GREAT_BALL
- ld b,GREATTOSS_ANIM
- jr z,.done
- ld b,ULTRATOSS_ANIM
+ ld a, [wcf91]
+ cp POKE_BALL
+ ld b, TOSS_ANIM
+ jr z, .done
+ cp GREAT_BALL
+ ld b, GREATTOSS_ANIM
+ jr z, .done
+ ld b, ULTRATOSS_ANIM
.done
- ld a,b
+ ld a, b
.PlayNextAnimation
- ld [wAnimationID],a
+ ld [wAnimationID], a
push bc
push hl
call PlayAnimation
pop hl
- ld a,[hli]
+ ld a, [hli]
pop bc
dec c
- jr nz,.PlayNextAnimation
+ jr nz, .PlayNextAnimation
ret
.PokeBallAnimations:
@@ -2998,13 +2998,13 @@ TossBallAnimation:
db POOF_ANIM,HIDEPIC_ANIM,SHAKE_ANIM,POOF_ANIM,SHOWPIC_ANIM
.BlockBall
- ld a,TOSS_ANIM
- ld [wAnimationID],a
+ ld a, TOSS_ANIM
+ ld [wAnimationID], a
call PlayAnimation
- ld a,SFX_FAINT_THUD
+ ld a, SFX_FAINT_THUD
call PlaySound
- ld a,BLOCKBALL_ANIM
- ld [wAnimationID],a
+ ld a, BLOCKBALL_ANIM
+ ld [wAnimationID], a
jp PlayAnimation
PlayApplyingAttackSound:
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 4e7c8032..9265503d 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -381,15 +381,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
@@ -401,10 +401,10 @@ 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 multi-turn attack like wrap, so player is trapped and cannot execute a move
ld a, $ff
@@ -442,7 +442,7 @@ MainInBattleLoop:
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
@@ -579,7 +579,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
@@ -600,7 +600,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
@@ -667,7 +667,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
@@ -776,14 +776,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:
@@ -833,7 +833,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
@@ -1363,138 +1363,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
@@ -1507,27 +1507,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
@@ -1842,7 +1842,7 @@ SendOutMon:
ld b, SET_PAL_BATTLE
call RunPaletteCommand
ld hl, wEnemyBattleStatus1
- res UsingTrappingMove, [hl]
+ res USING_TRAPPING_MOVE, [hl]
ld a, $1
ld [H_WHOSETURN], a
ld a, POOF_ANIM
@@ -2343,13 +2343,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]
@@ -2456,7 +2456,7 @@ PartyMenuOrRockOrRun:
predef StatusScreen2
; now we need to reload the enemy mon pic
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
@@ -3014,20 +3014,20 @@ SelectEnemyMove:
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
@@ -3154,7 +3154,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
@@ -3169,160 +3169,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).
@@ -3334,26 +3334,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
@@ -3367,266 +3367,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 POKEMONTOWER_1
+ jr c, .next
+ cp LAVENDER_HOUSE_1
+ 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]
+ 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]
+ 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
@@ -3716,7 +3716,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
@@ -4250,7 +4250,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
@@ -4280,7 +4280,7 @@ 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
@@ -4363,7 +4363,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
@@ -4393,7 +4393,7 @@ 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
@@ -4515,7 +4515,7 @@ CalculateDamage:
.effect
; EXPLODE_EFFECT halves defense.
- cp a, EXPLODE_EFFECT
+ cp EXPLODE_EFFECT
jr nz, .ok
srl c
jr nz, .ok
@@ -4523,13 +4523,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.
@@ -4707,7 +4707,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)
@@ -4762,297 +4762,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
@@ -5065,51 +5065,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 HideSubstituteShowMonAnim ; 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:
@@ -5123,44 +5123,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:
@@ -5176,25 +5176,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
@@ -5205,78 +5205,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
@@ -5284,107 +5284,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
@@ -5402,26 +5402,26 @@ AdjustDamageForMoveType:
; ($05 is not very effective, $10 is neutral, $14 is super effective)
; as far is can tell, this is only used once in some AI code to help decide which move to use
AIGetTypeEffectiveness:
- 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 [wTypeEffectiveness],a ; initialize to neutral effectiveness
- ld hl,TypeEffects
+ ld c, [hl] ; c = type 2 of player's pokemon
+ ld a, $10
+ ld [wTypeEffectiveness], a ; initialize 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
@@ -5429,8 +5429,8 @@ AIGetTypeEffectiveness:
inc hl
jr .loop
.done
- ld a,[hl]
- ld [wTypeEffectiveness],a ; store damage multiplier
+ ld a, [hl]
+ ld [wTypeEffectiveness], a ; store damage multiplier
ret
INCLUDE "data/type_effects.asm"
@@ -5438,52 +5438,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
@@ -5492,98 +5492,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
@@ -5591,40 +5591,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%
@@ -5693,7 +5693,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
@@ -5706,8 +5706,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)
@@ -5775,7 +5775,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
@@ -5786,7 +5786,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
@@ -5805,7 +5805,7 @@ EnemyCheckIfFlyOrChargeEffect:
.playAnim
xor a
ld [wAnimationType], a
- ld a,STATUS_AFFECTED_ANIM
+ ld a, STATUS_AFFECTED_ANIM
call PlayMoveAnimation
EnemyCheckIfMirrorMoveEffect:
ld a, [wEnemyMoveEffect]
@@ -5852,14 +5852,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
@@ -5897,7 +5897,7 @@ CheckEnemyStatusConditions:
call PrintText
xor a
ld [wAnimationType], a
- ld a,SLP_ANIM
+ ld a, SLP_ANIM
call PlayMoveAnimation
jr .sleepDone
.wokeUp
@@ -5919,7 +5919,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
@@ -5927,18 +5927,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
@@ -5964,7 +5964,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
@@ -5973,14 +5973,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
@@ -6047,7 +6047,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
@@ -6065,7 +6065,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
@@ -6087,7 +6087,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
@@ -6114,7 +6114,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
@@ -6126,8 +6126,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
@@ -6136,7 +6136,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
@@ -6148,7 +6148,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
@@ -6206,7 +6206,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]
@@ -6238,7 +6238,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]
@@ -6815,7 +6815,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
@@ -6830,7 +6830,7 @@ HandleExplodingAnimation:
ld [wAnimationType], a
PlayMoveAnimation:
- ld [wAnimationID],a
+ ld [wAnimationID], a
call Delay3
predef_jump MoveAnimation
@@ -7240,8 +7240,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
@@ -7340,7 +7340,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
@@ -7393,7 +7393,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
@@ -7417,11 +7417,11 @@ FreezeBurnParalyzeEffect:
cp b ; do target type 2 and move type match?
ret z ; return if they match
ld a, [wPlayerMoveEffect]
- cp a, PARALYZE_SIDE_EFFECT1 + 1 ; 10% status effects are 04, 05, 06 so 07 will set carry for those
+ cp PARALYZE_SIDE_EFFECT1 + 1 ; 10% status effects are 04, 05, 06 so 07 will set carry for those
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
@@ -7429,9 +7429,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, .burn
- cp a, FREEZE_SIDE_EFFECT
+ cp FREEZE_SIDE_EFFECT
jr z, .freeze
; .paralyze
ld a, 1 << PAR
@@ -7469,11 +7469,11 @@ opponentAttacker:
cp b
ret z
ld a, [wEnemyMoveEffect]
- cp a, PARALYZE_SIDE_EFFECT1 + 1
+ cp PARALYZE_SIDE_EFFECT1 + 1
ld b, $1a
jr c, .next1
ld b, $4d
- sub a, $1e
+ sub $1e
.next1
push af
call BattleRandom
@@ -7481,9 +7481,9 @@ opponentAttacker:
pop bc
ret nc
ld a, b
- cp a, BURN_SIDE_EFFECT1
+ cp BURN_SIDE_EFFECT1
jr z, .burn
- cp a, FREEZE_SIDE_EFFECT
+ cp FREEZE_SIDE_EFFECT
jr z, .freeze
ld a, 1 << PAR
ld [wBattleMonStatus], a
@@ -7512,14 +7512,14 @@ 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 hl, wEnemyMon1Status
@@ -7532,7 +7532,7 @@ CheckDefrost:
jr .common
.opponent
ld a, [wEnemyMoveType] ; same as above with addresses swapped
- sub a, FIRE
+ sub FIRE
ret nz
ld [wBattleMonStatus], a
ld hl, wPartyMon1Status
@@ -7673,7 +7673,7 @@ UpdateStatDone:
jr nz, .asm_3f4f9
; 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
ld hl, HideSubstituteShowMonAnim
@@ -7776,7 +7776,7 @@ 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
@@ -7992,7 +7992,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
@@ -8017,7 +8017,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
@@ -8153,9 +8153,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
@@ -8208,7 +8208,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
@@ -8226,18 +8226,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
xor a
@@ -8306,11 +8306,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
@@ -8356,9 +8356,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
@@ -8395,7 +8395,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:
@@ -8406,7 +8406,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
@@ -8417,7 +8417,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:
@@ -8438,7 +8438,7 @@ MimicEffect:
ld hl, wEnemyMonMoves
ld a, [wEnemyBattleStatus1]
.enemyTurn
- bit Invulnerable, a
+ bit INVULNERABLE, a
jr nz, .mimicMissed
.getRandomMove
push hl
@@ -8462,7 +8462,7 @@ MimicEffect:
jr .playerTurn
.letPlayerChooseMove
ld a, [wEnemyBattleStatus1]
- bit Invulnerable, a
+ bit INVULNERABLE, a
jr nz, .mimicMissed
ld a, [wCurrentMenuItem]
push af
@@ -8661,7 +8661,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/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 69301d8e..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
diff --git a/engine/battle/moveEffects/haze_effect.asm b/engine/battle/moveEffects/haze_effect.asm
index 06907bcc..47723ba2 100644
--- a/engine/battle/moveEffects/haze_effect.asm
+++ b/engine/battle/moveEffects/haze_effect.asm
@@ -47,14 +47,14 @@ HazeEffect_:
jp PrintText
CureVolatileStatuses:
- 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/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/reflect_light_screen_effect.asm b/engine/battle/moveEffects/reflect_light_screen_effect.asm
index b45fbe20..2805a969 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 6cca3eae..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
@@ -43,7 +43,7 @@ SubstituteEffect_:
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 45f8c910..9a5de9cc 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 3672d8dc..ba00083b 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,[wCurOpponent]
+ ld a, [wCurOpponent]
sub $C9 ; convert value from pokemon to trainer
- add a,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
+ 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
; 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?
- jr z,.FinishUp
- ld [wcf91],a ; write species somewhere (XXX why?)
- ld a,ENEMY_PARTY_DATA
- ld [wMonDataLocation],a
+ jr z, .FinishUp
+ ld [wcf91], a ; write species somewhere (XXX why?)
+ ld a, ENEMY_PARTY_DATA
+ ld [wMonDataLocation], a
push hl
call AddPartyMon
pop hl
@@ -66,101 +66,101 @@ 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,.AddLoneMove
- ld [wCurEnemyLVL],a
- ld a,[hli]
- ld [wcf91],a
- ld a,ENEMY_PARTY_DATA
- ld [wMonDataLocation],a
+ jr z, .AddLoneMove
+ ld [wCurEnemyLVL], a
+ ld a, [hli]
+ ld [wcf91], a
+ ld a, ENEMY_PARTY_DATA
+ ld [wMonDataLocation], a
push hl
call AddPartyMon
pop hl
jr .SpecialTrainer
.AddLoneMove
; does the trainer have a single monster with a different move
- ld a,[wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
+ ld a, [wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
and a
- jr z,.AddTeamMove
+ jr z, .AddTeamMove
dec a
- add a,a
- ld c,a
- ld b,0
- ld hl,LoneMoves
- add hl,bc
- ld a,[hli]
- ld d,[hl]
- ld hl,wEnemyMon1Moves + 2
- ld bc,wEnemyMon2 - wEnemyMon1
+ add a
+ ld c, a
+ ld b, 0
+ ld hl, LoneMoves
+ add hl, bc
+ ld a, [hli]
+ ld d, [hl]
+ ld hl, wEnemyMon1Moves + 2
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
- ld [hl],d
+ ld [hl], d
jr .FinishUp
.AddTeamMove
; check if our trainer's team has special moves
; get trainer class number
- ld a,[wCurOpponent]
+ ld a, [wCurOpponent]
sub 200
- ld b,a
- ld hl,TeamMoves
+ ld b, a
+ ld hl, TeamMoves
; iterate through entries in TeamMoves, checking each for our trainer class
.IterateTeamMoves
- ld a,[hli]
+ ld a, [hli]
cp b
- jr z,.GiveTeamMoves ; is there a match?
+ jr z, .GiveTeamMoves ; is there a match?
inc hl ; if not, go to the next entry
inc a
- jr nz,.IterateTeamMoves
+ jr nz, .IterateTeamMoves
; no matches found. is this trainer champion rival?
- ld a,b
+ ld a, b
cp SONY3
- jr z,.ChampionRival
+ jr z, .ChampionRival
jr .FinishUp ; nope
.GiveTeamMoves
- ld a,[hl]
- ld [wEnemyMon5Moves + 2],a
+ ld a, [hl]
+ ld [wEnemyMon5Moves + 2], a
jr .FinishUp
.ChampionRival ; give moves to his team
; pidgeot
- ld a,SKY_ATTACK
- ld [wEnemyMon1Moves + 2],a
+ ld a, SKY_ATTACK
+ ld [wEnemyMon1Moves + 2], a
; starter
- ld a,[wRivalStarter]
+ ld a, [wRivalStarter]
cp STARTER3
- ld b,MEGA_DRAIN
- jr z,.GiveStarterMove
+ ld b, MEGA_DRAIN
+ jr z, .GiveStarterMove
cp STARTER1
- ld b,FIRE_BLAST
- jr z,.GiveStarterMove
- ld b,BLIZZARD ; must be squirtle
+ ld b, FIRE_BLAST
+ jr z, .GiveStarterMove
+ ld b, BLIZZARD ; must be squirtle
.GiveStarterMove
- ld a,b
- ld [wEnemyMon6Moves + 2],a
+ ld a, b
+ ld [wEnemyMon6Moves + 2], a
.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/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 fff064fa..6f699b9c 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -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
@@ -338,33 +338,33 @@ INCLUDE "data/trainer_parties.asm"
TrainerAI:
and a
- ld a,[wIsInBattle]
+ ld a, [wIsInBattle]
dec a
ret z ; if not a trainer, we're done here
- ld a,[wLinkState]
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z
- ld a,[wTrainerClass] ; what trainer class is this?
+ 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
ret z ; 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
@@ -442,17 +442,17 @@ CooltrainerMAI:
CooltrainerFAI:
cp $40
- ld a,$A
+ ld a, $A
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
@@ -470,7 +470,7 @@ LtSurgeAI:
ErikaAI:
cp $80
ret nc
- ld a,$A
+ ld a, $A
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -488,7 +488,7 @@ BlaineAI:
SabrinaAI:
cp $40
ret nc
- ld a,$A
+ ld a, $A
call AICheckIfHPBelowFraction
ret nc
jp AIUseHyperPotion
@@ -496,7 +496,7 @@ SabrinaAI:
Sony2AI:
cp $20
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUsePotion
@@ -504,7 +504,7 @@ Sony2AI:
Sony3AI:
cp $20
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseFullRestore
@@ -512,7 +512,7 @@ Sony3AI:
LoreleiAI:
cp $80
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -524,10 +524,10 @@ BrunoAI:
AgathaAI:
cp $14
- jp c,AISwitchIfEnoughMons
+ jp c, AISwitchIfEnoughMons
cp $80
ret nc
- ld a,4
+ ld a, 4
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -535,7 +535,7 @@ AgathaAI:
LanceAI:
cp $80
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseHyperPotion
@@ -547,133 +547,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
@@ -681,14 +681,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
@@ -696,13 +696,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
@@ -715,120 +715,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