pokecrystal-board/engine/battle_anims/functions.asm

4318 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:
; entries correspond to BATTLEANIMFUNC_* constants
dw BattleAnimFunction_Null
dw BattleAnimFunction_MoveFromUserToTarget
dw BattleAnimFunction_MoveFromUserToTargetAndDisappear
dw BattleAnimFunction_MoveInCircle
dw BattleAnimFunction_MoveWaveToTarget
dw BattleAnimFunction_ThrowFromUserToTarget
dw BattleAnimFunction_ThrowFromUserToTargetAndDisappear
dw BattleAnimFunction_Drop
dw BattleAnimFunction_MoveFromUserToTargetSpinAround
dw BattleAnimFunction_Shake
dw BattleAnimFunction_FireBlast
dw BattleAnimFunction_RazorLeaf
dw BattleAnimFunction_Bubble
dw BattleAnimFunction_Surf
dw BattleAnimFunction_Sing
dw BattleAnimFunction_WaterGun
dw BattleAnimFunction_Ember
dw BattleAnimFunction_Powder
dw BattleAnimFunction_PokeBall
dw BattleAnimFunction_PokeBallBlocked
dw BattleAnimFunction_Recover
dw BattleAnimFunction_ThunderWave
dw BattleAnimFunction_Clamp_Encore
dw BattleAnimFunction_Bite
dw BattleAnimFunction_SolarBeam
dw BattleAnimFunction_Gust
dw BattleAnimFunction_RazorWind
dw BattleAnimFunction_Kick
dw BattleAnimFunction_Absorb
dw BattleAnimFunction_Egg
dw BattleAnimFunction_MoveUp
dw BattleAnimFunction_Wrap
dw BattleAnimFunction_LeechSeed
dw BattleAnimFunction_Sound
dw BattleAnimFunction_ConfuseRay
dw BattleAnimFunction_Dizzy
dw BattleAnimFunction_Amnesia
dw BattleAnimFunction_FloatUp
dw BattleAnimFunction_Dig
dw BattleAnimFunction_String
dw BattleAnimFunction_Paralyzed
dw BattleAnimFunction_SpiralDescent
dw BattleAnimFunction_PoisonGas
dw BattleAnimFunction_Horn
dw BattleAnimFunction_Needle
dw BattleAnimFunction_PetalDance
dw BattleAnimFunction_ThiefPayday
dw BattleAnimFunction_AbsorbCircle
dw BattleAnimFunction_Bonemerang
dw BattleAnimFunction_Shiny
dw BattleAnimFunction_SkyAttack
dw BattleAnimFunction_GrowthSwordsDance
dw BattleAnimFunction_SmokeFlameWheel
dw BattleAnimFunction_PresentSmokescreen
dw BattleAnimFunction_StrengthSeismicToss
dw BattleAnimFunction_SpeedLine
dw BattleAnimFunction_Sludge
dw BattleAnimFunction_MetronomeHand
dw BattleAnimFunction_MetronomeSparkleSketch
dw BattleAnimFunction_Agility
dw BattleAnimFunction_SacredFire
dw BattleAnimFunction_SafeguardProtect
dw BattleAnimFunction_LockOnMindReader
dw BattleAnimFunction_Spikes
dw BattleAnimFunction_HealBellNotes
dw BattleAnimFunction_BatonPass
dw BattleAnimFunction_Conversion
dw BattleAnimFunction_EncoreBellyDrum
dw BattleAnimFunction_SwaggerMorningSun
dw BattleAnimFunction_HiddenPower
dw BattleAnimFunction_Curse
dw BattleAnimFunction_PerishSong
dw BattleAnimFunction_RapidSpin
dw BattleAnimFunction_BetaPursuit
dw BattleAnimFunction_RainSandstorm
dw BattleAnimFunction_AnimObjB0
dw BattleAnimFunction_PsychUp
dw BattleAnimFunction_AncientPower
dw BattleAnimFunction_RockSmash
dw BattleAnimFunction_Cotton
2015-12-23 14:10:50 -08:00
2018-06-24 07:09:41 -07:00
BattleAnimFunction_Null:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.one
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
ret
BattleAnimFunction_ThrowFromUserToTargetAndDisappear:
call BattleAnimFunction_ThrowFromUserToTarget
2015-12-23 14:10:50 -08:00
ret c
call DeinitBattleAnimation
ret
BattleAnimFunction_ThrowFromUserToTarget:
2016-05-05 12:07:37 -07:00
; If x coord at $88 or beyond, abort.
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $88
ret nc
2016-05-05 12:07:37 -07:00
; Move right 2 pixels
2015-12-23 14:10:50 -08:00
add $2
ld [hl], a
2016-05-05 12:07:37 -07:00
; Move down 1 pixel
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
dec [hl]
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
BattleAnimFunction_MoveWaveToTarget:
; Wave motion from one mon to another. Obj is cleared when it reaches x coord $88. Examples: Shadow Ball, Dragon Rage
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $88
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
BattleAnimFunction_MoveInCircle:
; Slow circular motion. Examples: Thundershock, Flamethrower
; Obj Param: Distance from center (masked with $7F). Bit 7 causes object to start on other side of the circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
BattleAnimFunction_MoveFromUserToTarget:
; Moves object diagonally at a ~30° angle towards opponent and stops when it reaches x coord $84. Obj Param changes the speed
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.one
2015-12-23 14:10:50 -08:00
call DeinitBattleAnimation
ret
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $84
ret nc
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
BattleAnimFunction_MoveFromUserToTargetAndDisappear:
; Same as BattleAnimFunction_01 but objs are cleared when they reach x coord $84
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $84
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
2018-06-24 07:09:41 -07:00
BattleAnimFunction_PokeBall:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
dw .five
dw .six
dw .seven
dw .eight
dw .nine
dw .ten
dw .eleven
2016-05-05 12:07:37 -07:00
.zero ; init
2016-01-27 09:25:12 -08:00
call GetBallAnimPal
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.one
call BattleAnimFunction_ThrowFromUserToTarget
2015-12-23 14:10:50 -08:00
ret c
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
add [hl]
ld [hl], a
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_0B
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.three
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_09
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_0C
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.six
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_0D
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_JUMPTABLE_INDEX
2015-12-23 14:10:50 -08:00
add hl, bc
dec [hl]
.two
.five
.nine
ret
2015-12-24 10:33:54 -08:00
.seven
2016-01-27 09:25:12 -08:00
call GetBallAnimPal
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_0A
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
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
2018-06-24 07:09:41 -07:00
BattleAnimFunction_PokeBallBlocked:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 14:10:50 -08:00
dw .zero
dw .one
dw .two
2015-12-24 10:33:54 -08:00
.zero
2016-01-27 09:25:12 -08:00
call GetBallAnimPal
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
ret
2015-12-24 10:33:54 -08:00
.one
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $70
jr nc, .next
call BattleAnimFunction_ThrowFromUserToTarget
2015-12-23 14:10:50 -08:00
ret
.next
call BattleAnim_IncAnonJumptableIndex
2015-12-24 10:33:54 -08:00
.two
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $80
jr nc, .done
add $4
ld [hl], a
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
dec [hl]
dec [hl]
ret
.done
call DeinitBattleAnimation
ret
2018-06-24 07:09:41 -07:00
GetBallAnimPal:
2017-12-11 14:11:30 -08:00
ld hl, BallColors
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
BattleAnimFunction_Ember:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
2015-12-24 10:33:54 -08:00
.zero
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_0F
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-24 10:33:54 -08:00
.four
2015-12-23 14:10:50 -08:00
ret
BattleAnimFunction_Drop:
; Drops obj. The Obj Param dictates how fast it is (lower value is faster) and how long it stays bouncing (lower value is longer). Example: Rock Slide
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
BattleAnimFunction_MoveFromUserToTargetSpinAround:
; Object moves from user to target target and spins around it once. Example: Fire Spin, Swift
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $80
2015-12-23 19:51:50 -08:00
jr nc, .next
call .SetCoords
2015-12-23 14:10:50 -08:00
ret
2015-12-23 19:51:50 -08:00
.next
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2015-12-24 10:33:54 -08:00
.one
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
BattleAnimFunction_Shake:
; Object switches position side to side. Obj Param defines how far to move it. Example: Dynamic Punch
; Some objects use this function with a Param of 0
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
BattleAnimFunction_FireBlast:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
dw .five
dw .six
dw .seven
dw .eight
dw .nine
2015-12-24 10:33:54 -08:00
.zero
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_11
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
2015-12-24 10:33:54 -08:00
.seven
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $88
2015-12-23 19:51:50 -08:00
jr nc, .set_up_eight
2015-12-23 14:10:50 -08:00
add $2
ld [hl], a
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
dec [hl]
ret
2015-12-23 19:51:50 -08:00
.set_up_eight
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_10
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-24 10:33:54 -08:00
.eight
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
2018-06-24 07:09:41 -07:00
BattleAnimFunction_RazorLeaf:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
dw .five
dw .six
dw .seven
dw .eight
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_17
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_16
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
BattleAnimFunction_RockSmash:
; Object moves at an arc
; Obj Param: Bit 7 makes arc flip horizontally
; Bit 6 defines offset from base frameset FRAMESET_19
; Rest defines arc radius
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
2015-12-24 10:33:54 -08:00
.zero
ld hl, BATTLEANIMSTRUCT_PARAM
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and $40
rlca
rlca
add BATTLEANIMFRAMESET_19
2015-12-23 14:10:50 -08:00
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
call BattleAnim_IncAnonJumptableIndex
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
BattleAnimFunction_Bubble:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_22
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-24 10:33:54 -08:00
.two
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $98
2015-12-23 19:51:50 -08:00
jr nc, .okay
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
BattleAnimFunction_Surf:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2015-12-23 19:51:50 -08:00
dw .zero
dw .one
dw .two
dw .three
dw .four
2015-12-24 10:33:54 -08:00
.zero
2015-12-23 14:10:50 -08:00
call BattleAnim_IncAnonJumptableIndex
2018-08-25 11:34:25 -07:00
ld a, LOW(rSCY)
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
BattleAnimFunction_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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_24
add [hl] ; BATTLEANIMFRAMESET_25 BATTLEANIMFRAMESET_26
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
BattleAnimFunction_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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_28
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $0
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $30
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_29
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.three
2015-12-23 14:10:50 -08:00
ret
BattleAnimFunction_Powder:
; Obj moves down and disappears at x coord $38
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $38
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
BattleAnimFunction_Recover:
; Obj moves in an ever shrinking circle. Obj Param defines initial position in the circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_35
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
BattleAnimFunction_Clamp_Encore:
; Claps two objects together, twice. Also used by Encore
; Second object's frameset and position relative to first are both defined via this function
; Obj Param: Distance from center (masked with $7F). Bit 7 flips object horizontally by switching to a different frameset
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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]
inc a ; BATTLEANIMFRAMESET_3B (Clamp Flipped)
; BATTLEANIMFRAMESET_A1 (Hands Flipped)
2016-05-05 12:07:37 -07:00
jr .reinit
2015-12-23 14:10:50 -08:00
2016-05-05 12:07:37 -07:00
.load_no_inc
ld hl, BATTLEANIMSTRUCT_VAR2
2015-12-23 19:51:50 -08:00
add hl, bc
ld a, [hl] ; BATTLEANIMFRAMESET_3A (Clamp)
; BATTLEANIMFRAMESET_A0 (Hands)
2016-05-05 12:07:37 -07:00
.reinit
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
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
BattleAnimFunction_Bite:
; Claps two objects together (vertically), twice
; Second object's frameset and position relative to first are both defined via this function
; Obj Param: Distance from center (masked with $7F). Bit 7 flips object vertically by switching to a different frameset
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
ld a, BATTLEANIMFRAMESET_3D
jr .got_frameset
2015-12-23 14:10:50 -08:00
.flipped2
ld a, BATTLEANIMFRAMESET_3C
.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
BattleAnimFunction_SolarBeam:
; Solar Beam charge up animation
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_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
BattleAnimFunction_Absorb:
; Moves object from target to user and disappears when reaches x coord $30. Example: Absorb, Mega Drain, Leech Seed status
; Obj Param: Speed in the X axis
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $30
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
BattleAnimFunction_Wrap:
; Plays out object Frameset. Use anim_incobj to move to next frameset
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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]
inc a ; BATTLEANIMFRAMESET_53
; BATTLEANIMFRAMESET_55
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
2018-06-24 07:09:41 -07:00
BattleAnimFunction_LeechSeed:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2016-05-05 12:07:37 -07:00
dw .zero
dw .one
dw .two
dw .three
.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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_57
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
.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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_58
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
BattleAnimFunction_Spikes:
; Object is thrown at target. After $20 frames it stops and waits another $20 frames then disappear
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_RazorWind:
call BattleAnimFunction_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
BattleAnimFunction_Kick:
; Uses anim_setobj for different kick types
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_Egg:
; Used by Egg Bomb and Softboiled
; Obj Param: Defines jumptable starting index
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
ld a, BATTLEANIMFRAMESET_4E ; 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
; First Softboiled ANIM_OBJ_EGG turns into the bottom half frameset
ld a, BATTLEANIMFRAMESET_50 ; Cracked egg bottom
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl, bc
ld [hl], $4
call BattleAnim_IncAnonJumptableIndex
ret
.eleven
; Second Softboiled ANIM_OBJ_EGG
ld a, BATTLEANIMFRAMESET_4F ; Cracked egg top
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
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
BattleAnimFunction_MoveUp:
; Moves object up for 41 frames
; Obj Param: Movement speed
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
and a
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
BattleAnimFunction_Sound:
; Moves object back and forth in one of three angles using a sine behavior and disappear after 8 frames. Used in Growl, Snore and Kinesis
; Obj Param: Used to define object angle. How much to increase from base frameset, which is hardcoded as BATTLEANIMFRAMESET_59
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_59
add [hl] ; BATTLEANIMFRAMESET_5A BATTLEANIMFRAMESET_5B
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
BattleAnimFunction_ConfuseRay:
; Creates the Confuse Ray object and moves it across the screen until x coord $80
; Moves horizontally every frame and vertically every 3 frames
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
add BATTLEANIMFRAMESET_5D ; BATTLEANIMFRAMESET_5E
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
BattleAnimFunction_Dizzy:
; Moves object in a circle where the height is 1/4 the width, with the next frameset from base whether moving left or right. Also used for Nightmare
; Obj Param: Defines starting position in the circle (masked with $80). Bit 7 flips it at the start
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
add [hl] ; BATTLEANIMFRAMESET_61 BATTLEANIMFRAMESET_62
; BATTLEANIMFRAMESET_9C BATTLEANIMFRAMESET_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]
inc a ; BATTLEANIMFRAMESET_62
; BATTLEANIMFRAMESET_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
ld a, [hl] ; BATTLEANIMFRAMESET_61
; BATTLEANIMFRAMESET_9C
.got_frameset
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
ret
BattleAnimFunction_Amnesia:
; Creates 3 objects based on Obj Param
; Obj Param: How much to increase from base frameset, which is hardcoded as BATTLEANIMFRAMESET_63
; anim_incobj is used to DeInit object (used by Present)
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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]
add BATTLEANIMFRAMESET_63 ; BATTLEANIMFRAMESET_64 BATTLEANIMFRAMESET_65
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
BattleAnimFunction_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
BattleAnimFunction_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
BattleAnimFunction_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
add BATTLEANIMFRAMESET_6A ; BATTLEANIMFRAMESET_6B BATTLEANIMFRAMESET_6C
2015-12-23 14:10:50 -08:00
call ReinitBattleAnimFrameset
.one
2015-12-23 14:10:50 -08:00
ret
BattleAnimFunction_Paralyzed:
; Also used by Disable
; Obj Param: When bit 7 is set, frameset is replaced with flipped version. This bit is discarded and object then moves back and forth between position in lower nybble and upper nybble of Param every other frame
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_6E
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
2018-06-24 07:09:41 -07:00
BattleAnimFunction_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
BattleAnimFunction_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
2018-06-24 07:09:41 -07:00
BattleAnimFunction_PoisonGas:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
dw .zero
2016-05-05 12:07:37 -07:00
dw BattleAnimFunction_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
BattleAnimFunction_SmokeFlameWheel:
; Object spins around target while also moving upward until it disappears at x coord $e8
; Obj Param: Defines where the object starts in the circle
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
BattleAnimFunction_SacredFire:
; Moves object in a circle where the height is 1/8 the width, while also moving upward 2 pixels per frame for 24 frames after which it disappears
; Obj Param: Is used internally only
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
BattleAnimFunction_PresentSmokescreen:
; Object bounces from user to target and stops at x coord $6c. Uses anim_incobj to clear object
; Obj Param: Defined but not used
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
2018-06-24 07:09:41 -07:00
BattleAnimFunction_Horn:
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
2016-05-05 12:07:37 -07:00
dw .zero
dw .one
dw .two
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
BattleAnimFunction_Needle:
; Moves object towards target, either in a straight line or arc. Stops at x coord $84
; Obj Param: Upper nybble defines the index of the jumptable. Lower nybble defines the speed.
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_ThiefPayday:
; Object drops off target and bounces once on the floor
; Obj Param: Defines every how many frames the object moves horizontally
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_AbsorbCircle:
; A circle of objects that starts at the target and moves to the user. It expands until x coord $5a and then shrinks. Once radius reaches 0, the object disappears. Also used by Mimic and Conversion2
; Obj Param: Defines the position in the circle the object starts at
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
BattleAnimFunction_Conversion:
; A rotating circle of objects centered at a position. It expands for $40 frames and then shrinks. Once radius reaches 0, the object disappears.
; Obj Param: Defines starting point in the circle
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
BattleAnimFunction_Bonemerang:
; Boomerang-like movement from user to target
; Obj Param: Defines position to start at in the circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_Shiny:
; Puts object in a circle formation of radius $10. Also used by Flash and Light Screen
; Obj Param: Defines where the object starts in the circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_SkyAttack:
; Uses anim_incobj to move to next step
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
ldh a, [hSGB]
2015-12-23 14:10:50 -08:00
and a
jr nz, .sgb
ld hl, .GBCPals
jr .got_pals
2015-12-23 14:10:50 -08:00
.sgb
ld hl, .SGBPals
.got_pals
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
.SGBPals:
2015-12-23 14:10:50 -08:00
db $ff, $ff, $00, $00
2018-01-25 18:34:42 -08:00
BattleAnimFunction_GrowthSwordsDance:
; Moves object in a circle where the height is 1/8 the width, while also moving upward 2 pixels per frame
; Obj Param: Defines where the object starts in the circle
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
BattleAnimFunction_StrengthSeismicToss:
; Moves object up for $e0 frames, then shakes it vertically and throws it at the target. Uses anim_incobj to move to final phase
; Obj Param: Defined but not used
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_SpeedLine:
; Used in moves where the user disappears for a speed-based attack such as Quick Attack, Mach Punch and Extremespeed
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
add BATTLEANIMFRAMESET_81 ; BATTLEANIMFRAMESET_82 BATTLEANIMFRAMESET_83
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
BattleAnimFunction_Sludge:
; Object moves upward for $c frames and switches to FRAMESET_20
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_20
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
BattleAnimFunction_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
BattleAnimFunction_MetronomeSparkleSketch:
; Sideways wave motion while also moving downward until it disappears at y coord $20
; Obj Param: Is used internally only
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $20
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
BattleAnimFunction_Agility:
; Object moves sideways at a speed determined by Obj Param. Can use anim_incobj to make it disappear
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_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
BattleAnimFunction_LockOnMindReader:
; Moves objects towards a center position
; Obj Param: Used to define object angle from 0 to 3. Lower nybble defines how much to increase from base frameset while upper nybble defines angle of movement. The object moves for $28 frames, then waits for $10 frames and disappears
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
add [hl] ; BATTLEANIMFRAMESET_8F BATTLEANIMFRAMESET_90 BATTLEANIMFRAMESET_91
; BATTLEANIMFRAMESET_93 BATTLEANIMFRAMESET_94 BATTLEANIMFRAMESET_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
BattleAnimFunction_HealBellNotes:
; Object moves horizontally in a sine wave, while also moving left every other frame and downwards for $38 frames after which it disappears
; Obj Param: Defines a frameset offset from FRAMESET_24
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
2016-05-05 12:07:37 -07:00
ld a, BATTLEANIMFRAMESET_24
add [hl] ; BATTLEANIMFRAMESET_25 BATTLEANIMFRAMESET_26
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
BattleAnimFunction_BatonPass:
; Object falls vertially 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
BattleAnimFunction_EncoreBellyDrum:
; Object moves at an arc for 8 frames and disappears
; Obj Param: Defines startging 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
BattleAnimFunction_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
BattleAnimFunction_HiddenPower:
; Moves object in a ring around position. Uses anim_incobj to move to second phase, where it expands the radius 8 pixels at a time for 13 frames and then disappears
; Obj Param: Defines starting position in circle
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_Curse:
; Object moves down and to the left 2 pixels at a time until it reaches x coord $30 and disappears
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_PerishSong:
; Moves object in a large circle with a x radius of $50 and a y radius 1/4 or that, while also moving downwards
; Obj Param: Defines starting position in the circle
2015-12-23 14:10:50 -08:00
ld d, $50
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
BattleAnimFunction_RapidSpin:
; Object moves upwards 4 pixels per frame until it disappears at y coord $d0
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_YOFFSET
2015-12-23 14:10:50 -08:00
add hl, bc
ld a, [hl]
cp $d0
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
BattleAnimFunction_BetaPursuit:
; Working but unused animation
; Object moves either down or up 4 pixels per frame, depending on Obj Param. Object disappears after 23 frames when going down, or at y coord $d8 when going up
; Obj Param: 0 moves downwards, 1 moves upwards
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_RainSandstorm:
; Object moves down 4 pixels at a time and right a variable distance
; Obj Param: Defines variation in the movement
; $0: 2 pixels horizontal movement
; $1: 8 pixels horizontal movement
; $2: 4 pixels horizontal movement
2015-12-23 14:10:50 -08:00
call BattleAnim_AnonJumptable
2015-12-26 18:59:03 -08:00
.anon_dw
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
BattleAnimFunction_AnimObjB0: ; unused
; Used by object ANIM_OBJ_B0, with itself is not used in any animation
; Obj Param: Lower nybble is added to VAR1 while upper nybble is added to XCOORD
2015-12-23 19:51:50 -08:00
ld hl, BATTLEANIMSTRUCT_XCOORD
2015-12-23 14:10:50 -08:00
add hl, bc
ld d, [hl]
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
BattleAnimFunction_PsychUp:
; Object moves in a circle
; Obj Param: Defines starting position in the circle
2015-12-23 14:10:50 -08:00
ld d, $18
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
BattleAnimFunction_Cotton:
; Object moves in a circle slowly
; Obj Param: Defines starting position in the circle
2015-12-23 14:10:50 -08:00
ld d, $18
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
BattleAnimFunction_AncientPower:
; Object moves up and down in an arc for $20 frames and then disappear
; 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