summaryrefslogtreecommitdiff
path: root/src/anim/orbit.c
diff options
context:
space:
mode:
authorProjectRevoTPP <projectrevotpp@hotmail.com>2017-11-25 02:42:34 -0500
committerProjectRevoTPP <projectrevotpp@hotmail.com>2017-11-25 02:42:34 -0500
commitbd45e6acb85fe854f58db5aa99f4004379765513 (patch)
treea4d58cc8ab37dec959602bb5e08a29c22ac7091f /src/anim/orbit.c
parent75cef1d9b80094ef5b875efac3ae0f0cb1ada165 (diff)
split battle_anim_80CA710.c (todo: split asm)
Diffstat (limited to 'src/anim/orbit.c')
-rwxr-xr-xsrc/anim/orbit.c147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/anim/orbit.c b/src/anim/orbit.c
new file mode 100755
index 000000000..9b77552fa
--- /dev/null
+++ b/src/anim/orbit.c
@@ -0,0 +1,147 @@
+#include "global.h"
+#include "rom_8077ABC.h"
+#include "trig.h"
+#include "battle_anim.h"
+
+extern s16 gBattleAnimArgs[];
+extern u8 gBattleAnimBankAttacker;
+extern u8 gBattleAnimBankTarget;
+
+static void sub_80CAC44(struct Sprite* sprite);
+static void sub_80CADA8(struct Sprite* sprite);
+static void sub_80CAE74(struct Sprite* sprite);
+
+// orbit (The effect of a sprite rotating around another one in a pseudo 3D effect.)
+// Used by Spore, Cotton Spore, and Petal Dance.
+
+void sub_80CABF8(struct Sprite* sprite)
+{
+ sub_8078764(sprite, 1);
+ StartSpriteAnim(sprite, gBattleAnimArgs[4]);
+ if (gBattleAnimArgs[4] == 1)
+ {
+ sprite->oam.objMode = 1;
+ }
+
+ sprite->data[0] = gBattleAnimArgs[3];
+ sprite->data[1] = gBattleAnimArgs[2];
+ sprite->callback = sub_80CAC44;
+ sub_80CAC44(sprite);
+}
+
+void sub_80CAC44(struct Sprite* sprite)
+{
+ u8 var1;
+
+ sprite->pos2.x = Sin(sprite->data[1], 32);
+ sprite->pos2.y = Cos(sprite->data[1], -3) + ((sprite->data[2] += 24) >> 8);
+ if ((u16)(sprite->data[1] - 0x40) < 0x80)
+ {
+ sprite->oam.priority = (sub_8079ED4(gBattleAnimBankTarget) & 3);
+ }
+ else
+ {
+ var1 = sub_8079ED4(gBattleAnimBankTarget) + 1;
+ if (var1 > 3)
+ {
+ var1 = 3;
+ }
+
+ sprite->oam.priority = var1;
+ }
+
+ sprite->data[1] = (sprite->data[1] + 2) & 0xFF;
+ sprite->data[0]--;
+ if (sprite->data[0] == -1)
+ move_anim_8072740(sprite);
+}
+
+void sub_80CACEC(u8 taskId)
+{
+ if (NotInBattle() || !IsDoubleBattle())
+ {
+ DestroyAnimVisualTask(taskId);
+ }
+ else
+ {
+ if (GetBankIdentity_permutated(gBattleAnimBankTarget) == 1)
+ {
+ REG_BG2CNT_BITFIELD.priority = 3;
+ }
+ else
+ {
+ REG_BG1CNT_BITFIELD.priority = 1;
+ }
+
+ DestroyAnimVisualTask(taskId);
+ }
+}
+
+void sub_80CAD54(struct Sprite* sprite)
+{
+ sub_80787B0(sprite, 0);
+ sprite->data[0] = gBattleAnimArgs[3];
+ sprite->data[1] = sprite->pos1.x;
+ sprite->data[2] = sprite->pos1.x;
+ sprite->data[3] = sprite->pos1.y;
+ sprite->data[4] = sub_8077ABC(gBattleAnimBankAttacker, 3) + gBattleAnimArgs[2];
+ obj_translate_based_on_private_1_2_3_4(sprite);
+ sprite->data[5] = 0x40;
+ sprite->callback = sub_80CADA8;
+ sub_80CADA8(sprite);
+}
+
+void sub_80CADA8(struct Sprite* sprite)
+{
+ if (!sub_8078B5C(sprite))
+ {
+ sprite->pos2.x += Sin(sprite->data[5], 32);
+ sprite->pos2.y += Cos(sprite->data[5], -5);
+ if ((u16)(sprite->data[5] - 0x40) < 0x80)
+ {
+ sprite->subpriority = sub_8079E90(gBattleAnimBankAttacker) - 1;
+ }
+ else
+ {
+ sprite->subpriority = sub_8079E90(gBattleAnimBankAttacker) + 1;
+ }
+
+ sprite->data[5] = (sprite->data[5] + 5) & 0xFF;
+ }
+ else
+ {
+ move_anim_8072740(sprite);
+ }
+}
+
+void sub_80CAE20(struct Sprite* sprite)
+{
+ sub_80787B0(sprite, 1);
+ sprite->data[0] = gBattleAnimArgs[3];
+ sprite->data[1] = sprite->pos1.x;
+ sprite->data[2] = sprite->pos1.x;
+ sprite->data[3] = sprite->pos1.y;
+ sprite->data[4] = sub_8077ABC(gBattleAnimBankAttacker, 3) + gBattleAnimArgs[2];
+ obj_translate_based_on_private_1_2_3_4(sprite);
+ sprite->data[5] = 0x40;
+ sprite->callback = sub_80CAE74;
+ sub_80CAE74(sprite);
+}
+
+void sub_80CAE74(struct Sprite* sprite)
+{
+ if (!sub_8078B5C(sprite))
+ {
+ sprite->pos2.x += Sin(sprite->data[5], 8);
+ if ((u16)(sprite->data[5] - 0x3B) < 5 || (u16)(sprite->data[5] - 0xBB) < 5)
+ {
+ sprite->oam.matrixNum ^= 8;
+ }
+
+ sprite->data[5] = (sprite->data[5] + 5) & 0xFF;
+ }
+ else
+ {
+ move_anim_8072740(sprite);
+ }
+}