2018-06-24 07:09:41 -07:00
DoBattleAnimFrame:
2015-12-23 14:10:50 -08:00
ld hl , BATTLEANIMSTRUCT_FUNCTION
add hl , bc
ld e , [ hl ]
ld d , 0
ld hl , .Jumptable
add hl , de
add hl , de
ld a , [ hli ]
ld h , [ hl ]
ld l , a
2017-06-09 14:01:10 -07:00
jp hl
2015-12-23 14:10:50 -08:00
2016-04-10 11:42:14 -07:00
.Jumptable:
2017-12-26 14:47:05 -08:00
; entries correspond to BATTLEANIMFUNC_* constants
2020-10-03 18:54:02 -07:00
dw BattleAnimFunction_Null
dw BattleAnimFunction_MoveFromUserToTarget
dw BattleAnimFunction_MoveFromUserToTargetAndDisappear
dw BattleAnimFunction_MoveInCircle
dw BattleAnimFunction_MoveWaveToTarget
dw BattleAnimFunction_ThrowFromUserToTarget
dw BattleAnimFunction_ThrowFromUserToTargetAndDisappear
dw BattleAnimFunction_Drop
dw BattleAnimFunction_MoveFromUserToTargetSpinAround
dw BattleAnimFunction_Shake
dw BattleAnimFunction_FireBlast
dw BattleAnimFunction_RazorLeaf
dw BattleAnimFunction_Bubble
dw BattleAnimFunction_Surf
dw BattleAnimFunction_Sing
dw BattleAnimFunction_WaterGun
dw BattleAnimFunction_Ember
dw BattleAnimFunction_Powder
dw BattleAnimFunction_PokeBall
dw BattleAnimFunction_PokeBallBlocked
dw BattleAnimFunction_Recover
dw BattleAnimFunction_ThunderWave
dw BattleAnimFunction_Clamp_Encore
dw BattleAnimFunction_Bite
dw BattleAnimFunction_SolarBeam
dw BattleAnimFunction_Gust
dw BattleAnimFunction_RazorWind
dw BattleAnimFunction_Kick
dw BattleAnimFunction_Absorb
dw BattleAnimFunction_Egg
dw BattleAnimFunction_MoveUp
dw BattleAnimFunction_Wrap
dw BattleAnimFunction_LeechSeed
dw BattleAnimFunction_Sound
dw BattleAnimFunction_ConfuseRay
dw BattleAnimFunction_Dizzy
dw BattleAnimFunction_Amnesia
dw BattleAnimFunction_FloatUp
dw BattleAnimFunction_Dig
dw BattleAnimFunction_String
dw BattleAnimFunction_Paralyzed
dw BattleAnimFunction_SpiralDescent
dw BattleAnimFunction_PoisonGas
dw BattleAnimFunction_Horn
dw BattleAnimFunction_Needle
dw BattleAnimFunction_PetalDance
dw BattleAnimFunction_ThiefPayday
dw BattleAnimFunction_AbsorbCircle
dw BattleAnimFunction_Bonemerang
dw BattleAnimFunction_Shiny
dw BattleAnimFunction_SkyAttack
dw BattleAnimFunction_GrowthSwordsDance
dw BattleAnimFunction_SmokeFlameWheel
dw BattleAnimFunction_PresentSmokescreen
dw BattleAnimFunction_StrengthSeismicToss
dw BattleAnimFunction_SpeedLine
dw BattleAnimFunction_Sludge
dw BattleAnimFunction_MetronomeHand
dw BattleAnimFunction_MetronomeSparkleSketch
dw BattleAnimFunction_Agility
dw BattleAnimFunction_SacredFire
dw BattleAnimFunction_SafeguardProtect
dw BattleAnimFunction_LockOnMindReader
dw BattleAnimFunction_Spikes
dw BattleAnimFunction_HealBellNotes
dw BattleAnimFunction_BatonPass
dw BattleAnimFunction_Conversion
dw BattleAnimFunction_EncoreBellyDrum
dw BattleAnimFunction_SwaggerMorningSun
dw BattleAnimFunction_HiddenPower
dw BattleAnimFunction_Curse
dw BattleAnimFunction_PerishSong
dw BattleAnimFunction_RapidSpin
dw BattleAnimFunction_BetaPursuit
dw BattleAnimFunction_RainSandstorm
dw BattleAnimFunction_AnimObjB0
dw BattleAnimFunction_PsychUp
dw BattleAnimFunction_AncientPower
dw BattleAnimFunction_RockSmash
dw BattleAnimFunction_Cotton
2015-12-23 14:10:50 -08:00
2018-06-24 07:09:41 -07:00
BattleAnimFunction_Null:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.one
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_ThrowFromUserToTargetAndDisappear:
call BattleAnimFunction_ThrowFromUserToTarget
2015-12-23 14:10:50 -08:00
ret c
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_ThrowFromUserToTarget:
2016-05-05 12:07:37 -07:00
; If x coord at $88 or beyond, abort.
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 88
ret nc
2016-05-05 12:07:37 -07:00
; Move right 2 pixels
2015-12-23 14:10:50 -08:00
add $ 2
ld [ hl ], a
2016-05-05 12:07:37 -07:00
; Move down 1 pixel
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
2016-05-05 12:07:37 -07:00
; Decrease ??? and hold onto its previous value (argument of the sine function)
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec [ hl ]
2016-05-05 12:07:37 -07:00
; Get ???, which is the amplitude of the sine function
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
call BattleAnim_Sine
2016-05-05 12:07:37 -07:00
; Store the result in the Y offset
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2016-05-05 12:07:37 -07:00
; Carry flag denotes success
2015-12-23 14:10:50 -08:00
scf
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_MoveWaveToTarget:
; Wave motion from one mon to another. Obj is cleared when it reaches x coord $88. Examples: Shadow Ball, Dragon Rage
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 88
2020-10-03 18:54:02 -07:00
jr c , .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move
2015-12-23 14:10:50 -08:00
add $ 2
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
2016-05-05 12:07:37 -07:00
inc [ hl ]
inc [ hl ]
inc [ hl ]
2015-12-23 14:10:50 -08:00
ld d , $ 10
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
sra a
sra a
sra a
sra a
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_MoveInCircle:
; Slow circular motion. Examples: Thundershock, Flamethrower
; Obj Param: Distance from center (masked with $7F). Bit 7 causes object to start on other side of the circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
bit 7 , [ hl ]
ld a , $ 0
2020-10-03 18:54:02 -07:00
jr z , .got_starting_position
2015-12-23 14:10:50 -08:00
ld a , $ 20
2020-10-03 18:54:02 -07:00
.got_starting_position
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 7 f
ld [ hl ], a
2015-12-24 10:33:54 -08:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_MoveFromUserToTarget:
; Moves object diagonally at a ~30° angle towards opponent and stops when it reaches x coord $84. Obj Param changes the speed
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.one
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 84
ret nc
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_MoveFromUserToTargetAndDisappear:
; Same as BattleAnimFunction_01 but objs are cleared when they reach x coord $84
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 84
2020-10-03 18:54:02 -07:00
jr nc , .done
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2018-06-24 07:09:41 -07:00
BattleAnimFunction_PokeBall:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
dw .five
dw .six
dw .seven
dw .eight
dw .nine
dw .ten
dw .eleven
2016-05-05 12:07:37 -07:00
.zero ; init
2016-01-27 09:25:12 -08:00
call GetBallAnimPal
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.one
2020-10-03 18:54:02 -07:00
call BattleAnimFunction_ThrowFromUserToTarget
2015-12-23 14:10:50 -08:00
ret c
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
ld [ hl ], a
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_0B
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.three
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_09
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 0
inc hl
ld [ hl ], $ 10
2015-12-24 10:33:54 -08:00
.four
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hli ]
ld d , [ hl ]
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec a
ld [ hl ], a
and $ 1 f
ret nz
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
sub $ 4
ld [ hl ], a
ret nz
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_0C
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.six
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_0D
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
.two
.five
.nine
ret
2015-12-24 10:33:54 -08:00
.seven
2016-01-27 09:25:12 -08:00
call GetBallAnimPal
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_0A
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 20
.eight
.ten
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hli ]
ld d , [ hl ]
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec a
ld [ hl ], a
and $ 1 f
jr z , .eleven
and $ f
ret nz
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.eleven
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2018-06-24 07:09:41 -07:00
BattleAnimFunction_PokeBallBlocked:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
dw .two
2015-12-24 10:33:54 -08:00
.zero
2016-01-27 09:25:12 -08:00
call GetBallAnimPal
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 70
jr nc , .next
2020-10-03 18:54:02 -07:00
call BattleAnimFunction_ThrowFromUserToTarget
2015-12-23 14:10:50 -08:00
ret
.next
call BattleAnim_IncAnonJumptableIndex
2015-12-24 10:33:54 -08:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 80
jr nc , .done
add $ 4
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
dec [ hl ]
ret
.done
call DeinitBattleAnimation
ret
2018-06-24 07:09:41 -07:00
GetBallAnimPal:
2017-12-11 14:11:30 -08:00
ld hl , BallColors
2018-08-25 11:28:22 -07:00
ldh a , [ rSVBK ]
2015-12-23 14:10:50 -08:00
push af
2018-01-23 14:39:09 -08:00
ld a , BANK ( wCurItem )
2018-08-25 11:28:22 -07:00
ldh [ rSVBK ], a
2018-01-23 14:39:09 -08:00
ld a , [ wCurItem ]
2015-12-23 14:10:50 -08:00
ld e , a
pop af
2018-08-25 11:28:22 -07:00
ldh [ rSVBK ], a
2016-04-10 11:42:14 -07:00
.IsInArray:
2015-12-23 14:10:50 -08:00
ld a , [ hli ]
cp - 1
jr z , .load
cp e
jr z , .load
inc hl
jr .IsInArray
.load
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_PALETTE
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2017-12-11 14:11:30 -08:00
2017-12-26 15:45:04 -08:00
INCLUDE "data/battle_anims/ball_colors.asm"
2017-12-11 14:11:30 -08:00
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Ember:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
2015-12-24 10:33:54 -08:00
.zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
swap a
and $ f
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2015-12-24 10:33:54 -08:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 88
ret nc
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2015-12-24 10:33:54 -08:00
.two
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2015-12-24 10:33:54 -08:00
.three
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_0F
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-24 10:33:54 -08:00
.four
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Drop:
; Drops obj. The Obj Param dictates how fast it is (lower value is faster) and how long it stays bouncing (lower value is longer). Example: Rock Slide
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 30
inc hl
ld [ hl ], $ 48
2015-12-24 10:33:54 -08:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hli ]
ld d , [ hl ]
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ld a , [ hl ]
and $ 3 f
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 20
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
sub [ hl ]
2015-12-23 19:51:50 -08:00
jr z , .done
jr c , .done
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], a
ret
2015-12-23 19:51:50 -08:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_MoveFromUserToTargetSpinAround:
; Object moves from user to target target and spins around it once. Example: Fire Spin, Swift
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 80
2015-12-23 19:51:50 -08:00
jr nc , .next
call .SetCoords
2015-12-23 14:10:50 -08:00
ret
2015-12-23 19:51:50 -08:00
.next
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2015-12-24 10:33:54 -08:00
.one
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 0
2015-12-24 10:33:54 -08:00
.two
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 40
2015-12-23 19:51:50 -08:00
jr nc , .loop_back
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 18
call BattleAnim_Cosine
sub $ 18
sra a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 18
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
ld [ hl ], a
ret
2015-12-23 19:51:50 -08:00
.loop_back
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f0
2015-12-23 19:51:50 -08:00
jr z , .finish
2015-12-23 14:10:50 -08:00
sub $ 10
ld d , a
ld a , [ hl ]
and $ f
or d
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2015-12-23 19:51:50 -08:00
.finish
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2015-12-24 10:33:54 -08:00
.three
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ b0
2015-12-23 19:51:50 -08:00
jr c , .retain
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2015-12-23 19:51:50 -08:00
.retain
call .SetCoords
2015-12-23 14:10:50 -08:00
ret
2016-04-10 11:42:14 -07:00
.SetCoords:
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f
ld e , a
srl e
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
2015-12-23 19:51:50 -08:00
.loop
2015-12-23 14:10:50 -08:00
dec [ hl ]
dec e
2015-12-23 19:51:50 -08:00
jr nz , .loop
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Shake:
; Object switches position side to side. Obj Param defines how far to move it. Example: Dynamic Punch
; Some objects use this function with a Param of 0
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 0
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-24 10:33:54 -08:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2015-12-23 19:51:50 -08:00
jr z , .done_one
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2015-12-23 19:51:50 -08:00
.done_one
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
swap a
and $ f
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
xor $ ff
inc a
ld [ hl ], a
ret
2015-12-24 10:33:54 -08:00
.two
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_FireBlast:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
dw .five
dw .six
dw .seven
dw .eight
dw .nine
2015-12-24 10:33:54 -08:00
.zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
cp $ 7
2015-12-23 19:51:50 -08:00
jr z , .seven
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_11
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
2015-12-24 10:33:54 -08:00
.seven
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 88
2015-12-23 19:51:50 -08:00
jr nc , .set_up_eight
2015-12-23 14:10:50 -08:00
add $ 2
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2015-12-23 19:51:50 -08:00
.set_up_eight
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_10
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-24 10:33:54 -08:00
.eight
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 10
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ret
2015-12-24 10:33:54 -08:00
.nine
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.one
; Flame that moves upward
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2015-12-24 10:33:54 -08:00
.four
2020-10-03 18:54:02 -07:00
; Flame that moves down and left
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
2015-12-24 10:33:54 -08:00
.two
2020-10-03 18:54:02 -07:00
; Flame that moves left
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2015-12-24 10:33:54 -08:00
.five
2020-10-03 18:54:02 -07:00
; Flame that moves down and right
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
2015-12-24 10:33:54 -08:00
.three
2020-10-03 18:54:02 -07:00
; Flame that moves right
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
2015-12-24 10:33:54 -08:00
.six
2015-12-23 14:10:50 -08:00
ret
2018-06-24 07:09:41 -07:00
BattleAnimFunction_RazorLeaf:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
dw .five
dw .six
dw .seven
dw .eight
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 40
2015-12-24 10:33:54 -08:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 30
2015-12-23 19:51:50 -08:00
jr nc , .sine_cosine
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
xor a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hli ], a
ld [ hl ], a
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_17
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
bit 6 , [ hl ]
ret z
ld hl , BATTLEANIMSTRUCT_FRAME
add hl , bc
ld [ hl ], $ 5
ret
2015-12-23 19:51:50 -08:00
.sine_cosine
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 3 f
ld d , a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec [ hl ]
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-10-05 08:24:47 -07:00
call BattleAnim_ScatterHorizontal
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld h , [ hl ]
ld l , a
add hl , de
ld e , l
ld d , h
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], e
ret
2015-12-24 10:33:54 -08:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 20
2015-12-23 19:51:50 -08:00
jr nz , .sine_cosine_2
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2015-12-23 19:51:50 -08:00
.sine_cosine_2
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 10
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
bit 6 , [ hl ]
2015-12-23 19:51:50 -08:00
jr nz , .decrease
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
2015-12-23 19:51:50 -08:00
jr .finish
2015-12-23 14:10:50 -08:00
2015-12-23 19:51:50 -08:00
.decrease
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
2015-12-23 19:51:50 -08:00
.finish
2015-12-23 14:10:50 -08:00
ld de , $ 80
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld h , [ hl ]
ld l , a
add hl , de
ld e , l
ld d , h
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], e
ret
2015-12-24 10:33:54 -08:00
.three
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_16
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_OAMFLAGS
2015-12-23 14:10:50 -08:00
add hl , bc
res 5 , [ hl ]
2015-12-23 19:51:50 -08:00
.four
.five
.six
.seven
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.eight
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ c0
ret nc
ld a , $ 8
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-05 08:24:47 -07:00
BattleAnim_ScatterHorizontal:
; Affects horizontal sine movement based on bit 7 of Obj Param
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
bit 7 , a
jr nz , .negative
cp $ 20
jr nc , .plus_256
cp $ 18
jr nc , .plus_384
ld de , $ 200
ret
.plus_384
ld de , $ 180
ret
.plus_256
ld de , $ 100
ret
.negative
2020-10-04 19:34:50 -07:00
and % 00111111
2015-12-23 14:10:50 -08:00
cp $ 20
jr nc , .minus_256
cp $ 18
jr nc , .minus_384
ld de , - $ 200
ret
.minus_384
ld de , - $ 180
ret
.minus_256
ld de , - $ 100
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_RockSmash:
; Object moves at an arc
; Obj Param: Bit 7 makes arc flip horizontally
; Bit 6 defines offset from base frameset FRAMESET_19
; Rest defines arc radius
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 40
rlca
rlca
2020-10-03 18:54:02 -07:00
add BATTLEANIMFRAMESET_19
2015-12-23 14:10:50 -08:00
ld hl , BATTLEANIMSTRUCT_FRAMESET_ID
add hl , bc
ld [ hl ], a
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 40
2015-12-24 10:33:54 -08:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 30
2015-12-23 19:51:50 -08:00
jr nc , .sine_cosine
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2015-12-23 19:51:50 -08:00
.sine_cosine
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 3 f
ld d , a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec [ hl ]
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-10-05 08:24:47 -07:00
call BattleAnim_ScatterHorizontal
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld h , [ hl ]
ld l , a
add hl , de
ld e , l
ld d , h
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], e
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Bubble:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ c
2015-12-24 10:33:54 -08:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2015-12-23 19:51:50 -08:00
jr z , .next
2015-12-23 14:10:50 -08:00
dec [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2015-12-23 19:51:50 -08:00
.next
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 0
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_22
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-24 10:33:54 -08:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 98
2015-12-23 19:51:50 -08:00
jr nc , .okay
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld h , [ hl ]
ld l , a
ld de , $ 60
add hl , de
ld e , l
ld d , h
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], e
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2015-12-23 19:51:50 -08:00
.okay
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 20
ret c
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f0
ld e , a
ld d , $ ff
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld h , [ hl ]
ld l , a
add hl , de
ld e , l
ld d , h
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], e
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Surf:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2018-08-25 11:34:25 -07:00
ld a , LOW ( rSCY )
2018-08-25 11:28:22 -07:00
ldh [ hLCDCPointer ], a
2015-12-23 14:10:50 -08:00
ld a , $ 58
2018-08-25 11:28:22 -07:00
ldh [ hLYOverrideStart ], a
2015-12-23 14:10:50 -08:00
ld a , $ 5 e
2018-08-25 11:28:22 -07:00
ldh [ hLYOverrideEnd ], a
2015-12-23 14:10:50 -08:00
ret
2015-12-24 10:33:54 -08:00
.one
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld e , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp e
2020-10-03 18:54:02 -07:00
jr nc , .move
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
xor a
2018-08-25 11:28:22 -07:00
ldh [ hLYOverrideStart ], a
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.move
2015-12-23 14:10:50 -08:00
dec a
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 10
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
sub $ 10
ret c
2018-08-25 11:28:22 -07:00
ldh [ hLYOverrideStart ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc a
and $ 7
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
inc [ hl ]
2015-12-24 10:33:54 -08:00
.two
2015-12-23 14:10:50 -08:00
ret
2015-12-24 10:33:54 -08:00
.three
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 70
2020-10-03 18:54:02 -07:00
jr c , .move_down
2015-12-23 14:10:50 -08:00
xor a
2018-08-25 11:28:22 -07:00
ldh [ hLCDCPointer ], a
ldh [ hLYOverrideStart ], a
ldh [ hLYOverrideEnd ], a
2015-12-24 10:33:54 -08:00
.four
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move_down
2015-12-23 14:10:50 -08:00
inc a
inc a
ld [ hl ], a
sub $ 10
ret c
2018-08-25 11:28:22 -07:00
ldh [ hLYOverrideStart ], a
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Sing:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_24
2019-02-06 01:16:40 -08:00
add [ hl ] ; BATTLEANIMFRAMESET_25 BATTLEANIMFRAMESET_26
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ b8
2020-10-03 18:54:02 -07:00
jr c , .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move
2015-12-23 14:10:50 -08:00
ld a , $ 2
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec [ hl ]
ld d , $ 8
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_WaterGun:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
dw .three
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-10-03 18:54:02 -07:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 30
2020-10-03 18:54:02 -07:00
jr c , .run_down
2015-12-23 14:10:50 -08:00
ld a , $ 2
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec [ hl ]
ld d , $ 8
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.run_down
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_28
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 0
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 30
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_OAMFLAGS
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 1
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 18
2020-10-03 18:54:02 -07:00
jr nc , .splash
2015-12-23 14:10:50 -08:00
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
.splash
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_29
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-10-03 18:54:02 -07:00
.three
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Powder:
; Obj moves down and disappears at x coord $38
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 38
2020-10-03 18:54:02 -07:00
jr c , .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld l , [ hl ]
ld h , a
ld de , $ 80
add hl , de
ld e , l
ld d , h
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], e
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-10-03 18:54:02 -07:00
; Shakes object back and forth 16 pixels
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
xor $ 10
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Recover:
; Obj moves in an ever shrinking circle. Obj Param defines initial position in the circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f0
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f
sla a
sla a
sla a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 1
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr nz , .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld d , [ hl ]
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
xor $ 1
ld [ hl ], a
ret z
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_ThunderWave:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
dw .three
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.one
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_35
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-10-03 18:54:02 -07:00
.zero
.two
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.three
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Clamp_Encore:
; Claps two objects together, twice. Also used by Encore
; Second object's frameset and position relative to first are both defined via this function
; Obj Param: Distance from center (masked with $7F). Bit 7 flips object horizontally by switching to a different frameset
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
dw .three
dw .four
dw .five
dw .six
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl , BATTLEANIMSTRUCT_FRAMESET_ID
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
bit 7 , [ hl ]
2020-10-03 18:54:02 -07:00
jr nz , .flipped
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 10
2020-10-03 18:54:02 -07:00
jr .got_sine_start
2015-12-23 14:10:50 -08:00
2020-10-03 18:54:02 -07:00
.flipped
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 30
2020-10-03 18:54:02 -07:00
.got_sine_start
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 7 f
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
bit 7 , a
2016-05-05 12:07:37 -07:00
jr nz , .load_no_inc
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
inc a ; BATTLEANIMFRAMESET_3B (Clamp Flipped)
; BATTLEANIMFRAMESET_A1 (Hands Flipped)
2016-05-05 12:07:37 -07:00
jr .reinit
2015-12-23 14:10:50 -08:00
2016-05-05 12:07:37 -07:00
.load_no_inc
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2020-10-03 18:54:02 -07:00
ld a , [ hl ] ; BATTLEANIMFRAMESET_3A (Clamp)
; BATTLEANIMFRAMESET_A0 (Hands)
2016-05-05 12:07:37 -07:00
.reinit
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ld a , [ hl ]
and $ 1 f
ret nz
2020-10-03 18:54:02 -07:00
.two
.three
.four
.five
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
.six
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 1
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Bite:
; Claps two objects together (vertically), twice
; Second object's frameset and position relative to first are both defined via this function
; Obj Param: Distance from center (masked with $7F). Bit 7 flips object vertically by switching to a different frameset
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
dw .three
dw .four
dw .five
dw .six
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
bit 7 , [ hl ]
2020-10-03 18:54:02 -07:00
jr nz , .flipped
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 10
2020-10-03 18:54:02 -07:00
jr .got_sine_start
2015-12-23 14:10:50 -08:00
2020-10-03 18:54:02 -07:00
.flipped
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 30
2020-10-03 18:54:02 -07:00
.got_sine_start
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 7 f
ld [ hl ], a
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
bit 7 , a
2020-10-03 18:54:02 -07:00
jr nz , .flipped2
2019-02-06 01:16:40 -08:00
ld a , BATTLEANIMFRAMESET_3D
2020-10-03 18:54:02 -07:00
jr .got_frameset
2015-12-23 14:10:50 -08:00
2020-10-03 18:54:02 -07:00
.flipped2
2019-02-06 01:16:40 -08:00
ld a , BATTLEANIMFRAMESET_3C
2020-10-03 18:54:02 -07:00
.got_frameset
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
inc [ hl ]
ld a , [ hl ]
and $ 1 f
ret nz
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.two
.three
.four
.five
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
.six
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 1
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_SolarBeam:
; Solar Beam charge up animation
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 28
inc hl
ld [ hl ], $ 0
2020-10-03 18:54:02 -07:00
.one
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .zero_radius
2015-12-23 14:10:50 -08:00
ld d , a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld e , [ hl ]
2018-08-25 11:43:02 -07:00
ld hl , - $ 80
2015-12-23 14:10:50 -08:00
add hl , de
ld e , l
ld d , h
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], e
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
ret
2020-10-03 18:54:02 -07:00
.zero_radius
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Gust:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
dw .three
dw .four
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
2020-10-05 08:24:47 -07:00
ld [ hl ], 0
2020-10-03 18:54:02 -07:00
.one
.three
call .GustWobble
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 88
2020-10-03 18:54:02 -07:00
jr c , .move
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
.four
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ b8
2020-10-03 18:54:02 -07:00
jr c , .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move
call .GustWobble
; Move horizontally every frame
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
; Move in the vertically every other frame
2015-12-23 14:10:50 -08:00
and $ 1
ret nz
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.GustWobble:
; Circular movement where width is retrieved from a list, and height is 1/16 of that
call .GetGustRadius
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
push af
push de
call BattleAnim_Sine
sra a
sra a
sra a
sra a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
sub $ 8
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-05 08:24:47 -07:00
jr z , .start_wobble
2015-12-23 14:10:50 -08:00
cp $ c2
2020-10-05 08:24:47 -07:00
jr c , .finish_wobble
.start_wobble
2015-12-23 14:10:50 -08:00
dec a
ld [ hl ], a
and $ 7
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
inc [ hl ]
ret
2020-10-05 08:24:47 -07:00
.finish_wobble
2015-12-23 14:10:50 -08:00
xor a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hli ], a
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.GetGustRadius:
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld e , [ hl ]
ld d , 0
2020-10-03 18:54:02 -07:00
ld hl , .GustOffsets
2015-12-23 14:10:50 -08:00
add hl , de
ld d , [ hl ]
ret
2020-10-03 18:54:02 -07:00
.GustOffsets:
2015-12-23 14:10:50 -08:00
db 8 , 6 , 5 , 4 , 5 , 6 , 8 , 12 , 16
2018-01-25 18:34:42 -08:00
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Absorb:
; Moves object from target to user and disappears when reaches x coord $30. Example: Absorb, Mega Drain, Leech Seed status
; Obj Param: Speed in the X axis
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 30
2020-10-03 18:54:02 -07:00
jr nc , .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f
ld e , a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
sub e
ld [ hl ], a
srl e
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
2020-10-03 18:54:02 -07:00
.loop
2015-12-23 14:10:50 -08:00
inc [ hl ]
dec e
2020-10-03 18:54:02 -07:00
jr nz , .loop
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Wrap:
; Plays out object Frameset. Use anim_incobj to move to next frameset
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.one
2015-12-23 14:10:50 -08:00
ld hl , BATTLEANIMSTRUCT_FRAMESET_ID
add hl , bc
ld a , [ hl ]
2019-02-06 01:16:40 -08:00
inc a ; BATTLEANIMFRAMESET_53
; BATTLEANIMFRAMESET_55
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
2020-10-03 18:54:02 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1 ; Unused?
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 8
2020-10-03 18:54:02 -07:00
.zero
.two
2015-12-23 14:10:50 -08:00
ret
2018-06-24 07:09:41 -07:00
BattleAnimFunction_LeechSeed:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2016-05-05 12:07:37 -07:00
dw .zero
dw .one
dw .two
dw .three
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 40
ret
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
cp $ 20
2016-05-05 12:07:37 -07:00
jr c , .sprout
2020-10-03 18:54:02 -07:00
call BattleAnim_StepThrownToTarget
2015-12-23 14:10:50 -08:00
ret
2016-05-05 12:07:37 -07:00
.sprout
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 40
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_57
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
.two
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
and a
2016-05-05 12:07:37 -07:00
jr z , .flutter
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2016-05-05 12:07:37 -07:00
.flutter
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_58
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-10-03 18:54:02 -07:00
.three
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnim_StepThrownToTarget:
; Inches object towards the opponent's side in a parabola arc defined by the lower and upper nybble of Obj Param
2015-12-23 14:10:50 -08:00
dec [ hl ]
ld d , $ 20
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-10-03 18:54:02 -07:00
ld hl , BATTLEANIMSTRUCT_FIX_Y
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ 2
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld e , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld h , [ hl ]
ld a , h
and $ f
swap a
ld l , a
ld a , h
and $ f0
swap a
ld h , a
add hl , de
ld e , l
ld d , h
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], e
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
and $ 1
ret nz
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Spikes:
; Object is thrown at target. After $20 frames it stops and waits another $20 frames then disappear
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 40
ret
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
cp $ 20
2020-10-03 18:54:02 -07:00
jr c , .wait
call BattleAnim_StepThrownToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.wait
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-10-03 18:54:02 -07:00
.two
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_RazorWind:
call BattleAnimFunction_MoveInCircle
; Causes object to skip ahead the circular motion every frame
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ f
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Kick:
; Uses anim_setobj for different kick types
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two ; Jump Kick, Hi Jump Kick
dw .three ; Rolling Kick
2020-10-04 19:34:50 -07:00
dw .four ; Rolling Kick (continued)
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.one ; Unused?
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 30
2020-10-04 19:34:50 -07:00
jr c , .move_down
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 0
ret
2020-10-04 19:34:50 -07:00
.move_down
2015-12-23 14:10:50 -08:00
add $ 4
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 98
ret nc
inc [ hl ]
inc [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_OAMFLAGS
2015-12-23 14:10:50 -08:00
add hl , bc
set 0 , [ hl ]
2020-10-03 18:54:02 -07:00
ld hl , BATTLEANIMSTRUCT_FIX_Y
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 90
ld hl , BATTLEANIMSTRUCT_FRAME
add hl , bc
ld [ hl ], $ 0
ld hl , BATTLEANIMSTRUCT_DURATION
add hl , bc
ld [ hl ], $ 2
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.three
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 2 c
ld hl , BATTLEANIMSTRUCT_FRAME
add hl , bc
ld [ hl ], $ 0
ld hl , BATTLEANIMSTRUCT_DURATION
add hl , bc
ld [ hl ], $ 80
2020-10-03 18:54:02 -07:00
.four
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 98
ret nc
inc [ hl ]
inc [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
ld d , $ 8
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Egg:
; Used by Egg Bomb and Softboiled
; Obj Param: Defines jumptable starting index
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one ; Egg Bomb start
dw .two
dw .three
dw .four ; ret
dw .five
dw .six ; Softboiled obj 1 start
dw .seven
dw .eight
dw .nine
dw .ten ; ret
dw .eleven ; Softboiled obj 2 start
dw .twelve
dw .thirteen ; ret
.zero
; Object starts here then jumps to the jumptable index defined by the Obj Param
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 28
2020-10-03 18:54:02 -07:00
inc hl ; BATTLEANIMSTRUCT_VAR2
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 10
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.one
; Initial Egg Bomb arc movement to x coord $40
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 40
2020-10-03 18:54:02 -07:00
jr nc , .egg_bomb_vertical_wave
2015-12-23 14:10:50 -08:00
inc [ hl ]
2020-10-03 18:54:02 -07:00
.egg_bomb_vertical_wave
call .EggVerticalWaveMotion
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.six
; Initial Softboiled arc movement to x coord $4b
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 4 b
2020-10-03 18:54:02 -07:00
jr nc , .softboiled_vertical_wave
2015-12-23 14:10:50 -08:00
inc [ hl ]
2020-10-03 18:54:02 -07:00
.softboiled_vertical_wave
call .EggVerticalWaveMotion
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.two
; Compares the egg's x coord to determine whether to move, wait or end animation
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 88
2020-10-03 18:54:02 -07:00
jr nc , .egg_bomb_done
2015-12-23 14:10:50 -08:00
and $ f
2020-10-03 18:54:02 -07:00
jr nz , .egg_bomb_step
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 10
2020-10-03 18:54:02 -07:00
call BattleAnim_IncAnonJumptableIndex ; jumps to three
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.egg_bomb_done
; Increases jumptable index twice to four
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
.three
; Waits in place
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .done_waiting
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.done_waiting
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
2020-10-03 18:54:02 -07:00
.egg_bomb_step
; Moves towards the target
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld e , [ hl ]
2018-08-25 11:43:02 -07:00
ld hl , - $ 80
2015-12-23 14:10:50 -08:00
add hl , de
ld e , l
ld d , h
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], e
ret
2020-10-03 18:54:02 -07:00
.five
; Clears Egg Bomb object via anim_incobj
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.seven
; Switches Softboiled frameset to egg wobbling
ld a , BATTLEANIMFRAMESET_4E ; Egg wobbling
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
.eight
; Softboiled object waves slightly side to side
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
inc [ hl ]
ld d , $ 2
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.nine
; First Softboiled ANIM_OBJ_EGG turns into the bottom half frameset
ld a , BATTLEANIMFRAMESET_50 ; Cracked egg bottom
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 4
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
.eleven
; Second Softboiled ANIM_OBJ_EGG
ld a , BATTLEANIMFRAMESET_4F ; Cracked egg top
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 40
ret
2020-10-03 18:54:02 -07:00
.twelve
; Top half of egg moves upward for $30 frames
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 20
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 30
2020-10-03 18:54:02 -07:00
jr c , .done_top_shell
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.done_top_shell
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-10-03 18:54:02 -07:00
.four
.ten
.thirteen
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.EggVerticalWaveMotion:
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hli ]
2020-10-03 18:54:02 -07:00
ld d , [ hl ] ; BATTLEANIMSTRUCT_VAR2
2015-12-23 14:10:50 -08:00
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
and $ 3 f ; cp 64
2015-12-23 14:10:50 -08:00
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 20
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
sub $ 8
ld [ hl ], a
ret nz
xor a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hli ], a
ld [ hl ], a
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_MoveUp:
; Moves object up for 41 frames
; Obj Param: Movement speed
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .move
2015-12-23 14:10:50 -08:00
cp $ d8
2020-10-03 18:54:02 -07:00
jr nc , .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
sub d
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Sound:
; Moves object back and forth in one of three angles using a sine behavior and disappear after 8 frames. Used in Growl, Snore and Kinesis
; Obj Param: Used to define object angle. How much to increase from base frameset, which is hardcoded as BATTLEANIMFRAMESET_59
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2018-08-25 11:28:22 -07:00
ldh a , [ hBattleTurn ]
2015-12-23 14:10:50 -08:00
and a
2020-10-03 18:54:02 -07:00
jr z , .got_turn
; enemy
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
xor $ ff
add $ 3
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.got_turn
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
2020-10-03 18:54:02 -07:00
ld [ hl ], $ 8 ; duration
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_59
2019-02-06 01:16:40 -08:00
add [ hl ] ; BATTLEANIMFRAMESET_5A BATTLEANIMFRAMESET_5B
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .done_anim
2015-12-23 14:10:50 -08:00
dec [ hl ]
2020-10-03 18:54:02 -07:00
call .SoundWaveMotion
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.done_anim
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.SoundWaveMotion:
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
inc [ hl ]
inc [ hl ]
ld d , $ 10
call BattleAnim_Sine
ld d , a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .negative
2015-12-23 14:10:50 -08:00
dec a
ret z
2020-10-03 18:54:02 -07:00
; Obj Param 2
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
ret
2020-10-03 18:54:02 -07:00
.negative
; Obj Param 0
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , d
xor $ ff
inc a
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_ConfuseRay:
; Creates the Confuse Ray object and moves it across the screen until x coord $80
; Moves horizontally every frame and vertically every 3 frames
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 3 f
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 80
rlca
ld [ hl ], a
2019-02-06 01:16:40 -08:00
add BATTLEANIMFRAMESET_5D ; BATTLEANIMFRAMESET_5E
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
2020-10-03 18:54:02 -07:00
.one
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
swap a
ld d , a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
inc [ hl ]
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 80
ret nc
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
and $ 3
2020-10-03 18:54:02 -07:00
jr nz , .skip_vertical_movement
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
2020-10-03 18:54:02 -07:00
.skip_vertical_movement
2015-12-23 14:10:50 -08:00
and $ 1
ret nz
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Dizzy:
; Moves object in a circle where the height is 1/4 the width, with the next frameset from base whether moving left or right. Also used for Nightmare
; Obj Param: Defines starting position in the circle (masked with $80). Bit 7 flips it at the start
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl , BATTLEANIMSTRUCT_FRAMESET_ID
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 80
rlca
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
2019-02-06 01:16:40 -08:00
add [ hl ] ; BATTLEANIMFRAMESET_61 BATTLEANIMFRAMESET_62
; BATTLEANIMFRAMESET_9C BATTLEANIMFRAMESET_9D
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 7 f
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.one
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 10
push af
push de
call BattleAnim_Sine
sra a
sra a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
and $ 3 f
2020-10-03 18:54:02 -07:00
jr z , .not_flipped
2015-12-23 14:10:50 -08:00
and $ 1 f
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2019-02-06 01:16:40 -08:00
inc a ; BATTLEANIMFRAMESET_62
; BATTLEANIMFRAMESET_9D
2020-10-03 18:54:02 -07:00
jr .got_frameset
2015-12-23 14:10:50 -08:00
2020-10-03 18:54:02 -07:00
.not_flipped
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
2019-02-06 01:16:40 -08:00
ld a , [ hl ] ; BATTLEANIMFRAMESET_61
; BATTLEANIMFRAMESET_9C
2020-10-03 18:54:02 -07:00
.got_frameset
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Amnesia:
; Creates 3 objects based on Obj Param
; Obj Param: How much to increase from base frameset, which is hardcoded as BATTLEANIMFRAMESET_63
; anim_incobj is used to DeInit object (used by Present)
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2019-02-06 01:16:40 -08:00
add BATTLEANIMFRAMESET_63 ; BATTLEANIMFRAMESET_64 BATTLEANIMFRAMESET_65
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld e , [ hl ]
ld d , 0
2020-10-03 18:54:02 -07:00
ld hl , .AmnesiaOffsets
2015-12-23 14:10:50 -08:00
add hl , de
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.one
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.two
; anim_incobj forces obj to deinit
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.AmnesiaOffsets: ; Hardcoded Y Offsets for each Obj Param
2015-12-23 14:10:50 -08:00
db $ ec , $ f8 , $ 00
2018-01-25 18:34:42 -08:00
2020-10-03 18:54:02 -07:00
BattleAnimFunction_FloatUp:
; Object moves horizontally in a sine wave, while also moving up. Also used by Charm and the Nightmare status
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
inc [ hl ]
ld d , $ 4
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld e , [ hl ]
2019-02-16 10:04:08 -08:00
lb hl , - 1 , $ a0
2015-12-23 14:10:50 -08:00
add hl , de
ld e , l
ld d , h
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], e
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Dig:
; Object moves up then down with a wave motion, while also moving away from the user 1 pixel per frame
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec [ hl ]
dec [ hl ]
ld d , $ 10
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_String:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr nz , .not_param_zero
; Obj Param 0 flips when used by enemy
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_OAMFLAGS
2015-12-23 14:10:50 -08:00
add hl , bc
2020-10-03 18:54:02 -07:00
set OAM_Y_FLIP , [ hl ]
.not_param_zero
2019-02-05 23:07:11 -08:00
add BATTLEANIMFRAMESET_6A ; BATTLEANIMFRAMESET_6B BATTLEANIMFRAMESET_6C
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-10-03 18:54:02 -07:00
.one
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Paralyzed:
; Also used by Disable
; Obj Param: When bit 7 is set, frameset is replaced with flipped version. This bit is discarded and object then moves back and forth between position in lower nybble and upper nybble of Param every other frame
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 0
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld e , [ hl ]
ld a , e
and $ 70
swap a
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , e
and $ 80
2020-10-03 18:54:02 -07:00
jr nz , .right
2015-12-23 14:10:50 -08:00
ld a , e
and $ f
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.right
2015-12-23 14:10:50 -08:00
ld a , e
and $ f
xor $ ff
inc a
ld [ hl ], a
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_6E
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .var1_zero
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.var1_zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
xor $ ff
inc a
ld [ hl ], a
ret
2018-06-24 07:09:41 -07:00
BattleAnimFunction_SpiralDescent:
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 18
push af
push de
call BattleAnim_Sine
sra a
sra a
sra a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
add [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ld a , [ hl ]
and $ 7
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
cp $ 28
2016-05-05 12:07:37 -07:00
jr nc , .delete
2015-12-23 14:10:50 -08:00
inc [ hl ]
ret
2016-05-05 12:07:37 -07:00
.delete
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_PetalDance:
; Object moves downwards in a spiral around the user. Object disappears at y coord $28
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 18
push af
push de
call BattleAnim_Sine
sra a
sra a
sra a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
add [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ld a , [ hl ]
and $ 3
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
cp $ 28
2020-10-03 18:54:02 -07:00
jr nc , .end
2015-12-23 14:10:50 -08:00
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
.end
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2018-06-24 07:09:41 -07:00
BattleAnimFunction_PoisonGas:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
2016-05-05 12:07:37 -07:00
dw BattleAnimFunction_SpiralDescent
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero:
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 84
2016-05-05 12:07:37 -07:00
jr nc , .next
2015-12-23 14:10:50 -08:00
inc [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
ld d , $ 18
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 1
ret nz
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2016-05-05 12:07:37 -07:00
.next
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_SmokeFlameWheel:
; Object spins around target while also moving upward until it disappears at x coord $e8
; Obj Param: Defines where the object starts in the circle
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 18
push af
push de
call BattleAnim_Sine
sra a
sra a
sra a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
add [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
inc [ hl ]
ld a , [ hl ]
and $ 7
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
cp $ e8
2020-10-03 18:54:02 -07:00
jr z , .done
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_SacredFire:
; Moves object in a circle where the height is 1/8 the width, while also moving upward 2 pixels per frame for 24 frames after which it disappears
; Obj Param: Is used internally only
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 18
push af
push de
call BattleAnim_Sine
sra a
sra a
sra a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
add [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
inc [ hl ]
ld a , [ hl ]
and $ 3
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
cp $ d0
2020-10-03 18:54:02 -07:00
jr z , .done
2015-12-23 14:10:50 -08:00
dec [ hl ]
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_PresentSmokescreen:
; Object bounces from user to target and stops at x coord $6c. Uses anim_incobj to clear object
; Obj Param: Defined but not used
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 34
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 10
2020-10-03 18:54:02 -07:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 6 c
2020-10-03 18:54:02 -07:00
jr c , .do_move
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.do_move
2015-12-23 14:10:50 -08:00
ld a , $ 2
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld d , [ hl ]
call BattleAnim_Sine
bit 7 , a
2020-10-03 18:54:02 -07:00
jr nz , .negative
2015-12-23 14:10:50 -08:00
xor $ ff
inc a
2020-10-03 18:54:02 -07:00
.negative
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
sub $ 4
ld [ hl ], a
and $ 1 f
cp $ 20
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
srl [ hl ]
ret
2020-10-03 18:54:02 -07:00
.two
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2018-06-24 07:09:41 -07:00
BattleAnimFunction_Horn:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2016-05-05 12:07:37 -07:00
dw .zero
dw .one
dw .two
2020-10-03 18:54:02 -07:00
dw .three
.zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 58
ret nc
ld a , $ 2
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.two
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
cp $ 20
2020-10-03 18:54:02 -07:00
jr c , .three
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.three
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
ld d , $ 8
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
sra a
xor $ ff
inc a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
add $ 8
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Needle:
; Moves object towards target, either in a straight line or arc. Stops at x coord $84
; Obj Param: Upper nybble defines the index of the jumptable. Lower nybble defines the speed.
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f0
swap a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.two
; Pin Missile needle (arc)
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 10
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
bit 7 , a
2020-10-03 18:54:02 -07:00
jr z , .negative
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.negative
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
sub $ 4
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.one
; Normal needle (line)
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 84
2020-10-03 18:54:02 -07:00
jr c , .move_to_target
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move_to_target
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_ThiefPayday:
; Object drops off target and bounces once on the floor
; Obj Param: Defines every how many frames the object moves horizontally
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 28
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
sub $ 28
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hli ]
ld d , [ hl ]
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
and [ hl ]
2020-10-03 18:54:02 -07:00
jr nz , .var_doesnt_equal_param
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
2020-10-03 18:54:02 -07:00
.var_doesnt_equal_param
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ld a , [ hl ]
and $ 3 f
ret nz
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 20
inc hl
srl [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_AbsorbCircle:
; A circle of objects that starts at the target and moves to the user. It expands until x coord $5a and then shrinks. Once radius reaches 0, the object disappears. Also used by Mimic and Conversion2
; Obj Param: Defines the position in the circle the object starts at
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ld a , [ hl ]
and $ 1
2020-10-03 18:54:02 -07:00
jr nz , .dont_move_x
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
2020-10-03 18:54:02 -07:00
.dont_move_x
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 3
2020-10-03 18:54:02 -07:00
jr nz , .dont_move_y
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
2020-10-03 18:54:02 -07:00
.dont_move_y
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
cp $ 5 a
2020-10-03 18:54:02 -07:00
jr nc , .increase_radius
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .end
dec [ hl ] ; decreases radius
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.increase_radius
2015-12-23 14:10:50 -08:00
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
.end
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Conversion:
; A rotating circle of objects centered at a position. It expands for $40 frames and then shrinks. Once radius reaches 0, the object disappears.
; Obj Param: Defines starting point in the circle
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
inc [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
cp $ 40
2020-10-03 18:54:02 -07:00
jr nc , .shrink
2015-12-23 14:10:50 -08:00
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
.shrink
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
dec [ hl ]
and a
ret nz
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Bonemerang:
; Boomerang-like movement from user to target
; Obj Param: Defines position to start at in the circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero:
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.one:
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 30
call BattleAnim_Sine
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
add [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ 8
ld d , $ 30
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Shiny:
; Puts object in a circle formation of radius $10. Also used by Flash and Light Screen
; Obj Param: Defines where the object starts in the circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero:
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 10
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 10
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-10-03 18:54:02 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2 ; unused?
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld [ hl ], $ f
2020-10-03 18:54:02 -07:00
.one:
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_SkyAttack:
; Uses anim_incobj to move to next step
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
dw .three
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2018-08-25 11:28:22 -07:00
ldh a , [ hBattleTurn ]
2015-12-23 14:10:50 -08:00
and a
2020-10-03 18:54:02 -07:00
jr nz , .enemy_turn
2015-12-23 14:10:50 -08:00
ld a , $ f0
2020-10-03 18:54:02 -07:00
jr .got_var1
2015-12-23 14:10:50 -08:00
2020-10-03 18:54:02 -07:00
.enemy_turn
2015-12-23 14:10:50 -08:00
ld a , $ cc
2020-10-03 18:54:02 -07:00
.got_var1
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.one
call .SkyAttack_CyclePalette
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.two
; Moves towards target and stops at x coord $84
call .SkyAttack_CyclePalette
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 84
ret nc
ld a , $ 4
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.three
; Moves towards target and disappears at x coord $d0
call .SkyAttack_CyclePalette
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ d0
2020-10-03 18:54:02 -07:00
jr nc , .done
2015-12-23 14:10:50 -08:00
ld a , $ 4
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.SkyAttack_CyclePalette:
; Cycles wOBP0 pallete
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
and $ 7
inc [ hl ]
srl a
ld e , a
ld d , $ 0
2018-08-25 11:28:22 -07:00
ldh a , [ hSGB ]
2015-12-23 14:10:50 -08:00
and a
2020-10-03 18:54:02 -07:00
jr nz , .sgb
ld hl , .GBCPals
jr .got_pals
2015-12-23 14:10:50 -08:00
2020-10-03 18:54:02 -07:00
.sgb
ld hl , .SGBPals
.got_pals
2015-12-23 14:10:50 -08:00
add hl , de
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
and [ hl ]
ld [ wOBP0 ], a
ret
2020-10-03 18:54:02 -07:00
.GBCPals:
2015-12-23 14:10:50 -08:00
db $ ff , $ aa , $ 55 , $ aa
2020-10-03 18:54:02 -07:00
.SGBPals:
2015-12-23 14:10:50 -08:00
db $ ff , $ ff , $ 00 , $ 00
2018-01-25 18:34:42 -08:00
2020-10-03 18:54:02 -07:00
BattleAnimFunction_GrowthSwordsDance:
; Moves object in a circle where the height is 1/8 the width, while also moving upward 2 pixels per frame
; Obj Param: Defines where the object starts in the circle
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 18
call BattleAnim_Sine
sra a
sra a
sra a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
add [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
ld d , $ 18
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
dec [ hl ]
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_StrengthSeismicToss:
; Moves object up for $e0 frames, then shakes it vertically and throws it at the target. Uses anim_incobj to move to final phase
; Obj Param: Defined but not used
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ e0
2020-10-03 18:54:02 -07:00
jr nz , .move_up
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 2
ret
2020-10-03 18:54:02 -07:00
.move_up
2015-12-23 14:10:50 -08:00
ld d , a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld e , [ hl ]
2018-08-25 11:43:02 -07:00
ld hl , - $ 80
2015-12-23 14:10:50 -08:00
add hl , de
ld e , l
ld d , h
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], e
ret
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .switch_position
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.switch_position
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 4
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
xor $ ff
inc a
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 84
2020-10-03 18:54:02 -07:00
jr nc , .done
2015-12-23 14:10:50 -08:00
ld a , $ 4
2020-10-03 18:54:02 -07:00
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_SpeedLine:
; Used in moves where the user disappears for a speed-based attack such as Quick Attack, Mach Punch and Extremespeed
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 7 f
2019-02-06 01:16:40 -08:00
add BATTLEANIMFRAMESET_81 ; BATTLEANIMFRAMESET_82 BATTLEANIMFRAMESET_83
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-10-03 18:54:02 -07:00
.one
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
bit 7 , [ hl ]
2020-10-03 18:54:02 -07:00
jr nz , .inverted
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
.inverted
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Sludge:
; Object moves upward for $c frames and switches to FRAMESET_20
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ c
ret
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .done
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_20
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-10-03 18:54:02 -07:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_MetronomeHand:
; Fast circular motion with an x radius of $8 and y radius of $2
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
inc [ hl ]
push af
ld d , $ 2
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop af
ld d , $ 8
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_MetronomeSparkleSketch:
; Sideways wave motion while also moving downward until it disappears at y coord $20
; Obj Param: Is used internally only
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 20
2020-10-03 18:54:02 -07:00
jr c , .do_move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.do_move
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 8
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ 2
ld [ hl ], a
and $ 7
ret nz
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Agility:
; Object moves sideways at a speed determined by Obj Param. Can use anim_incobj to make it disappear
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.one
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_SafeguardProtect:
; Moves object in a circle where the width is 1/2 the height
; Obj Param: Defines starting point in circle
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld d , $ 18
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
sra a
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_LockOnMindReader:
; Moves objects towards a center position
; Obj Param: Used to define object angle from 0 to 3. Lower nybble defines how much to increase from base frameset while upper nybble defines angle of movement. The object moves for $28 frames, then waits for $10 frames and disappears
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 28
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f
ld hl , BATTLEANIMSTRUCT_FRAMESET_ID
add hl , bc
2019-02-06 01:16:40 -08:00
add [ hl ] ; BATTLEANIMFRAMESET_8F BATTLEANIMFRAMESET_90 BATTLEANIMFRAMESET_91
; BATTLEANIMFRAMESET_93 BATTLEANIMFRAMESET_94 BATTLEANIMFRAMESET_95
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ f0
or $ 8
ld [ hl ], a
2020-10-03 18:54:02 -07:00
.one
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr z , .done
2015-12-23 14:10:50 -08:00
dec [ hl ]
add $ 8
ld d , a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
ld [ hl ], $ 10
call BattleAnim_IncAnonJumptableIndex
2020-10-03 18:54:02 -07:00
.two
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
dec [ hl ]
and a
ret nz
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_HealBellNotes:
; Object moves horizontally in a sine wave, while also moving left every other frame and downwards for $38 frames after which it disappears
; Obj Param: Defines a frameset offset from FRAMESET_24
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
2016-05-05 12:07:37 -07:00
ld a , BATTLEANIMFRAMESET_24
2019-02-06 01:16:40 -08:00
add [ hl ] ; BATTLEANIMFRAMESET_25 BATTLEANIMFRAMESET_26
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2020-10-03 18:54:02 -07:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 38
2020-10-03 18:54:02 -07:00
jr nc , .done
2015-12-23 14:10:50 -08:00
inc [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
ld d , $ 18
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 1
ret nz
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_BatonPass:
; Object falls vertially and bounces on the ground
; Obj Param: Defines speed and duration
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
ret z
ld d , a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
call BattleAnim_Sine
bit 7 , a
2020-10-03 18:54:02 -07:00
jr nz , .negative
2015-12-23 14:10:50 -08:00
xor $ ff
inc a
2020-10-03 18:54:02 -07:00
.negative
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and $ 1 f
ret nz
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
srl [ hl ]
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_EncoreBellyDrum:
; Object moves at an arc for 8 frames and disappears
; Obj Param: Defines startging position in the arc
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 10
2020-10-03 18:54:02 -07:00
jr nc , .done
2015-12-23 14:10:50 -08:00
inc [ hl ]
inc [ hl ]
ld d , a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_SwaggerMorningSun:
; Moves object at an angle
; Obj Param: Lower 6 bits define angle of movement and upper 2 bits define speed
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld e , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
ld a , e
and $ c0
rlca
rlca
add [ hl ]
ld [ hl ], a
ld a , e
and $ 3 f
push af
push de
call BattleAnim_Sine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_HiddenPower:
; Moves object in a ring around position. Uses anim_incobj to move to second phase, where it expands the radius 8 pixels at a time for 13 frames and then disappears
; Obj Param: Defines starting position in circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2015-12-23 14:10:50 -08:00
ld d , $ 18
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
2020-10-03 18:54:02 -07:00
jr .step_circle
2015-12-23 14:10:50 -08:00
2020-10-03 18:54:02 -07:00
.one
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ 18
2020-10-03 18:54:02 -07:00
.two
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 80
2020-10-03 18:54:02 -07:00
jr nc , .done
2015-12-23 14:10:50 -08:00
ld d , a
add $ 8
ld [ hl ], a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-10-03 18:54:02 -07:00
jr .step_circle
2015-12-23 14:10:50 -08:00
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.step_circle
call BattleAnim_StepCircle
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Curse:
; Object moves down and to the left 2 pixels at a time until it reaches x coord $30 and disappears
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 30
2020-10-03 18:54:02 -07:00
jr c , .done
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
dec [ hl ]
dec [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
2020-10-03 18:54:02 -07:00
.zero:
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_PerishSong:
; Moves object in a large circle with a x radius of $50 and a y radius 1/4 or that, while also moving downwards
; Obj Param: Defines starting position in the circle
2015-12-23 14:10:50 -08:00
ld d , $ 50
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
inc [ hl ]
push af
push de
call BattleAnim_Sine
sra a
sra a
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
inc [ hl ]
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_RapidSpin:
; Object moves upwards 4 pixels per frame until it disappears at y coord $d0
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ d0
2020-10-03 18:54:02 -07:00
jr z , .done
2016-05-05 12:07:37 -07:00
dec [ hl ]
dec [ hl ]
dec [ hl ]
2015-12-23 14:10:50 -08:00
dec [ hl ]
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_BetaPursuit:
; Working but unused animation
; Object moves either down or up 4 pixels per frame, depending on Obj Param. Object disappears after 23 frames when going down, or at y coord $d8 when going up
; Obj Param: 0 moves downwards, 1 moves upwards
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
dw .three
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
and a
2020-10-03 18:54:02 -07:00
jr nz , .move_up
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], $ ec
2020-10-03 18:54:02 -07:00
.one
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 4
2020-10-03 18:54:02 -07:00
jr z , .three
2015-12-23 14:10:50 -08:00
inc [ hl ]
2016-05-05 12:07:37 -07:00
inc [ hl ]
inc [ hl ]
inc [ hl ]
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
.three
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
.move_up
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
call BattleAnim_IncAnonJumptableIndex
2020-10-03 18:54:02 -07:00
.two
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ d8
ret z
dec [ hl ]
2016-05-05 12:07:37 -07:00
dec [ hl ]
dec [ hl ]
dec [ hl ]
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_RainSandstorm:
; Object moves down 4 pixels at a time and right a variable distance
; Obj Param: Defines variation in the movement
; $0: 2 pixels horizontal movement
; $1: 8 pixels horizontal movement
; $2: 4 pixels horizontal movement
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2020-10-03 18:54:02 -07:00
dw .zero
dw .one
dw .two
dw .three
2018-02-03 17:40:21 -08:00
2020-10-03 18:54:02 -07:00
.zero
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
call BattleAnim_IncAnonJumptableIndex
ret
2020-10-03 18:54:02 -07:00
.one ; Obj Param 0
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ 4
cp $ 70
2020-10-03 18:54:02 -07:00
jr c , .dont_reset_y_offset_one
2015-12-23 14:10:50 -08:00
xor a
2020-10-03 18:54:02 -07:00
.dont_reset_y_offset_one
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
inc [ hl ]
ret
2020-10-03 18:54:02 -07:00
.two ; Obj Param 1
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ 4
cp $ 70
2020-10-03 18:54:02 -07:00
jr c , .dont_reset_y_offset_two
2015-12-23 14:10:50 -08:00
xor a
2020-10-03 18:54:02 -07:00
.dont_reset_y_offset_two
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ 8
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.three ; Obj Param 2
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ 4
cp $ 70
2020-10-03 18:54:02 -07:00
jr c , .dont_reset_y_offset_three
2015-12-23 14:10:50 -08:00
xor a
2020-10-03 18:54:02 -07:00
.dont_reset_y_offset_three
2015-12-23 14:10:50 -08:00
ld [ hl ], a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
add $ 4
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_AnimObjB0: ; unused
; Used by object ANIM_OBJ_B0, with itself is not used in any animation
; Obj Param: Lower nybble is added to VAR1 while upper nybble is added to XCOORD
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld e , [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
ld l , a
and $ f0
ld h , a
swap a
or h
ld h , a
ld a , l
and $ f
swap a
ld l , a
add hl , de
ld e , l
ld d , h
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], d
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], e
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_PsychUp:
; Object moves in a circle
; Obj Param: Defines starting position in the circle
2015-12-23 14:10:50 -08:00
ld d , $ 18
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
inc [ hl ]
2020-10-03 18:54:02 -07:00
call BattleAnim_StepCircle
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_Cotton:
; Object moves in a circle slowly
; Obj Param: Defines starting position in the circle
2015-12-23 14:10:50 -08:00
ld d , $ 18
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl , bc
2015-12-23 14:10:50 -08:00
ld a , [ hl ]
inc [ hl ]
srl a
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
2020-10-03 18:54:02 -07:00
call BattleAnim_StepCircle
2015-12-23 14:10:50 -08:00
ret
2020-10-03 18:54:02 -07:00
BattleAnimFunction_AncientPower:
; Object moves up and down in an arc for $20 frames and then disappear
; Obj Param: Defines range of arc motion
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl , bc
ld a , [ hl ]
cp $ 20
2020-10-03 18:54:02 -07:00
jr nc , .done
2015-12-23 14:10:50 -08:00
inc [ hl ]
2019-02-05 23:07:11 -08:00
ld hl , BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl , bc
ld d , [ hl ]
call BattleAnim_Sine
xor $ ff
inc a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2020-10-03 18:54:02 -07:00
BattleAnim_StepCircle:
; Inches object in a circular movement where its height is 1/4 the width
2015-12-23 14:10:50 -08:00
push af
push de
call BattleAnim_Sine
sra a
sra a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
pop de
pop af
call BattleAnim_Cosine
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XOFFSET
2015-12-23 14:10:50 -08:00
add hl , bc
ld [ hl ], a
ret
2020-10-03 18:54:02 -07:00
BattleAnim_StepToTarget:
; Inches object towards the opponent's side, moving half as much in the Y axis as it did in the X axis. Uses lower nybble of A
2015-12-23 14:10:50 -08:00
and $ f
ld e , a
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
add [ hl ]
ld [ hl ], a
srl e
2015-12-23 19:51:50 -08:00
ld hl , BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl , bc
2020-10-03 18:54:02 -07:00
.loop
2015-12-23 14:10:50 -08:00
dec [ hl ]
dec e
2020-10-03 18:54:02 -07:00
jr nz , .loop
2015-12-23 14:10:50 -08:00
ret
2018-06-24 07:09:41 -07:00
BattleAnim_AnonJumptable:
2015-12-23 14:10:50 -08:00
pop de
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
ld l , [ hl ]
ld h , $ 0
add hl , hl
add hl , de
ld a , [ hli ]
ld h , [ hl ]
ld l , a
2017-06-09 14:01:10 -07:00
jp hl
2015-12-23 14:10:50 -08:00
2018-06-24 07:09:41 -07:00
BattleAnim_IncAnonJumptableIndex:
2020-08-22 07:22:37 -07:00
ld hl , BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl , bc
inc [ hl ]
ret
2018-06-24 07:09:41 -07:00
BattleAnim_Cosine:
2018-01-09 13:39:36 -08:00
; a = d * cos(a * pi/32)
2018-02-03 18:11:55 -08:00
add % 010000 ; cos(x) = sin(x + pi/2)
; fallthrough
2018-06-24 07:09:41 -07:00
BattleAnim_Sine:
2018-01-09 13:39:36 -08:00
; a = d * sin(a * pi/32)
2018-02-03 18:11:55 -08:00
calc_sine_wave BattleAnimSineWave
2015-12-23 14:10:50 -08:00
2018-06-24 07:09:41 -07:00
BattleAnim_Sine_e:
2015-12-23 14:10:50 -08:00
ld a , e
call BattleAnim_Sine
ld e , a
ret
2018-06-24 07:09:41 -07:00
BattleAnim_Cosine_e:
2015-12-23 14:10:50 -08:00
ld a , e
call BattleAnim_Cosine
ld e , a
ret
2018-02-03 17:40:21 -08:00
2018-06-24 07:09:41 -07:00
BattleAnim_AbsSinePrecise:
2015-12-23 14:10:50 -08:00
ld a , e
call BattleAnim_Sine
ld e , l
ld d , h
ret
2018-02-03 17:40:21 -08:00
2018-06-24 07:09:41 -07:00
BattleAnim_AbsCosinePrecise:
2015-12-23 14:10:50 -08:00
ld a , e
call BattleAnim_Cosine
ld e , l
ld d , h
ret
2018-02-03 17:40:21 -08:00
2018-06-24 07:09:41 -07:00
BattleAnimSineWave:
2018-02-03 18:11:55 -08:00
sine_table 32