Name more in-battle functions and labels

and better document some animation related functions
This commit is contained in:
xCrystal 2015-03-31 22:22:12 +02:00
parent e6185ac358
commit 4e2084b0f1
2 changed files with 64 additions and 55 deletions

View file

@ -3188,30 +3188,30 @@ PlayerCalcMoveDamage: ; 3d6dc (f:56dc)
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 CriticalHitTest
call HandleCounterMove call HandleCounterMove
jr z,handleIfMoveMissed jr z,handleIfPlayerMoveMissed
call GetDamageVarsForPlayerAttack call GetDamageVarsForPlayerAttack
call CalculateDamage call CalculateDamage
jp z,asm_3d74b ; 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 ; for these moves, accuracy tests will only occur if they are called as part of the effect itself
call AdjustDamageForMoveType call AdjustDamageForMoveType
call RandomizeDamage call RandomizeDamage
.moveHitTest .moveHitTest
call MoveHitTest call MoveHitTest
handleIfMoveMissed handleIfPlayerMoveMissed
ld a,[W_MOVEMISSED] ld a,[W_MOVEMISSED]
and a and a
jr z,asm_3d714 jr z,getPlayerAnimationType
ld a,[W_PLAYERMOVEEFFECT] ld a,[W_PLAYERMOVEEFFECT]
sub a,EXPLODE_EFFECT sub a,EXPLODE_EFFECT
jr z,asm_3d71e ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
jr asm_3d74b jr playerCheckIfFlyOrChargeEffect
asm_3d714 getPlayerAnimationType
ld a,[W_PLAYERMOVEEFFECT] ld a,[W_PLAYERMOVEEFFECT]
and a and a
ld a,4 ld a,4 ; move has no effect other than dealing damage
jr z,asm_3d71e jr z,playPlayerMoveAnimation
ld a,5 ld a,5 ; move has effect
asm_3d71e playPlayerMoveAnimation
push af push af
ld a,[W_PLAYERBATTSTATUS2] ld a,[W_PLAYERBATTSTATUS2]
bit 4,a bit 4,a
@ -3230,7 +3230,7 @@ asm_3d71e
ld b,BANK(Func_79771) ld b,BANK(Func_79771)
call nz,Bankswitch call nz,Bankswitch
jr MirrorMoveCheck jr MirrorMoveCheck
asm_3d74b playerCheckIfFlyOrChargeEffect
ld c,$1E ld c,$1E
call DelayFrames call DelayFrames
ld a,[W_PLAYERMOVEEFFECT] ld a,[W_PLAYERMOVEEFFECT]
@ -3297,7 +3297,7 @@ MirrorMoveCheck
ld a,[wPlayerNumAttacksLeft] ld a,[wPlayerNumAttacksLeft]
dec a dec a
ld [wPlayerNumAttacksLeft],a ld [wPlayerNumAttacksLeft],a
jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. jp nz,getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
; damage calculation and accuracy tests only happen for the first hit ; damage calculation and accuracy tests only happen for the first hit
res AttackingMultipleTimes,[hl] ; clear attacking multiple times status when all attacks are over res AttackingMultipleTimes,[hl] ; clear attacking multiple times status when all attacks are over
ld hl,MultiHitText ld hl,MultiHitText
@ -3573,7 +3573,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
ld [hl],a ld [hl],a
ld a,BIDE ld a,BIDE
ld [W_PLAYERMOVENUM],a ld [W_PLAYERMOVENUM],a
ld hl,handleIfMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest ld hl,handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .returnToHL jp .returnToHL
.ThrashingAboutCheck .ThrashingAboutCheck
@ -3607,7 +3607,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
ld a,[wPlayerNumAttacksLeft] ld a,[wPlayerNumAttacksLeft]
dec a ; did multi-turn move end? dec a ; did multi-turn move end?
ld [wPlayerNumAttacksLeft],a ld [wPlayerNumAttacksLeft],a
ld hl,asm_3d714 ; if it didn't, skip damage calculation (deal damage equal to last hit), ld hl,getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
; DecrementPP and MoveHitTest ; DecrementPP and MoveHitTest
jp nz,.returnToHL jp nz,.returnToHL
jp .returnToHL jp .returnToHL
@ -3783,7 +3783,7 @@ MonName1Text: ; 3dafb (f:5afb)
ld hl, Used2Text ld hl, Used2Text
ret nz ret nz
ld a, [wd11e] ld a, [wd11e]
cp DOUBLESLAP cp 3
ld hl, Used2Text ld hl, Used2Text
ret c ret c
ld hl, Used1Text ld hl, Used1Text
@ -5639,6 +5639,7 @@ RandomizeDamage: ; 3e687 (f:6687)
ld [hl], a ld [hl], a
ret ret
; for more detailed commentary, see equivalent function for player side (ExecutePlayerMove)
ExecuteEnemyMove: ; 3e6bc (f:66bc) ExecuteEnemyMove: ; 3e6bc (f:66bc)
ld a, [wEnemySelectedMove] ld a, [wEnemySelectedMove]
inc a inc a
@ -5711,42 +5712,42 @@ EnemyCalcMoveDamage: ; 3e750 (f:6750)
ld hl, SetDamageEffects ld hl, SetDamageEffects
ld de, $1 ld de, $1
call IsInArray call IsInArray
jp c, Func_3e77f jp c, EnemyMoveHitTest
call CriticalHitTest call CriticalHitTest
call HandleCounterMove call HandleCounterMove
jr z, asm_3e782 jr z, handleIfEnemyMoveMissed
call SwapPlayerAndEnemyLevels call SwapPlayerAndEnemyLevels
call GetDamageVarsForEnemyAttack call GetDamageVarsForEnemyAttack
call SwapPlayerAndEnemyLevels call SwapPlayerAndEnemyLevels
call CalculateDamage call CalculateDamage
jp z, Func_3e7d1 jp z, EnemyCheckIfFlyOrChargeEffect
call AdjustDamageForMoveType call AdjustDamageForMoveType
call RandomizeDamage call RandomizeDamage
Func_3e77f: ; 3e77f (f:677f) EnemyMoveHitTest: ; 3e77f (f:677f)
call MoveHitTest call MoveHitTest
asm_3e782: ; 3e782 (f:6782) handleIfEnemyMoveMissed: ; 3e782 (f:6782)
ld a, [W_MOVEMISSED] ld a, [W_MOVEMISSED]
and a and a
jr z, .asm_3e791 jr z, .asm_3e791
ld a, [W_ENEMYMOVEEFFECT] ld a, [W_ENEMYMOVEEFFECT]
cp EXPLODE_EFFECT cp EXPLODE_EFFECT
jr z, asm_3e7a0 jr z, asm_3e7a0
jr Func_3e7d1 jr EnemyCheckIfFlyOrChargeEffect
.asm_3e791 .asm_3e791
call SwapPlayerAndEnemyLevels call SwapPlayerAndEnemyLevels
Func_3e794: ; 3e794 (f:6794) GetEnemyAnimationType: ; 3e794 (f:6794)
ld a, [W_ENEMYMOVEEFFECT] ld a, [W_ENEMYMOVEEFFECT]
and a and a
ld a, $1 ld a, $1
jr z, asm_3e7a4 jr z, playEnemyMoveAnimation
ld a, $2 ld a, $2
jr asm_3e7a4 jr playEnemyMoveAnimation
asm_3e7a0: ; 3e7a0 (f:67a0) asm_3e7a0: ; 3e7a0 (f:67a0)
call SwapPlayerAndEnemyLevels call SwapPlayerAndEnemyLevels
xor a xor a
asm_3e7a4: ; 3e7a4 (f:67a4) playEnemyMoveAnimation: ; 3e7a4 (f:67a4)
push af push af
ld a, [W_ENEMYBATTSTATUS2] ld a, [W_ENEMYBATTSTATUS2]
bit HasSubstituteUp, a ; does mon have a substitute? bit HasSubstituteUp, a ; does mon have a substitute?
@ -5764,24 +5765,24 @@ asm_3e7a4: ; 3e7a4 (f:67a4)
ld hl, Func_79771 ld hl, Func_79771
ld b, BANK(Func_79771) ld b, BANK(Func_79771)
call nz, Bankswitch ; slide the substitute's sprite out call nz, Bankswitch ; slide the substitute's sprite out
jr asm_3e7ef jr EnemyCheckIfMirrorMoveEffect
Func_3e7d1: ; 3e7d1 (f:67d1) EnemyCheckIfFlyOrChargeEffect: ; 3e7d1 (f:67d1)
call SwapPlayerAndEnemyLevels call SwapPlayerAndEnemyLevels
ld c, $1e ld c, $1e
call DelayFrames call DelayFrames
ld a, [W_ENEMYMOVEEFFECT] ld a, [W_ENEMYMOVEEFFECT]
cp FLY_EFFECT cp FLY_EFFECT
jr z, .asm_3e7e6 jr z, .playAnim
cp CHARGE_EFFECT cp CHARGE_EFFECT
jr z, .asm_3e7e6 jr z, .playAnim
jr asm_3e7ef jr EnemyCheckIfMirrorMoveEffect
.asm_3e7e6 .playAnim
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
ld a,STATUS_AFFECTED_ANIM ld a,STATUS_AFFECTED_ANIM
call PlayMoveAnimation call PlayMoveAnimation
asm_3e7ef: ; 3e7ef (f:67ef) EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
ld a, [W_ENEMYMOVEEFFECT] ld a, [W_ENEMYMOVEEFFECT]
cp MIRROR_MOVE_EFFECT cp MIRROR_MOVE_EFFECT
jr nz, .notMirrorMoveEffect jr nz, .notMirrorMoveEffect
@ -5832,7 +5833,7 @@ asm_3e7ef: ; 3e7ef (f:67ef)
ld hl, wEnemyNumAttacksLeft ld hl, wEnemyNumAttacksLeft
dec [hl] dec [hl]
pop hl pop hl
jp nz, Func_3e794 jp nz, GetEnemyAnimationType
res AttackingMultipleTimes, [hl] ; mon is no longer hitting multiple times res AttackingMultipleTimes, [hl] ; mon is no longer hitting multiple times
ld hl, HitXTimesText ld hl, HitXTimesText
call PrintText call PrintText
@ -6084,7 +6085,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld a, BIDE ld a, BIDE
ld [W_ENEMYMOVENUM], a ld [W_ENEMYMOVENUM], a
call SwapPlayerAndEnemyLevels call SwapPlayerAndEnemyLevels
ld hl, asm_3e782 ld hl, handleIfEnemyMoveMissed
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfThrashingAbout .checkIfThrashingAbout
bit ThrashingAbout, [hl] ; is mon using thrash or petal dance? bit ThrashingAbout, [hl] ; is mon using thrash or petal dance?
@ -6115,7 +6116,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call PrintText call PrintText
ld hl, wEnemyNumAttacksLeft ld hl, wEnemyNumAttacksLeft
dec [hl] dec [hl]
ld hl, Func_3e794 ld hl, GetEnemyAnimationType
jp nz, .enemyReturnToHL jp nz, .enemyReturnToHL
jp .enemyReturnToHL jp .enemyReturnToHL
.checkIfUsingRage .checkIfUsingRage
@ -6971,6 +6972,7 @@ _LoadTrainerPic: ; 3f04b (f:704b)
ld c, a ld c, a
jp LoadUncompressedSpriteData jp LoadUncompressedSpriteData
; unreferenced
Func_3f069: ; 3f069 (f:7069) Func_3f069: ; 3f069 (f:7069)
xor a xor a
ld [wc0f1], a ld [wc0f1], a
@ -7046,6 +7048,7 @@ asm_3f0d0: ; 3f0d0 (f:70d0)
dec b dec b
jr nz, .asm_3f0de jr nz, .asm_3f0de
ret ret
.asm_3f0ed .asm_3f0ed
push bc push bc
ld b, $0 ld b, $0
@ -7069,7 +7072,7 @@ asm_3f0d0: ; 3f0d0 (f:70d0)
jr nz, .asm_3f0f4 jr nz, .asm_3f0f4
ret ret
LoadMonBackPic: LoadMonBackPic: ; 3f103 (f:7103)
; Assumes the monster's attributes have ; Assumes the monster's attributes have
; been loaded with GetMonHeader. ; been loaded with GetMonHeader.
ld a, [wBattleMonSpecies2] ld a, [wBattleMonSpecies2]
@ -7239,7 +7242,7 @@ SleepEffect: ; 3f1fc (f:71fc)
and $7 and $7
jr z, .setSleepCounter jr z, .setSleepCounter
ld [de], a ld [de], a
call StoreCurrentMoveAnimationIDAndType call PlayCurrentMoveAnimation2
ld hl, FellAsleepText ld hl, FellAsleepText
jp PrintText jp PrintText
.didntAffect .didntAffect
@ -7325,10 +7328,10 @@ PoisonEffect: ; 3f24f (f:724f)
cp POISON_EFFECT cp POISON_EFFECT
jr z, .asm_3f2cd jr z, .asm_3f2cd
ld a, b ld a, b
call StoreAnimationIDAndType call PlayBattleAnimation2
jp PrintText jp PrintText
.asm_3f2cd .asm_3f2cd
call StoreCurrentMoveAnimationIDAndType call PlayCurrentMoveAnimation2
jp PrintText jp PrintText
.noEffect .noEffect
ld a, [de] ld a, [de]
@ -7584,7 +7587,7 @@ StatModifierUpEffect: ; 3f428 (f:7428)
jr nz, .recalculateStat jr nz, .recalculateStat
ld a, [hl] ld a, [hl]
sbc 999 / $100 sbc 999 / $100
jp z, Func_3f520 jp z, RestoreOriginalStatModifier
.recalculateStat ; recalculate affected stat .recalculateStat ; recalculate affected stat
; paralysis and burn penalties, as well as badge boosts are ignored ; paralysis and burn penalties, as well as badge boosts are ignored
push hl push hl
@ -7677,7 +7680,7 @@ UpdateStatDone: ; 3f4ca (f:74ca)
call QuarterSpeedDueToParalysis ; apply speed penalty to the player whose turn is not, if it's paralyzed call QuarterSpeedDueToParalysis ; apply speed penalty to the player whose turn is not, if it's paralyzed
jp HalveAttackDueToBurn ; apply attack penalty to the player whose turn is not, if it's burned jp HalveAttackDueToBurn ; apply attack penalty to the player whose turn is not, if it's burned
Func_3f520: ; 3f520 (f:7520) RestoreOriginalStatModifier: ; 3f520 (f:7520)
pop hl pop hl
dec [hl] dec [hl]
@ -7854,7 +7857,7 @@ UpdateLoweredStatDone: ; 3f62c (f:762c)
ld a, [de] ld a, [de]
cp $44 cp $44
jr nc, .ApplyBadgeBoostsAndStatusPenalties jr nc, .ApplyBadgeBoostsAndStatusPenalties
call StoreCurrentMoveAnimationIDAndType call PlayCurrentMoveAnimation2
.ApplyBadgeBoostsAndStatusPenalties .ApplyBadgeBoostsAndStatusPenalties
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
and a and a
@ -7977,7 +7980,7 @@ BideEffect: ; 3f6e5 (f:76e5)
ld [bc], a ; set Bide counter to 2 or 3 at random ld [bc], a ; set Bide counter to 2 or 3 at random
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
add XSTATITEM_ANIM add XSTATITEM_ANIM
jp StoreAnimationIDAndType jp PlayBattleAnimation2
ThrashPetalDanceEffect: ; 3f717 (f:7717) ThrashPetalDanceEffect: ; 3f717 (f:7717)
ld hl, W_PLAYERBATTSTATUS1 ld hl, W_PLAYERBATTSTATUS1
@ -7996,7 +7999,7 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717)
ld [de], a ; set thrash/petal dance counter to 2 or 3 at random ld [de], a ; set thrash/petal dance counter to 2 or 3 at random
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
add ANIM_B0 add ANIM_B0
jp StoreAnimationIDAndType jp PlayBattleAnimation2
SwitchAndTeleportEffect: ; 3f739 (f:7739) SwitchAndTeleportEffect: ; 3f739 (f:7739)
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
@ -8345,7 +8348,7 @@ ConfusionSideEffectSuccess: ; 3f96f (f:796f)
ld [bc], a ; confusion status will last 2-5 turns ld [bc], a ; confusion status will last 2-5 turns
pop af pop af
cp CONFUSION_SIDE_EFFECT cp CONFUSION_SIDE_EFFECT
call nz, StoreCurrentMoveAnimationIDAndType call nz, PlayCurrentMoveAnimation2
ld hl, BecameConfusedText ld hl, BecameConfusedText
jp PrintText jp PrintText
@ -8550,7 +8553,7 @@ DisableEffect: ; 3fa8a (f:7a8a)
swap c swap c
add c add c
ld [de], a ld [de], a
call StoreCurrentMoveAnimationIDAndType call PlayCurrentMoveAnimation2
ld hl, wccee ld hl, wccee
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
and a and a
@ -8658,18 +8661,20 @@ CheckTargetSubstitute: ; 3fb79 (f:7b79)
pop hl pop hl
ret ret
StoreCurrentMoveAnimationIDAndType: ; 3fb89 (f:7b89) PlayCurrentMoveAnimation2: ; 3fb89 (f:7b89)
; animation at MOVENUM will be played unless MOVENUM is 0 ; animation at MOVENUM will be played unless MOVENUM is 0
; plays wAnimationType 3 or 6
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
and a and a
ld a, [W_PLAYERMOVENUM] ld a, [W_PLAYERMOVENUM]
jr z, .asm_3fb94 jr z, .notEnemyTurn
ld a, [W_ENEMYMOVENUM] ld a, [W_ENEMYMOVENUM]
.asm_3fb94 .notEnemyTurn
and a and a
ret z ret z
StoreAnimationIDAndType: ; 3fb96 (f:7b96) PlayBattleAnimation2: ; 3fb96 (f:7b96)
; play animation ID at a and animation type 6 or 3
ld [W_ANIMATIONID], a ld [W_ANIMATIONID], a
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
and a and a
@ -8681,6 +8686,8 @@ StoreAnimationIDAndType: ; 3fb96 (f:7b96)
jp PlayBattleAnimationGotID jp PlayBattleAnimationGotID
PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8) PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8)
; animation at MOVENUM will be played unless MOVENUM is 0
; resets wAnimationType
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
ld a, [H_WHOSETURN] ld a, [H_WHOSETURN]
@ -8693,9 +8700,11 @@ PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8)
ret z ret z
PlayBattleAnimation: ; 3fbb9 (f:7bb9) PlayBattleAnimation: ; 3fbb9 (f:7bb9)
; play animation ID at a and predefined animation type
ld [W_ANIMATIONID], a ld [W_ANIMATIONID], a
PlayBattleAnimationGotID: ; 3fbbc (f:7bbc) PlayBattleAnimationGotID: ; 3fbbc (f:7bbc)
; play animation at W_ANIMATIONID
push hl push hl
push de push de
push bc push bc

View file

@ -273,7 +273,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7)
ld a, [wAILayer2Encouragement] ld a, [wAILayer2Encouragement]
cp $1 cp $1
ret nz ret nz
ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
ld de, wEnemyMonMoves ; enemy moves ld de, wEnemyMonMoves ; enemy moves
ld b, NUM_MOVES + 1 ld b, NUM_MOVES + 1
.nextMove .nextMove
@ -303,7 +303,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7)
; discourage damaging moves that are ineffective or not very effective against the player's mon, ; discourage damaging moves that are ineffective or not very effective against the player's mon,
; unless there's no damaging move that deals at least neutral damage ; unless there's no damaging move that deals at least neutral damage
AIMoveChoiceModification3: ; 39817 (e:5817) AIMoveChoiceModification3: ; 39817 (e:5817)
ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
ld de, wEnemyMonMoves ; enemy moves ld de, wEnemyMonMoves ; enemy moves
ld b, $5 ld b, $5
.nextMove .nextMove