summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2017-12-19 20:43:18 -0600
committerMarcus Huderle <huderlem@gmail.com>2017-12-19 20:43:18 -0600
commit5f32e88a6abb90507ddcac68673e35de8b4d8c26 (patch)
tree32d4b9f548b3e8dfb73645f759ccc957ce09f1de
parentf17a25cdc3a944be2a8ea5d8ec97f75047e99e2c (diff)
Decompile battle_anim thunder
-rwxr-xr-xasm/thunder.s68
-rw-r--r--ld_script.txt2
-rw-r--r--src/battle/anim/thunder.c36
3 files changed, 37 insertions, 69 deletions
diff --git a/asm/thunder.s b/asm/thunder.s
deleted file mode 100755
index df97608f9..000000000
--- a/asm/thunder.s
+++ /dev/null
@@ -1,68 +0,0 @@
- .include "constants/gba_constants.inc"
- .include "asm/macros.inc"
-
- .syntax unified
-
- .text
-
- @ thunder
-
- thumb_func_start sub_80D61C8
-sub_80D61C8: @ 80D61C8
- push {r4,lr}
- adds r4, r0, 0
- ldr r0, _080D61E8 @ =gBattleAnimBankAttacker
- ldrb r0, [r0]
- bl GetBankSide
- lsls r0, 24
- cmp r0, 0
- beq _080D61F0
- ldr r0, _080D61EC @ =gBattleAnimArgs
- ldrh r1, [r4, 0x20]
- ldrh r2, [r0]
- subs r1, r2
- strh r1, [r4, 0x20]
- b _080D61FC
- .align 2, 0
-_080D61E8: .4byte gBattleAnimBankAttacker
-_080D61EC: .4byte gBattleAnimArgs
-_080D61F0:
- ldr r1, _080D6210 @ =gBattleAnimArgs
- ldrh r0, [r1]
- ldrh r2, [r4, 0x20]
- adds r0, r2
- strh r0, [r4, 0x20]
- adds r0, r1, 0
-_080D61FC:
- ldrh r0, [r0, 0x2]
- ldrh r1, [r4, 0x22]
- adds r0, r1
- strh r0, [r4, 0x22]
- ldr r0, _080D6214 @ =sub_80D6218
- str r0, [r4, 0x1C]
- pop {r4}
- pop {r0}
- bx r0
- .align 2, 0
-_080D6210: .4byte gBattleAnimArgs
-_080D6214: .4byte sub_80D6218
- thumb_func_end sub_80D61C8
-
- thumb_func_start sub_80D6218
-sub_80D6218: @ 80D6218
- push {lr}
- adds r2, r0, 0
- adds r0, 0x3F
- ldrb r1, [r0]
- movs r0, 0x10
- ands r0, r1
- cmp r0, 0
- beq _080D622E
- adds r0, r2, 0
- bl move_anim_8072740
-_080D622E:
- pop {r0}
- bx r0
- thumb_func_end sub_80D6218
-
- .align 2, 0 @ Don't pad with nop.
diff --git a/ld_script.txt b/ld_script.txt
index 1b42d7253..819e9be26 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -284,7 +284,7 @@ SECTIONS {
src/battle/anim/heated_rock.o(.text);
src/battle/anim/wisp_orb.o(.text);
asm/wisp_fire.o(.text);
- asm/thunder.o(.text);
+ src/battle/anim/thunder.o(.text);
asm/beta_beat_up.o(.text);
asm/shock.o(.text);
asm/current.o(.text);
diff --git a/src/battle/anim/thunder.c b/src/battle/anim/thunder.c
new file mode 100644
index 000000000..5064148ef
--- /dev/null
+++ b/src/battle/anim/thunder.c
@@ -0,0 +1,36 @@
+#include "global.h"
+#include "battle_anim.h"
+#include "rom_8077ABC.h"
+
+extern s16 gBattleAnimArgs[8];
+extern u8 gBattleAnimBankAttacker;
+extern u8 gBattleAnimBankTarget;
+extern u16 gBattleTypeFlags;
+
+static void sub_80D6218(struct Sprite *);
+
+// thunder (positions the lightning bolts)
+// Used in Thunder, Thunder Punch, and Tri Attack.
+
+void sub_80D61C8(struct Sprite *sprite)
+{
+ if (GetBankSide(gBattleAnimBankAttacker) != 0)
+ {
+ sprite->pos1.x -= gBattleAnimArgs[0];
+ }
+ else
+ {
+ sprite->pos1.x += gBattleAnimArgs[0];
+ }
+
+ sprite->pos1.y += gBattleAnimArgs[1];
+ sprite->callback = sub_80D6218;
+}
+
+static void sub_80D6218(struct Sprite *sprite)
+{
+ if (sprite->animEnded)
+ {
+ move_anim_8072740(sprite);
+ }
+}