pokecrystal-board/engine/battle_anims/functions.asm

4310 lines
73 KiB
NASM
Raw Normal View History

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
jp hl
2015-12-23 14:10:50 -08:00
.Jumptable:
2023-09-24 06:06:19 -07:00
; entries correspond to BATTLE_ANIM_FUNC_* constants
table_width 2, DoBattleAnimFrame.Jumptable
2023-09-24 06:06:19 -07:00
dw BattleAnimFunc_Null
dw BattleAnimFunc_MoveFromUserToTarget
dw BattleAnimFunc_MoveFromUserToTargetAndDisappear
dw BattleAnimFunc_MoveInCircle
dw BattleAnimFunc_MoveWaveToTarget
dw BattleAnimFunc_ThrowFromUserToTarget
dw BattleAnimFunc_ThrowFromUserToTargetAndDisappear
dw BattleAnimFunc_Drop
dw BattleAnimFunc_MoveFromUserToTargetSpinAround
dw BattleAnimFunc_Shake
dw BattleAnimFunc_FireBlast
dw BattleAnimFunc_RazorLeaf
dw BattleAnimFunc_Bubble
dw BattleAnimFunc_Surf
dw BattleAnimFunc_Sing
dw BattleAnimFunc_WaterGun
dw BattleAnimFunc_Ember
dw BattleAnimFunc_Powder
dw BattleAnimFunc_PokeBall
dw BattleAnimFunc_PokeBallBlocked
dw BattleAnimFunc_Recover
dw BattleAnimFunc_ThunderWave
dw BattleAnimFunc_Clamp_Encore
dw BattleAnimFunc_Bite
dw BattleAnimFunc_SolarBeam
dw BattleAnimFunc_Gust
dw BattleAnimFunc_RazorWind
dw BattleAnimFunc_Kick
dw BattleAnimFunc_Absorb
dw BattleAnimFunc_Egg
dw BattleAnimFunc_MoveUp
dw BattleAnimFunc_Wrap
dw BattleAnimFunc_LeechSeed
dw BattleAnimFunc_Sound
dw BattleAnimFunc_ConfuseRay
dw BattleAnimFunc_Dizzy
dw BattleAnimFunc_Amnesia
dw BattleAnimFunc_FloatUp
dw BattleAnimFunc_Dig
dw BattleAnimFunc_String
dw BattleAnimFunc_Paralyzed
dw BattleAnimFunc_SpiralDescent
dw BattleAnimFunc_PoisonGas
dw BattleAnimFunc_Horn
dw BattleAnimFunc_Needle
dw BattleAnimFunc_PetalDance
dw BattleAnimFunc_ThiefPayday
dw BattleAnimFunc_AbsorbCircle
dw BattleAnimFunc_Bonemerang
dw BattleAnimFunc_Shiny
dw BattleAnimFunc_SkyAttack
dw BattleAnimFunc_GrowthSwordsDance
dw BattleAnimFunc_SmokeFlameWheel
dw BattleAnimFunc_PresentSmokescreen
dw BattleAnimFunc_StrengthSeismicToss
dw BattleAnimFunc_SpeedLine
dw BattleAnimFunc_Sludge
dw BattleAnimFunc_MetronomeHand
dw BattleAnimFunc_MetronomeSparkleSketch
dw BattleAnimFunc_Agility
dw BattleAnimFunc_SacredFire
dw BattleAnimFunc_SafeguardProtect
dw BattleAnimFunc_LockOnMindReader
dw BattleAnimFunc_Spikes
dw BattleAnimFunc_HealBellNotes
dw BattleAnimFunc_BatonPass
dw BattleAnimFunc_Conversion
dw BattleAnimFunc_EncoreBellyDrum
dw BattleAnimFunc_SwaggerMorningSun
dw BattleAnimFunc_HiddenPower
dw BattleAnimFunc_Curse
dw BattleAnimFunc_PerishSong
dw BattleAnimFunc_RapidSpin
dw BattleAnimFunc_BetaPursuit
dw BattleAnimFunc_RainSandstorm
dw BattleAnimFunc_AnimObjB0
dw BattleAnimFunc_PsychUp
dw BattleAnimFunc_AncientPower
dw BattleAnimFunc_RockSmash
dw BattleAnimFunc_Cotton
assert_table_length NUM_BATTLE_ANIM_FUNCS
BattleAnimFunc_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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_ThrowFromUserToTargetAndDisappear:
call BattleAnimFunc_ThrowFromUserToTarget
2015-12-23 14:10:50 -08:00
ret c
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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]
2020-11-17 08:09:02 -08:00
; Decrease var1 and hold onto its previous value (argument of the sine function)
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
dec [hl]
2020-11-17 08:09:02 -08:00
; Get param (amplitude of the sine function)
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld d, [hl]
call BattleAnim_Sine
2020-11-17 08:09:02 -08:00
; Store the sine 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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
jr c, .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.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]
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
bit 7, [hl]
ld a, $0
jr z, .got_starting_position
2015-12-23 14:10:50 -08:00
ld a, $20
.got_starting_position
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], a
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $7f
ld [hl], a
2015-12-24 10:33:54 -08:00
.one
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_MoveFromUserToTargetAndDisappear:
; Same as BattleAnimFunc_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
jr nc, .done
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
2023-09-24 06:06:19 -07:00
call BattleAnimFunc_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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_POKE_BALL_3
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_POKE_BALL_1
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
dec a
ld [hl], a
and $1f
ret nz
ld [hl], a
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_POKE_BALL_4
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.six
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_POKE_BALL_5
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_POKE_BALL_2
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
dec a
ld [hl], a
and $1f
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
2023-09-24 06:06:19 -07:00
call BattleAnimFunc_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
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)
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
ldh [rSVBK], a
.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
INCLUDE "data/battle_anims/ball_colors.asm"
2017-12-11 14:11:30 -08:00
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
swap a
and $f
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_FLAMETHROWER
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ld a, [hl]
and $3f
ret nz
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $20
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 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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
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
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
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $f
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
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
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
.SetCoords:
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $0
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
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
swap a
and $f
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_BURNED
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_EMBER
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-24 10:33:54 -08:00
.eight
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
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
.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
; 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
; 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
; 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
; 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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hli], a
ld [hl], a
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_RAZOR_LEAF_2
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $3f
ld d, a
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
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
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
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
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
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
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
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
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_RAZOR_LEAF_1
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
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
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $40
rlca
rlca
2023-09-24 06:06:19 -07:00
add BATTLE_ANIM_FRAMESET_BIG_ROCK
2015-12-23 14:10:50 -08:00
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
call BattleAnim_IncAnonJumptableIndex
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
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $3f
ld d, a
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
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
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]
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $0
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_PULSING_BUBBLE
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
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
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
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
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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)
ldh [hLCDCPointer], a
2015-12-23 14:10:50 -08:00
ld a, $58
ldh [hLYOverrideStart], a
2015-12-23 14:10:50 -08:00
ld a, $5e
ldh [hLYOverrideEnd], a
2015-12-23 14:10:50 -08:00
ret
2015-12-24 10:33:54 -08:00
.one
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
jr nc, .move
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
xor a
ldh [hLYOverrideStart], a
2015-12-23 14:10:50 -08:00
ret
.move
2015-12-23 14:10:50 -08:00
dec a
ld [hl], a
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
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
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
jr c, .move_down
2015-12-23 14:10:50 -08:00
xor a
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
.move_down
2015-12-23 14:10:50 -08:00
inc a
inc a
ld [hl], a
sub $10
ret c
ldh [hLYOverrideStart], a
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_Sing:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_MUSIC_NOTE_1
add [hl] ; BATTLE_ANIM_FRAMESET_MUSIC_NOTE_2 BATTLE_ANIM_FRAMESET_MUSIC_NOTE_3
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.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
jr c, .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.move
2015-12-23 14:10:50 -08:00
ld a, $2
call BattleAnim_StepToTarget
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_WaterGun:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
dw .one
dw .two
dw .three
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
.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
jr c, .run_down
2015-12-23 14:10:50 -08:00
ld a, $2
call BattleAnim_StepToTarget
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
.run_down
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_WATER_GUN_2
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
ld hl, BATTLEANIMSTRUCT_OAMFLAGS
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $1
ld [hl], a
.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
jr nc, .splash
2015-12-23 14:10:50 -08:00
inc [hl]
ret
.splash
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_WATER_GUN_3
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.three
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
jr c, .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.move
2015-12-23 14:10:50 -08:00
ld a, [hl]
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
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
; 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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $f0
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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], a
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $1
.one
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
jr nz, .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.move
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
inc [hl]
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
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_ThunderWave:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
dw .one
dw .two
dw .three
.one
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_THUNDER_WAVE_EXTRA
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.zero
.two
2015-12-23 14:10:50 -08:00
ret
.three
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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]
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
bit 7, [hl]
jr nz, .flipped
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $10
jr .got_sine_start
2015-12-23 14:10:50 -08:00
.flipped
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $30
.got_sine_start
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $7f
ld [hl], a
.one
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
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]
2023-09-24 06:06:19 -07:00
inc a ; BATTLE_ANIM_FRAMESET_3B (Clamp Flipped)
; BATTLE_ANIM_FRAMESET_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
ld hl, BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl, bc
2023-09-24 06:06:19 -07:00
ld a, [hl] ; BATTLE_ANIM_FRAMESET_3A (Clamp)
; BATTLE_ANIM_FRAMESET_A0 (Hands)
2016-05-05 12:07:37 -07:00
.reinit
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ld a, [hl]
and $1f
ret nz
.two
.three
.four
.five
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
.six
ld hl, BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $1
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
bit 7, [hl]
jr nz, .flipped
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $10
jr .got_sine_start
2015-12-23 14:10:50 -08:00
.flipped
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $30
.got_sine_start
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $7f
ld [hl], a
.one
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
jr nz, .flipped2
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_BITE_2
jr .got_frameset
2015-12-23 14:10:50 -08:00
.flipped2
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_BITE_1
.got_frameset
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
inc [hl]
ld a, [hl]
and $1f
ret nz
.two
.three
.four
.five
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
.six
ld hl, BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $1
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $28
inc hl
ld [hl], $0
.one
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .zero_radius
2015-12-23 14:10:50 -08:00
ld d, a
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 hl, -$80
2015-12-23 14:10:50 -08:00
add hl, de
ld e, l
ld d, h
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], d
ret
.zero_radius
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_Gust:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
dw .one
dw .two
dw .three
dw .four
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
.one
.three
call .GustWobble
2015-12-23 14:10:50 -08:00
ret
.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
jr c, .move
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
.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
jr c, .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.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]
; 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
.GustWobble:
; Circular movement where width is retrieved from a list, and height is 1/16 of that
call .GetGustRadius
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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
sub $8
ld [hl], a
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
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
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
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
.GetGustRadius:
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
ld hl, .GustOffsets
2015-12-23 14:10:50 -08:00
add hl, de
ld d, [hl]
ret
.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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
jr nc, .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.move
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
.loop
2015-12-23 14:10:50 -08:00
inc [hl]
dec e
jr nz, .loop
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
.one
2015-12-23 14:10:50 -08:00
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld a, [hl]
2023-09-24 06:06:19 -07:00
inc a ; BATTLE_ANIM_FRAMESET_BIND_2
; BATTLE_ANIM_FRAMESET_BIND_4
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1 ; Unused?
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $8
.zero
.two
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
.one
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
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_LEECH_SEED_2
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
.two
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
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_LEECH_SEED_3
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.three
2015-12-23 14:10:50 -08:00
ret
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
ld hl, BATTLEANIMSTRUCT_FIX_Y
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
add $2
ld [hl], a
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]
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
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
.one
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
jr c, .wait
call BattleAnim_StepThrownToTarget
2015-12-23 14:10:50 -08:00
ret
.wait
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
.two
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_RazorWind:
call BattleAnimFunc_MoveInCircle
; Causes object to skip ahead the circular motion every frame
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
add $f
ld [hl], a
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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)
.zero
2015-12-23 14:10:50 -08:00
ret
.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
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
.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]
ld hl, BATTLEANIMSTRUCT_OAMFLAGS
2015-12-23 14:10:50 -08:00
add hl, bc
set 0, [hl]
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
.three
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $2c
ld hl, BATTLEANIMSTRUCT_FRAME
add hl, bc
ld [hl], $0
ld hl, BATTLEANIMSTRUCT_DURATION
add hl, bc
ld [hl], $80
.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]
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $28
inc hl ; BATTLEANIMSTRUCT_VAR2
2015-12-23 14:10:50 -08:00
ld [hl], $10
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
ld hl, BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], a
ret
.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
jr nc, .egg_bomb_vertical_wave
2015-12-23 14:10:50 -08:00
inc [hl]
.egg_bomb_vertical_wave
call .EggVerticalWaveMotion
2015-12-23 14:10:50 -08:00
ret
.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 $4b
jr nc, .softboiled_vertical_wave
2015-12-23 14:10:50 -08:00
inc [hl]
.softboiled_vertical_wave
call .EggVerticalWaveMotion
2015-12-23 14:10:50 -08:00
ret
.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
jr nc, .egg_bomb_done
2015-12-23 14:10:50 -08:00
and $f
jr nz, .egg_bomb_step
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
call BattleAnim_IncAnonJumptableIndex ; jumps to three
2015-12-23 14:10:50 -08:00
ret
.egg_bomb_done
; Increases jumptable index twice to four
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
inc [hl]
ret
.three
; Waits in place
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
jr z, .done_waiting
2015-12-23 14:10:50 -08:00
dec [hl]
ret
.done_waiting
ld hl, BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl, bc
dec [hl]
.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]
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld e, [hl]
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], e
ret
.five
; Clears Egg Bomb object via anim_incobj
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.seven
; Switches Softboiled frameset to egg wobbling
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_EGG_WOBBLE ; Egg wobbling
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
.eight
; Softboiled object waves slightly side to side
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
.nine
2023-09-24 06:06:19 -07:00
; First Softboiled BATTLE_ANIM_OBJ_EGG turns into the bottom half frameset
ld a, BATTLE_ANIM_FRAMESET_EGG_CRACKED_BOTTOM ; 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
.eleven
2023-09-24 06:06:19 -07:00
; Second Softboiled BATTLE_ANIM_OBJ_EGG
ld a, BATTLE_ANIM_FRAMESET_EGG_CRACKED_TOP ; Cracked egg top
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $40
ret
.twelve
; Top half of egg moves upward for $30 frames
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $30
jr c, .done_top_shell
2015-12-23 14:10:50 -08:00
dec [hl]
ret
.done_top_shell
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
.four
.ten
.thirteen
2015-12-23 14:10:50 -08:00
ret
.EggVerticalWaveMotion:
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hli]
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ld a, [hl]
and $3f ; cp 64
2015-12-23 14:10:50 -08:00
ret nz
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $20
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
jr z, .move
2015-12-23 14:10:50 -08:00
cp $d8
jr nc, .move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.move
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
2023-09-24 06:06:19 -07:00
; Obj Param: Used to define object angle. How much to increase from base frameset, which is hardcoded as BATTLE_ANIM_FRAMESET_SOUND_1
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
dw .one
.zero
ldh a, [hBattleTurn]
2015-12-23 14:10:50 -08:00
and a
jr z, .got_turn
; enemy
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
.got_turn
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $8 ; duration
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_SOUND_1
add [hl] ; BATTLE_ANIM_FRAMESET_SOUND_2 BATTLE_ANIM_FRAMESET_SOUND_3
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
.one
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .done_anim
2015-12-23 14:10:50 -08:00
dec [hl]
call .SoundWaveMotion
2015-12-23 14:10:50 -08:00
ret
.done_anim
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.SoundWaveMotion:
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .negative
2015-12-23 14:10:50 -08:00
dec a
ret z
; 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
.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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $3f
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $80
rlca
ld [hl], a
2023-09-24 06:06:19 -07:00
add BATTLE_ANIM_FRAMESET_CONFUSE_RAY_1 ; BATTLE_ANIM_FRAMESET_CONFUSE_RAY_2
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
.one
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
swap a
ld d, a
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
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
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]
.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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld a, [hl]
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], a
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $80
rlca
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
2023-09-24 06:06:19 -07:00
add [hl] ; BATTLE_ANIM_FRAMESET_61 BATTLE_ANIM_FRAMESET_62
; BATTLE_ANIM_FRAMESET_9C BATTLE_ANIM_FRAMESET_9D
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $7f
ld [hl], a
.one
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
inc [hl]
and $3f
jr z, .not_flipped
2015-12-23 14:10:50 -08:00
and $1f
ret nz
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
2023-09-24 06:06:19 -07:00
inc a ; BATTLE_ANIM_FRAMESET_62
; BATTLE_ANIM_FRAMESET_9D
jr .got_frameset
2015-12-23 14:10:50 -08:00
.not_flipped
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
2023-09-24 06:06:19 -07:00
ld a, [hl] ; BATTLE_ANIM_FRAMESET_61
; BATTLE_ANIM_FRAMESET_9C
.got_frameset
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_Amnesia:
; Creates 3 objects based on Obj Param
2023-09-24 06:06:19 -07:00
; Obj Param: How much to increase from base frameset, which is hardcoded as BATTLE_ANIM_FRAMESET_AMNESIA_1
; 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
dw .zero
dw .one
dw .two
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
2023-09-24 06:06:19 -07:00
add BATTLE_ANIM_FRAMESET_AMNESIA_1 ; BATTLE_ANIM_FRAMESET_AMNESIA_2 BATTLE_ANIM_FRAMESET_AMNESIA_3
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld e, [hl]
ld d, 0
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
.one
2015-12-23 14:10:50 -08:00
ret
.two
; anim_incobj forces obj to deinit
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_FloatUp:
; Object moves horizontally in a sine wave, while also moving up. Also used by Charm and the Nightmare status
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]
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_Dig:
; Object moves up then down with a wave motion, while also moving away from the user 1 pixel per frame
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_String:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
jr nz, .not_param_zero
; Obj Param 0 flips when used by enemy
ld hl, BATTLEANIMSTRUCT_OAMFLAGS
2015-12-23 14:10:50 -08:00
add hl, bc
set OAM_Y_FLIP, [hl]
.not_param_zero
2023-09-24 06:06:19 -07:00
add BATTLE_ANIM_FRAMESET_STRING_SHOT_1 ; BATTLE_ANIM_FRAMESET_STRING_SHOT_2 BATTLE_ANIM_FRAMESET_STRING_SHOT_3
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.one
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $0
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
jr nz, .right
2015-12-23 14:10:50 -08:00
ld a, e
and $f
ld [hl], a
ret
.right
2015-12-23 14:10:50 -08:00
ld a, e
and $f
xor $ff
inc a
ld [hl], a
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_PARALYZED_FLIPPED
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
.one
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .var1_zero
2015-12-23 14:10:50 -08:00
dec [hl]
ret
.var1_zero
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_SpiralDescent:
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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ld a, [hl]
and $7
ret nz
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_PetalDance:
; Object moves downwards in a spiral around the user. Object disappears at y coord $28
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
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ld a, [hl]
and $3
ret nz
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
jr nc, .end
2015-12-23 14:10:50 -08:00
inc [hl]
ret
.end
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_PoisonGas:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
2023-09-24 06:06:19 -07:00
dw BattleAnimFunc_SpiralDescent
.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]
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
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
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
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
jr z, .done
2015-12-23 14:10:50 -08:00
dec [hl]
ret
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
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
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
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
jr z, .done
2015-12-23 14:10:50 -08:00
dec [hl]
dec [hl]
ret
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $34
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
.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 $6c
jr c, .do_move
2015-12-23 14:10:50 -08:00
ret
.do_move
2015-12-23 14:10:50 -08:00
ld a, $2
call BattleAnim_StepToTarget
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
jr nz, .negative
2015-12-23 14:10:50 -08:00
xor $ff
inc a
.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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
sub $4
ld [hl], a
and $1f
cp $20
ret nz
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
.two
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .three
.zero
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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]
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], a
ret
.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
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
.two
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
jr c, .three
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.three
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
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
.zero
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $f0
swap a
ld hl, BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], a
ret
.two
; Pin Missile needle (arc)
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
jr z, .negative
2015-12-23 14:10:50 -08:00
ld [hl], a
.negative
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
sub $4
ld [hl], a
.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
jr c, .move_to_target
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.move_to_target
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
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
.one
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
and [hl]
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]
.var_doesnt_equal_param
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ld a, [hl]
and $3f
ret nz
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $20
inc hl
srl [hl]
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ld a, [hl]
and $1
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]
.dont_move_x
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $3
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]
.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]
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
cp $5a
jr nc, .increase_radius
2015-12-23 14:10:50 -08:00
ld a, [hl]
and a
jr z, .end
dec [hl] ; decreases radius
2015-12-23 14:10:50 -08:00
ret
.increase_radius
2015-12-23 14:10:50 -08:00
inc [hl]
ret
.end
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
inc [hl]
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
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]
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
cp $40
jr nc, .shrink
2015-12-23 14:10:50 -08:00
inc [hl]
ret
.shrink
2015-12-23 14:10:50 -08:00
ld a, [hl]
dec [hl]
and a
ret nz
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.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]
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
.one:
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
ld d, $30
call BattleAnim_Sine
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
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
inc [hl]
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero:
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
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
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
.one:
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
dw .three
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ldh a, [hBattleTurn]
2015-12-23 14:10:50 -08:00
and a
jr nz, .enemy_turn
2015-12-23 14:10:50 -08:00
ld a, $f0
jr .got_var1
2015-12-23 14:10:50 -08:00
.enemy_turn
2015-12-23 14:10:50 -08:00
ld a, $cc
.got_var1
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], a
ret
.one
call .SkyAttack_CyclePalette
2015-12-23 14:10:50 -08:00
ret
.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
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
.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
jr nc, .done
2015-12-23 14:10:50 -08:00
ld a, $4
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.SkyAttack_CyclePalette:
; Cycles wOBP0 pallete
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
ld hl, .GBCPals
2015-12-23 14:10:50 -08:00
add hl, de
ld a, [hl]
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
and [hl]
ld [wOBP0], a
ret
.GBCPals:
2015-12-23 14:10:50 -08:00
db $ff, $aa, $55, $aa
2018-01-25 18:34:42 -08:00
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
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
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
.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
jr nz, .move_up
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $2
ret
.move_up
2015-12-23 14:10:50 -08:00
ld d, a
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld e, [hl]
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], e
ret
.one
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
jr z, .switch_position
2015-12-23 14:10:50 -08:00
dec [hl]
ret
.switch_position
2015-12-23 14:10:50 -08:00
ld [hl], $4
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
.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
jr nc, .done
2015-12-23 14:10:50 -08:00
ld a, $4
call BattleAnim_StepToTarget
2015-12-23 14:10:50 -08:00
ret
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $7f
2023-09-24 06:06:19 -07:00
add BATTLE_ANIM_FRAMESET_SPEED_LINE_1 ; BATTLE_ANIM_FRAMESET_SPEED_LINE_2 BATTLE_ANIM_FRAMESET_SPEED_LINE_3
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.one
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
bit 7, [hl]
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
.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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_Sludge:
; Object moves upward for $c frames and switches to BATTLE_ANIM_FRAMESET_SLUDGE_BUBBLE_BURST
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
dw .one
dw .two
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $c
ret
.one
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .done
2015-12-23 14:10:50 -08:00
dec [hl]
ret
.done
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_SLUDGE_BUBBLE_BURST
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_MetronomeHand:
; Fast circular motion with an x radius of $8 and y radius of $2
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_MetronomeSparkleSketch:
; Sideways wave motion while also moving downward until it disappears at y coord $20
; Obj Param: Only used internally
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
jr c, .do_move
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.do_move
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
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
.one
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_SafeguardProtect:
; Moves object in a circle where the width is 1/2 the height
; Obj Param: Defines starting point in circle
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
inc [hl]
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $28
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
2023-09-24 06:06:19 -07:00
add [hl] ; BATTLE_ANIM_FRAMESET_8F BATTLE_ANIM_FRAMESET_90 BATTLE_ANIM_FRAMESET_91
; BATTLE_ANIM_FRAMESET_93 BATTLE_ANIM_FRAMESET_94 BATTLE_ANIM_FRAMESET_95
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
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
.one
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .done
2015-12-23 14:10:50 -08:00
dec [hl]
add $8
ld d, a
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
.done
2015-12-23 14:10:50 -08:00
ld [hl], $10
call BattleAnim_IncAnonJumptableIndex
.two
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
2023-09-24 06:06:19 -07:00
ld a, BATTLE_ANIM_FRAMESET_MUSIC_NOTE_1
add [hl] ; BATTLE_ANIM_FRAMESET_MUSIC_NOTE_2 BATTLE_ANIM_FRAMESET_MUSIC_NOTE_3
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.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
jr nc, .done
2015-12-23 14:10:50 -08:00
inc [hl]
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
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_BatonPass:
; Object falls vertically and bounces on the ground
; Obj Param: Defines speed and duration
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
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
jr nz, .negative
2015-12-23 14:10:50 -08:00
xor $ff
inc a
.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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $1f
ret nz
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
srl [hl]
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_EncoreBellyDrum:
; Object moves at an arc for 8 frames and disappears
; Obj Param: Defines starting position in the arc
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $10
jr nc, .done
2015-12-23 14:10:50 -08:00
inc [hl]
inc [hl]
ld d, a
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
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_SwaggerMorningSun:
; Moves object at an angle
; Obj Param: Lower 6 bits define angle of movement and upper 2 bits define speed
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld e, [hl]
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 $3f
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
.zero
2015-12-23 14:10:50 -08:00
ld d, $18
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
inc [hl]
jr .step_circle
2015-12-23 14:10:50 -08:00
.one
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $18
.two
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $80
jr nc, .done
2015-12-23 14:10:50 -08:00
ld d, a
add $8
ld [hl], a
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
jr .step_circle
2015-12-23 14:10:50 -08:00
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.step_circle
call BattleAnim_StepCircle
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
.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
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
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
.zero:
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
dw .three
.zero
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
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
.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
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
.three
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
.move_up
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
call BattleAnim_IncAnonJumptableIndex
.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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
dw .zero
dw .one
dw .two
dw .three
.zero
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
ld hl, BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], a
call BattleAnim_IncAnonJumptableIndex
ret
.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
jr c, .dont_reset_y_offset_one
2015-12-23 14:10:50 -08:00
xor a
.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
.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
jr c, .dont_reset_y_offset_two
2015-12-23 14:10:50 -08:00
xor a
.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
.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
jr c, .dont_reset_y_offset_three
2015-12-23 14:10:50 -08:00
xor a
.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
2023-09-24 06:06:19 -07:00
BattleAnimFunc_AnimObjB0: ; unused
; Used by object BATTLE_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]
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld e, [hl]
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
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], e
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
inc [hl]
call BattleAnim_StepCircle
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_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
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
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
add [hl]
call BattleAnim_StepCircle
2015-12-23 14:10:50 -08:00
ret
2023-09-24 06:06:19 -07:00
BattleAnimFunc_AncientPower:
; Object moves up and down in an arc for $20 frames and then disappears
; Obj Param: Defines range of arc motion
ld hl, BATTLEANIMSTRUCT_VAR1
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $20
jr nc, .done
2015-12-23 14:10:50 -08:00
inc [hl]
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
.done
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
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
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
.loop
2015-12-23 14:10:50 -08:00
dec [hl]
dec e
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
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
jp hl
2015-12-23 14:10:50 -08:00
2018-06-24 07:09:41 -07:00
BattleAnim_IncAnonJumptableIndex:
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)
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)
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
BattleAnim_AbsSinePrecise: ; unreferenced
2015-12-23 14:10:50 -08:00
ld a, e
call BattleAnim_Sine
ld e, l
ld d, h
ret
BattleAnim_AbsCosinePrecise: ; unreferenced
2015-12-23 14:10:50 -08:00
ld a, e
call BattleAnim_Cosine
ld e, l
ld d, h
ret
2018-06-24 07:09:41 -07:00
BattleAnimSineWave:
sine_table 32