Decompile fight.c

This commit is contained in:
Marcus Huderle 2018-11-26 10:25:51 -06:00
parent 35c0fb5154
commit 2425a14b19
5 changed files with 666 additions and 1676 deletions

File diff suppressed because it is too large Load Diff

View File

@ -96,6 +96,12 @@ void sub_80A6864(struct Sprite *sprite, s16 a2);
s16 sub_80A861C(u8 battlerId, u8 a2); s16 sub_80A861C(u8 battlerId, u8 a2);
u8 GetBattlerYCoordWithElevation(u8 battlerId); u8 GetBattlerYCoordWithElevation(u8 battlerId);
void WaitAnimForDuration(struct Sprite *sprite); void WaitAnimForDuration(struct Sprite *sprite);
void sub_80A7938(struct Sprite *sprite);
void InitAnimLinearTranslation(struct Sprite *sprite);
void sub_80A6F98(struct Sprite *sprite);
u8 sub_80A8328(u8 battlerId);
void *sub_80A8050(s16 bottom, s16 top);
void sub_80A8048(s16 *bottom, s16 *top, const void *ptr);
void sub_80A8278(void); void sub_80A8278(void);
void sub_80A6B30(struct UnknownAnimStruct2*); void sub_80A6B30(struct UnknownAnimStruct2*);
void sub_80A6B90(struct UnknownAnimStruct2*, u32 arg1); void sub_80A6B90(struct UnknownAnimStruct2*, u32 arg1);

View File

