summaryrefslogtreecommitdiff
path: root/src/battle
diff options
context:
space:
mode:
authorwho-knows-who <j.williams.8@warwick.ac.uk>2018-08-28 00:26:14 +0100
committerwho-knows-who <j.williams.8@warwick.ac.uk>2018-08-28 00:26:14 +0100
commit70bb9b8f6f9a3169b83b98b266baa3e9923fba3e (patch)
tree27c6ef336e50779dd090a6468cbf73ad7f39c7a9 /src/battle
parent6a7b3033eadef95b9fb8788b3bf7251bc4ee27ae (diff)
parent3f1288e3e055013e0ab847ba5fea4b566bc31996 (diff)
Merge branch 'master' of github.com:pret/pokeruby into flying
Diffstat (limited to 'src/battle')
-rw-r--r--src/battle/battle_anim_812C144.c1589
-rwxr-xr-xsrc/battle/battle_anim_813F0F4.c140
-rw-r--r--src/battle/battle_controller_linkopponent.c4
-rw-r--r--src/battle/battle_controller_linkpartner.c4
-rw-r--r--src/battle/battle_controller_opponent.c4
-rw-r--r--src/battle/battle_controller_player.c4
-rw-r--r--src/battle/battle_controller_wally.c4
-rw-r--r--src/battle/pokeball.c181
-rw-r--r--src/battle/post_battle_event_funcs.c5
9 files changed, 1767 insertions, 168 deletions
diff --git a/src/battle/battle_anim_812C144.c b/src/battle/battle_anim_812C144.c
index 0e9c45023..6edc56549 100644
--- a/src/battle/battle_anim_812C144.c
+++ b/src/battle/battle_anim_812C144.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "battle.h"
#include "battle_anim.h"
+#include "blend_palette.h"
#include "contest.h"
#include "data2.h"
#include "decompress.h"
@@ -18,6 +19,7 @@ extern s16 gBattleAnimArgs[];
extern u8 gAnimBankAttacker;
extern u8 gAnimBankTarget;
extern u8 gAnimVisualTaskCount;
+extern u8 gAnimFriendship;
extern s32 gAnimMoveDmg;
extern u16 gBattle_WIN0H;
extern u16 gBattle_WIN0V;
@@ -30,6 +32,9 @@ extern u16 gBattle_BG2_Y;
extern const struct SpriteTemplate gBattleAnimSpriteTemplate_83D7220;
extern const struct SpriteTemplate gSpriteTemplate_8402500;
+extern const struct SpriteTemplate gSpriteTemplate_84028CC;
+extern const struct SpriteTemplate gSpriteTemplate_840294C;
+extern const struct SpriteTemplate gSpriteTemplate_84029AC;
extern const union AffineAnimCmd *const gSpriteAffineAnimTable_81E7C18[];
extern const union AffineAnimCmd *const gSpriteAffineAnimTable_81E7BEC[];
extern const union AffineAnimCmd gUnknown_08402400[];
@@ -38,6 +43,9 @@ extern const union AffineAnimCmd gUnknown_08402518[];
extern const union AffineAnimCmd gUnknown_08402540[];
extern const union AffineAnimCmd gUnknown_08402590[];
extern const union AffineAnimCmd gUnknown_08402610[];
+extern const union AffineAnimCmd gUnknown_08402750[];
+extern const union AffineAnimCmd gUnknown_084028AC[];
+extern const union AffineAnimCmd gUnknown_084029DC[];
extern const u32 gUnknown_08D2AA98[];
extern const u32 gUnknown_08D2A9E0[];
extern const u16 gUnknown_08D2AA80[];
@@ -45,11 +53,17 @@ extern const s8 gUnknown_084025C0[];
extern const s8 gUnknown_08402604[];
extern const u8 gUnknown_08402608[];
extern const struct SpriteTemplate gBattleAnimSpriteTemplate_84025EC;
+extern const u8 gUnknown_08D2E014[];
+extern const u8 gUnknown_08D2E170[];
+extern const u16 gUnknown_08D2E150[];
extern u8 gBattleMonForms[];
extern u8 gBankSpriteIds[];
extern u16 gBattlerPartyIndexes[];
+extern s16 gUnknown_084028E4[];
extern u8 sub_8046234(s16 x, s16 y, u8 a3);
+extern void sub_80DA48C(struct Sprite *);
+extern void sub_80E3C4C(u8 taskId, int unused, u16 arg2, u8 battler1, u8 arg4, u8 arg5, u8 arg6, u8 arg7, const u8 *arg8, const u8 *arg9, const u16 *palette);
static void sub_812C184(struct Sprite *sprite);
static void sub_812C268(struct Sprite *sprite);
@@ -82,7 +96,26 @@ static void sub_812EE00(struct Sprite *sprite);
static void sub_812EEEC(struct Sprite *sprite);
/*static*/ void sub_812F238(u8 taskId);
static void sub_812F290(u8 taskId);
-void sub_812F474(u8 taskId);
+static void sub_812F474(u8 taskId);
+static void sub_812F76C(u8 taskId);
+static void sub_812F8DC(struct Sprite *sprite);
+static void sub_812FE20(u8 taskId);
+static void sub_812FEB8(u8, bool8);
+static void sub_813003C(u8 taskId);
+static void sub_81301B4(struct Sprite *sprite);
+static void sub_81302E4(u8 taskId);
+static void sub_8130424(s16, s16, s16, s16, u8, u8, s16*, s16*);
+static void sub_81306A4(u8 taskId);
+static void sub_813085C(struct Sprite *sprite);
+static void sub_8130970(u8 taskId);
+static void sub_8130A94(struct Sprite *sprite);
+static void sub_8130B38(struct Sprite *sprite);
+static void sub_8130DBC(u8 taskId);
+static void sub_8130FE0(struct Sprite *sprite);
+static void sub_8131408(u8 taskId);
+static void sub_81315C8(struct Sprite *sprite);
+static void sub_8131810(u8 taskId);
+static void sub_8131838(struct Sprite *sprite);
void sub_812C144(struct Sprite *sprite)
@@ -2553,3 +2586,1557 @@ void sub_812F314(u8 taskId)
ScanlineEffect_SetParams(scanlineParams);
task->func = sub_812F474;
}
+
+static void sub_812F474(u8 taskId)
+{
+ struct Task *task;
+ s16 var1;
+ s16 var2;
+ s16 bgX, bgY;
+ s16 offset;
+ s16 var0;
+ s16 i;
+ s16 sineIndex;
+ s16 var3;
+
+ task = &gTasks[taskId];
+ if (GetBattlerPosition_permutated(task->data[5]) == 1)
+ {
+ bgX = gBattle_BG1_X;
+ bgY = gBattle_BG1_Y;
+ }
+ else
+ {
+ bgX = gBattle_BG2_X;
+ bgY = gBattle_BG2_Y;
+ }
+
+ switch (task->data[0])
+ {
+ case 0:
+ offset = task->data[14] * 2;
+ var1 = 0;
+ var2 = 0;
+ i = 0;
+ task->data[1] = (task->data[1] + 2) & 0xFF;
+ sineIndex = task->data[1];
+ task->data[9] = 0x7E0 / task->data[6];
+ task->data[10] = -((task->data[7] * 2) / task->data[9]);
+ task->data[11] = task->data[7];
+ var3 = task->data[11] >> 5;
+ task->data[12] = var3;
+ var0 = task->data[14];
+ while (var0 > task->data[13])
+ {
+ gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][offset + 1] = (i - var2) + bgY;
+ gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][offset] = bgX + var3 + (gSineTable[sineIndex] >> 5);
+ sineIndex = (sineIndex + 10) & 0xFF;
+ task->data[11] += task->data[10];
+ var3 = task->data[11] >> 5;
+ task->data[12] = var3;
+
+ i++;
+ offset -= 2;
+ var1 += task->data[6];
+ var2 = var1 >> 5;
+ var0--;
+ }
+
+ var0 *= 2;
+ while (var0 >= 0)
+ {
+ gScanlineEffectRegBuffers[0][var0] = bgX + 240;
+ gScanlineEffectRegBuffers[1][var0] = bgX + 240;
+ var0 -= 2;
+ }
+
+ if (++task->data[6] > 63)
+ {
+ task->data[6] = 64;
+ task->data[2]++;
+ if (task->data[2] & 1)
+ task->data[3]--;
+ else
+ task->data[4]++;
+
+ REG_BLDALPHA = (task->data[4] << 8) | task->data[3];
+ if (task->data[3] == 0 && task->data[4] == 16)
+ {
+ task->data[2] = 0;
+ task->data[3] = 0;
+ task->data[0]++;
+ }
+ }
+ else
+ {
+ task->data[7] += task->data[8];
+ }
+ break;
+ case 1:
+ if (++task->data[2] > 12)
+ {
+ gScanlineEffect.state = 3;
+ task->data[2] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 2:
+ task->data[2]++;
+ if (task->data[2] & 1)
+ task->data[3]++;
+ else
+ task->data[4]--;
+
+ REG_BLDALPHA = (task->data[4] << 8) | task->data[3];
+ if (task->data[3] == 16 && task->data[4] == 0)
+ {
+ task->data[2] = 0;
+ task->data[3] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 3:
+ DestroyAnimVisualTask(taskId);
+ break;
+ }
+}
+
+void sub_812F724(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+ task->data[0] = 0;
+ task->data[15] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]);
+ sub_80798F4(&gTasks[taskId], task->data[15], &gUnknown_08402750);
+ task->func = sub_812F76C;
+}
+
+static void sub_812F76C(u8 taskId)
+{
+ u16 var0;
+
+ struct Task *task = &gTasks[taskId];
+ var0 = task->data[0];
+ task->data[0]++;
+ var0 -= 20;
+ if (var0 < 23)
+ {
+ if (++task->data[1] > 1)
+ {
+ task->data[1] = 0;
+ task->data[2]++;
+ if (task->data[2] & 1)
+ gSprites[task->data[15]].pos2.x = 1;
+ else
+ gSprites[task->data[15]].pos2.x = -1;
+ }
+ }
+ else
+ {
+ gSprites[task->data[15]].pos2.x = 0;
+ }
+
+ if (!sub_807992C(&gTasks[taskId]))
+ DestroyAnimVisualTask(taskId);
+}
+
+static void sub_812F804(struct Sprite *sprite, s16 b, s16 c, s16 d, s16 e, u16 f)
+{
+ sprite->pos1.x = b;
+ sprite->pos1.y = c;
+ sprite->data[4] = b << 4;
+ sprite->data[5] = c << 4;
+ sprite->data[6] = ((d - b) << 4) / f;
+ sprite->data[7] = ((e - c) << 4) / f;
+}
+
+void sub_812F86C(struct Sprite *sprite)
+{
+ 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;
+}
+
+void sub_812F88C(struct Sprite *sprite)
+{
+ s16 x = sprite->pos1.x;
+ s16 y = sprite->pos1.y;
+
+ sub_8078650(sprite);
+ StartSpriteAffineAnim(sprite, gBattleAnimArgs[0]);
+ sub_812F804(sprite, sprite->pos1.x, sprite->pos1.y, x, y, 64);
+ sprite->data[0] = 0;
+ sprite->callback = sub_812F8DC;
+}
+
+static void sub_812F8DC(struct Sprite *sprite)
+{
+ int index;
+
+ sprite->data[0]++;
+ index = (sprite->data[0] * 8) & 0xFF;
+ sub_812F86C(sprite);
+ sprite->pos2.y = Sin(index, 8);
+ if (sprite->data[0] > 58)
+ {
+ if (++sprite->data[1] > 1)
+ {
+ sprite->data[1] = 0;
+ sprite->data[2]++;
+ sprite->invisible = sprite->data[2] & 1;
+ if (sprite->data[2] > 3)
+ move_anim_8074EE0(sprite);
+ }
+ }
+}
+
+void sub_812F948(struct Sprite *sprite)
+{
+ sprite->data[0] = gBattleAnimArgs[3];
+ StartSpriteAffineAnim(sprite, gBattleAnimArgs[0]);
+ if (GetBattlerSide(gAnimBankTarget) != B_SIDE_PLAYER)
+ gBattleAnimArgs[1] = -gBattleAnimArgs[1];
+
+ sprite->pos1.x = GetBattlerSpriteCoord(gAnimBankAttacker, 2) + gBattleAnimArgs[1];
+ sprite->pos1.y = GetBattlerSpriteCoord(gAnimBankAttacker, 3) + gBattleAnimArgs[2];
+ sprite->callback = sub_80DA48C;
+}
+
+static void sub_812F9B0(u8 taskId)
+{
+ u16 var0 = 0;
+ u16 var1 = 0;
+
+ gTasks[taskId].data[0]--;
+ if ((gTasks[taskId].data[6] & 0x8000) && (--gTasks[taskId].data[1] == -1))
+ {
+ if (gTasks[taskId].data[9] == 0)
+ {
+ gTasks[taskId].data[9] = gTasks[taskId].data[4];
+ gTasks[taskId].data[4] = -gTasks[taskId].data[4];
+ }
+ else
+ {
+ gTasks[taskId].data[9] = 0;
+ }
+
+ if (gTasks[taskId].data[10] == 0)
+ {
+ gTasks[taskId].data[10] = gTasks[taskId].data[5];
+ gTasks[taskId].data[5] = -gTasks[taskId].data[5];
+ }
+ else
+ {
+ gTasks[taskId].data[10] = 0;
+ }
+
+ gTasks[taskId].data[1] = gTasks[taskId].data[13];
+ }
+
+ var0 = gTasks[taskId].data[7];
+ var1 = gTasks[taskId].data[8];
+ if (gTasks[taskId].data[2] & 0x8000)
+ gSprites[gTasks[taskId].data[15]].pos2.x = gTasks[taskId].data[9] - (var0 >> 8);
+ else
+ gSprites[gTasks[taskId].data[15]].pos2.x = gTasks[taskId].data[9] + (var0 >> 8);
+
+ if (gTasks[taskId].data[3] & 0x8000)
+ gSprites[gTasks[taskId].data[15]].pos2.y = gTasks[taskId].data[10] - (var1 >> 8);
+ else
+ gSprites[gTasks[taskId].data[15]].pos2.y = gTasks[taskId].data[10] + (var1 >> 8);
+
+ if (gTasks[taskId].data[0] < 1)
+ {
+ DestroyTask(taskId);
+ gAnimVisualTaskCount--;
+ }
+}
+
+static void sub_812FAF8(u8 taskId)
+{
+ u16 var0 = 0;
+ u16 var1 = 0;
+
+ gTasks[taskId].data[0]--;
+ if ((gTasks[taskId].data[6] & 0x8000) && (--gTasks[taskId].data[1] == -1))
+ {
+ if (gTasks[taskId].data[9] == 0)
+ {
+ gTasks[taskId].data[9] = gTasks[taskId].data[4];
+ gTasks[taskId].data[4] = -gTasks[taskId].data[4];
+ }
+ else
+ {
+ gTasks[taskId].data[9] = var0;
+ }
+
+ if (gTasks[taskId].data[10] == 0)
+ {
+ gTasks[taskId].data[10] = gTasks[taskId].data[5];
+ gTasks[taskId].data[5] = -gTasks[taskId].data[5];
+ }
+ else
+ {
+ gTasks[taskId].data[10] = 0;
+ }
+
+ gTasks[taskId].data[1] = gTasks[taskId].data[13];
+ }
+
+ var0 = (gTasks[taskId].data[2] & 0x7FFF) + gTasks[taskId].data[7];
+ var1 = (gTasks[taskId].data[3] & 0x7FFF) + gTasks[taskId].data[8];
+ if (gTasks[taskId].data[2] & 0x8000)
+ gSprites[gTasks[taskId].data[15]].pos2.x = gTasks[taskId].data[9] - (var0 >> 8);
+ else
+ gSprites[gTasks[taskId].data[15]].pos2.x = gTasks[taskId].data[9] + (var0 >> 8);
+
+ if (gTasks[taskId].data[3] & 0x8000)
+ gSprites[gTasks[taskId].data[15]].pos2.y = gTasks[taskId].data[10] - (var1 >> 8);
+ else
+ gSprites[gTasks[taskId].data[15]].pos2.y = gTasks[taskId].data[10] + (var1 >> 8);
+
+ gTasks[taskId].data[7] = var0;
+ gTasks[taskId].data[8] = var1;
+ if (gTasks[taskId].data[0] < 1)
+ {
+ gTasks[taskId].data[0] = 30;
+ gTasks[taskId].data[13] = 0;
+ gTasks[taskId].func = sub_812F9B0;
+ }
+}
+
+void sub_812FC68(u8 taskId)
+{
+ gTasks[taskId].data[15] = gBankSpriteIds[gAnimBankAttacker];
+ gTasks[taskId].data[14] = gBattleAnimArgs[0];
+ gTasks[taskId].data[0] = gBattleAnimArgs[0];
+ gTasks[taskId].data[13] = gBattleAnimArgs[6];
+ if (gBattleAnimArgs[3])
+ gTasks[taskId].data[6] = gTasks[taskId].data[6] | -0x8000;
+
+ if (GetBattlerSide(gAnimBankAttacker) != B_SIDE_PLAYER)
+ {
+ gTasks[taskId].data[2] = gBattleAnimArgs[1];
+ gTasks[taskId].data[3] = gBattleAnimArgs[2];
+ }
+ else
+ {
+ if (gBattleAnimArgs[1] & 0x8000)
+ gTasks[taskId].data[2] = gBattleAnimArgs[1] & 0x7FFF;
+ else
+ gTasks[taskId].data[2] = gBattleAnimArgs[1] | -0x8000;
+
+ if (gBattleAnimArgs[2] & 0x8000)
+ gTasks[taskId].data[3] = gBattleAnimArgs[2] & 0x7FFF;
+ else
+ gTasks[taskId].data[3] = gBattleAnimArgs[2] | -0x8000;
+ }
+
+ gTasks[taskId].data[8] = 0;
+ gTasks[taskId].data[7] = 0;
+ gTasks[taskId].data[4] = gBattleAnimArgs[4];
+ gTasks[taskId].data[5] = gBattleAnimArgs[5];
+ gTasks[taskId].func = sub_812FAF8;
+}
+
+void sub_812FD7C(u8 taskId)
+{
+ u8 battler;
+ struct Task *task = &gTasks[taskId];
+
+ if (gBattleAnimArgs[1] == 0)
+ DestroyAnimVisualTask(taskId);
+
+ task->data[0] = 0;
+ task->data[1] = 0;
+ task->data[2] = 0;
+ task->data[3] = gBattleAnimArgs[1];
+ if (gBattleAnimArgs[0] == 0)
+ battler = gAnimBankAttacker;
+ else
+ battler = gAnimBankTarget;
+
+ task->data[4] = GetBattlerSpriteCoord(battler, 0);
+ task->data[5] = GetBattlerSpriteCoord(battler, 1);
+ task->data[6] = sub_8079E90(battler);
+ task->data[15] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]);
+ sub_80798F4(task, task->data[15], &gUnknown_084028AC);
+ task->func = sub_812FE20;
+}
+
+static void sub_812FE20(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+
+ switch (task->data[0])
+ {
+ case 0:
+ if (++task->data[1] == 6)
+ sub_812FEB8(taskId, TRUE);
+
+ if (task->data[1] == 18)
+ sub_812FEB8(taskId, FALSE);
+
+ if (!sub_807992C(task))
+ {
+ if (--task->data[3] == 0)
+ {
+ task->data[0]++;
+ }
+ else
+ {
+ task->data[1] = 0;
+ sub_80798F4(task, task->data[15], &gUnknown_084028AC);
+ }
+ }
+ break;
+ case 1:
+ if (task->data[2] == 0)
+ DestroyAnimVisualTask(taskId);
+ break;
+ }
+}
+
+static void sub_812FEB8(u8 taskId, bool8 arg1)
+{
+ u8 i;
+ s8 xOffset, yOffset;
+ struct Task *task;
+ s16 xCoords[4];
+ s16 yCoords[2];
+
+ task = &gTasks[taskId];
+ if (!arg1)
+ {
+ xOffset = 18;
+ yOffset = -20;
+ }
+ else
+ {
+ xOffset = 30;
+ yOffset = 20;
+ }
+
+ xCoords[0] = task->data[4] - xOffset;
+ xCoords[1] = task->data[4] - xOffset - 4;
+ xCoords[2] = task->data[4] + xOffset;
+ xCoords[3] = task->data[4] + xOffset + 4;
+ yCoords[0] = task->data[5] + yOffset;
+ yCoords[1] = task->data[5] + yOffset + 6;
+
+ for (i = 0; i < 4; i++)
+ {
+ u8 spriteId = CreateSprite(&gSpriteTemplate_84028CC, xCoords[i], yCoords[i & 1], task->data[6] - 5);
+ if (spriteId != MAX_SPRITES)
+ {
+ gSprites[spriteId].data[0] = 0;
+ gSprites[spriteId].data[1] = i < 2 ? -2 : 2;
+ gSprites[spriteId].data[2] = -1;
+ gSprites[spriteId].data[3] = taskId;
+ gSprites[spriteId].data[4] = 2;
+ task->data[2]++;
+ }
+ }
+}
+
+void sub_812FF94(struct Sprite *sprite)
+{
+ sprite->pos1.x += sprite->data[1];
+ sprite->pos1.y += sprite->data[2];
+ if (++sprite->data[0] > 6)
+ {
+ gTasks[sprite->data[3]].data[sprite->data[4]]--;
+ DestroySprite(sprite);
+ }
+}
+
+void sub_812FFE4(u8 taskId)
+{
+ u8 spriteId;
+
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = gBattleAnimArgs[1];
+ spriteId = GetAnimBattlerSpriteId(gBattleAnimArgs[0]);
+ gTasks[taskId].data[2] = 0x100 + gSprites[spriteId].oam.paletteNum * 16;
+ gTasks[taskId].func = sub_813003C;
+}
+
+static void sub_813003C(u8 taskId)
+{
+ if (gTasks[taskId].data[1])
+ {
+ BlendPalette(gTasks[taskId].data[2], 16, 8, gUnknown_084028E4[gTasks[taskId].data[0]]);
+ if (++gTasks[taskId].data[0] > 23)
+ gTasks[taskId].data[0] = 0;
+
+ gTasks[taskId].data[1]--;
+ }
+ else
+ {
+ BlendPalette(gTasks[taskId].data[2], 16, 0, RGB(0, 0, 0));
+ DestroyAnimVisualTask(taskId);
+ }
+}
+
+void sub_81300A4(u8 taskId)
+{
+ sub_80E3C4C(
+ taskId,
+ 0,
+ 0x1A0,
+ gAnimBankAttacker,
+ gBattleAnimArgs[0],
+ 10,
+ 2,
+ 30,
+ gUnknown_08D2E014,
+ gUnknown_08D2E170,
+ gUnknown_08D2E150);
+}
+
+void sub_81300F4(struct Sprite *sprite)
+{
+ if (GetBattlerSide(gAnimBankAttacker) == B_SIDE_OPPONENT)
+ gBattleAnimArgs[0] = -gBattleAnimArgs[0];
+
+ sprite->pos1.x = GetBattlerSpriteCoord(gAnimBankAttacker, 0) + gBattleAnimArgs[0];
+ sprite->pos1.y = GetBattlerSpriteCoord(gAnimBankAttacker, 1) + gBattleAnimArgs[1];
+ if (gBattleAnimArgs[2] == 0)
+ {
+ sprite->data[0] = 640;
+ sprite->data[1] = -640;
+ }
+ else if (gBattleAnimArgs[2] == 1)
+ {
+ sprite->vFlip = 1;
+ sprite->data[0] = 640;
+ sprite->data[1] = 640;
+ }
+ else
+ {
+ StartSpriteAnim(sprite, 1);
+ sprite->data[0] = 640;
+ }
+
+ if (GetBattlerSide(gAnimBankAttacker) != B_SIDE_PLAYER)
+ {
+ sprite->data[0] = -sprite->data[0];
+ sprite->hFlip = 1;
+ }
+
+ sprite->callback = sub_81301B4;
+}
+
+static void sub_81301B4(struct Sprite *sprite)
+{
+ sprite->data[6] += sprite->data[0];
+ sprite->data[7] += sprite->data[1];
+ sprite->pos2.x = sprite->data[6] >> 8;
+ sprite->pos2.y = sprite->data[7] >> 8;
+ if (++sprite->data[5] == 14)
+ DestroyAnimSprite(sprite);
+}
+
+void sub_81301EC(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+
+ if (IsContest())
+ {
+ task->data[5] = 8;
+ task->data[6] = 3;
+ task->data[7] = 1;
+ }
+ else
+ {
+ task->data[5] = 12;
+ task->data[6] = 3;
+ task->data[7] = 0;
+ }
+
+ if (GetBattlerSide(gAnimBankAttacker) == B_SIDE_PLAYER)
+ task->data[11] = GetBattlerSpriteCoord(gAnimBankAttacker, 2) + sub_807A100(gAnimBankAttacker, 0) / 4;
+ else
+ task->data[11] = GetBattlerSpriteCoord(gAnimBankAttacker, 2) - sub_807A100(gAnimBankAttacker, 0) / 4;
+
+ task->data[12] = GetBattlerSpriteCoord(gAnimBankAttacker, 3) - sub_807A100(gAnimBankAttacker, 0) / 4;
+ task->data[13] = GetBattlerSpriteCoord(gAnimBankTarget, 2);
+ task->data[14] = GetBattlerSpriteCoord(gAnimBankTarget, 3);
+ task->func = sub_81302E4;
+}
+
+static void sub_81302E4(u8 taskId)
+{
+ u8 i;
+ s16 x, y;
+ struct Task *task = &gTasks[taskId];
+
+ switch (task->data[0])
+ {
+ case 0:
+ if (++task->data[1] > 3)
+ {
+ task->data[1] = 0;
+ sub_8130424(
+ task->data[11],
+ task->data[12],
+ task->data[13],
+ task->data[14],
+ task->data[5],
+ task->data[2],
+ &x,
+ &y);
+
+ for (i = 0; i < 2; i++)
+ {
+ u8 spriteId = CreateSprite(&gSpriteTemplate_840294C, x, y, 35);
+ if (spriteId != MAX_SPRITES)
+ {
+ if (task->data[7] == 0)
+ {
+ if (i == 0)
+ gSprites[spriteId].pos2.x = gSprites[spriteId].pos2.y = -task->data[6];
+ else
+ gSprites[spriteId].pos2.x = gSprites[spriteId].pos2.y = task->data[6];
+ }
+ else
+ {
+ if (i == 0)
+ {
+ gSprites[spriteId].pos2.x = -task->data[6];
+ gSprites[spriteId].pos2.y = task->data[6];
+ }
+ else
+ {
+ gSprites[spriteId].pos2.x = task->data[6];
+ gSprites[spriteId].pos2.y = -task->data[6];
+ }
+ }
+
+ gSprites[spriteId].data[0] = 0;
+ gSprites[spriteId].data[1] = taskId;
+ gSprites[spriteId].data[2] = 10;
+ task->data[10]++;
+ }
+ }
+
+ if (task->data[2] == task->data[5])
+ task->data[0]++;
+
+ task->data[2]++;
+ }
+ break;
+ case 1:
+ if (task->data[10] == 0)
+ DestroyAnimVisualTask(taskId);
+ break;
+ }
+}
+
+static void sub_8130424(s16 arg0, s16 arg1, s16 arg2, s16 arg3, u8 arg4, u8 arg5, s16 *x, s16 *y)
+{
+ int x2;
+ int y2;
+
+ if (arg5 == 0)
+ {
+ *x = arg0;
+ *y = arg1;
+ return;
+ }
+
+ if (arg5 >= arg4)
+ {
+ *x = arg2;
+ *y = arg3;
+ return;
+ }
+
+ arg4--;
+ x2 = (arg0 << 8) + arg5 * (((arg2 - arg0) << 8) / arg4);
+ y2 = (arg1 << 8) + arg5 * (((arg3 - arg1) << 8) / arg4);
+ *x = x2 >> 8;
+ *y = y2 >> 8;
+}
+
+void sub_81304DC(struct Sprite *sprite)
+{
+ if (++sprite->data[0] > 36)
+ {
+ gTasks[sprite->data[1]].data[sprite->data[2]]--;
+ DestroySprite(sprite);
+ }
+}
+
+void sub_813051C(struct Sprite *sprite)
+{
+ sprite->pos1.x = gBattleAnimArgs[0];
+ sprite->pos1.y = gBattleAnimArgs[1];
+ sprite->data[2] = gBattleAnimArgs[2];
+ sprite->data[4] = gBattleAnimArgs[3];
+ sprite->data[0] = gBattleAnimArgs[4];
+ StoreSpriteCallbackInData(sprite, DestroyAnimSprite);
+ sprite->callback = sub_8078CC0;
+}
+
+void sub_8130554(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+
+ task->data[11] = GetBattlerSpriteCoord(gAnimBankAttacker, 2);
+ task->data[12] = GetBattlerSpriteCoord(gAnimBankAttacker, 3);
+ task->data[13] = GetBattlerSpriteCoord(gAnimBankTarget, 2);
+ task->data[14] = GetBattlerSpriteCoord(gAnimBankTarget, 3) + sub_807A100(gAnimBankTarget, 0) / 4;
+ task->data[15] = CreateSprite(&gSpriteTemplate_84029AC, task->data[11], task->data[12], sub_8079E90(gAnimBankTarget) - 5);
+ if (task->data[15] != MAX_SPRITES)
+ {
+ gSprites[task->data[15]].data[0] = 16;
+ gSprites[task->data[15]].data[2] = task->data[13];
+ gSprites[task->data[15]].data[4] = task->data[14];
+ gSprites[task->data[15]].data[5] = -32;
+ InitAnimArcTranslation(&gSprites[task->data[15]]);
+ if (GetBattlerSide(gAnimBankAttacker) == B_SIDE_OPPONENT)
+ StartSpriteAffineAnim(&gSprites[task->data[15]], 1);
+
+ task->func = sub_81306A4;
+ }
+ else
+ {
+ DestroyAnimVisualTask(taskId);
+ }
+}
+
+static void sub_81306A4(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+
+ switch (task->data[0])
+ {
+ case 0:
+ if (++task->data[1] > 1)
+ {
+ task->data[1] = 0;
+ TranslateAnimArc(&gSprites[task->data[15]]);
+ if (++task->data[2] > 7)
+ task->data[0]++;
+ }
+ break;
+ case 1:
+ if (TranslateAnimArc(&gSprites[task->data[15]]))
+ {
+ task->data[1] = 0;
+ task->data[2] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 2:
+ if (++task->data[1] > 1)
+ {
+ task->data[1] = 0;
+ task->data[2]++;
+ gSprites[task->data[15]].invisible = task->data[2] & 1;
+ if (task->data[2] == 16)
+ {
+ FreeOamMatrix(gSprites[task->data[15]].oam.matrixNum);
+ DestroySprite(&gSprites[task->data[15]]);
+ task->data[0]++;
+ }
+ }
+ break;
+ case 3:
+ DestroyAnimVisualTask(taskId);
+ break;
+ }
+}
+
+void sub_81307B0(struct Sprite *sprite)
+{
+ u8 battler;
+
+ if (gBattleAnimArgs[0] == 0)
+ battler = gAnimBankAttacker;
+ else
+ battler = gAnimBankTarget;
+
+ sprite->oam.tileNum += 16;
+ sprite->data[6] = gBattleAnimArgs[2];
+ sprite->data[7] = gBattleAnimArgs[1] == 0 ? -1 : 1;
+ sprite->pos1.y = GetBattlerSpriteCoord(battler, 3);
+ if (gBattleAnimArgs[1] == 0)
+ {
+ sprite->oam.matrixNum |= 0x8;
+ sprite->pos1.x = sub_807A100(battler, 4) - 8;
+ }
+ else
+ {
+ sprite->pos1.x = sub_807A100(battler, 5) + 8;
+ }
+
+ sprite->callback = sub_813085C;
+}
+
+static void sub_813085C(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ if (++sprite->data[1] > 1)
+ {
+ sprite->data[1] = 0;
+ sprite->pos2.x += sprite->data[7];
+ if (++sprite->data[2] == 12)
+ sprite->data[0]++;
+ }
+ break;
+ case 1:
+ if (++sprite->data[1] == 8)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 2:
+ sprite->pos2.x -= sprite->data[7] * 4;
+ if (++sprite->data[1] == 6)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 3:
+ sprite->pos2.x += sprite->data[7] * 3;
+ if (++sprite->data[1] == 8)
+ {
+ if (--sprite->data[6])
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]--;
+ }
+ else
+ {
+ DestroyAnimSprite(sprite);
+ }
+ }
+ break;
+ }
+}
+
+void sub_8130918(u8 taskId)
+{
+ if (gBattleAnimArgs[0] == 0)
+ {
+ DestroyAnimVisualTask(taskId);
+ }
+ else
+ {
+ gTasks[taskId].data[0] = gBattleAnimArgs[1];
+ gTasks[taskId].data[15] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]);
+ sub_80798F4(&gTasks[taskId], gTasks[taskId].data[15], &gUnknown_084029DC);
+ gTasks[taskId].func = sub_8130970;
+ }
+}
+
+static void sub_8130970(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+
+ if (++task->data[1] > 1)
+ {
+ task->data[1] = 0;
+ if (!(task->data[2] & 1))
+ gSprites[task->data[15]].pos2.x = 2;
+ else
+ gSprites[task->data[15]].pos2.x = -2;
+ }
+
+ if (!sub_807992C(task))
+ {
+ gSprites[task->data[15]].pos2.x = 0;
+ if (--task->data[0])
+ {
+ sub_80798F4(&gTasks[taskId], gTasks[taskId].data[15], &gUnknown_084029DC);
+ task->data[1] = 0;
+ task->data[2] = 0;
+ }
+ else
+ {
+ DestroyAnimVisualTask(taskId);
+ }
+ }
+}
+
+void sub_8130A2C(struct Sprite *sprite)
+{
+ if (gBattleAnimArgs[0] == 0)
+ {
+ sprite->pos1.x = GetBattlerSpriteCoord(gAnimBankAttacker, 2);
+ sprite->pos1.y = sub_807A100(gAnimBankAttacker, 2);
+ }
+ else
+ {
+ sprite->pos1.x = GetBattlerSpriteCoord(gAnimBankTarget, 2);
+ sprite->pos1.y = sub_807A100(gAnimBankTarget, 2);
+ }
+
+ if (sprite->pos1.y < 8)
+ sprite->pos1.y = 8;
+
+ sprite->data[0] = 0;
+ sprite->data[1] = gBattleAnimArgs[1];
+ sprite->data[2] = 0;
+ sprite->data[3] = gBattleAnimArgs[2];
+ sprite->callback = sub_8130A94;
+}
+
+static void sub_8130A94(struct Sprite *sprite)
+{
+ if (++sprite->data[0] >= sprite->data[1])
+ {
+ sprite->data[0] = 0;
+ sprite->data[2] = (sprite->data[2] + 1) & 1;
+ sprite->invisible = sprite->data[2];
+ if (sprite->data[2] && --sprite->data[3] == 0)
+ DestroyAnimSprite(sprite);
+ }
+}
+
+void sub_8130AEC(struct Sprite *sprite)
+{
+ if (gBattleAnimArgs[0] == 0)
+ {
+ sprite->oam.matrixNum |= 0x8;
+ sprite->pos1.x = 100;
+ sprite->data[7] = 1;
+ }
+ else
+ {
+ sprite->pos1.x = 140;
+ sprite->data[7] = -1;
+ }
+
+ sprite->pos1.y = 56;
+ sprite->callback = sub_8130B38;
+}
+
+static void sub_8130B38(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ sprite->pos1.y -= sprite->data[7] * 2;
+ if (sprite->data[1] & 1)
+ sprite->pos1.x -= sprite->data[7] * 2;
+
+ if (++sprite->data[1] == 9)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 1:
+ if (++sprite->data[1] == 4)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 2:
+ sprite->data[1]++;
+ sprite->pos1.y += sprite->data[7] * 3;
+ sprite->pos2.x = sprite->data[7] * (gSineTable[sprite->data[1] * 10] >> 3);
+ if (sprite->data[1] == 12)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 3:
+ if (++sprite->data[1] == 2)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 4:
+ sprite->data[1]++;
+ sprite->pos1.y -= sprite->data[7] * 3;
+ sprite->pos2.x = sprite->data[7] * (gSineTable[sprite->data[1] * 10] >> 3);
+ if (sprite->data[1] == 12)
+ sprite->data[0]++;
+ break;
+ case 5:
+ sprite->data[1]++;
+ sprite->pos1.y += sprite->data[7] * 3;
+ sprite->pos2.x = sprite->data[7] * (gSineTable[sprite->data[1] * 10] >> 3);
+ if (sprite->data[1] == 15)
+ sprite->oam.tileNum += 16;
+
+ if (sprite->data[1] == 18)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 6:
+ sprite->pos1.x += sprite->data[7] * 6;
+ if (++sprite->data[1] == 9)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 7:
+ sprite->pos1.x += sprite->data[7] * 2;
+ if (++sprite->data[1] == 1)
+ {
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 8:
+ sprite->pos1.x -= sprite->data[7] * 3;
+ if (++sprite->data[1] == 5)
+ DestroyAnimSprite(sprite);
+ break;
+ }
+}
+
+void sub_8130D20(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+
+ task->data[15] = GetAnimBattlerSpriteId(0);
+ if (!IsContest())
+ {
+ if (IsDoubleBattle() == TRUE)
+ {
+ int x = GetBattlerSpriteCoord(gAnimBankAttacker, 0);
+ int y = GetBattlerSpriteCoord(gAnimBankAttacker ^ 2, 0);
+ if (x > y)
+ task->data[14] = 1;
+ else
+ task->data[14] = -1;
+ }
+ else
+ {
+ if (GetBattlerSide(gAnimBankAttacker) == B_SIDE_PLAYER)
+ task->data[14] = -1;
+ else
+ task->data[14] = 1;
+ }
+ }
+ else
+ {
+ task->data[14] = 1;
+ }
+
+ task->func = sub_8130DBC;
+}
+
+static void sub_8130DBC(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+
+ switch (task->data[0])
+ {
+ case 0:
+ if (++task->data[1] == 13)
+ {
+ task->data[1] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 1:
+ gSprites[task->data[15]].pos2.x -= task->data[14] * 3;
+ if (++task->data[1] == 6)
+ {
+ task->data[1] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 2:
+ gSprites[task->data[15]].pos2.x += task->data[14] * 3;
+ if (++task->data[1] == 6)
+ {
+ task->data[1] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 3:
+ if (++task->data[1] == 2)
+ {
+ task->data[1] = 0;
+ if (task->data[2] == 0)
+ {
+ task->data[2]++;
+ task->data[0] = 1;
+ }
+ else
+ {
+ task->data[0]++;
+ }
+ }
+ break;
+ case 4:
+ gSprites[task->data[15]].pos2.x += task->data[14];
+ if (++task->data[1] == 3)
+ {
+ task->data[1] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 5:
+ if (++task->data[1] == 6)
+ {
+ task->data[1] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 6:
+ gSprites[task->data[15]].pos2.x -= task->data[14] * 4;
+ if (++task->data[1] == 5)
+ {
+ task->data[1] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 7:
+ gSprites[task->data[15]].pos2.x += task->data[14] * 4;
+ if (++task->data[1] == 5)
+ {
+ task->data[1] = 0;
+ task->data[0]++;
+ }
+ break;
+ case 8:
+ gSprites[task->data[15]].pos2.x = 0;
+ DestroyAnimVisualTask(taskId);
+ break;
+ }
+}
+
+void sub_8130F5C(struct Sprite *sprite)
+{
+ if (gBattleAnimArgs[0] == 0)
+ {
+ InitAnimSpritePos(sprite, 1);
+ sprite->data[7] = gAnimBankAttacker;
+ }
+ else
+ {
+ sprite->data[7] = gAnimBankTarget;
+ }
+
+ if (GetBattlerSide(sprite->data[7]) == B_SIDE_OPPONENT)
+ sprite->oam.matrixNum = 8;
+
+ sprite->oam.priority = sub_8079ED4(sprite->data[7]);
+ sprite->oam.objMode = ST_OAM_OBJ_BLEND;
+ sprite->callback = sub_8130FE0;
+}
+
+static void sub_8130FE0(struct Sprite *sprite)
+{
+ u16 x, y;
+
+ switch (sprite->data[5])
+ {
+ case 0:
+ switch (sprite->data[6])
+ {
+ default:
+ sprite->data[6] = 0;
+ case 0:
+ case 4:
+ x = sub_807A100(sprite->data[7], 5) - 4;
+ y = sub_807A100(sprite->data[7], 3) - 4;
+ break;
+ case 1:
+ x = sub_807A100(sprite->data[7], 5) - 4;
+ y = sub_807A100(sprite->data[7], 2) + 4;
+ break;
+ case 2:
+ x = sub_807A100(sprite->data[7], 4) + 4;
+ y = sub_807A100(sprite->data[7], 3) - 4;
+ break;
+ case 3:
+ x = sub_807A100(sprite->data[7], 4) + 4;
+ y = sub_807A100(sprite->data[7], 2) - 4;
+ break;
+ case 5:
+ x = GetBattlerSpriteCoord(sprite->data[7], 2);
+ y = GetBattlerSpriteCoord(sprite->data[7], 3);
+ break;
+ }
+
+ if (sprite->data[6] == 4)
+ sprite->data[0] = 24;
+ else if (sprite->data[6] == 5)
+ sprite->data[0] = 6;
+ else
+ sprite->data[0] = 12;
+
+ sprite->data[1] = sprite->pos1.x;
+ sprite->data[2] = x;
+ sprite->data[3] = sprite->pos1.y;
+ sprite->data[4] = y;
+ InitAnimLinearTranslation(sprite);
+ sprite->data[5]++;
+ break;
+ case 1:
+ if (TranslateAnimLinear(sprite))
+ {
+ switch (sprite->data[6])
+ {
+ default:
+ sprite->pos1.x += sprite->pos2.x;
+ sprite->pos1.y += sprite->pos2.y;
+ sprite->pos2.y = 0;
+ sprite->pos2.x = 0;
+ sprite->data[0] = 0;
+ sprite->data[5]++;
+ sprite->data[6]++;
+ break;
+ case 4:
+ sprite->pos1.x += sprite->pos2.x;
+ sprite->pos1.y += sprite->pos2.y;
+ sprite->pos2.y = 0;
+ sprite->pos2.x = 0;
+ sprite->data[5] = 0;
+ sprite->data[6]++;
+ break;
+ case 5:
+ sprite->data[0] = 0;
+ sprite->data[1] = 16;
+ sprite->data[2] = 0;
+ sprite->data[5] = 3;
+ break;
+ }
+ }
+ break;
+ case 2:
+ if (++sprite->data[0] == 4)
+ sprite->data[5] = 0;
+ break;
+ case 3:
+ if (!(sprite->data[0] & 1))
+ sprite->data[1]--;
+ else
+ sprite->data[2]++;
+
+ REG_BLDALPHA = (sprite->data[2] << 8) | sprite->data[1];
+ if (++sprite->data[0] == 32)
+ {
+ sprite->invisible = 1;
+ sprite->data[5]++;
+ }
+ break;
+ case 4:
+ DestroyAnimSprite(sprite);
+ break;
+ }
+}
+
+static void sub_81311E4(struct Sprite *sprite)
+{
+ sprite->pos2.x = ((sprite->data[2] - sprite->data[0]) * sprite->data[5]) / sprite->data[4];
+ sprite->pos2.y = ((sprite->data[3] - sprite->data[1]) * sprite->data[5]) / sprite->data[4];
+ if (!(sprite->data[5] & 1))
+ {
+ CreateSprite(
+ &gSpriteTemplate_8402500,
+ sprite->pos1.x + sprite->pos2.x,
+ sprite->pos1.y + sprite->pos2.y, 5);
+ }
+
+ if (sprite->data[5] == sprite->data[4])
+ DestroyAnimSprite(sprite);
+
+ sprite->data[5]++;
+}
+
+void sub_8131264(struct Sprite *sprite)
+{
+ GetBattlerSpriteCoord(gAnimBankTarget, 2); // unused local variable
+ GetBattlerSpriteCoord(gAnimBankTarget, 3); // unused local variable
+
+ if (GetBattlerSide(gAnimBankTarget) == B_SIDE_PLAYER || IsContest())
+ {
+ sprite->data[0] = sprite->pos1.x - gBattleAnimArgs[0];
+ sprite->data[2] = sprite->pos1.x - gBattleAnimArgs[2];
+ }
+ else
+ {
+ sprite->data[0] = sprite->pos1.x + gBattleAnimArgs[0];
+ sprite->data[2] = sprite->pos1.x + gBattleAnimArgs[2];
+ }
+
+ sprite->data[1] = sprite->pos1.y + gBattleAnimArgs[1];
+ sprite->data[3] = sprite->pos1.y + gBattleAnimArgs[3];
+ sprite->data[4] = gBattleAnimArgs[4];
+ sprite->pos1.x = sprite->data[0];
+ sprite->pos1.y = sprite->data[1];
+ sprite->callback = sub_81311E4;
+}
+
+void sub_81312E4(u8 taskId)
+{
+ int i;
+ u8 spriteId = GetAnimBattlerSpriteId(0);
+
+ if (gTasks[taskId].data[0] == 0)
+ {
+ sub_8078E70(spriteId, 0);
+ gTasks[taskId].data[1] = 0x100;
+ gTasks[taskId].data[2] = 0x100;
+ gTasks[taskId].data[0]++;
+ }
+ else if (gTasks[taskId].data[0] == 1)
+ {
+ gTasks[taskId].data[1] += 0x60;
+ gTasks[taskId].data[2] -= 0xD;
+ obj_id_set_rotscale(spriteId, gTasks[taskId].data[1], gTasks[taskId].data[2], 0);
+ if (++gTasks[taskId].data[3] == 9)
+ {
+ gTasks[taskId].data[3] = 0;
+ sub_8078F40(spriteId);
+ gSprites[spriteId].invisible = 1;
+ gTasks[taskId].data[0]++;
+ }
+ }
+ else
+ {
+ refresh_graphics_maybe(gAnimBankAttacker, 0, spriteId);
+ if (IsContest())
+ {
+ gSprites[gBankSpriteIds[gAnimBankAttacker]].affineAnims = gSpriteAffineAnimTable_81E7C18;
+ StartSpriteAffineAnim(&gSprites[gBankSpriteIds[gAnimBankAttacker]], 0);
+ }
+
+ for (i = 0; i < 16; i++)
+ gTasks[taskId].data[i] = 0;
+
+ gTasks[taskId].func = sub_8131408;
+ }
+}
+
+static void sub_8131408(u8 taskId)
+{
+ u8 spriteId = GetAnimBattlerSpriteId(0);
+
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ gSprites[spriteId].pos2.y = -200;
+ gSprites[spriteId].pos2.x = 200;
+ gSprites[spriteId].invisible = 0;
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0]++;
+ break;
+ case 1:
+ gTasks[taskId].data[10] += 112;
+ gSprites[spriteId].pos2.y += gTasks[taskId].data[10] >> 8;
+ if (gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y >= -32)
+ gSprites[spriteId].pos2.x = 0;
+
+ if (gSprites[spriteId].pos2.y > 0)
+ gSprites[spriteId].pos2.y = 0;
+
+ if (gSprites[spriteId].pos2.y == 0)
+ {
+ PlaySE12WithPanning(SE_W145B, BattleAnimAdjustPanning(-64));
+ gTasks[taskId].data[10] -= 0x800;
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 2:
+ gTasks[taskId].data[10] -= 112;
+ if (gTasks[taskId].data[10] < 0)
+ gTasks[taskId].data[10] = 0;
+
+ gSprites[spriteId].pos2.y -= gTasks[taskId].data[10] >> 8;
+ if (gTasks[taskId].data[10] == 0)
+ gTasks[taskId].data[0]++;
+ break;
+ case 3:
+ gTasks[taskId].data[10] += 112;
+ gSprites[spriteId].pos2.y += gTasks[taskId].data[10] >> 8;
+ if (gSprites[spriteId].pos2.y > 0)
+ gSprites[spriteId].pos2.y = 0;
+
+ if (gSprites[spriteId].pos2.y == 0)
+ {
+ PlaySE12WithPanning(SE_W145B, BattleAnimAdjustPanning(-64));
+ DestroyAnimVisualTask(taskId);
+ }
+ break;
+ }
+}
+
+void sub_8131564(struct Sprite *sprite)
+{
+ s16 y2;
+
+ if (GetBattlerSide(gAnimBankTarget) == B_SIDE_PLAYER)
+ {
+ sprite->subpriority = sub_8079E90(gAnimBankTarget) - 2;
+ y2 = -144;
+ }
+ else
+ {
+ sprite->subpriority = sub_8079E90(gAnimBankTarget) + 2;
+ y2 = -96;
+ }
+
+ sprite->pos1.y = GetBattlerSpriteCoord(gAnimBankTarget, 3);
+ sprite->pos2.y = y2;
+ sprite->callback = sub_81315C8;
+}
+
+static void sub_81315C8(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ sprite->pos2.y += 10;
+ if (sprite->pos2.y >= 0)
+ {
+ PlaySE12WithPanning(SE_W166, BattleAnimAdjustPanning(63));
+ sprite->pos2.y = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 1:
+ sprite->data[1] += 4;
+ sprite->pos2.y = -(gSineTable[sprite->data[1]] >> 3);
+ if (sprite->data[1] > 127)
+ {
+ PlaySE12WithPanning(SE_W166, BattleAnimAdjustPanning(63));
+ sprite->data[1] = 0;
+ sprite->pos2.y = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 2:
+ sprite->data[1] += 6;
+ sprite->pos2.y = -(gSineTable[sprite->data[1]] >> 4);
+ if (sprite->data[1] > 127)
+ {
+ sprite->data[1] = 0;
+ sprite->pos2.y = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 3:
+ if (++sprite->data[1] > 8)
+ {
+ PlaySE12WithPanning(SE_W043, BattleAnimAdjustPanning(63));
+ sprite->data[1] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 4:
+ if (++sprite->data[1] > 8)
+ {
+ sprite->data[1] = 0;
+ sprite->data[2]++;
+ sprite->invisible = sprite->data[2] & 1;
+ if (sprite->data[2] == 7)
+ DestroyAnimSprite(sprite);
+ }
+ break;
+ }
+}
+
+void sub_81316F8(u8 taskId)
+{
+ s16 spriteId1, spriteId2;
+
+ if (IsContest())
+ {
+ DestroyAnimVisualTask(taskId);
+ return;
+ }
+
+ spriteId1 = duplicate_obj_of_side_rel2move_in_transparent_mode(1);
+ if (spriteId1 < 0)
+ {
+ DestroyAnimVisualTask(taskId);
+ return;
+ }
+
+ spriteId2 = duplicate_obj_of_side_rel2move_in_transparent_mode(1);
+ if (spriteId2 < 0)
+ {
+ obj_delete_but_dont_free_vram(&gSprites[spriteId1]);
+ DestroyAnimVisualTask(taskId);
+ return;
+ }
+
+ gSprites[spriteId2].pos2.x += 24;
+ gSprites[spriteId1].pos2.x -= 24;
+ gSprites[spriteId2].data[0] = 0;
+ gSprites[spriteId1].data[0] = 0;
+ gSprites[spriteId2].data[1] = 0;
+ gSprites[spriteId1].data[1] = 0;
+ gSprites[spriteId2].data[2] = 0;
+ gSprites[spriteId1].data[2] = 0;
+ gSprites[spriteId2].data[3] = 16;
+ gSprites[spriteId1].data[3] = -16;
+ gSprites[spriteId2].data[4] = 0;
+ gSprites[spriteId1].data[4] = 128;
+ gSprites[spriteId2].data[5] = 24;
+ gSprites[spriteId1].data[5] = 24;
+ gSprites[spriteId2].data[6] = taskId;
+ gSprites[spriteId1].data[6] = taskId;
+ gSprites[spriteId2].data[7] = 0;
+ gSprites[spriteId1].data[7] = 0;
+ gTasks[taskId].data[0] = 2;
+ gSprites[spriteId2].invisible = 0;
+ gSprites[spriteId1].invisible = 1;
+ gSprites[spriteId2].oam.objMode = ST_OAM_OBJ_NORMAL;
+ gSprites[spriteId1].oam.objMode = ST_OAM_OBJ_NORMAL;
+ gSprites[spriteId2].callback = sub_8131838;
+ gSprites[spriteId1].callback = sub_8131838;
+ gTasks[taskId].func = sub_8131810;
+}
+
+static void sub_8131810(u8 taskId)
+{
+ if (gTasks[taskId].data[0] == 0)
+ DestroyAnimVisualTask(taskId);
+}
+
+static void sub_8131838(struct Sprite *sprite)
+{
+ if (++sprite->data[1] > 1)
+ {
+ sprite->data[1] = 0;
+ sprite->invisible ^= 1;
+ }
+
+ sprite->data[4] = (sprite->data[4] + sprite->data[3]) & 0xFF;
+ sprite->pos2.x = Cos(sprite->data[4], sprite->data[5]);
+ switch (sprite->data[0])
+ {
+ case 0:
+ if (++sprite->data[2] == 60)
+ {
+ sprite->data[2] = 0;
+ sprite->data[0]++;
+ }
+ break;
+ case 1:
+ if (++sprite->data[2] > 0)
+ {
+ sprite->data[2] = 0;
+ sprite->data[5] -= 2;
+ if (sprite->data[5] < 0)
+ {
+ gTasks[sprite->data[6]].data[sprite->data[7]]--;
+ obj_delete_but_dont_free_vram(sprite);
+ }
+ }
+ break;
+ }
+}
diff --git a/src/battle/battle_anim_813F0F4.c b/src/battle/battle_anim_813F0F4.c
index 219395baf..f112c59aa 100755
--- a/src/battle/battle_anim_813F0F4.c
+++ b/src/battle/battle_anim_813F0F4.c
@@ -36,13 +36,13 @@ extern u8 gEffectBank;
extern const u8 gUnknown_08D2EE48[];
extern const u8 gUnknown_08D2EDFC[];
extern const u16 gUnknown_08D2E150[];
-extern const struct CompressedSpritePalette gUnknown_0840B2B8[];
-extern const struct SpriteTemplate gSpriteTemplate_840B3B4[];
+extern const struct CompressedSpritePalette gBallOpenParticlePalettes[];
+extern const struct SpriteTemplate gSpriteTemplates_840B3B4[];
extern const struct SpriteTemplate gSpriteTemplate_8402500;
extern const struct SpriteTemplate gBattleAnimSpriteTemplate_84024E8;
-extern const u8 gUnknown_0840B378[];
-extern const struct CompressedSpriteSheet gUnknown_0840B258[];
-extern const TaskFunc gUnknown_0840B384[];
+extern const u8 gBallOpenParticleAnimNums[];
+extern const struct CompressedSpriteSheet gBallOpenParticleSpritesheets[];
+extern const TaskFunc gBallOpenParticleAnimationFuncs[];
extern const u16 gUnknown_0840B4D4[];
extern const struct CompressedSpriteSheet gBattleAnimPicTable[];
extern const struct CompressedSpritePalette gBattleAnimPaletteTable[];
@@ -69,12 +69,12 @@ static void sub_81404E4(struct Sprite *sprite);
static void sub_81405C8(struct Sprite *sprite);
static void sub_81406BC(struct Sprite *sprite);
static void sub_81407F4(struct Sprite *sprite);
-static void sub_8140A08(struct Sprite *sprite);
-static void sub_8140A28(struct Sprite *sprite);
-static void sub_8141294(struct Sprite *sprite);
-static void sub_8140ECC(struct Sprite *sprite);
-static void sub_8140FF8(struct Sprite *sprite);
-static void sub_8141230(struct Sprite *sprite);
+static void PokeBallOpenParticleAnimation_Step1(struct Sprite *sprite);
+static void PokeBallOpenParticleAnimation_Step2(struct Sprite *sprite);
+static void DestroyBallOpenAnimationParticle(struct Sprite *sprite);
+static void FanOutBallOpenParticles_Step1(struct Sprite *sprite);
+static void RepeatBallOpenParticleAnimation_Step1(struct Sprite *sprite);
+static void PremierBallOpenParticleAnimation_Step1(struct Sprite *sprite);
static void sub_81413DC(u8 taskId);
static void sub_814146C(u8 taskId);
static void sub_81414BC(u8 taskId);
@@ -338,7 +338,7 @@ void sub_813F844(u8 taskId)
y = GetBattlerSpriteCoord(gAnimBankAttacker, 1);
priority = gSprites[spriteId].oam.priority;
subpriority = gSprites[spriteId].subpriority;
- gTasks[taskId].data[10] = sub_814086C(x, y + 32, priority, subpriority, ballIndex);
+ gTasks[taskId].data[10] = AnimateBallOpenParticles(x, y + 32, priority, subpriority, ballIndex);
selectedPalettes = sub_80791A8(1, 0, 0, 0, 0, 0, 0);
gTasks[taskId].data[11] = sub_8141314(0, gAnimBankAttacker, selectedPalettes, ballIndex);
gTasks[taskId].data[0]++;
@@ -353,14 +353,14 @@ void sub_813F844(u8 taskId)
void sub_813F990(u8 taskId)
{
u8 ballIndex = ball_number_to_ball_processing_index(gLastUsedItem);
- sub_80478DC(ballIndex);
+ LoadBallGraphics(ballIndex);
DestroyAnimVisualTask(taskId);
}
void sub_813F9B8(u8 taskId)
{
u8 ballIndex = ball_number_to_ball_processing_index(gLastUsedItem);
- sub_804794C(ballIndex);
+ FreeBallGraphics(ballIndex);
DestroyAnimVisualTask(taskId);
}
@@ -526,7 +526,7 @@ static void sub_813FDC0(struct Sprite *sprite)
if (ballIndex2 < 0)
return;
- sub_814086C(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballIndex);
+ AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballIndex);
sub_8141314(0, gAnimBankTarget, 14, ballIndex);
}
}
@@ -946,7 +946,7 @@ static void sub_81405F4(struct Sprite *sprite)
if (ballIndex2 < 0)
goto LABEL;
- sub_814086C(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballIndex);
+ AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballIndex);
sub_8141314(1, gAnimBankTarget, 14, ballIndex);
LABEL:
@@ -1090,17 +1090,17 @@ _08140868: .4byte gDoingBattleAnim\n\
}
#endif // NONMATCHING
-u8 sub_814086C(u8 x, u8 y, u8 priority, u8 subpriority, u8 ballIndex)
+u8 AnimateBallOpenParticles(u8 x, u8 y, u8 priority, u8 subpriority, u8 ballIndex)
{
u8 taskId;
- if (GetSpriteTileStartByTag(gUnknown_0840B258[ballIndex].tag) == 0xFFFF)
+ if (GetSpriteTileStartByTag(gBallOpenParticleSpritesheets[ballIndex].tag) == 0xFFFF)
{
- LoadCompressedObjectPic(&gUnknown_0840B258[ballIndex]);
- LoadCompressedObjectPalette(&gUnknown_0840B2B8[ballIndex]);
+ LoadCompressedObjectPic(&gBallOpenParticleSpritesheets[ballIndex]);
+ LoadCompressedObjectPalette(&gBallOpenParticlePalettes[ballIndex]);
}
- taskId = CreateTask(gUnknown_0840B384[ballIndex], 5);
+ taskId = CreateTask(gBallOpenParticleAnimationFuncs[ballIndex], 5);
gTasks[taskId].data[1] = x;
gTasks[taskId].data[2] = y;
gTasks[taskId].data[3] = priority;
@@ -1113,7 +1113,7 @@ u8 sub_814086C(u8 x, u8 y, u8 priority, u8 subpriority, u8 ballIndex)
return taskId;
}
-void sub_8140930(u8 taskId)
+void PokeBallOpenParticleAnimation(u8 taskId)
{
u8 spriteId;
u8 x, y;
@@ -1129,9 +1129,9 @@ void sub_8140930(u8 taskId)
priority = gTasks[taskId].data[3];
subpriority = gTasks[taskId].data[4];
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8140A08;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = PokeBallOpenParticleAnimation_Step1;
gSprites[spriteId].oam.priority = priority;
var0 = (u8)gTasks[taskId].data[0];
@@ -1150,24 +1150,24 @@ void sub_8140930(u8 taskId)
gTasks[taskId].data[0]++;
}
-static void sub_8140A08(struct Sprite *sprite)
+static void PokeBallOpenParticleAnimation_Step1(struct Sprite *sprite)
{
if (sprite->data[1] == 0)
- sprite->callback = sub_8140A28;
+ sprite->callback = PokeBallOpenParticleAnimation_Step2;
else
sprite->data[1]--;
}
-static void sub_8140A28(struct Sprite *sprite)
+static void PokeBallOpenParticleAnimation_Step2(struct Sprite *sprite)
{
sprite->pos2.x = Sin(sprite->data[0], sprite->data[1]);
sprite->pos2.y = Cos(sprite->data[0], sprite->data[1]);
sprite->data[1] += 2;
if (sprite->data[1] == 50)
- sub_8141294(sprite);
+ DestroyBallOpenAnimationParticle(sprite);
}
-void sub_8140A64(u8 taskId)
+void TimerBallOpenParticleAnimation(u8 taskId)
{
u8 i;
u8 x, y, priority, subpriority, ballIndex;
@@ -1181,9 +1181,9 @@ void sub_8140A64(u8 taskId)
for (i = 0; i < 8; i++)
{
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8140ECC;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = FanOutBallOpenParticles_Step1;
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].data[0] = i * 32;
gSprites[spriteId].data[4] = 10;
@@ -1195,7 +1195,7 @@ void sub_8140A64(u8 taskId)
DestroyTask(taskId);
}
-void sub_8140B3C(u8 taskId)
+void DiveBallOpenParticleAnimation(u8 taskId)
{
u8 i;
u8 x, y, priority, subpriority, ballIndex;
@@ -1209,9 +1209,9 @@ void sub_8140B3C(u8 taskId)
for (i = 0; i < 8; i++)
{
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8140ECC;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = FanOutBallOpenParticles_Step1;
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].data[0] = i * 32;
gSprites[spriteId].data[4] = 10;
@@ -1223,7 +1223,7 @@ void sub_8140B3C(u8 taskId)
DestroyTask(taskId);
}
-void sub_8140C14(u8 taskId)
+void SafariBallOpenParticleAnimation(u8 taskId)
{
u8 i;
u8 x, y, priority, subpriority, ballIndex;
@@ -1237,9 +1237,9 @@ void sub_8140C14(u8 taskId)
for (i = 0; i < 8; i++)
{
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8140ECC;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = FanOutBallOpenParticles_Step1;
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].data[0] = i * 32;
gSprites[spriteId].data[4] = 4;
@@ -1251,7 +1251,7 @@ void sub_8140C14(u8 taskId)
DestroyTask(taskId);
}
-void sub_8140CE8(u8 taskId)
+void UltraBallOpenParticleAnimation(u8 taskId)
{
u8 i;
u8 x, y, priority, subpriority, ballIndex;
@@ -1265,9 +1265,9 @@ void sub_8140CE8(u8 taskId)
for (i = 0; i < 10; i++)
{
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8140ECC;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = FanOutBallOpenParticles_Step1;
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].data[0] = i * 25;
gSprites[spriteId].data[4] = 5;
@@ -1279,7 +1279,7 @@ void sub_8140CE8(u8 taskId)
DestroyTask(taskId);
}
-void sub_8140DC4(u8 taskId)
+void GreatBallOpenParticleAnimation(u8 taskId)
{
u8 i;
u8 x, y, priority, subpriority, ballIndex;
@@ -1299,9 +1299,9 @@ void sub_8140DC4(u8 taskId)
for (i = 0; i < 8; i++)
{
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8140ECC;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = FanOutBallOpenParticles_Step1;
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].data[0] = i * 32;
gSprites[spriteId].data[4] = 8;
@@ -1318,7 +1318,7 @@ void sub_8140DC4(u8 taskId)
}
}
-static void sub_8140ECC(struct Sprite *sprite)
+static void FanOutBallOpenParticles_Step1(struct Sprite *sprite)
{
sprite->pos2.x = Sin(sprite->data[0], sprite->data[1]);
sprite->pos2.y = Cos(sprite->data[0], sprite->data[2]);
@@ -1326,10 +1326,10 @@ static void sub_8140ECC(struct Sprite *sprite)
sprite->data[1] += sprite->data[5];
sprite->data[2] += sprite->data[6];
if (++sprite->data[3] == 51)
- sub_8141294(sprite);
+ DestroyBallOpenAnimationParticle(sprite);
}
-void sub_8140F24(u8 taskId)
+void RepeatBallOpenParticleAnimation(u8 taskId)
{
u8 i;
u8 x, y, priority, subpriority, ballIndex;
@@ -1343,9 +1343,9 @@ void sub_8140F24(u8 taskId)
for (i = 0; i < 12; i++)
{
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8140FF8;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = RepeatBallOpenParticleAnimation_Step1;
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].data[0] = i * 21;
}
@@ -1354,7 +1354,7 @@ void sub_8140F24(u8 taskId)
DestroyTask(taskId);
}
-static void sub_8140FF8(struct Sprite *sprite)
+static void RepeatBallOpenParticleAnimation_Step1(struct Sprite *sprite)
{
sprite->pos2.x = Sin(sprite->data[0], sprite->data[1]);
sprite->pos2.y = Cos(sprite->data[0], Sin(sprite->data[0], sprite->data[2]));
@@ -1362,10 +1362,10 @@ static void sub_8140FF8(struct Sprite *sprite)
sprite->data[1]++;
sprite->data[2]++;
if (++sprite->data[3] == 51)
- sub_8141294(sprite);
+ DestroyBallOpenAnimationParticle(sprite);
}
-void sub_8141058(u8 taskId)
+void MasterBallOpenParticleAnimation(u8 taskId)
{
u8 i, j;
u8 x, y, priority, subpriority, ballIndex;
@@ -1381,9 +1381,9 @@ void sub_8141058(u8 taskId)
{
for (i = 0; i < 8; i++)
{
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8140ECC;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = FanOutBallOpenParticles_Step1;
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].data[0] = i * 32;
gSprites[spriteId].data[4] = 8;
@@ -1405,7 +1405,7 @@ void sub_8141058(u8 taskId)
DestroyTask(taskId);
}
-void sub_8141164(u8 taskId)
+void PremierBallOpenParticleAnimation(u8 taskId)
{
u8 i;
u8 x, y, priority, subpriority, ballIndex;
@@ -1419,9 +1419,9 @@ void sub_8141164(u8 taskId)
for (i = 0; i < 8; i++)
{
- spriteId = CreateSprite(&gSpriteTemplate_840B3B4[ballIndex], x, y, subpriority);
- StartSpriteAnim(&gSprites[spriteId], gUnknown_0840B378[ballIndex]);
- gSprites[spriteId].callback = sub_8141230;
+ spriteId = CreateSprite(&gSpriteTemplates_840B3B4[ballIndex], x, y, subpriority);
+ StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballIndex]);
+ gSprites[spriteId].callback = PremierBallOpenParticleAnimation_Step1;
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].data[0] = i * 32;
}
@@ -1430,7 +1430,7 @@ void sub_8141164(u8 taskId)
DestroyTask(taskId);
}
-static void sub_8141230(struct Sprite *sprite)
+static void PremierBallOpenParticleAnimation_Step1(struct Sprite *sprite)
{
sprite->pos2.x = Sin(sprite->data[0], sprite->data[1]);
sprite->pos2.y = Cos(sprite->data[0], Sin(sprite->data[0] & 0x3F, sprite->data[2]));
@@ -1438,10 +1438,10 @@ static void sub_8141230(struct Sprite *sprite)
sprite->data[1]++;
sprite->data[2]++;
if (++sprite->data[3] == 51)
- sub_8141294(sprite);
+ DestroyBallOpenAnimationParticle(sprite);
}
-static void sub_8141294(struct Sprite *sprite)
+static void DestroyBallOpenAnimationParticle(struct Sprite *sprite)
{
int i;
int temp;
@@ -1460,8 +1460,8 @@ static void sub_8141294(struct Sprite *sprite)
{
for (i = 0; i < 12; i++)
{
- FreeSpriteTilesByTag(gUnknown_0840B258[i].tag);
- FreeSpritePaletteByTag(gUnknown_0840B2B8[i].tag);
+ FreeSpriteTilesByTag(gBallOpenParticleSpritesheets[i].tag);
+ FreeSpritePaletteByTag(gBallOpenParticlePalettes[i].tag);
}
DestroySprite(sprite);
diff --git a/src/battle/battle_controller_linkopponent.c b/src/battle/battle_controller_linkopponent.c
index 8ca3d160a..f9c8fe7d1 100644
--- a/src/battle/battle_controller_linkopponent.c
+++ b/src/battle/battle_controller_linkopponent.c
@@ -62,7 +62,7 @@ extern void sub_8037A74(void);
extern void sub_8032984(u8, u16);
extern void sub_8037E30(void);
extern void sub_80312F0(struct Sprite *);
-extern u8 sub_8046400();
+extern u8 StartSendOutMonAnimation();
extern void sub_8032A08();
extern void sub_8043DB0();
extern void sub_8037BBC(void);
@@ -1195,7 +1195,7 @@ void sub_8039430(u8 a, u8 b)
StartSpriteAnim(&gSprites[gBankSpriteIds[a]], gBattleMonForms[a]);
gSprites[gBankSpriteIds[a]].invisible = TRUE;
gSprites[gBankSpriteIds[a]].callback = SpriteCallbackDummy;
- gSprites[gUnknown_0300434C[a]].data[0] = sub_8046400(0, 0xFE);
+ gSprites[gUnknown_0300434C[a]].data[0] = StartSendOutMonAnimation(0, 0xFE);
}
void LinkOpponentHandleReturnPokeToBall(void)
diff --git a/src/battle/battle_controller_linkpartner.c b/src/battle/battle_controller_linkpartner.c
index dff4edfc1..38514bfb5 100644
--- a/src/battle/battle_controller_linkpartner.c
+++ b/src/battle/battle_controller_linkpartner.c
@@ -79,7 +79,7 @@ extern void sub_80105EC(struct Sprite *);
extern s32 sub_803FC34(u16);
extern void LoadPlayerTrainerBankSprite();
extern void sub_80313A0(struct Sprite *);
-extern u8 sub_8046400();
+extern u8 StartSendOutMonAnimation();
extern void sub_80312F0(struct Sprite *);
extern u8 CreateInvisibleSpriteWithCallback();
extern void BattleLoadPlayerMonSprite();
@@ -1143,7 +1143,7 @@ void sub_811F864(u8 a, u8 b)
StartSpriteAnim(&gSprites[gBankSpriteIds[a]], gBattleMonForms[a]);
gSprites[gBankSpriteIds[a]].invisible = TRUE;
gSprites[gBankSpriteIds[a]].callback = SpriteCallbackDummy;
- gSprites[gUnknown_0300434C[a]].data[0] = sub_8046400(0, 0xFF);
+ gSprites[gUnknown_0300434C[a]].data[0] = StartSendOutMonAnimation(0, 0xFF);
}
void LinkPartnerHandleReturnPokeToBall(void)
diff --git a/src/battle/battle_controller_opponent.c b/src/battle/battle_controller_opponent.c
index ee313c098..a7e99900b 100644
--- a/src/battle/battle_controller_opponent.c
+++ b/src/battle/battle_controller_opponent.c
@@ -74,7 +74,7 @@ extern u8 GetBattlerPosition(u8);
extern void sub_8032984(u8, u16);
extern void sub_80333D4(void);
extern void sub_80312F0(struct Sprite *);
-extern u8 sub_8046400();
+extern u8 StartSendOutMonAnimation();
extern void sub_8032A08();
extern void sub_8043DB0();
extern void sub_8033160(void);
@@ -1168,7 +1168,7 @@ void sub_803495C(u8 a, u8 b)
StartSpriteAnim(&gSprites[gBankSpriteIds[a]], gBattleMonForms[a]);
gSprites[gBankSpriteIds[a]].invisible = TRUE;
gSprites[gBankSpriteIds[a]].callback = SpriteCallbackDummy;
- gSprites[gUnknown_0300434C[a]].data[0] = sub_8046400(0, 0xFE);
+ gSprites[gUnknown_0300434C[a]].data[0] = StartSendOutMonAnimation(0, 0xFE);
}
void OpponentHandleReturnPokeToBall(void)
diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c
index 654a2c195..de8b1579b 100644
--- a/src/battle/battle_controller_player.c
+++ b/src/battle/battle_controller_player.c
@@ -126,7 +126,7 @@ extern void sub_802DEAC(void);
extern void sub_80312F0(struct Sprite *);
extern u8 GetBattlerSpriteCoord();
extern u8 sub_8077F68();
-extern u8 sub_8046400();
+extern u8 StartSendOutMonAnimation();
extern void sub_802D798(void);
extern void bx_0802E404(void);
extern u8 gActiveBattler;
@@ -2523,7 +2523,7 @@ void sub_802F934(u8 bank, u8 b)
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy;
- gSprites[gUnknown_0300434C[bank]].data[0] = sub_8046400(0, 0xFF);
+ gSprites[gUnknown_0300434C[bank]].data[0] = StartSendOutMonAnimation(0, 0xFF);
}
void PlayerHandleReturnPokeToBall(void)
diff --git a/src/battle/battle_controller_wally.c b/src/battle/battle_controller_wally.c
index 312ef9d12..a7ce7d27d 100644
--- a/src/battle/battle_controller_wally.c
+++ b/src/battle/battle_controller_wally.c
@@ -88,7 +88,7 @@ extern void oamt_add_pos2_onto_pos1();
extern void StartAnimLinearTranslation(struct Sprite *);
extern void sub_8030E38(struct Sprite *);
extern void StoreSpriteCallbackInData();
-extern u8 sub_8046400();
+extern u8 StartSendOutMonAnimation();
extern u8 GetBattlerSpriteCoord();
extern u8 sub_8077F68();
extern u8 sub_8079E90();
@@ -1518,7 +1518,7 @@ void sub_81398BC(u8 bank)
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy;
- gSprites[gUnknown_0300434C[bank]].data[0] = sub_8046400(0, 0xFF);
+ gSprites[gUnknown_0300434C[bank]].data[0] = StartSendOutMonAnimation(0, 0xFF);
}
void sub_8139A2C(u8 taskId)
diff --git a/src/battle/pokeball.c b/src/battle/pokeball.c
index ac15246d6..abfdf2c3d 100644
--- a/src/battle/pokeball.c
+++ b/src/battle/pokeball.c
@@ -300,7 +300,7 @@ const struct SpriteTemplate gBallSpriteTemplates[] =
extern void InitAnimArcTranslation();
extern bool8 TranslateAnimArc(struct Sprite *);
-static void sub_8046464(u8);
+static void SendOutMonAnimation(u8);
static void sub_80466E8(struct Sprite *);
static void sub_80466F4(struct Sprite *);
static void sub_8046760(struct Sprite *);
@@ -312,10 +312,10 @@ static void sub_8046C78(struct Sprite *);
static void sub_8046E7C(struct Sprite *);
static void sub_8046E9C(struct Sprite *);
static void sub_8046FBC(struct Sprite *);
-static void sub_8047074(struct Sprite *);
-static void sub_80470C4(struct Sprite *);
-static void sub_8047230(struct Sprite *);
-static void sub_8047254(struct Sprite *);
+static void SendOutPlayerMonAnimation_Step0(struct Sprite *);
+static void SendOutPlayerMonAnimation_Step1(struct Sprite *);
+static void SendOutMonAnimation_Delay(struct Sprite *);
+static void SendOutOpponentMonAnimation_Step0(struct Sprite *);
static void sub_80473D0(struct Sprite *);
static void sub_804748C(struct Sprite *);
static void sub_8047638(struct Sprite *);
@@ -324,28 +324,28 @@ static void sub_8047754(struct Sprite *);
static void sub_804780C(struct Sprite *);
static void sub_8047830(struct Sprite *);
static void oamc_804BEB4(struct Sprite *);
-static u16 sub_8047978(u8);
+static u16 GetBattlerBall(u8);
-u8 sub_8046400(u16 a, u8 b)
+u8 StartSendOutMonAnimation(u16 a, u8 side)
{
u8 taskId;
gDoingBattleAnim = 1;
ewram17810[gActiveBattler].unk0_3 = 1;
- taskId = CreateTask(sub_8046464, 5);
+ taskId = CreateTask(SendOutMonAnimation, 5);
gTasks[taskId].data[1] = a;
- gTasks[taskId].data[2] = b;
+ gTasks[taskId].data[2] = side;
gTasks[taskId].data[3] = gActiveBattler;
return 0;
}
-static void sub_8046464(u8 taskId)
+static void SendOutMonAnimation(u8 taskId)
{
- bool8 sp0 = FALSE;
- u16 r8;
- u8 r5;
+ bool8 debug = FALSE;
+ u16 side;
+ u8 battler;
u16 ball;
- u8 r4;
+ u8 ballIndex;
u8 spriteId;
if (gTasks[taskId].data[0] == 0)
@@ -353,44 +353,49 @@ static void sub_8046464(u8 taskId)
gTasks[taskId].data[0]++;
return;
}
- r8 = gTasks[taskId].data[2];
- r5 = gTasks[taskId].data[3];
- if (GetBattlerSide(r5) != 0)
- ball = GetMonData(&gEnemyParty[gBattlerPartyIndexes[r5]], MON_DATA_POKEBALL);
+
+ side = gTasks[taskId].data[2];
+ battler = gTasks[taskId].data[3];
+ if (GetBattlerSide(battler) != B_SIDE_PLAYER)
+ ball = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_POKEBALL);
else
- ball = GetMonData(&gPlayerParty[gBattlerPartyIndexes[r5]], MON_DATA_POKEBALL);
- r4 = ball_number_to_ball_processing_index(ball);
- sub_80478DC(r4);
- spriteId = CreateSprite(&gBallSpriteTemplates[r4], 32, 80, 0x1D);
+ ball = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_POKEBALL);
+
+ ballIndex = ball_number_to_ball_processing_index(ball);
+ LoadBallGraphics(ballIndex);
+ spriteId = CreateSprite(&gBallSpriteTemplates[ballIndex], 32, 80, 29);
gSprites[spriteId].data[0] = 0x80;
gSprites[spriteId].data[1] = 0;
- gSprites[spriteId].data[7] = r8;
- switch (r8)
+ gSprites[spriteId].data[7] = side;
+
+ switch (side)
{
- case 0xFF:
- gBankTarget = r5;
+ case 0xFF: // Player's side
+ gBankTarget = battler;
gSprites[spriteId].pos1.x = 24;
gSprites[spriteId].pos1.y = 68;
- gSprites[spriteId].callback = sub_8047074;
+ gSprites[spriteId].callback = SendOutPlayerMonAnimation_Step0;
break;
- case 0xFE:
- gSprites[spriteId].pos1.x = GetBattlerSpriteCoord(r5, 0);
- gSprites[spriteId].pos1.y = GetBattlerSpriteCoord(r5, 1) + 24;
- gBankTarget = r5;
+ case 0xFE: // Opponent's side
+ gSprites[spriteId].pos1.x = GetBattlerSpriteCoord(battler, 0);
+ gSprites[spriteId].pos1.y = GetBattlerSpriteCoord(battler, 1) + 24;
+ gBankTarget = battler;
gSprites[spriteId].data[0] = 0;
- gSprites[spriteId].callback = sub_8047254;
+ gSprites[spriteId].callback = SendOutOpponentMonAnimation_Step0;
break;
default:
gBankTarget = GetBattlerAtPosition(1);
- sp0 = TRUE;
+ debug = TRUE;
break;
}
+
gSprites[spriteId].data[6] = gBankTarget;
- if (!sp0)
+ if (!debug)
{
DestroyTask(taskId);
return;
}
+
gSprites[spriteId].data[0] = 0x22;
gSprites[spriteId].data[2] = GetBattlerSpriteCoord(gBankTarget, 0);
gSprites[spriteId].data[4] = GetBattlerSpriteCoord(gBankTarget, 1) - 16;
@@ -418,8 +423,8 @@ static void objc_0804ABD4(struct Sprite *sprite)
sprite->pos2.x = 0;
sprite->pos2.y = 0;
sprite->data[5] = 0;
- r4 = ball_number_to_ball_processing_index(sub_8047978(r5));
- sub_814086C(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, r4);
+ r4 = ball_number_to_ball_processing_index(GetBattlerBall(r5));
+ AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, r4);
sprite->data[0] = sub_8141314(0, r5, 14, r4);
sprite->data[6] = r5;
sprite->data[7] = r8;
@@ -693,34 +698,35 @@ static void sub_8046AD0(u8 taskId)
static void sub_8046C78(struct Sprite *sprite)
{
- u8 r5 = sprite->data[6];
- u32 r4; // not sure of this type
+ int ballIndex;
+ u8 battler = sprite->data[6];
StartSpriteAnim(sprite, 1);
- r4 = ball_number_to_ball_processing_index(sub_8047978(r5));
- sub_814086C(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, r4);
- sprite->data[0] = sub_8141314(1, sprite->data[6], 14, r4);
+ ballIndex = ball_number_to_ball_processing_index(GetBattlerBall(battler));
+ AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballIndex);
+ sprite->data[0] = sub_8141314(1, sprite->data[6], 14, ballIndex);
sprite->callback = sub_8046E9C;
if (gMain.inBattle)
{
- struct Pokemon *pkmn;
+ struct Pokemon *mon;
u16 species;
- s8 r8;
- u16 r4_2;
+ s8 cryPanning;
+ u16 cryBehavior;
u8 taskId;
- if (GetBattlerSide(r5) != 0)
+ if (GetBattlerSide(battler) != 0)
{
- pkmn = &gEnemyParty[gBattlerPartyIndexes[r5]];
- r8 = 25;
+ mon = &gEnemyParty[gBattlerPartyIndexes[battler]];
+ cryPanning = 25;
}
else
{
- pkmn = &gPlayerParty[gBattlerPartyIndexes[r5]];
- r8 = -25;
+ mon = &gPlayerParty[gBattlerPartyIndexes[battler]];
+ cryPanning = -25;
}
- species = GetMonData(pkmn, MON_DATA_SPECIES);
- if ((r5 == GetBattlerAtPosition(0) || r5 == GetBattlerAtPosition(1))
+
+ species = GetMonData(mon, MON_DATA_SPECIES);
+ if ((battler == GetBattlerAtPosition(0) || battler == GetBattlerAtPosition(1))
&& IsDoubleBattle() && ewram17840.unk9_0)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
@@ -733,18 +739,21 @@ static void sub_8046C78(struct Sprite *sprite)
m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 128);
}
}
+
if (!IsDoubleBattle() || !ewram17840.unk9_0)
- r4_2 = 0;
- else if (r5 == GetBattlerAtPosition(0) || r5 == GetBattlerAtPosition(1))
- r4_2 = 1;
+ cryBehavior = 0;
+ else if (battler == GetBattlerAtPosition(0) || battler == GetBattlerAtPosition(1))
+ cryBehavior = 1;
else
- r4_2 = 2;
+ cryBehavior = 2;
+
taskId = CreateTask(sub_8046AD0, 3);
gTasks[taskId].data[0] = species;
- gTasks[taskId].data[1] = r8;
- gTasks[taskId].data[2] = r4_2;
+ gTasks[taskId].data[1] = cryPanning;
+ gTasks[taskId].data[2] = cryBehavior;
gTasks[taskId].data[15] = 0;
}
+
StartSpriteAffineAnim(&gSprites[gBankSpriteIds[sprite->data[6]]], 1);
AnimateSprite(&gSprites[gBankSpriteIds[sprite->data[6]]]);
gSprites[gBankSpriteIds[sprite->data[6]]].data[1] = 0x1000;
@@ -795,7 +804,7 @@ static void sub_8046E9C(struct Sprite *sprite)
if (r3 == 4)
{
for (i = 0; i < 12; i++)
- sub_804794C(i);
+ FreeBallGraphics(i);
}
}
}
@@ -825,7 +834,7 @@ static void sub_8046FBC(struct Sprite *sprite)
}
}
-static void sub_8047074(struct Sprite *sprite)
+static void SendOutPlayerMonAnimation_Step0(struct Sprite *sprite)
{
sprite->data[0] = 25;
sprite->data[2] = GetBattlerSpriteCoord(sprite->data[6], 2);
@@ -833,12 +842,12 @@ static void sub_8047074(struct Sprite *sprite)
sprite->data[5] = -30;
sprite->oam.affineParam = sprite->data[6];
InitAnimArcTranslation(sprite);
- sprite->callback = sub_80470C4;
+ sprite->callback = SendOutPlayerMonAnimation_Step1;
}
#define HIBYTE(x) (((x) >> 8) & 0xFF)
-static void sub_80470C4(struct Sprite *sprite)
+static void SendOutPlayerMonAnimation_Step1(struct Sprite *sprite)
{
u32 r6;
u32 r7;
@@ -855,6 +864,7 @@ static void sub_80470C4(struct Sprite *sprite)
sprite->data[2] = ((sprite->data[2] / 3) & ~1) | r7;
StartSpriteAffineAnim(sprite, 4);
}
+
r4 = sprite->data[0];
TranslateAnimLinear(sprite);
sprite->data[7] += sprite->data[6] / 3;
@@ -864,6 +874,7 @@ static void sub_80470C4(struct Sprite *sprite)
sprite->data[0] = r4;
else
sprite->data[0] = r4 - 1;
+
if (HIBYTE(sprite->data[7]) >= 80)
{
r6 = sprite->data[1] & 1;
@@ -882,17 +893,17 @@ static void sub_80470C4(struct Sprite *sprite)
sprite->pos2.x = 0;
sprite->data[6] = sprite->oam.affineParam & 0xFF;
sprite->data[0] = 0;
- if (IsDoubleBattle() && ewram17840.unk9_0
- && sprite->data[6] == GetBattlerAtPosition(2))
- sprite->callback = sub_8047230;
+ if (IsDoubleBattle() && ewram17840.unk9_0 && sprite->data[6] == GetBattlerAtPosition(2))
+ sprite->callback = SendOutMonAnimation_Delay;
else
sprite->callback = sub_8046C78;
+
StartSpriteAffineAnim(sprite, 0);
}
}
}
-static void sub_8047230(struct Sprite *sprite)
+static void SendOutMonAnimation_Delay(struct Sprite *sprite)
{
if (sprite->data[0]++ > 24)
{
@@ -901,15 +912,14 @@ static void sub_8047230(struct Sprite *sprite)
}
}
-static void sub_8047254(struct Sprite *sprite)
+static void SendOutOpponentMonAnimation_Step0(struct Sprite *sprite)
{
sprite->data[0]++;
if (sprite->data[0] > 15)
{
sprite->data[0] = 0;
- if (IsDoubleBattle() && ewram17840.unk9_0
- && sprite->data[6] == GetBattlerAtPosition(3))
- sprite->callback = sub_8047230;
+ if (IsDoubleBattle() && ewram17840.unk9_0 && sprite->data[6] == GetBattlerAtPosition(3))
+ sprite->callback = SendOutMonAnimation_Delay;
else
sprite->callback = sub_8046C78;
}
@@ -917,7 +927,7 @@ static void sub_8047254(struct Sprite *sprite)
static u8 sub_80472B0(u8 a, u8 b, u8 c, u8 d)
{
- return sub_814086C(a, b, c, d, 0);
+ return AnimateBallOpenParticles(a, b, c, d, 0);
}
static u8 sub_80472D8(u8 a, u8 b, u32 c)
@@ -1155,38 +1165,39 @@ static void oamc_804BEB4(struct Sprite *sprite)
}
}
-void sub_80478DC(u8 a)
+void LoadBallGraphics(u8 ballIndex)
{
- u16 var;
+ u16 tileStart;
- if (GetSpriteTileStartByTag(sBallSpriteSheets[a].tag) == 0xFFFF)
+ if (GetSpriteTileStartByTag(sBallSpriteSheets[ballIndex].tag) == 0xFFFF)
{
- LoadCompressedObjectPic(&sBallSpriteSheets[a]);
- LoadCompressedObjectPalette(&sBallSpritePalettes[a]);
+ LoadCompressedObjectPic(&sBallSpriteSheets[ballIndex]);
+ LoadCompressedObjectPalette(&sBallSpritePalettes[ballIndex]);
}
- switch (a)
+
+ switch (ballIndex)
{
case 6:
case 10:
case 11:
break;
default:
- var = GetSpriteTileStartByTag(sBallSpriteSheets[a].tag);
- LZDecompressVram(gUnknown_08D030D0, (void *)(VRAM + 0x10100 + var * 32));
+ tileStart = GetSpriteTileStartByTag(sBallSpriteSheets[ballIndex].tag);
+ LZDecompressVram(gUnknown_08D030D0, (void *)(VRAM + 0x10100 + tileStart * 32));
break;
}
}
-void sub_804794C(u8 a)
+void FreeBallGraphics(u8 ballIndex)
{
- FreeSpriteTilesByTag(sBallSpriteSheets[a].tag);
- FreeSpritePaletteByTag(sBallSpritePalettes[a].tag);
+ FreeSpriteTilesByTag(sBallSpriteSheets[ballIndex].tag);
+ FreeSpritePaletteByTag(sBallSpritePalettes[ballIndex].tag);
}
-static u16 sub_8047978(u8 a)
+static u16 GetBattlerBall(u8 battler)
{
- if (GetBattlerSide(a) == 0)
- return GetMonData(&gPlayerParty[gBattlerPartyIndexes[a]], MON_DATA_POKEBALL);
+ if (GetBattlerSide(battler) == B_SIDE_PLAYER)
+ return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_POKEBALL);
else
- return GetMonData(&gEnemyParty[gBattlerPartyIndexes[a]], MON_DATA_POKEBALL);
+ return GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_POKEBALL);
}
diff --git a/src/battle/post_battle_event_funcs.c b/src/battle/post_battle_event_funcs.c
index a44cf028b..d0fbbec85 100644
--- a/src/battle/post_battle_event_funcs.c
+++ b/src/battle/post_battle_event_funcs.c
@@ -6,6 +6,7 @@
#include "pokemon.h"
#include "overworld.h"
#include "script_pokemon_80C4.h"
+#include "constants/heal_locations.h"
extern u8 gUnknown_02039324;
@@ -32,9 +33,9 @@ int GameClear(void)
SetSecretBase2Field_9();
if (gSaveBlock2.playerGender == MALE)
- sub_80537CC(1);
+ sub_80537CC(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F);
else
- sub_80537CC(2);
+ sub_80537CC(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F);
ribbonGet = FALSE;