2018-10-25 23:46:23 +02:00
|
|
|
#include "global.h"
|
2018-12-09 14:08:15 +01:00
|
|
|
#include "battle.h"
|
2018-10-25 23:46:23 +02:00
|
|
|
#include "battle_anim.h"
|
2018-12-09 09:14:07 +01:00
|
|
|
#include "gpu_regs.h"
|
2018-12-09 14:08:15 +01:00
|
|
|
#include "palette.h"
|
2018-10-25 23:46:23 +02:00
|
|
|
#include "constants/rgb.h"
|
2018-12-09 14:08:15 +01:00
|
|
|
#include "scanline_effect.h"
|
2018-12-09 09:14:07 +01:00
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "trig.h"
|
2018-12-09 14:08:15 +01:00
|
|
|
#include "util.h"
|
2018-10-25 23:46:23 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
static void sub_811160C(struct Sprite *);
|
|
|
|
static void sub_8111674(struct Sprite *);
|
|
|
|
static void sub_81116E8(struct Sprite *);
|
|
|
|
static void sub_8111764(struct Sprite *);
|
|
|
|
static void sub_81117F4(struct Sprite *);
|
|
|
|
static void sub_8111814(struct Sprite *);
|
|
|
|
static void sub_8111914(u8 taskId);
|
|
|
|
static void sub_811196C(u8 taskId);
|
|
|
|
static void InitAnimShadowBall(struct Sprite *);
|
|
|
|
static void AnimShadowBallStep(struct Sprite *);
|
|
|
|
static void sub_8111B9C(struct Sprite *);
|
|
|
|
static void sub_8111BB4(struct Sprite *);
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8111D78(u8 taskId);
|
|
|
|
static void sub_8111E78(u8 taskId);
|
|
|
|
static void sub_81120DC(u8 taskId);
|
|
|
|
static void sub_8112170(u8 taskId);
|
|
|
|
static void sub_8112264(struct Sprite *);
|
|
|
|
static void sub_8112384(struct Sprite *);
|
|
|
|
static void sub_81125E0(u8 taskId);
|
|
|
|
static void sub_811280C(u8 taskId);
|
|
|
|
static void sub_8112994(u8 taskId);
|
|
|
|
static void sub_81129F0(struct Sprite *);
|
|
|
|
static void sub_8112A4C(struct Sprite *);
|
|
|
|
static void sub_8112ACC(struct Sprite *);
|
|
|
|
static void sub_8112B44(struct Sprite *);
|
|
|
|
static void sub_8112B78(struct Sprite *);
|
|
|
|
static void sub_8112C4C(struct Sprite *);
|
|
|
|
static void sub_8112D10(u8 taskId);
|
|
|
|
static void sub_8112E9C(struct Sprite *);
|
|
|
|
static void sub_8112F60(struct Sprite *);
|
|
|
|
static void sub_8112FB8(struct Sprite *);
|
2018-10-25 23:46:23 +02:00
|
|
|
|
|
|
|
const union AffineAnimCmd gUnknown_08596CF8[] =
|
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(0x1E, 0x1E, 10, 5),
|
|
|
|
AFFINEANIMCMD_FRAME(0xFFE2, 0xFFE2, 10, 5),
|
|
|
|
AFFINEANIMCMD_JUMP(0),
|
|
|
|
};
|
|
|
|
|
|
|
|
const union AffineAnimCmd *const gUnknown_08596D10[] =
|
|
|
|
{
|
|
|
|
gUnknown_08596CF8,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gUnknown_08596D14 =
|
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_YELLOW_BALL,
|
|
|
|
.paletteTag = ANIM_TAG_YELLOW_BALL,
|
|
|
|
.oam = &gUnknown_085249CC,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gUnknown_08596D10,
|
|
|
|
.callback = sub_811160C,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gUnknown_08596D2C =
|
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_YELLOW_BALL,
|
|
|
|
.paletteTag = ANIM_TAG_YELLOW_BALL,
|
|
|
|
.oam = &gUnknown_08524A2C,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_81117F4,
|
|
|
|
};
|
|
|
|
|
|
|
|
const union AffineAnimCmd gUnknown_08596D44[] =
|
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(0x0, 0x0, 10, 1),
|
|
|
|
AFFINEANIMCMD_JUMP(0),
|
|
|
|
};
|
|
|
|
|
|
|
|
const union AffineAnimCmd *const gUnknown_08596D54[] =
|
|
|
|
{
|
|
|
|
gUnknown_08596D44,
|
|
|
|
};
|
|
|
|
|
2019-04-02 13:35:52 +02:00
|
|
|
const struct SpriteTemplate gShadowBallSpriteTemplate =
|
2018-10-25 23:46:23 +02:00
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_SHADOW_BALL,
|
|
|
|
.paletteTag = ANIM_TAG_SHADOW_BALL,
|
|
|
|
.oam = &gUnknown_08524974,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gUnknown_08596D54,
|
2018-12-09 09:14:07 +01:00
|
|
|
.callback = InitAnimShadowBall,
|
2018-10-25 23:46:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const union AnimCmd gUnknown_08596D70[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 2),
|
|
|
|
ANIMCMD_FRAME(8, 2),
|
|
|
|
ANIMCMD_FRAME(16, 2),
|
|
|
|
ANIMCMD_FRAME(24, 2),
|
|
|
|
ANIMCMD_FRAME(32, 2),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
const union AnimCmd *const gUnknown_08596D88[] =
|
|
|
|
{
|
|
|
|
gUnknown_08596D70,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gUnknown_08596D8C =
|
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_LICK,
|
|
|
|
.paletteTag = ANIM_TAG_LICK,
|
|
|
|
.oam = &gUnknown_08524954,
|
|
|
|
.anims = gUnknown_08596D88,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_8111B9C,
|
|
|
|
};
|
|
|
|
|
|
|
|
const union AffineAnimCmd gUnknown_08596DA4[] =
|
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(0x200, 0x200, 0, 0),
|
|
|
|
AFFINEANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
const union AffineAnimCmd *const gUnknown_08596DB4[] =
|
|
|
|
{
|
|
|
|
gUnknown_08596DA4,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gUnknown_08596DB8 =
|
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_WHITE_SHADOW,
|
|
|
|
.paletteTag = ANIM_TAG_WHITE_SHADOW,
|
|
|
|
.oam = &gUnknown_08524A5C,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_8112264,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gUnknown_08596DD0 =
|
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_NAIL,
|
|
|
|
.paletteTag = ANIM_TAG_NAIL,
|
|
|
|
.oam = &gUnknown_08524A54,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_81129F0,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gBattleAnimSpriteTemplate_8596DE8 =
|
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_GHOSTLY_SPIRIT,
|
|
|
|
.paletteTag = ANIM_TAG_GHOSTLY_SPIRIT,
|
|
|
|
.oam = &gUnknown_08524A34,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_8112B78,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gBattleAnimSpriteTemplate_8596E00 =
|
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_DEVIL,
|
|
|
|
.paletteTag = ANIM_TAG_DEVIL,
|
|
|
|
.oam = &gUnknown_08524A34,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_8112B78,
|
|
|
|
};
|
|
|
|
|
|
|
|
const union AnimCmd gUnknown_08596E18[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 4),
|
|
|
|
ANIMCMD_FRAME(8, 4),
|
|
|
|
ANIMCMD_FRAME(16, 4),
|
|
|
|
ANIMCMD_FRAME(24, 4),
|
|
|
|
ANIMCMD_JUMP(0),
|
|
|
|
};
|
|
|
|
|
|
|
|
const union AnimCmd *const gUnknown_08596E2C[] =
|
|
|
|
{
|
|
|
|
gUnknown_08596E18,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gUnknown_08596E30 =
|
|
|
|
{
|
|
|
|
.tileTag = ANIM_TAG_PURPLE_FLAME,
|
|
|
|
.paletteTag = ANIM_TAG_PURPLE_FLAME,
|
|
|
|
.oam = &gUnknown_08524A74,
|
|
|
|
.anims = gUnknown_08596E2C,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_8112E9C,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct SpriteTemplate gUnknown_08596E48 =
|
|
|
|
{
|
|
|
|
.tileTag = 0,
|
|
|
|
.paletteTag = 0,
|
|
|
|
.oam = &gDummyOamData,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_8112F60,
|
|
|
|
};
|
2018-12-09 09:14:07 +01:00
|
|
|
|
|
|
|
static void sub_811160C(struct Sprite *sprite)
|
|
|
|
{
|
2018-12-20 04:13:26 +01:00
|
|
|
InitSpritePosToAnimAttacker(sprite, 1);
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->data[0] = gBattleAnimArgs[2];
|
|
|
|
sprite->data[1] = sprite->pos1.x;
|
|
|
|
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
|
|
|
|
sprite->data[3] = sprite->pos1.y;
|
|
|
|
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
|
|
|
|
sub_80A6FD4(sprite);
|
|
|
|
sprite->callback = sub_8111674;
|
|
|
|
sprite->data[6] = 16;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
|
2018-12-09 09:14:07 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, sprite->data[6]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_8111674(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
s16 r0;
|
|
|
|
s16 r2;
|
|
|
|
sub_8111764(sprite);
|
2018-12-20 04:13:26 +01:00
|
|
|
if (AnimTranslateLinear(sprite))
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
sprite->callback = sub_81116E8;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprite->pos2.x += Sin(sprite->data[5], 10);
|
|
|
|
sprite->pos2.y += Cos(sprite->data[5], 15);
|
|
|
|
r2 = sprite->data[5];
|
|
|
|
sprite->data[5] = (sprite->data[5] + 5) & 0xFF;
|
|
|
|
r0 = sprite->data[5];
|
|
|
|
if (r2 != 0 && r2 <= 196)
|
|
|
|
return;
|
|
|
|
if (r0 <= 0)
|
|
|
|
return;
|
|
|
|
PlaySE12WithPanning(SE_W109, gUnknown_02038440);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_81116E8(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
s16 r2;
|
|
|
|
s16 r0;
|
|
|
|
sprite->data[0] = 1;
|
2018-12-20 04:13:26 +01:00
|
|
|
AnimTranslateLinear(sprite);
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->pos2.x += Sin(sprite->data[5], 10);
|
|
|
|
sprite->pos2.y += Cos(sprite->data[5], 15);
|
2019-04-02 13:35:52 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
r2 = sprite->data[5];
|
|
|
|
sprite->data[5] = (sprite->data[5] + 5) & 0xFF;
|
|
|
|
r0 = sprite->data[5];
|
2019-04-02 13:35:52 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
if (r2 == 0 || r2 > 196)
|
|
|
|
{
|
|
|
|
if (r0 > 0)
|
|
|
|
PlaySE(SE_W109);
|
|
|
|
}
|
2019-04-02 13:35:52 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
if (sprite->data[6] == 0)
|
|
|
|
{
|
2019-04-02 13:35:52 +02:00
|
|
|
sprite->invisible = TRUE;
|
2019-02-06 20:17:09 +01:00
|
|
|
sprite->callback = DestroyAnimSpriteAndDisableBlend;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
sub_8111764(sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_8111764(struct Sprite *sprite)
|
|
|
|
{
|
2019-04-02 13:35:52 +02:00
|
|
|
|
|
|
|
s16 r0;
|
2018-12-09 09:14:07 +01:00
|
|
|
if (sprite->data[6] > 0xFF)
|
|
|
|
{
|
|
|
|
if (++sprite->data[6] == 0x10d)
|
|
|
|
sprite->data[6] = 0;
|
|
|
|
return;
|
|
|
|
}
|
2019-04-02 13:35:52 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
r0 = sprite->data[7];
|
|
|
|
sprite->data[7]++;
|
2019-04-02 13:35:52 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
if ((r0 & 0xFF) == 0)
|
|
|
|
{
|
|
|
|
sprite->data[7] &= 0xff00;
|
|
|
|
if ((sprite->data[7] & 0x100) != 0)
|
|
|
|
sprite->data[6]++;
|
|
|
|
else
|
|
|
|
sprite->data[6]--;
|
|
|
|
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(sprite->data[6], 16 - sprite->data[6]));
|
|
|
|
if (sprite->data[6] == 0 || sprite->data[6] == 16)
|
|
|
|
sprite->data[7] ^= 0x100;
|
|
|
|
if (sprite->data[6] == 0)
|
|
|
|
sprite->data[6] = 0x100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_81117F4(struct Sprite *sprite)
|
|
|
|
{
|
2018-12-20 04:13:26 +01:00
|
|
|
InitSpritePosToAnimTarget(sprite, TRUE);
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->callback = sub_8111814;
|
|
|
|
sprite->callback(sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_8111814(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
u16 temp1;
|
|
|
|
sprite->pos2.x = Sin(sprite->data[0], 32);
|
|
|
|
sprite->pos2.y = Cos(sprite->data[0], 8);
|
|
|
|
temp1 = sprite->data[0] - 65;
|
|
|
|
if (temp1 <= 130)
|
|
|
|
sprite->oam.priority = 2;
|
|
|
|
else
|
|
|
|
sprite->oam.priority = 1;
|
|
|
|
sprite->data[0] = (sprite->data[0] + 19) & 0xFF;
|
|
|
|
sprite->data[2] += 80;
|
|
|
|
sprite->pos2.y += sprite->data[2] >> 8;
|
|
|
|
sprite->data[7] += 1;
|
|
|
|
if (sprite->data[7] == 61)
|
|
|
|
DestroyAnimSprite(sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_811188C(u8 taskId)
|
|
|
|
{
|
|
|
|
u8 spriteId;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0x10));
|
2018-12-09 09:14:07 +01:00
|
|
|
spriteId = GetAnimBattlerSpriteId(0);
|
2018-12-18 05:08:08 +01:00
|
|
|
PrepareBattlerSpriteForRotScale(spriteId, ST_OAM_OBJ_BLEND);
|
|
|
|
SetSpriteRotScale(spriteId, 128, 128, 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
gSprites[spriteId].invisible = FALSE;
|
|
|
|
gTasks[taskId].data[0] = 128;
|
|
|
|
gTasks[taskId].data[1] = *gBattleAnimArgs;
|
|
|
|
gTasks[taskId].data[2] = 0;
|
|
|
|
gTasks[taskId].data[3] = 16;
|
|
|
|
gTasks[taskId].func = sub_8111914;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_8111914(u8 taskId)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[10] += 1;
|
|
|
|
if (gTasks[taskId].data[10] == 3)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[10] = 0;
|
|
|
|
gTasks[taskId].data[2] += 1;
|
|
|
|
gTasks[taskId].data[3] -= 1;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[2], gTasks[taskId].data[3]));
|
2018-12-09 09:14:07 +01:00
|
|
|
if (gTasks[taskId].data[2] != 9)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gTasks[taskId].func = sub_811196C;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_811196C(u8 taskId)
|
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
if (gTasks[taskId].data[1] > 0)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[1] -= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
spriteId = GetAnimBattlerSpriteId(0);
|
|
|
|
gTasks[taskId].data[0] += 8;
|
|
|
|
if (gTasks[taskId].data[0] <= 0xFF)
|
|
|
|
{
|
2018-12-18 05:08:08 +01:00
|
|
|
SetSpriteRotScale(spriteId, gTasks[taskId].data[0], gTasks[taskId].data[0], 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-18 05:08:08 +01:00
|
|
|
ResetSpriteRotScale(spriteId);
|
2018-12-09 09:14:07 +01:00
|
|
|
DestroyAnimVisualTask(taskId);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-02 13:35:52 +02:00
|
|
|
// Spins a sprite towards the target, pausing in the middle.
|
|
|
|
// Used in Shadow Ball.
|
2018-12-09 09:14:07 +01:00
|
|
|
// arg 0: duration step 1 (attacker -> center)
|
|
|
|
// arg 1: duration step 2 (spin center)
|
|
|
|
// arg 2: duration step 3 (center -> target)
|
|
|
|
static void InitAnimShadowBall(struct Sprite *sprite)
|
|
|
|
{
|
2019-04-02 13:35:52 +02:00
|
|
|
s16 oldPosX = sprite->pos1.x;
|
|
|
|
s16 oldPosY = sprite->pos1.y;
|
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
|
|
|
|
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3);
|
|
|
|
sprite->data[0] = 0;
|
|
|
|
sprite->data[1] = gBattleAnimArgs[0];
|
|
|
|
sprite->data[2] = gBattleAnimArgs[1];
|
|
|
|
sprite->data[3] = gBattleAnimArgs[2];
|
|
|
|
sprite->data[4] = sprite->pos1.x << 4;
|
|
|
|
sprite->data[5] = sprite->pos1.y << 4;
|
2019-04-02 13:35:52 +02:00
|
|
|
sprite->data[6] = ((oldPosX - sprite->pos1.x) << 4) / (gBattleAnimArgs[0] << 1);
|
|
|
|
sprite->data[7] = ((oldPosY - sprite->pos1.y) << 4) / (gBattleAnimArgs[0] << 1);
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->callback = AnimShadowBallStep;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void AnimShadowBallStep(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
switch (sprite->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sprite->data[4] += sprite->data[6];
|
|
|
|
sprite->data[5] += sprite->data[7];
|
|
|
|
sprite->pos1.x = sprite->data[4] >> 4;
|
|
|
|
sprite->pos1.y = sprite->data[5] >> 4;
|
|
|
|
sprite->data[1] -= 1;
|
|
|
|
if (sprite->data[1] > 0)
|
|
|
|
break;
|
|
|
|
sprite->data[0] += 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
sprite->data[2] -= 1;
|
|
|
|
if (sprite->data[2] > 0)
|
|
|
|
break;
|
|
|
|
sprite->data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
|
|
|
|
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
|
|
|
|
sprite->data[4] = sprite->pos1.x << 4;
|
|
|
|
sprite->data[5] = sprite->pos1.y << 4;
|
|
|
|
sprite->data[6] = ((sprite->data[1] - sprite->pos1.x) << 4) / sprite->data[3];
|
|
|
|
sprite->data[7] = ((sprite->data[2] - sprite->pos1.y) << 4) / sprite->data[3];
|
|
|
|
sprite->data[0] += 1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
sprite->data[4] += sprite->data[6];
|
|
|
|
sprite->data[5] += sprite->data[7];
|
|
|
|
sprite->pos1.x = sprite->data[4] >> 4;
|
|
|
|
sprite->pos1.y = sprite->data[5] >> 4;
|
|
|
|
sprite->data[3] -= 1;
|
|
|
|
if (sprite->data[3] > 0)
|
|
|
|
break;
|
|
|
|
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
|
|
|
|
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
|
|
|
|
sprite->data[0] += 1;
|
|
|
|
break;
|
|
|
|
case 3:
|
2018-12-18 05:08:08 +01:00
|
|
|
DestroySpriteAndMatrix(sprite);
|
2018-12-09 09:14:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_8111B9C(struct Sprite *sprite)
|
|
|
|
{
|
2018-12-20 04:13:26 +01:00
|
|
|
InitSpritePosToAnimTarget(sprite, TRUE);
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->callback = sub_8111BB4;
|
|
|
|
}
|
|
|
|
|
2019-04-02 13:35:52 +02:00
|
|
|
static void sub_8111BB4(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
bool8 r5 = FALSE;
|
2018-12-09 09:14:07 +01:00
|
|
|
bool8 r6 = FALSE;
|
2019-04-02 13:35:52 +02:00
|
|
|
|
|
|
|
if (sprite->animEnded)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
2019-04-02 13:35:52 +02:00
|
|
|
if (!sprite->invisible)
|
|
|
|
sprite->invisible = TRUE;
|
|
|
|
|
|
|
|
switch (sprite->data[0])
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
2019-04-02 13:35:52 +02:00
|
|
|
default:
|
|
|
|
r6 = TRUE;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
if (sprite->data[1] == 2)
|
|
|
|
r5 = TRUE;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (sprite->data[1] == 4)
|
|
|
|
r5 = TRUE;
|
|
|
|
break;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
2019-04-02 13:35:52 +02:00
|
|
|
|
|
|
|
if (r5)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
sprite->invisible ^= 1;
|
|
|
|
sprite->data[2]++;
|
|
|
|
sprite->data[1] = 0;
|
2019-04-02 13:35:52 +02:00
|
|
|
if (sprite->data[2] == 5)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
sprite->data[2] = 0;
|
|
|
|
sprite->data[0]++;
|
|
|
|
}
|
|
|
|
}
|
2019-04-02 13:35:52 +02:00
|
|
|
else if (r6)
|
|
|
|
{
|
2018-12-09 09:14:07 +01:00
|
|
|
DestroyAnimSprite(sprite);
|
2019-04-02 13:35:52 +02:00
|
|
|
}
|
2018-12-09 09:14:07 +01:00
|
|
|
else
|
2019-04-02 13:35:52 +02:00
|
|
|
{
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->data[1]++;
|
2019-04-02 13:35:52 +02:00
|
|
|
}
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
void sub_8111C50(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
struct Task *task;
|
2019-04-02 13:35:52 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
task = &gTasks[taskId];
|
2018-12-18 05:08:08 +01:00
|
|
|
task->data[0] = CloneBattlerSpriteWithBlend(1);
|
2018-12-09 09:14:07 +01:00
|
|
|
if (task->data[0] < 0)
|
|
|
|
{
|
|
|
|
DestroyAnimVisualTask(taskId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
task->data[1] = 0;
|
|
|
|
task->data[2] = 15;
|
|
|
|
task->data[3] = 2;
|
|
|
|
task->data[4] = 0;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[2], task->data[3]));
|
2018-12-09 09:14:07 +01:00
|
|
|
gSprites[task->data[0]].data[0] = 80;
|
2019-04-02 13:35:52 +02:00
|
|
|
if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
gSprites[task->data[0]].data[1] = -144;
|
|
|
|
gSprites[task->data[0]].data[2] = 112;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gSprites[task->data[0]].data[1] = 144;
|
|
|
|
gSprites[task->data[0]].data[2] = -112;
|
|
|
|
}
|
|
|
|
gSprites[task->data[0]].data[3] = 0;
|
|
|
|
gSprites[task->data[0]].data[4] = 0;
|
2018-12-09 14:08:15 +01:00
|
|
|
StoreSpriteCallbackInData6(&gSprites[task->data[0]], SpriteCallbackDummy);
|
2019-02-06 20:17:09 +01:00
|
|
|
gSprites[task->data[0]].callback = TranslateSpriteLinearFixedPoint;
|
2018-12-09 14:08:15 +01:00
|
|
|
task->func = sub_8111D78;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8111D78(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
struct Task *task;
|
|
|
|
|
|
|
|
task = &gTasks[taskId];
|
|
|
|
switch (task->data[4])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
task->data[1] += 1;
|
|
|
|
task->data[5] = task->data[1] & 3;
|
|
|
|
if (task->data[5] == 1)
|
|
|
|
if (task->data[2] > 0)
|
|
|
|
task->data[2] -= 1;
|
|
|
|
if (task->data[5] == 3)
|
|
|
|
if (task->data[3] <= 15)
|
|
|
|
task->data[3] += 1;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[2], task->data[3]));
|
2018-12-09 09:14:07 +01:00
|
|
|
if (task->data[3] != 16 || task->data[2] != 0)
|
|
|
|
break;
|
|
|
|
if (task->data[1] <= 80)
|
|
|
|
break;
|
|
|
|
obj_delete_but_dont_free_vram(&gSprites[task->data[0]]);
|
|
|
|
task->data[4] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (++task->data[6] <= 1)
|
|
|
|
break;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[4] += 1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
DestroyAnimVisualTask(taskId);
|
2019-04-02 13:35:52 +02:00
|
|
|
break;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
void sub_8111E50(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
struct Task *task;
|
|
|
|
|
|
|
|
task = &gTasks[taskId];
|
|
|
|
task->data[15] = 0;
|
2018-12-09 14:08:15 +01:00
|
|
|
task->func = sub_8111E78;
|
2018-12-09 09:14:07 +01:00
|
|
|
task->func(taskId);
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8111E78(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
s16 startLine;
|
|
|
|
struct Task *task = &gTasks[taskId];
|
2018-12-20 04:13:26 +01:00
|
|
|
u8 position = GetBattlerSpriteBGPriorityRank(gBattleAnimTarget);
|
2018-12-09 09:14:07 +01:00
|
|
|
|
|
|
|
switch (task->data[15])
|
|
|
|
{
|
|
|
|
case 0:
|
2019-04-02 13:35:52 +02:00
|
|
|
task->data[14] = AllocSpritePalette(ANIM_TAG_BENT_SPOON);
|
2018-12-09 14:08:15 +01:00
|
|
|
if (task->data[14] == 0xFF || task->data[14] == 0xF)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
DestroyAnimVisualTask(taskId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-18 05:08:08 +01:00
|
|
|
task->data[0] = CloneBattlerSpriteWithBlend(1);
|
2018-12-09 09:14:07 +01:00
|
|
|
if (task->data[0] < 0)
|
|
|
|
{
|
2019-04-02 13:35:52 +02:00
|
|
|
FreeSpritePaletteByTag(ANIM_TAG_BENT_SPOON);
|
2018-12-09 09:14:07 +01:00
|
|
|
DestroyAnimVisualTask(taskId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
s16 mask2;
|
2018-12-09 09:14:07 +01:00
|
|
|
gSprites[task->data[0]].oam.paletteNum = task->data[14];
|
|
|
|
gSprites[task->data[0]].oam.objMode = ST_OAM_OBJ_NORMAL;
|
|
|
|
gSprites[task->data[0]].oam.priority = 3;
|
2018-12-09 14:08:15 +01:00
|
|
|
gSprites[task->data[0]].invisible = (gBattleSpritesDataPtr->battlerData[gBattleAnimTarget].invisible);
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[1] = 0;
|
|
|
|
task->data[2] = 0;
|
|
|
|
task->data[3] = 16;
|
|
|
|
task->data[13] = GetAnimBattlerSpriteId(1);
|
|
|
|
task->data[4] = (gSprites[task->data[13]].oam.paletteNum + 16) * 16;
|
2018-12-09 14:08:15 +01:00
|
|
|
if (position == 1) {
|
|
|
|
u16 mask = DISPCNT_BG1_ON;
|
|
|
|
mask2 = mask;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
u16 mask = DISPCNT_BG2_ON;
|
|
|
|
mask2 = mask;
|
|
|
|
}
|
|
|
|
ClearGpuRegBits(REG_OFFSET_DISPCNT, mask2);
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[15]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
task->data[14] = (task->data[14] + 16) * 16;
|
|
|
|
CpuSet(&gPlttBufferUnfaded[task->data[4]], &gPlttBufferFaded[task->data[14]], 0x4000008);
|
|
|
|
BlendPalette(task->data[4], 16, 10, RGB(13, 0, 15));
|
|
|
|
task->data[15]++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
startLine = gSprites[task->data[13]].pos1.y + gSprites[task->data[13]].pos2.y - 32;
|
|
|
|
if (startLine < 0)
|
|
|
|
startLine = 0;
|
|
|
|
|
|
|
|
if (position == 1)
|
|
|
|
task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, 4, 1);
|
|
|
|
else
|
|
|
|
task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, 8, 1);
|
|
|
|
|
|
|
|
task->data[15]++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (position == 1)
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL | BLDCNT_TGT1_BG1));
|
2018-12-09 09:14:07 +01:00
|
|
|
else
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL | BLDCNT_TGT1_BG2));
|
2018-12-09 09:14:07 +01:00
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0x10));
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[15]++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (position == 1)
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG1_ON);
|
2018-12-09 09:14:07 +01:00
|
|
|
else
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
|
2018-12-09 09:14:07 +01:00
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
task->func = sub_81120DC;
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[15]++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
task->data[15]++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_81120DC(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
task->data[1]++;
|
|
|
|
task->data[5] = task->data[1] & 1;
|
|
|
|
if (task->data[5] == 0)
|
|
|
|
task->data[2] = gSineTable[task->data[1]] / 18;
|
|
|
|
|
|
|
|
if (task->data[5] == 1)
|
|
|
|
task->data[3] = 16 - (gSineTable[task->data[1]] / 18);
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[2], task->data[3]));
|
2018-12-09 09:14:07 +01:00
|
|
|
if (task->data[1] == 128)
|
|
|
|
{
|
|
|
|
task->data[15] = 0;
|
2018-12-09 14:08:15 +01:00
|
|
|
task->func = sub_8112170;
|
2018-12-09 09:14:07 +01:00
|
|
|
task->func(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112170(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
2019-04-02 13:35:52 +02:00
|
|
|
u8 rank = GetBattlerSpriteBGPriorityRank(gBattleAnimTarget);
|
2018-12-09 09:14:07 +01:00
|
|
|
|
|
|
|
switch (task->data[15])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
gScanlineEffect.state = 3;
|
|
|
|
task->data[14] = GetAnimBattlerSpriteId(1);
|
2019-04-02 13:35:52 +02:00
|
|
|
if (rank == 1)
|
2018-12-09 14:08:15 +01:00
|
|
|
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG1_ON);
|
2018-12-09 09:14:07 +01:00
|
|
|
else
|
2018-12-09 14:08:15 +01:00
|
|
|
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
|
2018-12-09 09:14:07 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
BlendPalette(task->data[4], 16, 0, RGB(13, 0, 15));
|
|
|
|
break;
|
|
|
|
case 2:
|
2019-04-02 13:35:52 +02:00
|
|
|
gSprites[task->data[14]].invisible = TRUE;
|
2018-12-09 09:14:07 +01:00
|
|
|
obj_delete_but_dont_free_vram(&gSprites[task->data[0]]);
|
2019-04-02 13:35:52 +02:00
|
|
|
FreeSpritePaletteByTag(ANIM_TAG_BENT_SPOON);
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
2019-04-02 13:35:52 +02:00
|
|
|
if (rank == 1)
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG1_ON);
|
2018-12-09 09:14:07 +01:00
|
|
|
else
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
|
2018-12-09 09:14:07 +01:00
|
|
|
|
|
|
|
DestroyAnimVisualTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
task->data[15]++;
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112264(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
s16 battler1X, battler1Y;
|
|
|
|
s16 battler2X, battler2Y;
|
|
|
|
s16 yDiff;
|
|
|
|
|
|
|
|
if (gBattleAnimArgs[0] == 0)
|
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
battler1X = GetBattlerSpriteCoord(gBattleAnimAttacker, 0);
|
|
|
|
battler1Y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1) + 28;
|
|
|
|
battler2X = GetBattlerSpriteCoord(gBattleAnimTarget, 0);
|
|
|
|
battler2Y = GetBattlerSpriteCoord(gBattleAnimTarget, 1) + 28;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
battler1X = GetBattlerSpriteCoord(gBattleAnimTarget, 0);
|
|
|
|
battler1Y = GetBattlerSpriteCoord(gBattleAnimTarget, 1) + 28;
|
|
|
|
battler2X = GetBattlerSpriteCoord(gBattleAnimAttacker, 0);
|
|
|
|
battler2Y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1) + 28;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
yDiff = battler2Y - battler1Y;
|
|
|
|
sprite->data[0] = battler1X * 16;
|
|
|
|
sprite->data[1] = battler1Y * 16;
|
|
|
|
sprite->data[2] = ((battler2X - battler1X) * 16) / gBattleAnimArgs[1];
|
|
|
|
sprite->data[3] = (yDiff * 16) / gBattleAnimArgs[1];
|
|
|
|
sprite->data[4] = gBattleAnimArgs[1];
|
|
|
|
sprite->data[5] = battler2X;
|
|
|
|
sprite->data[6] = battler2Y;
|
|
|
|
sprite->data[7] = sprite->data[4] / 2;
|
|
|
|
sprite->oam.priority = 2;
|
|
|
|
sprite->pos1.x = battler1X;
|
|
|
|
sprite->pos1.y = battler1Y;
|
2018-12-09 14:08:15 +01:00
|
|
|
sprite->callback = sub_8112384;
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->invisible = 1;
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112384(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
if (sprite->data[4])
|
|
|
|
{
|
|
|
|
sprite->data[0] += sprite->data[2];
|
|
|
|
sprite->data[1] += sprite->data[3];
|
|
|
|
sprite->pos1.x = sprite->data[0] >> 4;
|
|
|
|
sprite->pos1.y = sprite->data[1] >> 4;
|
|
|
|
if (--sprite->data[4] == 0)
|
|
|
|
sprite->data[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
void sub_81123C4(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
struct Task *task;
|
|
|
|
s16 battler;
|
|
|
|
u8 spriteId;
|
|
|
|
s16 baseX, baseY;
|
|
|
|
s16 x, y;
|
|
|
|
|
|
|
|
task = &gTasks[taskId];
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0x10));
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[5] = 0;
|
|
|
|
task->data[6] = 0;
|
|
|
|
task->data[7] = 0;
|
|
|
|
task->data[8] = 0;
|
|
|
|
task->data[9] = 16;
|
|
|
|
task->data[10] = gBattleAnimArgs[0];
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
baseX = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
|
2018-12-30 17:58:42 +01:00
|
|
|
baseY = GetBattlerSpriteCoordAttr(gBattleAnimAttacker, BATTLER_COORD_ATTR_BOTTOM);
|
2018-12-09 09:14:07 +01:00
|
|
|
if (!IsContest())
|
|
|
|
{
|
|
|
|
for (battler = 0; battler < 4; battler++)
|
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
if (battler != gBattleAnimAttacker
|
|
|
|
&& battler != (gBattleAnimAttacker ^ 2)
|
|
|
|
&& IsBattlerSpriteVisible(battler))
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
spriteId = CreateSprite(&gUnknown_08596DB8, baseX, baseY, 55);
|
2018-12-09 09:14:07 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
x = GetBattlerSpriteCoord(battler, 2);
|
2018-12-30 17:58:42 +01:00
|
|
|
y = GetBattlerSpriteCoordAttr(battler, BATTLER_COORD_ATTR_BOTTOM);
|
2018-12-09 09:14:07 +01:00
|
|
|
gSprites[spriteId].data[0] = baseX << 4;
|
|
|
|
gSprites[spriteId].data[1] = baseY << 4;
|
|
|
|
gSprites[spriteId].data[2] = ((x - baseX) << 4) / gBattleAnimArgs[1];
|
|
|
|
gSprites[spriteId].data[3] = ((y - baseY) << 4) / gBattleAnimArgs[1];
|
|
|
|
gSprites[spriteId].data[4] = gBattleAnimArgs[1];
|
|
|
|
gSprites[spriteId].data[5] = x;
|
|
|
|
gSprites[spriteId].data[6] = y;
|
2018-12-09 14:08:15 +01:00
|
|
|
gSprites[spriteId].callback = sub_8112384;
|
2018-12-09 09:14:07 +01:00
|
|
|
|
|
|
|
task->data[task->data[12] + 13] = spriteId;
|
|
|
|
task->data[12]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
spriteId = CreateSprite(&gUnknown_08596DB8, baseX, baseY, 55);
|
2018-12-09 09:14:07 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
x = 48;
|
|
|
|
y = 40;
|
|
|
|
gSprites[spriteId].data[0] = baseX << 4;
|
|
|
|
gSprites[spriteId].data[1] = baseY << 4;
|
|
|
|
gSprites[spriteId].data[2] = ((x - baseX) << 4) / gBattleAnimArgs[1];
|
|
|
|
gSprites[spriteId].data[3] = ((y - baseY) << 4) / gBattleAnimArgs[1];
|
|
|
|
gSprites[spriteId].data[4] = gBattleAnimArgs[1];
|
|
|
|
gSprites[spriteId].data[5] = x;
|
|
|
|
gSprites[spriteId].data[6] = y;
|
2018-12-09 14:08:15 +01:00
|
|
|
gSprites[spriteId].callback = sub_8112384;
|
2018-12-09 09:14:07 +01:00
|
|
|
|
|
|
|
task->data[13] = spriteId;
|
|
|
|
task->data[12] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
task->func = sub_81125E0;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_81125E0(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (task->data[6] == 0)
|
|
|
|
{
|
|
|
|
if (++task->data[5] > 1)
|
|
|
|
{
|
|
|
|
task->data[5] = 0;
|
|
|
|
task->data[7]++;
|
|
|
|
if (task->data[7] & 1)
|
|
|
|
{
|
|
|
|
if (task->data[8] < 16)
|
|
|
|
task->data[8]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (task->data[9])
|
|
|
|
task->data[9]--;
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[8], task->data[9]));
|
2018-12-09 09:14:07 +01:00
|
|
|
if (task->data[7] >= 24)
|
|
|
|
{
|
|
|
|
task->data[7] = 0;
|
|
|
|
task->data[6] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-02 13:35:52 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
if (task->data[10])
|
|
|
|
task->data[10]--;
|
|
|
|
else if (task->data[6])
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (++task->data[5] > 1)
|
|
|
|
{
|
|
|
|
task->data[5] = 0;
|
|
|
|
task->data[7]++;
|
|
|
|
if (task->data[7] & 1)
|
|
|
|
{
|
|
|
|
if (task->data[8])
|
|
|
|
task->data[8]--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (task->data[9] < 16)
|
|
|
|
task->data[9]++;
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[8], task->data[9]));
|
2018-12-09 09:14:07 +01:00
|
|
|
if (task->data[8] == 0 && task->data[9] == 16)
|
|
|
|
{
|
|
|
|
for (i = 0; i < task->data[12]; i++)
|
|
|
|
DestroySprite(&gSprites[task->data[i + 13]]);
|
|
|
|
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (++task->data[5] > 0)
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 3:
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
DestroyAnimVisualTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
void sub_8112758(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
s16 startX, startY;
|
|
|
|
s16 leftDistance, topDistance, bottomDistance, rightDistance;
|
|
|
|
|
|
|
|
gBattle_WIN0H = 0;
|
|
|
|
gBattle_WIN0V = 0;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_WININ, ((WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR) |
|
|
|
|
(WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR)));
|
|
|
|
SetGpuReg(REG_OFFSET_WINOUT, ((WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ) |
|
|
|
|
(WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR)));
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_DARKEN));
|
|
|
|
SetGpuReg(REG_OFFSET_BLDY, 0x10);
|
|
|
|
|
|
|
|
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER || IsContest())
|
2018-12-09 09:14:07 +01:00
|
|
|
startX = 40;
|
|
|
|
else
|
|
|
|
startX = 200;
|
|
|
|
|
|
|
|
gBattle_WIN0H = (startX << 8) | startX;
|
|
|
|
startY = 40;
|
|
|
|
gBattle_WIN0V = (startY << 8) | startY;
|
|
|
|
|
|
|
|
leftDistance = startX;
|
|
|
|
rightDistance = 240 - startX;
|
|
|
|
topDistance = startY;
|
|
|
|
bottomDistance = 72;
|
|
|
|
gTasks[taskId].data[1] = leftDistance;
|
|
|
|
gTasks[taskId].data[2] = rightDistance;
|
|
|
|
gTasks[taskId].data[3] = topDistance;
|
|
|
|
gTasks[taskId].data[4] = bottomDistance;
|
|
|
|
gTasks[taskId].data[5] = startX;
|
|
|
|
gTasks[taskId].data[6] = startY;
|
2018-12-09 14:08:15 +01:00
|
|
|
gTasks[taskId].func = sub_811280C;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_811280C(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
s16 step;
|
|
|
|
s16 leftDistance, rightDistance, topDistance, bottomDistance;
|
|
|
|
s16 startX, startY;
|
|
|
|
u16 left, right, top, bottom;
|
|
|
|
u16 selectedPalettes;
|
|
|
|
|
|
|
|
step = gTasks[taskId].data[0];
|
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
leftDistance = gTasks[taskId].data[1];
|
|
|
|
rightDistance = gTasks[taskId].data[2];
|
|
|
|
topDistance = gTasks[taskId].data[3];
|
|
|
|
bottomDistance = gTasks[taskId].data[4];
|
|
|
|
startX = gTasks[taskId].data[5];
|
|
|
|
startY = gTasks[taskId].data[6];
|
|
|
|
|
|
|
|
if (step < 16)
|
|
|
|
{
|
|
|
|
left = startX - (leftDistance * 0.0625) * step;
|
|
|
|
right = startX + (rightDistance * 0.0625) * step;
|
|
|
|
top = startY - (topDistance * 0.0625) * step;
|
|
|
|
bottom = startY + (bottomDistance * 0.0625) * step;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
left = 0;
|
|
|
|
right = 240;
|
|
|
|
top = 0;
|
|
|
|
bottom = 112;
|
2018-12-09 14:08:15 +01:00
|
|
|
selectedPalettes = sub_80A75AC(1, 0, 0, 0, 0, 0, 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
BeginNormalPaletteFade(selectedPalettes, 0, 16, 16, RGB(0, 0, 0));
|
2018-12-09 14:08:15 +01:00
|
|
|
gTasks[taskId].func = sub_8112994;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gBattle_WIN0H = (left << 8) | right;
|
|
|
|
gBattle_WIN0V = (top << 8) | bottom;
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112994(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
gBattle_WIN0H = 0;
|
|
|
|
gBattle_WIN0V = 0;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_WININ, ((WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR) |
|
|
|
|
(WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR)));
|
|
|
|
SetGpuReg(REG_OFFSET_WINOUT, ((WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR) |
|
|
|
|
(WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR)));
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDY, 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
DestroyAnimVisualTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_81129F0(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
s16 xDelta;
|
|
|
|
s16 xDelta2;
|
|
|
|
|
2018-12-20 04:13:26 +01:00
|
|
|
InitSpritePosToAnimAttacker(sprite, 1);
|
2018-12-09 14:08:15 +01:00
|
|
|
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
xDelta = 24;
|
|
|
|
xDelta2 = -2;
|
2019-08-10 02:31:24 +02:00
|
|
|
sprite->oam.matrixNum = ST_OAM_MNUM_HFLIP;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xDelta = -24;
|
|
|
|
xDelta2 = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprite->pos1.x += xDelta;
|
|
|
|
sprite->data[1] = xDelta2;
|
|
|
|
sprite->data[0] = 60;
|
2018-12-09 14:08:15 +01:00
|
|
|
sprite->callback = sub_8112A4C;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112A4C(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
u16 var0;
|
|
|
|
|
|
|
|
if (sprite->data[0] > 0)
|
|
|
|
{
|
|
|
|
sprite->data[0]--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite->pos2.x += sprite->data[1];
|
|
|
|
var0 = sprite->pos2.x + 7;
|
|
|
|
if (var0 > 14)
|
|
|
|
{
|
|
|
|
sprite->pos1.x += sprite->pos2.x;
|
|
|
|
sprite->pos2.x = 0;
|
|
|
|
sprite->oam.tileNum += 8;
|
|
|
|
if (++sprite->data[2] == 3)
|
|
|
|
{
|
|
|
|
sprite->data[0] = 30;
|
|
|
|
sprite->callback = WaitAnimForDuration;
|
2018-12-09 14:08:15 +01:00
|
|
|
StoreSpriteCallbackInData6(sprite, sub_8112ACC);
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite->data[0] = 40;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112ACC(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
if (sprite->data[0] == 0)
|
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
|
2019-04-02 13:35:52 +02:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->data[0]++;
|
|
|
|
sprite->data[1] = 0;
|
|
|
|
sprite->data[2] = 0;
|
|
|
|
}
|
|
|
|
else if (sprite->data[1] < 2)
|
|
|
|
{
|
|
|
|
sprite->data[1]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite->data[1] = 0;
|
|
|
|
sprite->data[2]++;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, (16 - sprite->data[2]) | (sprite->data[2] << 8));
|
2018-12-09 09:14:07 +01:00
|
|
|
if (sprite->data[2] == 16)
|
|
|
|
{
|
|
|
|
sprite->invisible = 1;
|
2018-12-09 14:08:15 +01:00
|
|
|
sprite->callback = sub_8112B44;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112B44(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
gBattle_WIN0H = 0;
|
|
|
|
gBattle_WIN0V = 0;
|
|
|
|
DestroyAnimSprite(sprite);
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112B78(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
u16 coeffB;
|
|
|
|
u16 coeffA;
|
|
|
|
|
|
|
|
sprite->pos2.x = Sin(sprite->data[0], 12);
|
2018-12-09 14:08:15 +01:00
|
|
|
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->pos2.x = -sprite->pos2.x;
|
2019-04-02 13:35:52 +02:00
|
|
|
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->data[0] = (sprite->data[0] + 6) & 0xFF;
|
|
|
|
sprite->data[1] += 0x100;
|
|
|
|
sprite->pos2.y = -(sprite->data[1] >> 8);
|
|
|
|
|
|
|
|
sprite->data[7]++;
|
|
|
|
if (sprite->data[7] == 1)
|
|
|
|
{
|
|
|
|
sprite->data[6] = 0x050B;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, sprite->data[6]);
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
else if (sprite->data[7] > 30)
|
|
|
|
{
|
|
|
|
sprite->data[2]++;
|
|
|
|
coeffB = sprite->data[6] >> 8;
|
|
|
|
coeffA = sprite->data[6] & 0xFF;
|
|
|
|
|
|
|
|
if (++coeffB > 16)
|
|
|
|
coeffB = 16;
|
2019-06-26 14:13:38 +02:00
|
|
|
--coeffA;
|
|
|
|
if ((s16)coeffA < 0)
|
2018-12-09 09:14:07 +01:00
|
|
|
coeffA = 0;
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(coeffA, coeffB));
|
|
|
|
sprite->data[6] = BLDALPHA_BLEND(coeffA, coeffB);
|
2018-12-09 09:14:07 +01:00
|
|
|
if (coeffB == 16 && coeffA == 0)
|
|
|
|
{
|
|
|
|
sprite->invisible = 1;
|
2018-12-09 14:08:15 +01:00
|
|
|
sprite->callback = sub_8112C4C;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112C4C(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
DestroyAnimSprite(sprite);
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
void sub_8112C6C(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
task->data[0] = 0;
|
|
|
|
task->data[1] = 16;
|
2018-12-09 14:08:15 +01:00
|
|
|
task->data[9] = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
|
|
|
|
task->data[10] = GetBattlerYCoordWithElevation(gBattleAnimAttacker);
|
2018-12-30 17:58:42 +01:00
|
|
|
task->data[11] = (GetBattlerSpriteCoordAttr(gBattleAnimAttacker, BATTLER_COORD_ATTR_WIDTH) / 2) + 8;
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[7] = 0;
|
2018-12-20 04:13:26 +01:00
|
|
|
task->data[5] = GetBattlerSpriteBGPriority(gBattleAnimAttacker);
|
2018-12-18 05:08:08 +01:00
|
|
|
task->data[6] = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 2;
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[3] = 0;
|
|
|
|
task->data[4] = 16;
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0x10));
|
2018-12-09 09:14:07 +01:00
|
|
|
task->data[8] = 0;
|
2018-12-09 14:08:15 +01:00
|
|
|
task->func = sub_8112D10;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112D10(u8 taskId)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u8 spriteId;
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
2018-12-09 14:08:15 +01:00
|
|
|
spriteId = CreateSprite(&gUnknown_08596E30, task->data[9], task->data[10], task->data[6]);
|
2018-12-09 09:14:07 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
gSprites[spriteId].data[0] = taskId;
|
2018-12-09 14:08:15 +01:00
|
|
|
gSprites[spriteId].data[1] = GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER;
|
2018-12-09 09:14:07 +01:00
|
|
|
|
|
|
|
gSprites[spriteId].data[2] = (i * 42) & 0xFF;
|
|
|
|
gSprites[spriteId].data[3] = task->data[11];
|
|
|
|
gSprites[spriteId].data[5] = i * 6;
|
|
|
|
task->data[7]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (++task->data[1] & 1)
|
|
|
|
{
|
|
|
|
if (task->data[3] < 14)
|
|
|
|
task->data[3]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (task->data[4] > 4)
|
|
|
|
task->data[4]--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (task->data[3] == 14 && task->data[4] == 4)
|
|
|
|
{
|
|
|
|
task->data[1] = 0;
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[3], task->data[4]));
|
2018-12-09 09:14:07 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (++task->data[1] > 30)
|
|
|
|
{
|
|
|
|
task->data[1] = 0;
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (++task->data[1] & 1)
|
|
|
|
{
|
|
|
|
if (task->data[3] > 0)
|
|
|
|
task->data[3]--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (task->data[4] < 16)
|
|
|
|
task->data[4]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (task->data[3] == 0 && task->data[4] == 16)
|
|
|
|
{
|
|
|
|
task->data[8] = 1;
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[3], task->data[4]));
|
2018-12-09 09:14:07 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (task->data[7] == 0)
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 5:
|
2018-12-09 14:08:15 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
2018-12-09 09:14:07 +01:00
|
|
|
DestroyAnimVisualTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112E9C(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
u16 index;
|
|
|
|
|
|
|
|
if (sprite->data[1] == 0)
|
|
|
|
sprite->data[2] += 2;
|
|
|
|
else
|
|
|
|
sprite->data[2] -= 2;
|
|
|
|
|
|
|
|
sprite->data[2] &= 0xFF;
|
|
|
|
sprite->pos2.x = Sin(sprite->data[2], sprite->data[3]);
|
|
|
|
|
|
|
|
index = sprite->data[2] - 65;
|
|
|
|
if (index < 127)
|
|
|
|
sprite->oam.priority = gTasks[sprite->data[0]].data[5] + 1;
|
|
|
|
else
|
|
|
|
sprite->oam.priority = gTasks[sprite->data[0]].data[5];
|
|
|
|
|
|
|
|
sprite->data[5]++;
|
|
|
|
sprite->data[6] = (sprite->data[5] * 8) & 0xFF;
|
|
|
|
sprite->pos2.y = Sin(sprite->data[6], 7);
|
|
|
|
if (gTasks[sprite->data[0]].data[8])
|
|
|
|
{
|
|
|
|
gTasks[sprite->data[0]].data[7]--;
|
|
|
|
DestroySprite(sprite);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112F60(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
sprite->invisible = 1;
|
2018-12-09 14:08:15 +01:00
|
|
|
sprite->data[5] = gBattlerSpriteIds[gBattleAnimAttacker];
|
2018-12-09 09:14:07 +01:00
|
|
|
sprite->data[0] = 128;
|
|
|
|
sprite->data[1] = 10;
|
|
|
|
sprite->data[2] = gBattleAnimArgs[0];
|
|
|
|
sprite->data[3] = gBattleAnimArgs[1];
|
2018-12-09 14:08:15 +01:00
|
|
|
sprite->callback = sub_8112FB8;
|
2018-12-09 09:14:07 +01:00
|
|
|
|
|
|
|
gSprites[sprite->data[5]].pos1.y += 8;
|
|
|
|
}
|
|
|
|
|
2018-12-09 14:08:15 +01:00
|
|
|
static void sub_8112FB8(struct Sprite *sprite)
|
2018-12-09 09:14:07 +01:00
|
|
|
{
|
|
|
|
if (sprite->data[3])
|
|
|
|
{
|
|
|
|
sprite->data[3]--;
|
|
|
|
gSprites[sprite->data[5]].pos2.x = Sin(sprite->data[0], sprite->data[1]);
|
|
|
|
gSprites[sprite->data[5]].pos2.y = Cos(sprite->data[0], sprite->data[1]);
|
|
|
|
sprite->data[0] += sprite->data[2];
|
|
|
|
if (sprite->data[0] > 255)
|
|
|
|
sprite->data[0] -= 256;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gSprites[sprite->data[5]].pos2.x = 0;
|
|
|
|
gSprites[sprite->data[5]].pos2.y = 0;
|
|
|
|
gSprites[sprite->data[5]].pos1.y -= 8;
|
2018-12-18 05:08:08 +01:00
|
|
|
sprite->callback = DestroySpriteAndMatrix;
|
2018-12-09 09:14:07 +01:00
|
|
|
}
|
2018-12-09 14:08:15 +01:00
|
|
|
}
|