From 35c0fb5154e9348423ca780ec6211fc0206ad8cd Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 26 Nov 2018 09:55:31 -0600 Subject: [PATCH] Decompile ground.c --- asm/battle_anim_815A0D4.s | 4 +- asm/battle_anim_effects_1.s | 16 +- asm/battle_anim_effects_2.s | 4 +- asm/electric.s | 2 +- asm/fight.s | 10 +- asm/fire.s | 2 +- asm/ghost.s | 2 +- asm/ground.s | 1675 ----------------------------------- asm/normal.s | 2 +- asm/water.s | 2 +- include/battle_anim.h | 1 + ld_script.txt | 2 +- src/battle_anim_80A5C6C.c | 2 +- src/ground.c | 655 +++++++++++++- 14 files changed, 666 insertions(+), 1713 deletions(-) delete mode 100644 asm/ground.s diff --git a/asm/battle_anim_815A0D4.s b/asm/battle_anim_815A0D4.s index d6a9ac8e6..362183765 100644 --- a/asm/battle_anim_815A0D4.s +++ b/asm/battle_anim_815A0D4.s @@ -125,7 +125,7 @@ sub_815A1B0: @ 815A1B0 adds r4, r0, 0 movs r0, 0x5A strh r0, [r4, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] movs r0, 0x7 strh r0, [r4, 0x30] @@ -824,7 +824,7 @@ sub_815A73C: @ 815A73C movs r0, 0x1E strh r0, [r4, 0x2E] strh r1, [r4, 0x30] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =sub_815A76C adds r0, r4, 0 diff --git a/asm/battle_anim_effects_1.s b/asm/battle_anim_effects_1.s index eb1fc50f3..910b09b8c 100644 --- a/asm/battle_anim_effects_1.s +++ b/asm/battle_anim_effects_1.s @@ -553,7 +553,7 @@ sub_80FECB8: @ 80FECB8 strb r0, [r2] movs r0, 0xA strh r0, [r4, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =sub_80FECF0 adds r0, r4, 0 @@ -581,7 +581,7 @@ sub_80FECF0: @ 80FECF0 bl StartSpriteAnim movs r0, 0x3C strh r0, [r4, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =DestroyAnimSprite adds r0, r4, 0 @@ -4624,7 +4624,7 @@ _08100CF2: bl StoreSpriteCallbackInData6 movs r0, 0x3 strh r0, [r4, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] _08100D28: pop {r4} @@ -5704,7 +5704,7 @@ sub_81015AC: @ 81015AC strh r1, [r0, 0x22] movs r1, 0x14 strh r1, [r0, 0x2E] - ldr r1, =sub_80A64B0 + ldr r1, =WaitAnimForDuration str r1, [r0, 0x1C] ldr r1, =sub_81015D4 bl StoreSpriteCallbackInData6 @@ -5728,7 +5728,7 @@ sub_81015D4: @ 81015D4 b _0810166A _081015EA: strh r1, [r5, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r5, 0x1C] ldr r1, =sub_81015D4 adds r0, r5, 0 @@ -5806,7 +5806,7 @@ sub_8101684: @ 8101684 bne _081016AC movs r0, 0xA strh r0, [r2, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r2, 0x1C] ldr r1, =sub_81016B8 adds r0, r2, 0 @@ -5833,7 +5833,7 @@ sub_81016B8: @ 81016B8 strh r0, [r5, 0x2E] strh r1, [r5, 0x30] strh r1, [r5, 0x32] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r5, 0x1C] ldr r1, =sub_8101774 adds r0, r5, 0 @@ -9019,7 +9019,7 @@ _08102FDE: strh r0, [r5, 0x22] movs r0, 0x8 strh r0, [r5, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r5, 0x1C] ldr r1, =DestroyAnimSprite adds r0, r5, 0 diff --git a/asm/battle_anim_effects_2.s b/asm/battle_anim_effects_2.s index 088e84ca3..c8cd53398 100644 --- a/asm/battle_anim_effects_2.s +++ b/asm/battle_anim_effects_2.s @@ -248,7 +248,7 @@ sub_8103620: @ 8103620 strh r0, [r4, 0x30] ldrh r0, [r1, 0x8] strh r0, [r4, 0x38] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =sub_8103658 adds r0, r4, 0 @@ -5667,7 +5667,7 @@ sub_810624C: @ 810624C strh r1, [r0, 0x2E] ldrh r1, [r2, 0x2] strh r1, [r0, 0x30] - ldr r1, =sub_80A64B0 + ldr r1, =WaitAnimForDuration str r1, [r0, 0x1C] ldr r1, =sub_810627C bl StoreSpriteCallbackInData6 diff --git a/asm/electric.s b/asm/electric.s index a6fd31319..b1fa8b9ae 100644 --- a/asm/electric.s +++ b/asm/electric.s @@ -744,7 +744,7 @@ _0810A7B6: ldr r0, =gBattleAnimArgs ldrh r0, [r0, 0x4] strh r0, [r4, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =DestroyAnimSprite adds r0, r4, 0 diff --git a/asm/fight.s b/asm/fight.s index 191e2e28a..bc0320757 100644 --- a/asm/fight.s +++ b/asm/fight.s @@ -20,7 +20,7 @@ unc_080B08A0: @ 810CE2C strh r0, [r4, 0x22] movs r0, 0xF strh r0, [r4, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =DestroyAnimSprite adds r0, r4, 0 @@ -115,7 +115,7 @@ _0810CF0C: ldr r0, =gBattleAnimArgs ldrh r0, [r0, 0x4] strh r0, [r5, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r5, 0x1C] ldr r1, =DestroyAnimSprite adds r0, r5, 0 @@ -537,7 +537,7 @@ sub_810D278: @ 810D278 bl StartSpriteAnim ldrh r0, [r5, 0x6] strh r0, [r4, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =sub_810D2B0 adds r0, r4, 0 @@ -562,7 +562,7 @@ sub_810D2B0: @ 810D2B0 strb r0, [r2] movs r0, 0x14 strh r0, [r4, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =DestroyAnimSprite adds r0, r4, 0 @@ -635,7 +635,7 @@ sub_810D360: @ 810D360 push {lr} movs r1, 0xF strh r1, [r0, 0x2E] - ldr r1, =sub_80A64B0 + ldr r1, =WaitAnimForDuration str r1, [r0, 0x1C] ldr r1, =DestroyAnimSprite bl StoreSpriteCallbackInData6 diff --git a/asm/fire.s b/asm/fire.s index 6efd9f45e..cd0339b9b 100644 --- a/asm/fire.s +++ b/asm/fire.s @@ -625,7 +625,7 @@ sub_81093A4: @ 81093A4 movs r1, 0x4 orrs r0, r1 strb r0, [r2] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] ldr r1, =sub_81093E4 adds r0, r4, 0 diff --git a/asm/ghost.s b/asm/ghost.s index 53f394e04..5a0991468 100644 --- a/asm/ghost.s +++ b/asm/ghost.s @@ -2525,7 +2525,7 @@ _08112A5E: bne _08112AC0 movs r0, 0x1E strh r0, [r3, 0x2E] - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r3, 0x1C] ldr r1, =sub_8112ACC adds r0, r3, 0 diff --git a/asm/ground.s b/asm/ground.s deleted file mode 100644 index d53f2aabf..000000000 --- a/asm/ground.s +++ /dev/null @@ -1,1675 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8114994 -sub_8114994: @ 8114994 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gBattleAnimAttacker - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x20] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x22] - movs r0, 0x14 - strh r0, [r4, 0x2E] - ldr r5, =gBattleAnimTarget - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x32] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x36] - ldr r0, =0x0000ffd8 - strh r0, [r4, 0x38] - adds r0, r4, 0 - bl InitAnimArcTranslation - ldr r0, =sub_81149FC - str r0, [r4, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114994 - - thumb_func_start sub_81149FC -sub_81149FC: @ 81149FC - push {r4,r5,lr} - adds r5, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _08114A50 - ldrh r0, [r5, 0x24] - ldrh r1, [r5, 0x20] - adds r0, r1 - movs r1, 0 - strh r0, [r5, 0x20] - ldrh r0, [r5, 0x26] - ldrh r2, [r5, 0x22] - adds r0, r2 - strh r0, [r5, 0x22] - strh r1, [r5, 0x26] - strh r1, [r5, 0x24] - movs r0, 0x14 - strh r0, [r5, 0x2E] - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x32] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x36] - movs r0, 0x28 - strh r0, [r5, 0x38] - adds r0, r5, 0 - bl InitAnimArcTranslation - ldr r0, =sub_8114A60 - str r0, [r5, 0x1C] -_08114A50: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81149FC - - thumb_func_start sub_8114A60 -sub_8114A60: @ 8114A60 - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _08114A74 - adds r0, r4, 0 - bl DestroyAnimSprite -_08114A74: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8114A60 - - thumb_func_start sub_8114A7C -sub_8114A7C: @ 8114A7C - push {r4-r6,lr} - adds r6, r0, 0 - movs r1, 0x1 - bl sub_80A6980 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08114A9C - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - negs r0, r0 - strh r0, [r1, 0x4] -_08114A9C: - ldr r4, =gBattleAnimArgs - ldrh r0, [r4, 0x8] - strh r0, [r6, 0x2E] - ldr r5, =gBattleAnimTarget - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x4] - adds r0, r1 - strh r0, [r6, 0x32] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r4, [r4, 0x6] - adds r0, r4 - strh r0, [r6, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r6, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r6, 0 - bl StoreSpriteCallbackInData6 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114A7C - - thumb_func_start sub_8114AF0 -sub_8114AF0: @ 8114AF0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - movs r1, 0x1 - bl InitAnimSpritePos - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord2 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord2 - lsls r0, 24 - lsrs r7, r0, 24 - bl Random2 - movs r4, 0x1F - adds r5, r4, 0 - ands r5, r0 - bl Random2 - ands r4, r0 - adds r1, r5, 0 - cmp r1, 0x10 - ble _08114B38 - movs r0, 0x10 - subs r0, r1 - lsls r0, 16 - lsrs r5, r0, 16 -_08114B38: - lsls r0, r4, 16 - asrs r1, r0, 16 - cmp r1, 0x10 - ble _08114B48 - movs r0, 0x10 - subs r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 -_08114B48: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x4] - strh r0, [r6, 0x2E] - mov r1, r8 - adds r0, r1, r5 - strh r0, [r6, 0x32] - adds r0, r7, r4 - strh r0, [r6, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r6, 0x1C] - ldr r1, =move_anim_8074EE0 - adds r0, r6, 0 - bl StoreSpriteCallbackInData6 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114AF0 - - thumb_func_start sub_8114B80 -sub_8114B80: @ 8114B80 - push {r4-r6,lr} - adds r5, r0, 0 - ldrh r2, [r5, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - adds r1, 0x1 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r5, 0x4] - ldr r6, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _08114BF4 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r2, [r6, 0x2] - adds r0, r2 - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r3, [r6, 0x4] - adds r0, r3 - strh r0, [r5, 0x22] - movs r1, 0x2 - ldrsh r0, [r6, r1] - movs r2, 0x1 - negs r2, r2 - adds r1, r2, 0 - cmp r0, 0 - ble _08114BDA - movs r1, 0x1 -_08114BDA: - strh r1, [r5, 0x2E] - ldr r0, =sub_8114C10 - b _08114C02 - .pool -_08114BF4: - ldrh r0, [r6, 0x2] - strh r0, [r5, 0x20] - ldrh r0, [r6, 0x4] - strh r0, [r5, 0x22] - negs r0, r0 - strh r0, [r5, 0x26] - ldr r0, =sub_8114C4C -_08114C02: - str r0, [r5, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114B80 - - thumb_func_start sub_8114C10 -sub_8114C10: @ 8114C10 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x30] - adds r0, 0x1 - strh r0, [r2, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _08114C2E - movs r0, 0 - strh r0, [r2, 0x30] - ldrh r0, [r2, 0x2E] - ldrh r1, [r2, 0x20] - adds r0, r1 - strh r0, [r2, 0x20] -_08114C2E: - ldrh r0, [r2, 0x22] - subs r0, 0x4 - strh r0, [r2, 0x22] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x4 - negs r1, r1 - cmp r0, r1 - bge _08114C46 - adds r0, r2, 0 - bl DestroyAnimSprite -_08114C46: - pop {r0} - bx r0 - thumb_func_end sub_8114C10 - - thumb_func_start sub_8114C4C -sub_8114C4C: @ 8114C4C - push {lr} - adds r3, r0, 0 - movs r0, 0x2E - ldrsh r1, [r3, r0] - cmp r1, 0 - beq _08114C5E - cmp r1, 0x1 - beq _08114C74 - b _08114CB6 -_08114C5E: - ldrh r0, [r3, 0x26] - adds r0, 0x4 - strh r0, [r3, 0x26] - lsls r0, 16 - cmp r0, 0 - blt _08114CB6 - strh r1, [r3, 0x26] - ldrh r0, [r3, 0x2E] - adds r0, 0x1 - strh r0, [r3, 0x2E] - b _08114CB6 -_08114C74: - ldrh r0, [r3, 0x30] - adds r0, 0x1 - strh r0, [r3, 0x30] - lsls r0, 16 - cmp r0, 0 - ble _08114CB6 - movs r0, 0 - strh r0, [r3, 0x30] - movs r1, 0x3E - adds r1, r3 - mov r12, r1 - ldrb r2, [r1] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - mov r1, r12 - strb r0, [r1] - ldrh r0, [r3, 0x32] - adds r0, 0x1 - strh r0, [r3, 0x32] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - bne _08114CB6 - adds r0, r3, 0 - bl DestroyAnimSprite -_08114CB6: - pop {r0} - bx r0 - thumb_func_end sub_8114C4C - - thumb_func_start sub_8114CBC -sub_8114CBC: @ 8114CBC - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r1, r0, r1 - ldr r0, =gBattleAnimArgs - movs r3, 0 - ldrsh r0, [r0, r3] - cmp r0, 0 - bne _08114CE8 - ldr r0, =sub_8114CFC - b _08114CEA - .pool -_08114CE8: - ldr r0, =sub_8114EB4 -_08114CEA: - str r0, [r1] - ldr r1, [r1] - adds r0, r2, 0 - bl _call_via_r1 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114CBC - - thumb_func_start sub_8114CFC -sub_8114CFC: @ 8114CFC - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x4 - bls _08114D16 - b _08114EAA -_08114D16: - lsls r0, 2 - ldr r1, =_08114D28 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08114D28: - .4byte _08114D3C - .4byte _08114DC4 - .4byte _08114DD4 - .4byte _08114E78 - .4byte _08114E8C -_08114D3C: - movs r0, 0 - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x1C] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl sub_80A8364 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x1E] - cmp r0, 0x1 - bne _08114D70 - ldr r0, =gBattle_BG1_X - ldrh r0, [r0] - strh r0, [r4, 0x20] - ldr r0, =gBattle_BG1_Y - b _08114D78 - .pool -_08114D70: - ldr r0, =gBattle_BG2_X - ldrh r0, [r0] - strh r0, [r4, 0x20] - ldr r0, =gBattle_BG2_Y -_08114D78: - ldrh r0, [r0] - strh r0, [r4, 0x22] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerYCoordWithElevation - lsls r0, 24 - lsrs r0, 24 - adds r1, r0, 0 - subs r1, 0x20 - strh r1, [r4, 0x24] - adds r0, 0x20 - strh r0, [r4, 0x26] - cmp r1, 0 - bge _08114D9A - movs r0, 0 - strh r0, [r4, 0x24] -_08114D9A: - ldr r2, =gSprites - movs r3, 0x1C - ldrsh r1, [r4, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - b _08114E7E - .pool -_08114DC4: - ldrb r0, [r4, 0x1E] - movs r2, 0x24 - ldrsh r1, [r4, r2] - movs r3, 0x26 - ldrsh r2, [r4, r3] - bl sub_81150E0 - b _08114E7E -_08114DD4: - ldrh r0, [r4, 0xC] - adds r0, 0x6 - movs r1, 0x7F - ands r0, r1 - strh r0, [r4, 0xC] - ldrh r0, [r4, 0x10] - adds r0, 0x1 - strh r0, [r4, 0x10] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _08114DF6 - movs r0, 0 - strh r0, [r4, 0x10] - ldrh r0, [r4, 0xE] - adds r0, 0x1 - strh r0, [r4, 0xE] -_08114DF6: - ldr r1, =gSineTable - movs r2, 0xC - ldrsh r0, [r4, r2] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - lsls r0, 16 - asrs r0, 20 - ldrh r3, [r4, 0xE] - adds r2, r0, r3 - strh r2, [r4, 0x12] - movs r1, 0x1E - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _08114E20 - ldr r1, =gBattle_BG1_Y - b _08114E22 - .pool -_08114E20: - ldr r1, =gBattle_BG2_Y -_08114E22: - ldrh r0, [r4, 0x22] - subs r0, r2 - strh r0, [r1] - movs r2, 0x12 - ldrsh r0, [r4, r2] - cmp r0, 0x3F - ble _08114EAA - ldrh r0, [r4, 0x24] - movs r1, 0x78 - subs r2, r1, r0 - strh r2, [r4, 0x12] - movs r3, 0x1E - ldrsh r0, [r4, r3] - cmp r0, 0x1 - bne _08114E4C - ldr r1, =gBattle_BG1_Y - b _08114E4E - .pool -_08114E4C: - ldr r1, =gBattle_BG2_Y -_08114E4E: - ldrh r0, [r4, 0x22] - subs r0, r2 - strh r0, [r1] - ldr r2, =gSprites - movs r1, 0x1C - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrh r2, [r1, 0x20] - movs r3, 0x88 - lsls r3, 1 - adds r0, r3, 0 - subs r0, r2 - strh r0, [r1, 0x24] - b _08114E7E - .pool -_08114E78: - ldr r1, =gScanlineEffect - movs r0, 0x3 - strb r0, [r1, 0x15] -_08114E7E: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08114EAA - .pool -_08114E8C: - adds r0, r2, 0 - bl DestroyAnimVisualTask - ldr r2, =gSprites - movs r0, 0x1C - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_08114EAA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114CFC - - thumb_func_start sub_8114EB4 -sub_8114EB4: @ 8114EB4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0 - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - adds r3, r1, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r3] - movs r4, 0 - strh r4, [r1, 0x24] - strh r4, [r1, 0x26] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl sub_80A8364 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08114F00 - ldr r0, =gBattle_BG1_Y - b _08114F02 - .pool -_08114F00: - ldr r0, =gBattle_BG2_Y -_08114F02: - strh r4, [r0] - adds r0, r5, 0 - bl DestroyAnimVisualTask - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114EB4 - - thumb_func_start sub_8114F14 -sub_8114F14: @ 8114F14 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r1, r0, r1 - ldr r0, =gBattleAnimArgs - movs r3, 0 - ldrsh r0, [r0, r3] - cmp r0, 0 - bne _08114F40 - ldr r0, =sub_8114F54 - b _08114F42 - .pool -_08114F40: - ldr r0, =sub_8114FD8 -_08114F42: - str r0, [r1] - ldr r1, [r1] - adds r0, r2, 0 - bl _call_via_r1 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114F14 - - thumb_func_start sub_8114F54 -sub_8114F54: @ 8114F54 - push {r4,r5,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r0, 0x8 - ldrsh r5, [r4, r0] - cmp r5, 0 - beq _08114F78 - cmp r5, 0x1 - beq _08114FCC - b _08114FD2 - .pool -_08114F78: - movs r0, 0 - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x1C] - ldr r3, =gSprites - movs r0, 0x1C - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - movs r0, 0x1C - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r5, [r0, 0x24] - movs r1, 0x1C - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r3 - ldrh r2, [r1, 0x22] - movs r0, 0xA0 - subs r0, r2 - strh r0, [r1, 0x26] - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08114FD2 - .pool -_08114FCC: - adds r0, r2, 0 - bl DestroyAnimVisualTask -_08114FD2: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8114F54 - - thumb_func_start sub_8114FD8 -sub_8114FD8: @ 8114FD8 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x4 - bhi _081150DA - lsls r0, 2 - ldr r1, =_08115004 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08115004: - .4byte _08115018 - .4byte _0811506C - .4byte _0811507A - .4byte _08115094 - .4byte _081150D4 -_08115018: - movs r0, 0 - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x1C] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl sub_80A8364 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x1E] - cmp r0, 0x1 - bne _08115044 - ldr r0, =gBattle_BG1_X - b _08115046 - .pool -_08115044: - ldr r0, =gBattle_BG2_X -_08115046: - ldrh r0, [r0] - strh r0, [r4, 0x20] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerYCoordWithElevation - lsls r0, 24 - lsrs r0, 24 - adds r1, r0, 0 - subs r1, 0x20 - strh r1, [r4, 0x24] - adds r0, 0x20 - strh r0, [r4, 0x26] - b _081150C2 - .pool -_0811506C: - ldrb r0, [r4, 0x1E] - movs r1, 0x26 - ldrsh r2, [r4, r1] - movs r1, 0 - bl sub_81150E0 - b _081150C2 -_0811507A: - ldr r2, =gSprites - movs r0, 0x1C - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x60 - strh r1, [r0, 0x26] - b _081150C2 - .pool -_08115094: - ldr r2, =gSprites - movs r0, 0x1C - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x26] - subs r1, 0x8 - strh r1, [r0, 0x26] - movs r0, 0x1C - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x26 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _081150DA - ldr r1, =gScanlineEffect - movs r0, 0x3 - strb r0, [r1, 0x15] -_081150C2: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _081150DA - .pool -_081150D4: - adds r0, r2, 0 - bl DestroyAnimVisualTask -_081150DA: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8114FD8 - - thumb_func_start sub_81150E0 -sub_81150E0: @ 81150E0 - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r4, r2, 16 - cmp r0, 0x1 - bne _08115104 - ldr r0, =gBattle_BG1_X - ldrh r3, [r0] - ldr r0, =0x04000014 - b _0811510A - .pool -_08115104: - ldr r0, =gBattle_BG2_X - ldrh r3, [r0] - ldr r0, =0x04000018 -_0811510A: - str r0, [sp] - lsls r0, r1, 16 - cmp r0, 0 - bge _08115114 - movs r1, 0 -_08115114: - lsls r2, r1, 16 - lsls r0, r4, 16 - asrs r4, r0, 16 - cmp r2, r0 - bge _08115140 - ldr r5, =gScanlineEffectRegBuffers - movs r0, 0xF0 - lsls r0, 3 - adds r6, r5, r0 -_08115126: - asrs r2, 16 - lsls r1, r2, 1 - adds r0, r1, r5 - strh r3, [r0] - adds r1, r6 - strh r3, [r1] - adds r2, 0x1 - lsls r2, 16 - lsrs r1, r2, 16 - lsls r2, r1, 16 - asrs r0, r2, 16 - cmp r0, r4 - blt _08115126 -_08115140: - lsls r1, 16 - asrs r0, r1, 16 - cmp r0, 0x9F - bgt _0811516E - ldr r4, =gScanlineEffectRegBuffers - lsls r0, r3, 16 - asrs r0, 16 - adds r3, r0, 0 - adds r3, 0xF0 - movs r0, 0xF0 - lsls r0, 3 - adds r5, r4, r0 -_08115158: - asrs r2, r1, 16 - lsls r1, r2, 1 - adds r0, r1, r4 - strh r3, [r0] - adds r1, r5 - strh r3, [r1] - adds r2, 0x1 - lsls r1, r2, 16 - asrs r0, r1, 16 - cmp r0, 0x9F - ble _08115158 -_0811516E: - ldr r0, =0xa2600001 - str r0, [sp, 0x4] - mov r1, sp - movs r2, 0 - movs r0, 0x1 - strb r0, [r1, 0x8] - mov r0, sp - strb r2, [r0, 0x9] - ldr r0, [sp] - ldr r1, [sp, 0x4] - ldr r2, [sp, 0x8] - bl ScanlineEffect_SetParams - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81150E0 - - thumb_func_start sub_81151A0 -sub_81151A0: @ 81151A0 - push {r4-r7,lr} - adds r5, r0, 0 - ldr r0, =gBattleAnimArgs - movs r2, 0 - ldrsh r1, [r0, r2] - adds r7, r0, 0 - cmp r1, 0 - bne _081151BC - ldr r0, =gBattleAnimAttacker - b _081151BE - .pool -_081151BC: - ldr r0, =gBattleAnimTarget -_081151BE: - ldrb r4, [r0] - movs r6, 0x18 - adds r1, r7, 0 - movs r2, 0x2 - ldrsh r0, [r1, r2] - cmp r0, 0x1 - bne _081151DA - negs r0, r6 - lsls r0, 16 - lsrs r6, r0, 16 - movs r2, 0x4 - ldrsh r0, [r1, r2] - negs r0, r0 - strh r0, [r1, 0x4] -_081151DA: - adds r0, r4, 0 - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - adds r0, r6 - strh r0, [r5, 0x20] - adds r0, r4, 0 - bl GetBattlerYCoordWithElevation - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x1E - strh r0, [r5, 0x22] - ldrh r1, [r7, 0xA] - strh r1, [r5, 0x2E] - ldrh r1, [r7, 0x4] - ldrh r2, [r5, 0x20] - adds r1, r2 - strh r1, [r5, 0x32] - ldrh r1, [r7, 0x6] - adds r0, r1 - strh r0, [r5, 0x36] - ldrh r0, [r7, 0x8] - strh r0, [r5, 0x38] - adds r0, r5, 0 - bl InitAnimArcTranslation - ldr r0, =sub_8115228 - str r0, [r5, 0x1C] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81151A0 - - thumb_func_start sub_8115228 -sub_8115228: @ 8115228 - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _0811523C - adds r0, r4, 0 - bl DestroyAnimSprite -_0811523C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8115228 - - thumb_func_start sub_8115244 -sub_8115244: @ 8115244 - push {r4-r6,lr} - adds r6, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _08115260 - ldr r0, =gBattleAnimAttacker - b _08115262 - .pool -_08115260: - ldr r0, =gBattleAnimTarget -_08115262: - ldrb r5, [r0] - adds r0, r5, 0 - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldr r2, =0x0000fff0 - adds r0, r2 - ldr r4, =gBattleAnimArgs - movs r3, 0x2 - ldrsh r1, [r4, r3] - lsls r1, 5 - adds r0, r1 - strh r0, [r6, 0x20] - adds r0, r5, 0 - bl GetBattlerYCoordWithElevation - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x20 - strh r0, [r6, 0x22] - ldrh r2, [r6, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - movs r3, 0x2 - ldrsh r0, [r4, r3] - lsls r0, 3 - adds r1, r0 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r6, 0x4] - ldr r1, =DestroyAnimSprite - adds r0, r6, 0 - bl StoreSpriteCallbackInData6 - ldrh r0, [r4, 0x4] - strh r0, [r6, 0x2E] - ldr r0, =sub_80A64B0 - str r0, [r6, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115244 - - thumb_func_start sub_81152DC -sub_81152DC: @ 81152DC - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - ldr r0, =gBattleAnimArgs - ldrh r2, [r0, 0x2] - movs r3, 0x2 - ldrsh r1, [r0, r3] - adds r6, r0, 0 - cmp r1, 0 - beq _08115308 - adds r0, r2, 0x3 - b _08115314 - .pool -_08115308: - ldr r0, =gAnimMovePower - ldrh r0, [r0] - movs r1, 0xA - bl __udivsi3 - adds r0, 0x3 -_08115314: - strh r0, [r4, 0x26] - strh r0, [r4, 0x24] - adds r1, r6, 0 - ldrh r0, [r1, 0x4] - strh r0, [r4, 0xE] - movs r2, 0 - ldrsh r0, [r1, r2] - cmp r0, 0x4 - beq _08115340 - cmp r0, 0x5 - bne _08115380 - ldr r0, =gBattle_BG3_X - ldrh r0, [r0] - strh r0, [r4, 0x22] - ldr r0, =sub_81153AC - b _0811539E - .pool -_08115340: - movs r0, 0 - strh r0, [r4, 0x22] - movs r5, 0 -_08115346: - lsls r0, r5, 24 - lsrs r0, 24 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _08115370 - movs r3, 0x22 - ldrsh r0, [r4, r3] - adds r0, 0x9 - lsls r0, 1 - adds r1, r4, 0 - adds r1, 0x8 - adds r1, r0 - ldr r0, =gBattlerSpriteIds - adds r0, r5, r0 - ldrb r0, [r0] - strh r0, [r1] - ldrh r0, [r4, 0x22] - adds r0, 0x1 - strh r0, [r4, 0x22] -_08115370: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x3 - bls _08115346 - b _0811539C - .pool -_08115380: - ldrb r0, [r6] - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x1A] - cmp r0, 0xFF - bne _08115398 - adds r0, r5, 0 - bl DestroyAnimVisualTask - b _081153A0 -_08115398: - movs r0, 0x1 - strh r0, [r4, 0x22] -_0811539C: - ldr r0, =sub_81154A4 -_0811539E: - str r0, [r4] -_081153A0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81152DC - - thumb_func_start sub_81153AC -sub_81153AC: @ 81153AC - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r3, r0, r1 - movs r0, 0x8 - ldrsh r1, [r3, r0] - cmp r1, 0x1 - beq _08115430 - cmp r1, 0x1 - bgt _081153D4 - cmp r1, 0 - beq _081153DA - b _0811549C - .pool -_081153D4: - cmp r1, 0x2 - beq _08115490 - b _0811549C -_081153DA: - ldrh r0, [r3, 0xA] - adds r0, 0x1 - strh r0, [r3, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _0811549C - strh r1, [r3, 0xA] - ldrh r1, [r3, 0xC] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08115404 - ldr r1, =gBattle_BG3_X - ldrh r0, [r3, 0x26] - ldrh r2, [r3, 0x22] - adds r0, r2 - strh r0, [r1] - b _0811540E - .pool -_08115404: - ldr r0, =gBattle_BG3_X - ldrh r1, [r3, 0x22] - ldrh r2, [r3, 0x26] - subs r1, r2 - strh r1, [r0] -_0811540E: - ldrh r0, [r3, 0xC] - adds r0, 0x1 - strh r0, [r3, 0xC] - lsls r0, 16 - asrs r0, 16 - movs r2, 0xE - ldrsh r1, [r3, r2] - cmp r0, r1 - bne _0811549C - movs r0, 0 - strh r0, [r3, 0xC] - ldrh r0, [r3, 0x24] - subs r0, 0x1 - strh r0, [r3, 0x24] - b _08115484 - .pool -_08115430: - ldrh r0, [r3, 0xA] - adds r0, 0x1 - strh r0, [r3, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _0811549C - movs r0, 0 - strh r0, [r3, 0xA] - ldrh r0, [r3, 0xC] - ands r1, r0 - cmp r1, 0 - bne _0811545C - ldr r1, =gBattle_BG3_X - ldrh r0, [r3, 0x24] - ldrh r2, [r3, 0x22] - adds r0, r2 - strh r0, [r1] - b _08115466 - .pool -_0811545C: - ldr r0, =gBattle_BG3_X - ldrh r1, [r3, 0x22] - ldrh r2, [r3, 0x24] - subs r1, r2 - strh r1, [r0] -_08115466: - ldrh r0, [r3, 0xC] - adds r0, 0x1 - strh r0, [r3, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - bne _0811549C - movs r0, 0 - strh r0, [r3, 0xC] - ldrh r0, [r3, 0x24] - subs r0, 0x1 - strh r0, [r3, 0x24] - lsls r0, 16 - cmp r0, 0 - bne _0811549C -_08115484: - ldrh r0, [r3, 0x8] - adds r0, 0x1 - strh r0, [r3, 0x8] - b _0811549C - .pool -_08115490: - ldr r1, =gBattle_BG3_X - ldrh r0, [r3, 0x22] - strh r0, [r1] - adds r0, r2, 0 - bl DestroyAnimVisualTask -_0811549C: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81153AC - - thumb_func_start sub_81154A4 -sub_81154A4: @ 81154A4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r0, 0x8 - ldrsh r5, [r4, r0] - cmp r5, 0x1 - beq _08115504 - cmp r5, 0x1 - bgt _081154CC - cmp r5, 0 - beq _081154D2 - b _0811557E - .pool -_081154CC: - cmp r5, 0x2 - beq _08115540 - b _0811557E -_081154D2: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _0811557E - strh r5, [r4, 0xA] - adds r0, r4, 0 - bl sub_8115588 - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - lsls r0, 16 - asrs r0, 16 - movs r2, 0xE - ldrsh r1, [r4, r2] - cmp r0, r1 - bne _0811557E - strh r5, [r4, 0xC] - ldrh r0, [r4, 0x24] - subs r0, 0x1 - strh r0, [r4, 0x24] - b _08115538 -_08115504: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - movs r5, 0 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _0811557E - strh r5, [r4, 0xA] - adds r0, r4, 0 - bl sub_8115588 - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - bne _0811557E - strh r5, [r4, 0xC] - ldrh r0, [r4, 0x24] - subs r0, 0x1 - strh r0, [r4, 0x24] - lsls r0, 16 - cmp r0, 0 - bne _0811557E -_08115538: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _0811557E -_08115540: - movs r2, 0 - movs r7, 0x22 - ldrsh r0, [r4, r7] - cmp r2, r0 - bge _08115578 - ldr r0, =gSprites - mov r12, r0 - adds r5, r4, 0 - adds r5, 0x8 - movs r6, 0 -_08115554: - adds r0, r2, 0 - adds r0, 0x9 - lsls r0, 1 - adds r0, r5, r0 - movs r7, 0 - ldrsh r1, [r0, r7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r12 - strh r6, [r0, 0x24] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - movs r1, 0x22 - ldrsh r0, [r4, r1] - cmp r2, r0 - blt _08115554 -_08115578: - adds r0, r3, 0 - bl DestroyAnimVisualTask -_0811557E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81154A4 - - thumb_func_start sub_8115588 -sub_8115588: @ 8115588 - push {r4-r7,lr} - adds r3, r0, 0 - ldrh r1, [r3, 0xC] - movs r4, 0x1 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - bne _081155B0 - movs r0, 0x24 - ldrsh r1, [r3, r0] - lsrs r0, r1, 31 - adds r1, r0 - asrs r1, 1 - ldrh r2, [r3, 0x24] - adds r0, r4, 0 - ands r0, r2 - adds r1, r0 - lsls r1, 16 - lsrs r4, r1, 16 - b _081155C0 -_081155B0: - movs r1, 0x24 - ldrsh r0, [r3, r1] - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - negs r0, r0 - lsls r0, 16 - lsrs r4, r0, 16 -_081155C0: - movs r2, 0 - movs r7, 0x22 - ldrsh r0, [r3, r7] - cmp r2, r0 - bge _081155F4 - ldr r6, =gSprites - adds r5, r3, 0 - adds r5, 0x8 -_081155D0: - adds r0, r2, 0 - adds r0, 0x9 - lsls r0, 1 - adds r0, r5, r0 - movs r7, 0 - ldrsh r1, [r0, r7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r4, [r0, 0x24] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - movs r1, 0x22 - ldrsh r0, [r3, r1] - cmp r2, r0 - blt _081155D0 -_081155F4: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115588 - - thumb_func_start AnimTask_IsPowerOver99 -AnimTask_IsPowerOver99: @ 8115600 - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - ldr r3, =gBattleAnimArgs - movs r2, 0 - ldr r0, =gAnimMovePower - ldrh r0, [r0] - cmp r0, 0x63 - bls _08115614 - movs r2, 0x1 -_08115614: - strh r2, [r3, 0x1E] - adds r0, r1, 0 - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_IsPowerOver99 - - thumb_func_start sub_8115628 -sub_8115628: @ 8115628 - push {r4-r7,lr} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r2, =gBattleAnimArgs - ldrh r1, [r2] - movs r0, 0x1 - ands r0, r1 - adds r6, r2, 0 - cmp r0, 0 - beq _08115648 - ldr r0, =gBattleAnimTarget - b _0811564A - .pool -_08115648: - ldr r0, =gBattleAnimAttacker -_0811564A: - ldrb r0, [r0] - adds r5, r0, 0 - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0x1 - ble _0811565A - movs r0, 0x2 - eors r5, r0 -_0811565A: - ldr r0, =sub_81156D0 - ldrb r1, [r6, 0x2] - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks - adds r4, r0 - adds r0, r5, 0 - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x20 - subs r1, r0 - ldr r2, =0x000001ff - adds r0, r2, 0 - ands r1, r0 - strh r1, [r4, 0xA] - adds r0, r5, 0 - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x40 - subs r1, r0 - movs r0, 0xFF - ands r1, r0 - strh r1, [r4, 0xC] - ldr r2, =gBattle_BG3_X - ldrh r0, [r4, 0xA] - strh r0, [r2] - ldr r0, =gBattle_BG3_Y - strh r1, [r0] - ldrh r0, [r6, 0x4] - strh r0, [r4, 0xE] - adds r0, r7, 0 - bl DestroyAnimVisualTask - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115628 - - thumb_func_start sub_81156D0 -sub_81156D0: @ 81156D0 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - ldr r1, =gTasks - adds r2, r0, r1 - ldr r0, =gBattleAnimArgs - movs r4, 0xE - ldrsh r1, [r0, r4] - movs r4, 0xE - ldrsh r0, [r2, r4] - cmp r1, r0 - bne _08115710 - ldr r0, =gBattle_BG3_X - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_BG3_Y - strh r1, [r0] - adds r0, r3, 0 - bl DestroyTask - b _0811571C - .pool -_08115710: - ldr r1, =gBattle_BG3_X - ldrh r0, [r2, 0xA] - strh r0, [r1] - ldr r1, =gBattle_BG3_Y - ldrh r0, [r2, 0xC] - strh r0, [r1] -_0811571C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81156D0 - - .align 2, 0 diff --git a/asm/normal.s b/asm/normal.s index 2c1df2298..3ee1308c9 100644 --- a/asm/normal.s +++ b/asm/normal.s @@ -1803,7 +1803,7 @@ _08116584: ldr r1, =DestroyAnimSprite adds r0, r4, 0 bl StoreSpriteCallbackInData6 - ldr r0, =sub_80A64B0 + ldr r0, =WaitAnimForDuration str r0, [r4, 0x1C] pop {r4} pop {r0} diff --git a/asm/water.s b/asm/water.s index 408bb8c01..6965d6371 100644 --- a/asm/water.s +++ b/asm/water.s @@ -329,7 +329,7 @@ sub_8107430: @ 8107430 push {lr} movs r1, 0xA strh r1, [r0, 0x2E] - ldr r1, =sub_80A64B0 + ldr r1, =WaitAnimForDuration str r1, [r0, 0x1C] ldr r1, =move_anim_8074EE0 bl StoreSpriteCallbackInData6 diff --git a/include/battle_anim.h b/include/battle_anim.h index f4e5d0077..293800623 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -95,6 +95,7 @@ void sub_80A67D8(struct Sprite *sprite); void sub_80A6864(struct Sprite *sprite, s16 a2); s16 sub_80A861C(u8 battlerId, u8 a2); u8 GetBattlerYCoordWithElevation(u8 battlerId); +void WaitAnimForDuration(struct Sprite *sprite); void sub_80A8278(void); void sub_80A6B30(struct UnknownAnimStruct2*); void sub_80A6B90(struct UnknownAnimStruct2*, u32 arg1); diff --git a/ld_script.txt b/ld_script.txt index 797d52a93..d9c4546ff 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -171,7 +171,7 @@ SECTIONS { asm/ghost.o(.text); src/dragon.o(.text); asm/dark.o(.text); - asm/ground.o(.text); + src/ground.o(.text); asm/normal.o(.text); src/battle_anim_utility_funcs.o(.text); asm/battle_intro.o(.text); diff --git a/src/battle_anim_80A5C6C.c b/src/battle_anim_80A5C6C.c index 2621ddcd5..4824b2b3f 100644 --- a/src/battle_anim_80A5C6C.c +++ b/src/battle_anim_80A5C6C.c @@ -532,7 +532,7 @@ void sub_80A6450(struct Sprite *sprite) // Simply waits until the sprite's data[0] hits zero. // This is used to let sprite anims or affine anims to run for a designated // duration. -void sub_80A64B0(struct Sprite *sprite) +void WaitAnimForDuration(struct Sprite *sprite) { if (sprite->data[0] > 0) sprite->data[0]--; diff --git a/src/ground.c b/src/ground.c index 33eb3660a..6cb7b8557 100644 --- a/src/ground.c +++ b/src/ground.c @@ -1,14 +1,31 @@ #include "global.h" #include "battle_anim.h" +#include "random.h" +#include "scanline_effect.h" +#include "task.h" +#include "trig.h" #include "constants/rgb.h" -extern void sub_8114994(struct Sprite *); -extern void sub_8114A7C(struct Sprite *); -extern void sub_8114AF0(struct Sprite *); -extern void sub_8114AF0(struct Sprite *); -extern void sub_8114B80(struct Sprite *); -extern void sub_81151A0(struct Sprite *); -extern void sub_8115244(struct Sprite *); +void AnimBonemerangProjectile(struct Sprite *); +void AnimBoneHitProjectile(struct Sprite *); +void AnimDirtScatter(struct Sprite *); +void AnimMudSportDirt(struct Sprite *); +void AnimFissureDirtPlumeParticle(struct Sprite *); +void AnimDigDirtMound(struct Sprite *); +static void AnimBonemerangProjectileStep(struct Sprite *); +static void AnimBonemerangProjectileEnd(struct Sprite *); +static void AnimMudSportDirtRising(struct Sprite *); +static void AnimMudSportDirtFalling(struct Sprite *); +static void sub_8114CFC(u8); +static void sub_8114EB4(u8); +static void sub_8114F54(u8); +static void sub_8114FD8(u8); +static void sub_81150E0(u8, s16, s16); +static void AnimFissureDirtPlumeParticleStep(struct Sprite *); +static void sub_81153AC(u8); +static void sub_81154A4(u8); +static void sub_8115588(struct Task *); +static void sub_81156D0(u8); const union AffineAnimCmd gUnknown_08597150[] = { @@ -40,7 +57,7 @@ const struct SpriteTemplate gUnknown_08597178 = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gUnknown_08597170, - .callback = sub_8114994, + .callback = AnimBonemerangProjectile, }; const struct SpriteTemplate gUnknown_08597190 = @@ -51,7 +68,7 @@ const struct SpriteTemplate gUnknown_08597190 = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gUnknown_08597174, - .callback = sub_8114A7C, + .callback = AnimBoneHitProjectile, }; const struct SpriteTemplate gUnknown_085971A8 = @@ -62,7 +79,7 @@ const struct SpriteTemplate gUnknown_085971A8 = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8114AF0, + .callback = AnimDirtScatter, }; const union AnimCmd gUnknown_085971C0[] = @@ -84,7 +101,7 @@ const struct SpriteTemplate gUnknown_085971CC = .anims = gUnknown_085971C8, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8114AF0, + .callback = AnimDirtScatter, }; const struct SpriteTemplate gUnknown_085971E4 = @@ -95,7 +112,7 @@ const struct SpriteTemplate gUnknown_085971E4 = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8114B80, + .callback = AnimMudSportDirt, }; const struct SpriteTemplate gUnknown_085971FC = @@ -106,7 +123,7 @@ const struct SpriteTemplate gUnknown_085971FC = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_81151A0, + .callback = AnimFissureDirtPlumeParticle, }; const struct SpriteTemplate gUnknown_08597214 = @@ -117,5 +134,615 @@ const struct SpriteTemplate gUnknown_08597214 = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8115244, + .callback = AnimDigDirtMound, }; + +// Moves a bone projectile towards the target mon, which moves like +// a boomerang. After hitting the target mon, it comes back to the user. +void AnimBonemerangProjectile(struct Sprite *sprite) +{ + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + sprite->data[0] = 20; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + sprite->data[5] = -40; + InitAnimArcTranslation(sprite); + sprite->callback = AnimBonemerangProjectileStep; +} + +static void AnimBonemerangProjectileStep(struct Sprite *sprite) +{ + if (TranslateAnimArc(sprite)) + { + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + sprite->data[0] = 20; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + sprite->data[5] = 40; + InitAnimArcTranslation(sprite); + sprite->callback = AnimBonemerangProjectileEnd; + } +} + +static void AnimBonemerangProjectileEnd(struct Sprite *sprite) +{ + if (TranslateAnimArc(sprite)) + DestroyAnimSprite(sprite); +} + +// Moves a bone projectile towards the target mon, starting right next to +// the target mon. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: target x pixel offset +// arg 3: target y pixel offset +// arg 4: duration +void AnimBoneHitProjectile(struct Sprite *sprite) +{ + sub_80A6980(sprite, TRUE); + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +// Moves a small dirt projectile towards the target mon. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: duration +// arg 3: target x pixel offset +// arg 4: target y pixel offset +void AnimDirtScatter(struct Sprite *sprite) +{ + u8 targetXPos, targetYPos; + s16 xOffset, yOffset; + + InitAnimSpritePos(sprite, 1); + + targetXPos = GetBattlerSpriteCoord2(gBattleAnimTarget, 2); + targetYPos = GetBattlerSpriteCoord2(gBattleAnimTarget, 3); + + xOffset = Random2() & 0x1F; + yOffset = Random2() & 0x1F; + if (xOffset > 16) + xOffset = 16 - xOffset; + if (yOffset > 16) + yOffset = 16 - yOffset; + + sprite->data[0] = gBattleAnimArgs[2]; + sprite->data[2] = targetXPos + xOffset; + sprite->data[4] = targetYPos + yOffset; + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, move_anim_8074EE0); +} + +// Moves a particle of dirt in the Mud Sport animation. +// The dirt can either be rising upward, or falling down. +// arg 0: 0 = dirt is rising into the air, 1 = dirt is falling down +// arg 1: initial x pixel offset +// arg 2: initial y pixel offset +void AnimMudSportDirt(struct Sprite *sprite) +{ + sprite->oam.tileNum++; + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2) + gBattleAnimArgs[1]; + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3) + gBattleAnimArgs[2]; + sprite->data[0] = gBattleAnimArgs[1] > 0 ? 1 : -1; + sprite->callback = AnimMudSportDirtRising; + } + else + { + sprite->pos1.x = gBattleAnimArgs[1]; + sprite->pos1.y = gBattleAnimArgs[2]; + sprite->pos2.y = -gBattleAnimArgs[2]; + sprite->callback = AnimMudSportDirtFalling; + } +} + +static void AnimMudSportDirtRising(struct Sprite *sprite) +{ + if (++sprite->data[1] > 1) + { + sprite->data[1] = 0; + sprite->pos1.x += sprite->data[0]; + } + + sprite->pos1.y -= 4; + if (sprite->pos1.y < -4) + DestroyAnimSprite(sprite); +} + +static void AnimMudSportDirtFalling(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->pos2.y += 4; + if (sprite->pos2.y >= 0) + { + sprite->pos2.y = 0; + sprite->data[0]++; + } + break; + case 1: + if (++sprite->data[1] > 0) + { + sprite->data[1] = 0; + sprite->invisible ^= 1; + if (++sprite->data[2] == 10) + DestroyAnimSprite(sprite); + } + break; + } +} + +void sub_8114CBC(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + if (gBattleAnimArgs[0] == 0) + task->func = sub_8114CFC; + else + task->func = sub_8114EB4; + + task->func(taskId); +} + +static void sub_8114CFC(u8 taskId) +{ + u8 var0; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[10] = GetAnimBattlerSpriteId(0); + task->data[11] = sub_80A8364(gBattleAnimAttacker); + if (task->data[11] == 1) + { + task->data[12] = gBattle_BG1_X; + task->data[13] = gBattle_BG1_Y; + } + else + { + task->data[12] = gBattle_BG2_X; + task->data[13] = gBattle_BG2_Y; + } + + var0 = GetBattlerYCoordWithElevation(gBattleAnimAttacker); + task->data[14] = var0 - 32; + task->data[15] = var0 + 32; + if (task->data[14] < 0) + task->data[14] = 0; + + gSprites[task->data[10]].invisible = 1; + task->data[0]++; + break; + case 1: + sub_81150E0(task->data[11], task->data[14], task->data[15]); + task->data[0]++; + break; + case 2: + task->data[2] = (task->data[2] + 6) & 0x7F; + if (++task->data[4] > 2) + { + task->data[4] = 0; + task->data[3]++; + } + + task->data[5] = task->data[3] + (gSineTable[task->data[2]] >> 4); + if (task->data[11] == 1) + gBattle_BG1_Y = task->data[13] - task->data[5]; + else + gBattle_BG2_Y = task->data[13] - task->data[5]; + + if (task->data[5] > 63) + { + task->data[5] = 120 - task->data[14]; + if (task->data[11] == 1) + gBattle_BG1_Y = task->data[13] - task->data[5]; + else + gBattle_BG2_Y = task->data[13] - task->data[5]; + + gSprites[task->data[10]].pos2.x = 272 - gSprites[task->data[10]].pos1.x; + task->data[0]++; + } + break; + case 3: + gScanlineEffect.state = 3; + task->data[0]++; + break; + case 4: + DestroyAnimVisualTask(taskId); + gSprites[task->data[10]].invisible = 1; + break; + } +} + +static void sub_8114EB4(u8 taskId) +{ + u8 spriteId = GetAnimBattlerSpriteId(0); + gSprites[spriteId].invisible = 1; + gSprites[spriteId].pos2.x = 0; + gSprites[spriteId].pos2.y = 0; + + if (sub_80A8364(gBattleAnimAttacker) == 1) + gBattle_BG1_Y = 0; + else + gBattle_BG2_Y = 0; + + DestroyAnimVisualTask(taskId); +} + +void sub_8114F14(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + if (gBattleAnimArgs[0] == 0) + task->func = sub_8114F54; + else + task->func = sub_8114FD8; + + task->func(taskId); +} + +static void sub_8114F54(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[10] = GetAnimBattlerSpriteId(0); + gSprites[task->data[10]].invisible = 0; + gSprites[task->data[10]].pos2.x = 0; + gSprites[task->data[10]].pos2.y = 160 - gSprites[task->data[10]].pos1.y; + task->data[0]++; + break; + case 1: + DestroyAnimVisualTask(taskId); + } +} + +static void sub_8114FD8(u8 taskId) +{ + u8 var0; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[10] = GetAnimBattlerSpriteId(0); + task->data[11] = sub_80A8364(gBattleAnimAttacker); + if (task->data[11] == 1) + task->data[12] = gBattle_BG1_X; + else + task->data[12] = gBattle_BG2_X; + + var0 = GetBattlerYCoordWithElevation(gBattleAnimAttacker); + task->data[14] = var0 - 32; + task->data[15] = var0 + 32; + task->data[0]++; + break; + case 1: + sub_81150E0(task->data[11], 0, task->data[15]); + task->data[0]++; + break; + case 2: + gSprites[task->data[10]].pos2.y = 96; + task->data[0]++; + break; + case 3: + gSprites[task->data[10]].pos2.y -= 8; + if (gSprites[task->data[10]].pos2.y == 0) + { + gScanlineEffect.state = 3; + task->data[0]++; + } + break; + case 4: + DestroyAnimVisualTask(taskId); + break; + } +} + +static void sub_81150E0(u8 useBG1, s16 y, s16 endY) +{ + s16 bgX; + struct ScanlineEffectParams scanlineParams; + + if (useBG1 == 1) + { + bgX = gBattle_BG1_X; + scanlineParams.dmaDest = ®_BG1HOFS; + } + else + { + bgX = gBattle_BG2_X; + scanlineParams.dmaDest = ®_BG2HOFS; + } + + if (y < 0) + y = 0; + + while (y < endY) + { + gScanlineEffectRegBuffers[0][y] = bgX; + gScanlineEffectRegBuffers[1][y] = bgX; + y++; + } + + while (y < 160) + { + gScanlineEffectRegBuffers[0][y] = bgX + 240; + gScanlineEffectRegBuffers[1][y] = bgX + 240; + y++; + } + + scanlineParams.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + scanlineParams.initState = 1; + scanlineParams.unused9 = 0; + ScanlineEffect_SetParams(scanlineParams); +} + +// Moves a particle of dirt in a plume of dirt. Used in Fissure and Dig. +// arg 0: which mon (0 = attacker, 1 = target) +// arg 1: which side of mon (0 = left, 1 = right) +// arg 2: target x offset +// arg 3: target y offset +// arg 4: wave amplitude +// arg 5: duration +void AnimFissureDirtPlumeParticle(struct Sprite *sprite) +{ + s8 battler; + s16 xOffset; + + if (gBattleAnimArgs[0] == 0) + battler = gBattleAnimAttacker; + else + battler = gBattleAnimTarget; + + xOffset = 24; + if (gBattleAnimArgs[1] == 1) + { + xOffset *= -1; + gBattleAnimArgs[2] *= -1; + } + + sprite->pos1.x = GetBattlerSpriteCoord(battler, 2) + xOffset; + sprite->pos1.y = GetBattlerYCoordWithElevation(battler) + 30; + sprite->data[0] = gBattleAnimArgs[5]; + sprite->data[2] = sprite->pos1.x + gBattleAnimArgs[2]; + sprite->data[4] = sprite->pos1.y + gBattleAnimArgs[3]; + sprite->data[5] = gBattleAnimArgs[4]; + InitAnimArcTranslation(sprite); + sprite->callback = AnimFissureDirtPlumeParticleStep; +} + +static void AnimFissureDirtPlumeParticleStep(struct Sprite *sprite) +{ + if (TranslateAnimArc(sprite)) + DestroyAnimSprite(sprite); +} + +// Displays the dirt mound seen in the move Dig for set duration. +// The dirt mound image is too large for a single sprite, so two +// sprites are lined up next to each other. +// arg 0: which mon (0 = attacker, 1 = target) +// arg 1: oam tile num (0 = left half of image, 1 = right half of image) +// arg 2: duration +void AnimDigDirtMound(struct Sprite *sprite) +{ + s8 battler; + + if (gBattleAnimArgs[0] == 0) + battler = gBattleAnimAttacker; + else + battler = gBattleAnimTarget; + + sprite->pos1.x = GetBattlerSpriteCoord(battler, 0) - 16 + (gBattleAnimArgs[1] * 32); + sprite->pos1.y = GetBattlerYCoordWithElevation(battler) + 32; + sprite->oam.tileNum += gBattleAnimArgs[1] * 8; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); + sprite->data[0] = gBattleAnimArgs[2]; + sprite->callback = WaitAnimForDuration; +} + +void sub_81152DC(u8 taskId) +{ + u16 i; + struct Task *task = &gTasks[taskId]; + + if (gBattleAnimArgs[1]) + task->data[14] = task->data[15] = gBattleAnimArgs[1] + 3; + else + task->data[14] = task->data[15] = (gAnimMovePower / 10) + 3; + + task->data[3] = gBattleAnimArgs[2]; + switch (gBattleAnimArgs[0]) + { + case 5: + task->data[13] = gBattle_BG3_X; + task->func = sub_81153AC; + break; + case 4: + task->data[13] = 0; + for (i = 0; i < MAX_BATTLERS_COUNT; i++) + { + if (IsBattlerSpriteVisible(i)) + { + task->data[task->data[13] + 9] = gBattlerSpriteIds[i]; + task->data[13]++; + } + } + task->func = sub_81154A4; + break; + default: + task->data[9] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]); + if (task->data[9] == 0xFF) + { + DestroyAnimVisualTask(taskId); + } + else + { + task->data[13] = 1; + task->func = sub_81154A4; + } + + break; + } +} + +static void sub_81153AC(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + if (++task->data[1] > 1) + { + task->data[1] = 0; + if ((task->data[2] & 1) == 0) + gBattle_BG3_X = task->data[13] + task->data[15]; + else + gBattle_BG3_X = task->data[13] - task->data[15]; + + if (++task->data[2] == task->data[3]) + { + task->data[2] = 0; + task->data[14]--; + task->data[0]++; + } + } + break; + case 1: + if (++task->data[1] > 1) + { + task->data[1] = 0; + if ((task->data[2] & 1) == 0) + gBattle_BG3_X = task->data[13] + task->data[14]; + else + gBattle_BG3_X = task->data[13] - task->data[14]; + + if (++task->data[2] == 4) + { + task->data[2] = 0; + if (--task->data[14] == 0) + task->data[0]++; + } + } + break; + case 2: + gBattle_BG3_X = task->data[13]; + DestroyAnimVisualTask(taskId); + break; + } +} + +static void sub_81154A4(u8 taskId) +{ + u16 i; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + if (++task->data[1] > 1) + { + task->data[1] = 0; + sub_8115588(task); + if (++task->data[2] == task->data[3]) + { + task->data[2] = 0; + task->data[14]--; + task->data[0]++; + } + } + break; + case 1: + if (++task->data[1] > 1) + { + task->data[1] = 0; + sub_8115588(task); + if (++task->data[2] == 4) + { + task->data[2] = 0; + if (--task->data[14] == 0) + task->data[0]++; + } + } + break; + case 2: + for (i = 0; i < task->data[13]; i++) + gSprites[task->data[9 + i]].pos2.x = 0; + + DestroyAnimVisualTask(taskId); + break; + } +} + +static void sub_8115588(struct Task *task) +{ + u16 i; + u16 xOffset; + + if ((task->data[2] & 1) == 0) + xOffset = (task->data[14] / 2) + (task->data[14] & 1); + else + xOffset = -(task->data[14] / 2); + + for (i = 0; i < task->data[13]; i++) + { + gSprites[task->data[9 + i]].pos2.x = xOffset; + } +} + +void AnimTask_IsPowerOver99(u8 taskId) +{ + gBattleAnimArgs[15] = gAnimMovePower > 99; + DestroyAnimVisualTask(taskId); +} + +void sub_8115628(u8 taskId) +{ + struct Task *newTask; + u8 battler = (gBattleAnimArgs[0] & 1) ? gBattleAnimTarget : gBattleAnimAttacker; + + if (gBattleAnimArgs[0] > 1) + battler ^= 2; + + newTask = &gTasks[CreateTask(sub_81156D0, gBattleAnimArgs[1])]; + newTask->data[1] = (32 - GetBattlerSpriteCoord(battler, 2)) & 0x1FF; + newTask->data[2] = (64 - GetBattlerSpriteCoord(battler, 3)) & 0xFF; + gBattle_BG3_X = newTask->data[1]; + gBattle_BG3_Y = newTask->data[2]; + newTask->data[3] = gBattleAnimArgs[2]; + DestroyAnimVisualTask(taskId); +} + +static void sub_81156D0(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + if (gBattleAnimArgs[7] == task->data[3]) + { + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; + DestroyTask(taskId); + } + else + { + gBattle_BG3_X = task->data[1]; + gBattle_BG3_Y = task->data[2]; + } +}