@ -162,7 +162,7 @@ SECTIONS {
asm/fire.o(.text); asm/fire.o(.text);
asm/electric.o(.text); asm/electric.o(.text);
asm/ice.o(.text); asm/ice.o(.text);
asm/fight.o(.text); src/fight.o(.text);
src/poison.o(.text); src/poison.o(.text);
asm/flying.o(.text); asm/flying.o(.text);
asm/psychic.o(.text); asm/psychic.o(.text);

View File

@ -36,9 +36,7 @@ extern const union AffineAnimCmd *gUnknown_082FF6C0[];
// This file's functions. // This file's functions.
void sub_80A64EC(struct Sprite *sprite); void sub_80A64EC(struct Sprite *sprite);
void sub_80A653C(struct Sprite *sprite); void sub_80A653C(struct Sprite *sprite);
void InitAnimLinearTranslation(struct Sprite *sprite);
void sub_80A6FB4(struct Sprite *sprite); void sub_80A6FB4(struct Sprite *sprite);
void sub_80A6F98(struct Sprite *sprite);
void sub_80A7144(struct Sprite *sprite); void sub_80A7144(struct Sprite *sprite);
void sub_80A791C(struct Sprite *sprite); void sub_80A791C(struct Sprite *sprite);
void sub_80A8DFC(struct Sprite *sprite); void sub_80A8DFC(struct Sprite *sprite);
@ -50,8 +48,6 @@ void sub_80A7AFC(u8 taskId);
void sub_80A8CAC(u8 taskId); void sub_80A8CAC(u8 taskId);
void AnimTask_BlendMonInAndOutStep(u8 taskId); void AnimTask_BlendMonInAndOutStep(u8 taskId);
bool8 sub_80A7238(void); bool8 sub_80A7238(void);
void sub_80A8048(s16 *bottom, s16 *top, const void *ptr);
void *sub_80A8050(s16 bottom, s16 top);
u8 sub_80A82E4(u8 battlerId); u8 sub_80A82E4(u8 battlerId);
void sub_80A8D78(struct Task *task, u8 taskId); void sub_80A8D78(struct Task *task, u8 taskId);

View File

@ -1,25 +1,42 @@
#include "global.h" #include "global.h"
#include "battle_anim.h" #include "battle_anim.h"
#include "gpu_regs.h"
#include "random.h"
#include "task.h"
#include "trig.h"
#include "constants/rgb.h" #include "constants/rgb.h"
extern void unc_080B08A0(struct Sprite *); void unc_080B08A0(struct Sprite *);
extern void sub_810CE68(struct Sprite *); void sub_810CE68(struct Sprite *);
extern void sub_810CEB4(struct Sprite *); void sub_810CEB4(struct Sprite *);
extern void sub_810CEE0(struct Sprite *); void AnimBasicFistOrFoot(struct Sprite *);
extern void sub_810CF30(struct Sprite *); void sub_810CF30(struct Sprite *);
extern void sub_810D10C(struct Sprite *); void sub_810D10C(struct Sprite *);
extern void sub_810D1B4(struct Sprite *); void sub_810D1B4(struct Sprite *);
extern void sub_810D278(struct Sprite *); void AnimSpinningKickOrPunch(struct Sprite *);
extern void sub_810D2E4(struct Sprite *); void AnimStompFoot(struct Sprite *);
extern void sub_810D37C(struct Sprite *); void sub_810D37C(struct Sprite *);
extern void sub_810D40C(struct Sprite *); void sub_810D40C(struct Sprite *);
extern void sub_810D4F4(struct Sprite *); void sub_810D4F4(struct Sprite *);
extern void sub_810D608(struct Sprite *); void sub_810D608(struct Sprite *);
extern void sub_810D714(struct Sprite *); void sub_810D714(struct Sprite *);
extern void sub_810D874(struct Sprite *); void sub_810D874(struct Sprite *);
extern void sub_810D984(struct Sprite *); void sub_810D984(struct Sprite *);
extern void sub_810DA10(struct Sprite *); void sub_810DA10(struct Sprite *);
extern void sub_810DA7C(struct Sprite *); void sub_810DA7C(struct Sprite *);
static void sub_810D0B8(struct Sprite *);
static void sub_810D164(struct Sprite *);
static void sub_810D240(struct Sprite *);
static void AnimSpinningKickOrPunchFinish(struct Sprite *);
static void AnimStompFootStep(struct Sprite *);
static void AnimStompFootEnd(struct Sprite *);
static void sub_810D47C(struct Sprite *);
static void sub_810D5DC(struct Sprite *);
static void sub_810D6A8(struct Sprite *);
static void sub_810D770(struct Sprite *);
static void sub_810D830(struct Sprite *);
extern struct SpriteTemplate gBasicHitSplatSpriteTemplate;
const struct SpriteTemplate gUnknown_08595E14 = const struct SpriteTemplate gUnknown_08595E14 =
{ {
@ -109,7 +126,7 @@ const struct SpriteTemplate gFistFootSpriteTemplate =
.anims = gUnknown_08595E54, .anims = gUnknown_08595E54,
.images = NULL, .images = NULL,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_810CEE0, .callback = AnimBasicFistOrFoot,
}; };
const struct SpriteTemplate gUnknown_08595EB0 = const struct SpriteTemplate gUnknown_08595EB0 =
@ -165,7 +182,7 @@ const struct SpriteTemplate gUnknown_08595F14 =
.anims = gUnknown_08595E54, .anims = gUnknown_08595E54,
.images = NULL, .images = NULL,
.affineAnims = gUnknown_08595F10, .affineAnims = gUnknown_08595F10,
.callback = sub_810D278, .callback = AnimSpinningKickOrPunch,
}; };
const union AffineAnimCmd gUnknown_08595F2C[] = const union AffineAnimCmd gUnknown_08595F2C[] =
@ -188,7 +205,7 @@ const struct SpriteTemplate gMegaPunchKickSpriteTemplate =
.anims = gUnknown_08595E54, .anims = gUnknown_08595E54,
.images = NULL, .images = NULL,
.affineAnims = gUnknown_08595F44, .affineAnims = gUnknown_08595F44,
.callback = sub_810D278, .callback = AnimSpinningKickOrPunch,
}; };
const struct SpriteTemplate gUnknown_08595F60 = const struct SpriteTemplate gUnknown_08595F60 =
@ -199,7 +216,7 @@ const struct SpriteTemplate gUnknown_08595F60 =
.anims = gUnknown_08595E58, .anims = gUnknown_08595E58,
.images = NULL, .images = NULL,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_810D2E4, .callback = AnimStompFoot,
}; };
const struct SpriteTemplate gUnknown_08595F78 = const struct SpriteTemplate gUnknown_08595F78 =
@ -396,3 +413,623 @@ const struct SpriteTemplate gUnknown_08596104 =
.affineAnims = gUnknown_08596100, .affineAnims = gUnknown_08596100,
.callback = sub_810DA7C, .callback = sub_810DA7C,
}; };
void unc_080B08A0(struct Sprite *sprite)
{
sub_80A6864(sprite, gBattleAnimArgs[0]);
sprite->pos1.y += gBattleAnimArgs[1];
sprite->data[0] = 15;
sprite->callback = WaitAnimForDuration;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
void sub_810CE68(struct Sprite *sprite)
{
if (gBattleAnimArgs[7] == 1 && GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
{
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
gBattleAnimArgs[3] = -gBattleAnimArgs[3];
}
StartSpriteAnim(sprite, gBattleAnimArgs[6]);
gBattleAnimArgs[6] = 0;
sub_80A7938(sprite);
}
void sub_810CEB4(struct Sprite *sprite)
{
if (IsContest())
{
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
gBattleAnimArgs[3] = -gBattleAnimArgs[3];
}
sub_810CE68(sprite);
}
// Displays a basic fist or foot sprite for a given duration.
// Used by many fighting moves (and elemental "punch" moves).
// arg 0: initial x pixel offset
// arg 1: initial y pixel offset
// arg 2: duration
// arg 3: ? (todo: related to initial pixel offsets)
// arg 4: anim num
void AnimBasicFistOrFoot(struct Sprite *sprite)
{
StartSpriteAnim(sprite, gBattleAnimArgs[4]);
if (gBattleAnimArgs[3] == 0)
InitAnimSpritePos(sprite, 1);
else
sub_80A6980(sprite, TRUE);
sprite->data[0] = gBattleAnimArgs[2];
sprite->callback = WaitAnimForDuration;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
void sub_810CF30(struct Sprite *sprite)
{
u8 battler;
s16 xMod, yMod;
s16 x, y;
if (gBattleAnimArgs[0] == 0)
battler = gBattleAnimAttacker;
else
battler = gBattleAnimTarget;
if (gBattleAnimArgs[2] < 0)
gBattleAnimArgs[2] = Random2() % 5;
StartSpriteAnim(sprite, gBattleAnimArgs[2]);
sprite->pos1.x = GetBattlerSpriteCoord(battler, 2);
sprite->pos1.y = GetBattlerSpriteCoord(battler, 3);
xMod = sub_80A861C(battler, 1) / 2;
yMod = sub_80A861C(battler, 0) / 4;
x = Random2() % xMod;
y = Random2() % yMod;
if (Random2() & 1)
x *= -1;
if (Random2() & 1)
y *= -1;
if ((gBattlerPositions[battler] & BIT_SIDE) == B_SIDE_PLAYER)
y += 0xFFF0;
sprite->pos1.x += x;
sprite->pos1.y += y;
sprite->data[0] = gBattleAnimArgs[1];
sprite->data[7] = CreateSprite(&gBasicHitSplatSpriteTemplate, sprite->pos1.x, sprite->pos1.y, sprite->subpriority + 1);
if (sprite->data[7] != 64)
{
StartSpriteAffineAnim(&gSprites[sprite->data[7]], 0);
gSprites[sprite->data[7]].callback = SpriteCallbackDummy;
}
sprite->callback = sub_810D0B8;
}
static void sub_810D0B8(struct Sprite *sprite)
{
if (sprite->data[0] == 0)
{
if (sprite->data[7] != 64)
{
FreeOamMatrix(gSprites[sprite->data[7]].oam.matrixNum);
DestroySprite(&gSprites[sprite->data[7]]);
}
DestroyAnimSprite(sprite);
}
else
{
sprite->data[0]--;
}
}
void sub_810D10C(struct Sprite *sprite)
{
sub_80A6980(sprite, TRUE);
sprite->data[0] = 30;
if (gBattleAnimArgs[2] == 0)
{
sprite->data[2] = sprite->pos1.x - 20;
}
else
{
sprite->data[2] = sprite->pos1.x + 20;
sprite->hFlip = 1;
}
sprite->data[4] = sprite->pos1.y - 20;
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, sub_810D164);
}
static void sub_810D164(struct Sprite *sprite)
{
if (++sprite->data[5] == 11)
{
sprite->data[2] = sprite->pos1.x - sprite->pos2.x;
sprite->data[4] = sprite->pos1.y - sprite->pos2.y;
sprite->data[0] = 8;
sprite->pos1.x += sprite->pos2.x;
sprite->pos1.y += sprite->pos2.y;
sprite->pos2.y = 0;
sprite->pos2.x = 0;
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
}
void sub_810D1B4(struct Sprite *sprite)
{
if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && GetBattlerPosition(gBattleAnimTarget) < B_POSITION_PLAYER_RIGHT)
gBattleAnimArgs[0] *= -1;
sub_80A6980(sprite, TRUE);
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
sprite->data[0] = gBattleAnimArgs[3];
sprite->data[1] = sprite->pos1.x;
sprite->data[2] = sprite->pos1.x + gBattleAnimArgs[2];
sprite->data[3] = sprite->pos1.y;
sprite->data[4] = sprite->pos1.y;
InitAnimLinearTranslation(sprite);
sprite->data[5] = gBattleAnimArgs[5];
sprite->data[6] = gBattleAnimArgs[4];
sprite->data[7] = 0;
sprite->callback = sub_810D240;
}
static void sub_810D240(struct Sprite *sprite)
{
if (!TranslateAnimLinear(sprite))
{
sprite->pos2.y += Sin(sprite->data[7] >> 8, sprite->data[5]);
sprite->data[7] += sprite->data[6];
}
else
{
DestroyAnimSprite(sprite);
}
}
// Animates the spinning, shrinking kick or punch, which then
// reappears at full size. Used by moves such as MOVE_MEGA_PUNCH and MOVE_MEGA_KICK.
// arg 0: initial x pixel offset
// arg 1: initial y pixel offset
// arg 2: anim num
// arg 3: spin duration
void AnimSpinningKickOrPunch(struct Sprite *sprite)
{
sub_80A6980(sprite, TRUE);
StartSpriteAnim(sprite, gBattleAnimArgs[2]);
sprite->data[0] = gBattleAnimArgs[3];
sprite->callback = WaitAnimForDuration;
StoreSpriteCallbackInData6(sprite, AnimSpinningKickOrPunchFinish);
}
static void AnimSpinningKickOrPunchFinish(struct Sprite *sprite)
{
StartSpriteAffineAnim(sprite, 0);
sprite->affineAnimPaused = 1;
sprite->data[0] = 20;
sprite->callback = WaitAnimForDuration;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
// Animates MOVE_STOMP's foot that slides downward.
// arg 0: initial x pixel offset
// arg 1: initial y pixel offset
// arg 2: initial wait duration
void AnimStompFoot(struct Sprite *sprite)
{
sub_80A6980(sprite, TRUE);
sprite->data[0] = gBattleAnimArgs[2];
sprite->callback = AnimStompFootStep;
}
static void AnimStompFootStep(struct Sprite *sprite)
{
if (--sprite->data[0] == -1)
{
sprite->data[0] = 6;
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, AnimStompFootEnd);
}
}
static void AnimStompFootEnd(struct Sprite *sprite)
{
sprite->data[0] = 15;
sprite->callback = WaitAnimForDuration;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
void sub_810D37C(struct Sprite *sprite)
{
if (sprite->data[0] == 0)
{
sub_80A6980(sprite, TRUE);
sprite->data[1] = gBattleAnimArgs[2];
sprite->data[2] = gBattleAnimArgs[3];
sprite->data[0]++;
}
else
{
sprite->data[4] += sprite->data[1];
sprite->pos2.x = sprite->data[4] >> 8;
sprite->pos2.y = Sin(sprite->data[3], sprite->data[2]);
sprite->data[3] = (sprite->data[3] + 3) & 0xFF;
if (sprite->data[3] > 100)
sprite->invisible = sprite->data[3] % 2;
if (sprite->data[3] > 120)
DestroyAnimSprite(sprite);
}
}
void sub_810D40C(struct Sprite *sprite)
{
if (gBattleAnimArgs[0] == 0)
{
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0);
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1);
}
else
{
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0);
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 1);
}
sprite->pos1.x += gBattleAnimArgs[1];
sprite->pos1.y += gBattleAnimArgs[2];
sprite->data[0] = 0;
sprite->data[1] = gBattleAnimArgs[3];
sprite->data[2] = gBattleAnimArgs[4];
sprite->data[3] = 0;
sprite->callback = sub_810D47C;
}
static void sub_810D47C(struct Sprite *sprite)
{
switch (sprite->data[0])
{
case 0:
if (--sprite->data[1] == 0)
{
if (sprite->data[2] == 0)
DestroyAnimSprite(sprite);
else
sprite->data[0]++;
}
break;
case 1:
if (++sprite->data[1] > 1)
{
sprite->data[1] = 0;
sprite->data[3]++;
if (sprite->data[3] & 1)
sprite->pos2.x = 2;
else
sprite->pos2.x = -2;
}
if (--sprite->data[2] == 0)
DestroyAnimSprite(sprite);
break;
}
}
void sub_810D4F4(struct Sprite *sprite)
{
if (gBattleAnimArgs[0] == 0)
{
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0) + gBattleAnimArgs[2];
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1) + gBattleAnimArgs[3];
}
else
{
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0) + gBattleAnimArgs[2];
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 1) + gBattleAnimArgs[3];
}
sprite->oam.tileNum += gBattleAnimArgs[1] * 16;
sprite->data[0] = 0;
switch (gBattleAnimArgs[1])
{
case 0:
sprite->data[6] = -3;
sprite->data[7] = -3;
break;
case 1:
sprite->data[6] = 3;
sprite->data[7] = -3;
break;
case 2:
sprite->data[6] = -3;
sprite->data[7] = 3;
break;
case 3:
sprite->data[6] = 3;
sprite->data[7] = 3;
break;
default:
DestroyAnimSprite(sprite);
return;
}
sprite->callback = sub_810D5DC;
}
static void sub_810D5DC(struct Sprite *sprite)
{
sprite->pos1.x += sprite->data[6];
sprite->pos1.y += sprite->data[7];
if (++sprite->data[0] > 40)
DestroyAnimSprite(sprite);
}
void sub_810D608(struct Sprite *sprite)
{
if (gBattleAnimArgs[0] == 0)
{
sprite->pos1.x = GetBattlerSpriteCoord(gBattlerAttacker, 2);
sprite->pos1.y = GetBattlerSpriteCoord(gBattlerAttacker, 3);
sprite->oam.priority = sub_80A8328(gBattleAnimAttacker);
sprite->data[7] = gBattleAnimTarget;
}
else
{
sprite->oam.priority = sub_80A8328(gBattleAnimTarget);
sprite->data[7] = gBattleAnimAttacker;
}
sprite->data[0] = 0;
sprite->data[1] = 12;
sprite->data[2] = 8;
sprite->callback = sub_810D6A8;
}
static void sub_810D6A8(struct Sprite *sprite)
{
if (++sprite->data[0] == 180)
{
SetGpuReg(REG_OFFSET_BLDCNT, 0);
sprite->data[0] = 16;
sprite->data[1] = sprite->pos1.x;
sprite->data[2] = GetBattlerSpriteCoord(sprite->data[7], 2);
sprite->data[3] = sprite->pos1.y;
sprite->data[4] = GetBattlerSpriteCoord(sprite->data[7], 3);
InitAnimLinearTranslation(sprite);
StoreSpriteCallbackInData6(sprite, move_anim_8074EE0);
sprite->callback = sub_80A6F98;
}
}
void sub_810D714(struct Sprite *sprite)
{
sprite->pos1.x = gBattleAnimArgs[0];
sprite->pos1.y = 120;
sprite->data[0] = gBattleAnimArgs[3];
sub_80A8048(&sprite->data[4], &sprite->data[5], (void *)(sprite->pos1.y << 8));
sprite->data[6] = gBattleAnimArgs[1];
sprite->oam.tileNum += gBattleAnimArgs[2] * 4;
sprite->callback = sub_810D770;
}
static void sub_810D770(struct Sprite *sprite)
{
void *var0;
if (sprite->data[0] != 0)
{
var0 = sub_80A8050(sprite->data[4], sprite->data[5]);
var0 -= sprite->data[6];
sub_80A8048(&sprite->data[4], &sprite->data[5], var0);
var0 = (void *)(((intptr_t)var0) >> 8);
sprite->pos1.y = (intptr_t)var0;
if (sprite->pos1.y < -8)
DestroyAnimSprite(sprite);
else
sprite->data[0]--;
}
else
{
s16 pos0 = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
s16 pos1 = GetBattlerSpriteCoord(gBattleAnimAttacker, 3);
s16 pos2 = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
s16 pos3 = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
sprite->data[0] = pos2 - pos0;
sprite->data[1] = pos3 - pos1;
sprite->data[2] = sprite->pos1.x << 4;
sprite->data[3] = sprite->pos1.y << 4;
sprite->callback = sub_810D830;
}
}
static void sub_810D830(struct Sprite *sprite)
{
u16 edgeX;
sprite->data[2] += sprite->data[0];
sprite->data[3] += sprite->data[1];
sprite->pos1.x = sprite->data[2] >> 4;
sprite->pos1.y = sprite->data[3] >> 4;
edgeX = sprite->pos1.x + 8;
if (edgeX > 256 || sprite->pos1.y < -8 || sprite->pos1.y > 120)
DestroyAnimSprite(sprite);
}
void sub_810D874(struct Sprite *sprite)
{
u8 battler;
if (gBattleAnimArgs[0] == 0)
{
sprite->pos1.x = GetBattlerSpriteCoord(gBattlerAttacker, 2);
sprite->pos1.y = GetBattlerSpriteCoord(gBattlerAttacker, 3);
battler = gBattleAnimTarget;
sprite->oam.priority = sub_80A8328(gBattleAnimAttacker);
}
else
{
battler = gBattleAnimAttacker;
sprite->oam.priority = sub_80A8328(gBattleAnimTarget);
}
if (IsContest())
sprite->oam.matrixNum |= 0x8;
else if (GetBattlerSide(battler) == B_SIDE_PLAYER)
sprite->oam.matrixNum |= 0x18;
sprite->data[0] = 16;
sprite->data[1] = sprite->pos1.x;
sprite->data[2] = GetBattlerSpriteCoord(battler, 2);
sprite->data[3] = sprite->pos1.y;
sprite->data[4] = GetBattlerSpriteCoord(battler, 3);
InitAnimLinearTranslation(sprite);
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
sprite->callback = sub_80A6F98;
}
static void sub_810D960(struct Sprite *sprite)
{
if (sprite->data[0] == sprite->data[4])
DestroyAnimSprite(sprite);
sprite->data[0]++;
}
void sub_810D984(struct Sprite *sprite)
{
u8 turn;
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
sprite->data[1] = gBattleAnimArgs[3];
sprite->data[2] = gBattleAnimArgs[0];
sprite->data[3] = gBattleAnimArgs[1];
sprite->data[4] = gBattleAnimArgs[2];
turn = gAnimMoveTurn;
if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
turn++;
if (turn & 1)
{
sprite->data[2] = -sprite->data[2];
sprite->data[1]++;
}
StartSpriteAnim(sprite, sprite->data[1]);
sprite->pos2.x = sprite->data[2];
sprite->pos2.y = sprite->data[3];
sprite->callback = sub_810D960;
}
void sub_810DA10(struct Sprite *sprite)
{
if (gBattleAnimArgs[2] == 0)
InitAnimSpritePos(sprite, 0);
else
sub_80A6980(sprite, FALSE);
if (IsContest())
{
StartSpriteAnim(sprite, 2);
}
else if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
{
StartSpriteAnim(sprite, 1);
}
sprite->callback = sub_80A67D8;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
void sub_810DA7C(struct Sprite *sprite)
{
if (sprite->affineAnimEnded)
{
sprite->data[1] = (sprite->data[1] + 40) & 0xFF;
sprite->pos2.x = Sin(sprite->data[1], 2);
if (++sprite->data[0] > 40)
DestroyAnimSprite(sprite);
}
}
void sub_810DABC(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
sub_80A6DAC(0);
task->data[8] = gBattleAnimArgs[0];
task->data[0]++;
break;
case 1:
if (--task->data[8] == -1)
task->data[0]++;
break;
case 2:
default:
task->data[9] += 1280;
break;
}
task->data[10] += 2816;
if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
gBattle_BG3_X += task->data[9] >> 8;
else
gBattle_BG3_X -= task->data[9] >> 8;
gBattle_BG3_Y += task->data[10] >> 8;
task->data[9] &= 0xFF;
task->data[10] &= 0xFF;
if (gBattleAnimArgs[7] == -1)
{
gBattle_BG3_X = 0;
gBattle_BG3_Y = 0;
sub_80A6DAC(1);
DestroyAnimVisualTask(taskId);
}
}