From 2c6849bee81f2c05cbf0df1f88c6d5460e7b1e2d Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Thu, 13 Dec 2018 21:33:54 -0600 Subject: [PATCH] Decompile battle_anim_8170478.c (#445) --- asm/battle_anim_8170478.s | 5832 --------------------------- common_syms/battle_anim_8170478.txt | 3 + data/battle_anim_8170478.s | 157 - include/battle.h | 3 +- include/battle_anim.h | 8 +- include/global.h | 6 + include/graphics.h | 6 + ld_script.txt | 4 +- src/battle_anim.c | 2 - src/battle_anim_8170478.c | 2267 +++++++++++ src/battle_intro.c | 7 +- src/pokeball.c | 12 +- src/pokemon.c | 12 - sym_common.txt | 11 +- 14 files changed, 2299 insertions(+), 6031 deletions(-) delete mode 100644 asm/battle_anim_8170478.s create mode 100755 common_syms/battle_anim_8170478.txt delete mode 100644 data/battle_anim_8170478.s create mode 100755 src/battle_anim_8170478.c diff --git a/asm/battle_anim_8170478.s b/asm/battle_anim_8170478.s deleted file mode 100644 index c0881e682..000000000 --- a/asm/battle_anim_8170478.s +++ /dev/null @@ -1,5832 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8170478 -sub_8170478: @ 8170478 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x10] - ldr r0, =gBattleAnimAttacker - ldrb r4, [r0] - ldr r0, =gBattle_WIN0H - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_WIN0V - strh r1, [r0] - ldr r1, =0x00003f3f - movs r0, 0x48 - bl SetGpuReg - ldr r1, =0x00003f3d - movs r0, 0x4A - bl SetGpuReg - movs r1, 0x80 - lsls r1, 8 - movs r0, 0 - bl SetGpuRegBits - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0 - bl SetAnimBgAttribute - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl SetAnimBgAttribute - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0x1 - bl SetAnimBgAttribute - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0x1 - bl SetAnimBgAttribute - ldr r0, =gHealthboxSpriteIds - adds r4, r0 - ldrb r0, [r4] - ldr r1, =gSprites - mov r9, r1 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - add r4, r9 - ldrb r7, [r4, 0x6] - ldrh r6, [r4, 0x38] - lsls r6, 24 - lsrs r6, 24 - ldr r0, =SpriteCallbackDummy - bl CreateInvisibleSpriteWithCallback - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x14] - ldr r0, =SpriteCallbackDummy - bl CreateInvisibleSpriteWithCallback - mov r10, r0 - mov r2, r10 - lsls r2, 24 - lsrs r2, 24 - mov r10, r2 - ldrb r1, [r4, 0x5] - movs r3, 0xD - negs r3, r3 - adds r0, r3, 0 - ands r0, r1 - movs r1, 0x4 - mov r8, r1 - mov r2, r8 - orrs r0, r2 - strb r0, [r4, 0x5] - lsls r5, r7, 4 - adds r5, r7 - lsls r5, 2 - add r5, r9 - ldrb r1, [r5, 0x5] - adds r0, r3, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x5] - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - add r1, r9 - ldrb r2, [r1, 0x5] - adds r0, r3, 0 - ands r0, r2 - mov r2, r8 - orrs r0, r2 - strb r0, [r1, 0x5] - ldr r0, [sp, 0x14] - lsls r6, r0, 4 - adds r6, r0 - lsls r6, 2 - mov r1, r9 - adds r7, r6, r1 - adds r0, r7, 0 - adds r1, r4, 0 - movs r2, 0x44 - str r3, [sp, 0x18] - bl memcpy - mov r2, r10 - lsls r4, r2, 4 - add r4, r10 - lsls r4, 2 - adds r0, r4, 0 - add r0, r9 - mov r8, r0 - adds r1, r5, 0 - movs r2, 0x44 - bl memcpy - ldrb r1, [r7, 0x1] - ldr r3, [sp, 0x18] - adds r0, r3, 0 - ands r0, r1 - movs r1, 0x8 - orrs r0, r1 - strb r0, [r7, 0x1] - mov r2, r8 - ldrb r0, [r2, 0x1] - ands r3, r0 - orrs r3, r1 - strb r3, [r2, 0x1] - movs r0, 0x1C - add r9, r0 - add r6, r9 - ldr r1, =SpriteCallbackDummy - str r1, [r6] - add r4, r9 - str r1, [r4] - mov r0, sp - bl sub_80A6B30 - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gUnknown_08C2EA9C - bl sub_80A6D48 - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gUnknown_08C2EA50 - mov r2, sp - ldrh r2, [r2, 0xA] - bl sub_80A6CC0 - ldr r0, =gUnknown_08C2DDA4 - mov r1, sp - ldrb r1, [r1, 0x8] - lsls r1, 4 - movs r2, 0x20 - bl LoadCompressedPalette - ldr r1, =gBattle_BG1_X - ldrh r0, [r7, 0x20] - negs r0, r0 - adds r0, 0x20 - strh r0, [r1] - ldr r1, =gBattle_BG1_Y - ldrh r0, [r7, 0x22] - negs r0, r0 - subs r0, 0x20 - strh r0, [r1] - ldr r1, =gTasks - ldr r2, [sp, 0x10] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - movs r1, 0xA0 - lsls r1, 2 - strh r1, [r0, 0xA] - mov r1, sp - ldrh r1, [r1, 0x14] - strh r1, [r0, 0x8] - mov r2, r10 - strh r2, [r0, 0xC] - ldr r1, =sub_8170660 - str r1, [r0] - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170478 - - thumb_func_start sub_8170660 -sub_8170660: @ 8170660 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - mov r8, r0 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r5, r0, r1 - ldrh r1, [r5, 0xA] - ldrh r0, [r5, 0x22] - adds r1, r0 - movs r3, 0 - strh r1, [r5, 0x22] - ldr r2, =gBattle_BG1_Y - lsls r0, r1, 16 - lsrs r0, 24 - ldrh r4, [r2] - adds r0, r4 - strh r0, [r2] - movs r0, 0xFF - ands r1, r0 - strh r1, [r5, 0x22] - movs r1, 0x26 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _081706F0 - cmp r0, 0x1 - bgt _081706B4 - cmp r0, 0 - beq _081706BA - b _08170814 - .pool -_081706B4: - cmp r0, 0x2 - beq _08170708 - b _08170814 -_081706BA: - ldrh r0, [r5, 0x1E] - adds r1, r0, 0x1 - strh r1, [r5, 0x1E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - bgt _081706CA - b _08170814 -_081706CA: - strh r3, [r5, 0x1E] - ldrh r1, [r5, 0x20] - adds r1, 0x1 - strh r1, [r5, 0x20] - movs r0, 0x10 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r2, 0x20 - ldrsh r0, [r5, r2] - cmp r0, 0x8 - beq _081706EE - b _08170814 -_081706EE: - b _08170700 -_081706F0: - ldrh r0, [r5, 0x1C] - adds r0, 0x1 - strh r0, [r5, 0x1C] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1E - beq _08170700 - b _08170814 -_08170700: - ldrh r0, [r5, 0x26] - adds r0, 0x1 - strh r0, [r5, 0x26] - b _08170814 -_08170708: - ldrh r0, [r5, 0x1E] - adds r1, r0, 0x1 - strh r1, [r5, 0x1E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _08170814 - strh r3, [r5, 0x1E] - ldrh r1, [r5, 0x20] - subs r1, 0x1 - strh r1, [r5, 0x20] - movs r0, 0x10 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x20 - ldrsh r4, [r5, r0] - cmp r4, 0 - bne _08170814 - movs r0, 0 - bl sub_80A477C - ldr r0, =gBattle_WIN0H - strh r4, [r0] - ldr r0, =gBattle_WIN0V - strh r4, [r0] - ldr r4, =0x00003f3f - movs r0, 0x48 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x4A - adds r1, r4, 0 - bl SetGpuReg - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0817076C - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0 - bl SetAnimBgAttribute -_0817076C: - movs r0, 0 - bl GetGpuReg - adds r1, r0, 0 - movs r2, 0x80 - lsls r2, 8 - adds r0, r2, 0 - eors r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r4, 0x8 - ldrsh r1, [r5, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r6, =gSprites - adds r0, r6 - bl DestroySprite - movs r0, 0xC - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - bl DestroySprite - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl SetAnimBgAttribute - ldr r0, =gHealthboxSpriteIds - add r0, r8 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - ldrb r2, [r1, 0x6] - mov r8, r2 - ldrh r4, [r1, 0x38] - lsls r4, 24 - lsrs r4, 24 - ldrb r3, [r1, 0x5] - movs r2, 0xD - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - movs r5, 0x4 - orrs r0, r5 - strb r0, [r1, 0x5] - mov r0, r8 - lsls r1, r0, 4 - add r1, r8 - lsls r1, 2 - adds r1, r6 - ldrb r3, [r1, 0x5] - adds r0, r2, 0 - ands r0, r3 - orrs r0, r5 - strb r0, [r1, 0x5] - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0, 0x5] - ands r2, r1 - orrs r2, r5 - strb r2, [r0, 0x5] - adds r0, r7, 0 - bl DestroyAnimVisualTask -_08170814: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170660 - - thumb_func_start sub_8170834 -sub_8170834: @ 8170834 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - mov r9, r0 - adds r7, r1, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gHealthboxSpriteIds - adds r2, r0 - ldrb r0, [r2] - lsls r5, r0, 4 - adds r5, r0 - lsls r5, 2 - ldr r0, =gSprites - adds r5, r0 - ldrb r1, [r5, 0x6] - mov r10, r1 - ldrh r4, [r5, 0x38] - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x0000d709 - bl AllocSpritePalette - mov r2, r9 - strb r0, [r2] - ldr r0, =0x0000d70a - bl AllocSpritePalette - strb r0, [r7] - ldrb r0, [r5, 0x5] - lsrs r0, 4 - lsls r0, 4 - movs r1, 0x80 - lsls r1, 1 - adds r3, r1, 0 - orrs r0, r3 - lsls r6, r4, 4 - adds r6, r4 - lsls r6, 2 - ldr r2, =gSprites - adds r6, r2 - ldrb r4, [r6, 0x5] - lsrs r4, 4 - lsls r4, 4 - orrs r4, r3 - lsls r0, 1 - ldr r1, =gPlttBufferUnfaded - mov r8, r1 - add r0, r8 - mov r2, r9 - ldrb r1, [r2] - lsls r1, 4 - adds r1, r3, r1 - movs r2, 0x20 - str r3, [sp] - bl LoadPalette - lsls r4, 1 - add r4, r8 - ldrb r0, [r7] - lsls r0, 4 - ldr r3, [sp] - adds r3, r0 - adds r0, r4, 0 - adds r1, r3, 0 - movs r2, 0x20 - bl LoadPalette - mov r0, r9 - ldrb r1, [r0] - lsls r1, 4 - ldrb r2, [r5, 0x5] - movs r3, 0xF - adds r0, r3, 0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x5] - mov r2, r10 - lsls r1, r2, 4 - add r1, r10 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - mov r0, r9 - ldrb r2, [r0] - lsls r2, 4 - ldrb r4, [r1, 0x5] - adds r0, r3, 0 - ands r0, r4 - orrs r0, r2 - strb r0, [r1, 0x5] - ldrb r0, [r7] - lsls r0, 4 - ldrb r1, [r6, 0x5] - ands r3, r1 - orrs r3, r0 - strb r3, [r6, 0x5] - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170834 - - thumb_func_start sub_8170920 -sub_8170920: @ 8170920 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - mov r1, sp - adds r1, 0x1 - ldr r0, =gBattleAnimAttacker - ldrb r2, [r0] - mov r0, sp - bl sub_8170834 - adds r0, r4, 0 - bl DestroyAnimVisualTask - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170920 - - thumb_func_start sub_817094C -sub_817094C: @ 817094C - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gHealthboxSpriteIds - adds r0, r1 - ldrb r0, [r0] - ldr r1, =gSprites - mov r8, r1 - lsls r5, r0, 4 - adds r5, r0 - lsls r5, 2 - add r5, r8 - ldrb r0, [r5, 0x6] - mov r9, r0 - ldrh r6, [r5, 0x38] - lsls r6, 24 - lsrs r6, 24 - ldr r0, =0x0000d709 - bl FreeSpritePaletteByTag - ldr r0, =0x0000d70a - bl FreeSpritePaletteByTag - ldr r0, =0x0000d6ff - bl IndexOfSpritePaletteTag - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x0000d704 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsls r4, 4 - ldrb r2, [r5, 0x5] - movs r3, 0xF - adds r1, r3, 0 - ands r1, r2 - orrs r1, r4 - strb r1, [r5, 0x5] - mov r1, r9 - lsls r2, r1, 4 - add r2, r9 - lsls r2, 2 - add r2, r8 - ldrb r5, [r2, 0x5] - adds r1, r3, 0 - ands r1, r5 - orrs r1, r4 - strb r1, [r2, 0x5] - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - add r1, r8 - lsrs r0, 20 - ldrb r2, [r1, 0x5] - ands r3, r2 - orrs r3, r0 - strb r3, [r1, 0x5] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817094C - - thumb_func_start sub_81709EC -sub_81709EC: @ 81709EC - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl sub_817094C - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81709EC - - thumb_func_start sub_8170A0C -sub_8170A0C: @ 8170A0C - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r2, =gBattleAnimArgs - ldrh r0, [r2] - strh r0, [r1, 0x1C] - ldrh r0, [r2, 0x2] - strh r0, [r1, 0x1E] - ldr r0, =sub_8170A38 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_8170A0C - - thumb_func_start sub_8170A38 -sub_8170A38: @ 8170A38 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - movs r6, 0 - adds r1, r0, 0x1 - strh r1, [r4, 0x8] - lsls r0, 16 - asrs r0, 16 - movs r2, 0x1E - ldrsh r1, [r4, r2] - cmp r0, r1 - blt _08170AF8 - strh r6, [r4, 0x8] - ldr r0, =0x0000d709 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r2, r0, 24 - movs r3, 0x1C - ldrsh r0, [r4, r3] - movs r1, 0x2 - cmp r0, 0 - bne _08170A76 - movs r1, 0x6 -_08170A76: - movs r3, 0xA - ldrsh r0, [r4, r3] - cmp r0, 0 - beq _08170A8C - cmp r0, 0x1 - beq _08170AC8 - b _08170AF8 - .pool -_08170A8C: - ldrh r0, [r4, 0xC] - adds r0, 0x2 - strh r0, [r4, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x10 - ble _08170A9E - movs r0, 0x10 - strh r0, [r4, 0xC] -_08170A9E: - lsls r0, r2, 4 - movs r2, 0x80 - lsls r2, 1 - adds r0, r2 - orrs r0, r1 - ldrb r2, [r4, 0xC] - ldr r3, =0x00007f74 - movs r1, 0x1 - bl BlendPalette - movs r3, 0xC - ldrsh r0, [r4, r3] - cmp r0, 0x10 - bne _08170AF8 - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - b _08170AF8 - .pool -_08170AC8: - ldrh r0, [r4, 0xC] - subs r0, 0x2 - strh r0, [r4, 0xC] - lsls r0, 16 - cmp r0, 0 - bge _08170AD6 - strh r6, [r4, 0xC] -_08170AD6: - lsls r0, r2, 4 - movs r2, 0x80 - lsls r2, 1 - adds r0, r2 - orrs r0, r1 - ldrb r2, [r4, 0xC] - ldr r3, =0x00007f74 - movs r1, 0x1 - bl BlendPalette - movs r3, 0xC - ldrsh r0, [r4, r3] - cmp r0, 0 - bne _08170AF8 - adds r0, r5, 0 - bl DestroyAnimVisualTask -_08170AF8: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170A38 - - thumb_func_start sub_8170B04 -sub_8170B04: @ 8170B04 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gBattlerSpriteIds - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - adds r0, r1 - ldrb r5, [r0] - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08170B52 - cmp r0, 0x1 - bgt _08170B3C - cmp r0, 0 - beq _08170B42 - b _08170BA4 - .pool -_08170B3C: - cmp r0, 0x2 - beq _08170B84 - b _08170BA4 -_08170B42: - adds r0, r5, 0 - movs r1, 0 - bl sub_80A7270 - movs r0, 0x80 - lsls r0, 1 - strh r0, [r4, 0x1C] - b _08170B76 -_08170B52: - ldrh r0, [r4, 0x1C] - adds r0, 0x30 - strh r0, [r4, 0x1C] - movs r0, 0x1C - ldrsh r2, [r4, r0] - adds r0, r5, 0 - adds r1, r2, 0 - movs r3, 0 - bl obj_id_set_rotscale - adds r0, r5, 0 - bl sub_80A7E6C - movs r0, 0x1C - ldrsh r1, [r4, r0] - ldr r0, =0x000002cf - cmp r1, r0 - ble _08170BA4 -_08170B76: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08170BA4 - .pool -_08170B84: - adds r0, r5, 0 - bl sub_80A7344 - ldr r1, =gSprites - lsls r0, r5, 4 - adds r0, r5 - lsls r0, 2 - adds r0, r1 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - adds r0, r6, 0 - bl DestroyAnimVisualTask -_08170BA4: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170B04 - - thumb_func_start sub_8170BB0 -sub_8170BB0: @ 8170BB0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0xC - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gBattlerSpriteIds - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - adds r1, r0, r1 - ldrb r1, [r1] - mov r9, r1 - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _08170BF8 - ldr r1, =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - b _08170C08 - .pool -_08170BF8: - ldr r1, =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty -_08170C08: - adds r0, r1 - movs r1, 0x26 - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - bl ItemIdToBallId - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r2, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r6, r0, r2 - movs r0, 0x8 - ldrsh r7, [r6, r0] - cmp r7, 0 - beq _08170C44 - cmp r7, 0x1 - beq _08170CC4 - b _08170CEE - .pool -_08170C44: - ldr r5, =gBattleAnimAttacker - ldrb r0, [r5] - movs r1, 0 - bl GetBattlerSpriteCoord - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldrb r0, [r5] - movs r1, 0x1 - bl GetBattlerSpriteCoord - adds r1, r0, 0 - lsls r1, 24 - ldr r2, =gSprites - mov r3, r9 - lsls r0, r3, 4 - add r0, r9 - lsls r0, 2 - adds r0, r2 - ldrb r2, [r0, 0x5] - lsls r2, 28 - lsrs r2, 30 - adds r0, 0x43 - ldrb r3, [r0] - movs r0, 0x80 - lsls r0, 22 - adds r1, r0 - lsrs r1, 24 - mov r0, r8 - str r0, [sp] - adds r0, r4, 0 - bl LaunchBallStarsTask - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x1C] - str r7, [sp] - str r7, [sp, 0x4] - str r7, [sp, 0x8] - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl sub_80A75AC - adds r2, r0, 0 - ldrb r1, [r5] - movs r0, 0 - mov r3, r8 - bl LaunchBallFadeMonTask - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x1E] - ldrh r0, [r6, 0x8] - adds r0, 0x1 - strh r0, [r6, 0x8] - b _08170CEE - .pool -_08170CC4: - movs r1, 0x1C - ldrsh r0, [r6, r1] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrb r0, [r1, 0x4] - cmp r0, 0 - bne _08170CEE - movs r3, 0x1E - ldrsh r0, [r6, r3] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrb r0, [r1, 0x4] - cmp r0, 0 - bne _08170CEE - adds r0, r5, 0 - bl DestroyAnimVisualTask -_08170CEE: - add sp, 0xC - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8170BB0 - - thumb_func_start sub_8170CFC -sub_8170CFC: @ 8170CFC - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gLastUsedItem - ldrh r0, [r0] - bl ItemIdToBallId - lsls r0, 24 - lsrs r0, 24 - bl LoadBallGfx - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170CFC - - thumb_func_start sub_8170D24 -sub_8170D24: @ 8170D24 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gLastUsedItem - ldrh r0, [r0] - bl ItemIdToBallId - lsls r0, 24 - lsrs r0, 24 - bl FreeBallGfx - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170D24 - - thumb_func_start AnimTask_IsBallBlockedByTrainer -AnimTask_IsBallBlockedByTrainer: @ 8170D4C - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - ldrb r0, [r0, 0x8] - cmp r0, 0x5 - bne _08170D70 - ldr r1, =gBattleAnimArgs - ldr r0, =0x0000ffff - b _08170D74 - .pool -_08170D70: - ldr r1, =gBattleAnimArgs - movs r0, 0 -_08170D74: - strh r0, [r1, 0xE] - adds r0, r2, 0 - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_IsBallBlockedByTrainer - - thumb_func_start ItemIdToBallId -ItemIdToBallId: @ 8170D84 - push {lr} - lsls r0, 16 - lsrs r0, 16 - subs r0, 0x1 - cmp r0, 0xB - bhi _08170DFC - lsls r0, 2 - ldr r1, =_08170DA0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08170DA0: - .4byte _08170DD0 - .4byte _08170DD4 - .4byte _08170DD8 - .4byte _08170DFC - .4byte _08170DDC - .4byte _08170DE0 - .4byte _08170DE4 - .4byte _08170DE8 - .4byte _08170DEC - .4byte _08170DF0 - .4byte _08170DF4 - .4byte _08170DF8 -_08170DD0: - movs r0, 0x4 - b _08170DFE -_08170DD4: - movs r0, 0x3 - b _08170DFE -_08170DD8: - movs r0, 0x1 - b _08170DFE -_08170DDC: - movs r0, 0x2 - b _08170DFE -_08170DE0: - movs r0, 0x5 - b _08170DFE -_08170DE4: - movs r0, 0x6 - b _08170DFE -_08170DE8: - movs r0, 0x7 - b _08170DFE -_08170DEC: - movs r0, 0x8 - b _08170DFE -_08170DF0: - movs r0, 0x9 - b _08170DFE -_08170DF4: - movs r0, 0xA - b _08170DFE -_08170DF8: - movs r0, 0xB - b _08170DFE -_08170DFC: - movs r0, 0 -_08170DFE: - pop {r1} - bx r1 - thumb_func_end ItemIdToBallId - - thumb_func_start sub_8170E04 -sub_8170E04: @ 8170E04 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - mov r10, r0 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r0, =gLastUsedItem - ldrh r0, [r0] - bl ItemIdToBallId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - ldr r1, =gBallSpriteTemplates - adds r0, r1 - movs r1, 0x20 - movs r2, 0x50 - movs r3, 0x1D - bl CreateSprite - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r1, =gSprites - mov r9, r1 - lsls r4, r5, 4 - adds r4, r5 - lsls r4, 2 - adds r6, r4, r1 - movs r0, 0x22 - strh r0, [r6, 0x2E] - ldr r2, =gBattleAnimTarget - mov r8, r2 - ldrb r0, [r2] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x30] - mov r1, r8 - ldrb r0, [r1] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - subs r0, 0x10 - strh r0, [r6, 0x32] - mov r0, r9 - adds r0, 0x1C - adds r4, r0 - ldr r0, =sub_8171104 - str r0, [r4] - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r3, [r0, 0x8] - ldr r1, =gBattlerSpriteIds - mov r2, r8 - ldrb r0, [r2] - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - adds r0, 0x3E - ldrb r1, [r0] - lsls r1, 29 - lsrs r1, 31 - lsls r1, 1 - ldrb r2, [r3, 0x9] - movs r0, 0x3 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x9] - ldr r1, =gTasks - mov r2, r10 - lsls r0, r2, 2 - add r0, r10 - lsls r0, 3 - adds r0, r1 - strh r5, [r0, 0x8] - ldr r1, =sub_8170EF0 - str r1, [r0] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170E04 - - thumb_func_start sub_8170EF0 -sub_8170EF0: @ 8170EF0 - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r1, =gTasks - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - adds r0, r1 - ldrb r1, [r0, 0x8] - ldr r2, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x2E] - ldr r0, =0x0000ffff - cmp r1, r0 - bne _08170F1A - adds r0, r3, 0 - bl DestroyAnimVisualTask -_08170F1A: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170EF0 - - thumb_func_start sub_8170F2C -sub_8170F2C: @ 8170F2C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 2 - ands r0, r1 - cmp r0, 0 - beq _08170F50 - movs r6, 0x20 - movs r5, 0xB - b _08170F54 - .pool -_08170F50: - movs r6, 0x17 - movs r5, 0x5 -_08170F54: - ldr r0, =gLastUsedItem - ldrh r0, [r0] - bl ItemIdToBallId - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r0, 24 - bl sub_80A82E4 - adds r3, r0, 0 - adds r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 3 - ldr r1, =gBallSpriteTemplates - adds r0, r1 - adds r1, r6, 0 - adds r1, 0x20 - movs r2, 0x50 - orrs r5, r2 - adds r2, r5, 0 - bl CreateSprite - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gSprites - mov r9, r0 - lsls r4, r5, 4 - adds r4, r5 - lsls r4, 2 - adds r6, r4, r0 - movs r0, 0x22 - strh r0, [r6, 0x2E] - ldr r1, =gBattleAnimTarget - mov r8, r1 - ldrb r0, [r1] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x30] - mov r1, r8 - ldrb r0, [r1] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - subs r0, 0x10 - strh r0, [r6, 0x32] - movs r0, 0x1C - add r9, r0 - add r4, r9 - ldr r0, =SpriteCallbackDummy - str r0, [r4] - movs r0, 0 - bl GetBattlerAtPosition - ldr r1, =gBattlerSpriteIds - lsls r0, 24 - lsrs r0, 24 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - ldr r1, =sub_8039E84 - str r1, [r0] - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - strh r5, [r0, 0x8] - ldr r1, =sub_8171030 - str r1, [r0] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8170F2C - - thumb_func_start sub_8171030 -sub_8171030: @ 8171030 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r6, =gSprites - movs r0, 0 - bl GetBattlerAtPosition - ldr r1, =gBattlerSpriteIds - lsls r0, 24 - lsrs r0, 24 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x2B - ldrb r0, [r0] - cmp r0, 0x1 - bne _0817108A - movs r0, 0x3D - movs r1, 0 - bl PlaySE12WithPanning - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - movs r0, 0x8 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r6, 0 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_8171104 - str r1, [r0] - ldr r0, =sub_81710A8 - movs r1, 0xA - bl CreateTask - ldr r0, =sub_8170EF0 - str r0, [r4] -_0817108A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171030 - - thumb_func_start sub_81710A8 -sub_81710A8: @ 81710A8 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r6, =gSprites - movs r0, 0 - bl GetBattlerAtPosition - ldr r4, =gBattlerSpriteIds - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 27 - cmp r0, 0 - bge _081710F4 - movs r0, 0 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0 - bl StartSpriteAnim - adds r0, r5, 0 - bl DestroyTask -_081710F4: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81710A8 - - thumb_func_start sub_8171104 -sub_8171104: @ 8171104 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x30] - ldrh r2, [r4, 0x32] - ldrh r0, [r4, 0x20] - strh r0, [r4, 0x30] - strh r1, [r4, 0x32] - ldrh r0, [r4, 0x22] - strh r0, [r4, 0x34] - strh r2, [r4, 0x36] - ldr r0, =0x0000ffd8 - strh r0, [r4, 0x38] - adds r0, r4, 0 - bl InitAnimArcTranslation - ldr r0, =sub_8171134 - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171104 - - thumb_func_start sub_8171134 -sub_8171134: @ 8171134 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _081711D2 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - ldrb r0, [r0, 0x8] - cmp r0, 0x5 - bne _08171160 - ldr r0, =sub_8171CAC - str r0, [r4, 0x1C] - b _081711D2 - .pool -_08171160: - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim - ldrh r0, [r4, 0x24] - ldrh r1, [r4, 0x20] - adds r0, r1 - movs r1, 0 - strh r0, [r4, 0x20] - ldrh r0, [r4, 0x26] - ldrh r2, [r4, 0x22] - adds r0, r2 - strh r0, [r4, 0x22] - strh r1, [r4, 0x24] - strh r1, [r4, 0x26] - adds r1, r4, 0 - adds r1, 0x2E - movs r2, 0 - adds r0, r4, 0 - adds r0, 0x3C -_08171188: - strh r2, [r0] - subs r0, 0x2 - cmp r0, r1 - bge _08171188 - movs r0, 0 - strh r0, [r4, 0x38] - ldr r0, =sub_81711E8 - str r0, [r4, 0x1C] - ldr r0, =gLastUsedItem - ldrh r0, [r0] - bl ItemIdToBallId - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0xB - bgt _081711D2 - cmp r5, 0 - blt _081711D2 - ldrh r0, [r4, 0x20] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x22] - subs r1, 0x5 - lsls r1, 24 - lsrs r1, 24 - str r5, [sp] - movs r2, 0x1 - movs r3, 0x1C - bl LaunchBallStarsTask - ldr r0, =gBattleAnimTarget - ldrb r1, [r0] - movs r0, 0 - movs r2, 0xE - adds r3, r5, 0 - bl LaunchBallFadeMonTask -_081711D2: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171134 - - thumb_func_start sub_81711E8 -sub_81711E8: @ 81711E8 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x38] - adds r0, 0x1 - strh r0, [r4, 0x38] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - bne _08171224 - ldr r0, =TaskDummy - movs r1, 0x32 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x38] - ldr r0, =sub_8171240 - str r0, [r4, 0x1C] - ldr r2, =gSprites - ldr r1, =gBattlerSpriteIds - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0 - strh r1, [r0, 0x30] -_08171224: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81711E8 - - thumb_func_start sub_8171240 -sub_8171240: @ 8171240 - push {r4-r7,lr} - adds r7, r0, 0 - ldr r1, =gBattlerSpriteIds - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - adds r0, r1 - ldrb r4, [r0] - ldrh r0, [r7, 0x38] - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r5, r0, r1 - ldrh r0, [r5, 0xA] - adds r0, 0x1 - strh r0, [r5, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xB - bne _08171272 - movs r0, 0x3C - bl PlaySE -_08171272: - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _081712E8 - cmp r0, 0x1 - bgt _08171290 - cmp r0, 0 - beq _08171296 - b _08171354 - .pool -_08171290: - cmp r0, 0x2 - beq _0817132C - b _08171354 -_08171296: - adds r0, r4, 0 - movs r1, 0 - bl sub_80A7270 - movs r0, 0x80 - lsls r0, 1 - strh r0, [r5, 0x1C] - ldr r1, =gUnknown_030062DC - movs r0, 0x1C - str r0, [r1] - ldr r2, =gUnknown_030062E4 - ldr r1, =gSprites - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - adds r0, r1 - ldrh r1, [r0, 0x26] - ldrh r0, [r0, 0x22] - adds r1, r0 - ldrh r0, [r7, 0x26] - ldrh r7, [r7, 0x22] - adds r0, r7 - subs r1, r0 - strh r1, [r2] - ldr r4, =gUnknown_030062E0 - ldrh r0, [r2] - lsls r0, 8 - movs r1, 0x1C - bl __udivsi3 - strh r0, [r4] - strh r0, [r5, 0xC] - b _08171346 - .pool -_081712E8: - ldrh r0, [r5, 0x1C] - adds r0, 0x20 - strh r0, [r5, 0x1C] - movs r0, 0x1C - ldrsh r2, [r5, r0] - adds r0, r4, 0 - adds r1, r2, 0 - movs r3, 0 - bl obj_id_set_rotscale - ldrh r0, [r5, 0xC] - ldrh r1, [r5, 0xE] - adds r0, r1 - strh r0, [r5, 0xE] - ldr r0, =gSprites - lsls r1, r4, 4 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - movs r2, 0xE - ldrsh r0, [r5, r2] - negs r0, r0 - asrs r0, 8 - strh r0, [r1, 0x26] - movs r0, 0x1C - ldrsh r1, [r5, r0] - ldr r0, =0x0000047f - cmp r1, r0 - ble _0817137C - b _08171346 - .pool -_0817132C: - adds r0, r4, 0 - bl sub_80A7344 - ldr r1, =gSprites - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - adds r0, r1 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_08171346: - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - b _0817137C - .pool -_08171354: - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - movs r2, 0xA - ldrsh r0, [r1, r2] - cmp r0, 0xA - ble _0817137C - adds r0, r6, 0 - bl DestroyTask - adds r0, r7, 0 - movs r1, 0x2 - bl StartSpriteAnim - movs r0, 0 - strh r0, [r7, 0x38] - ldr r0, =sub_817138C - str r0, [r7, 0x1C] -_0817137C: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171240 - - thumb_func_start sub_817138C -sub_817138C: @ 817138C - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081713C6 - movs r1, 0 - strh r1, [r4, 0x34] - movs r0, 0x28 - strh r0, [r4, 0x36] - strh r1, [r4, 0x38] - movs r0, 0 - movs r1, 0x28 - bl Cos - ldrh r1, [r4, 0x22] - adds r0, r1 - strh r0, [r4, 0x22] - movs r0, 0x36 - ldrsh r1, [r4, r0] - movs r0, 0 - bl Cos - negs r0, r0 - strh r0, [r4, 0x26] - ldr r0, =sub_81713D0 - str r0, [r4, 0x1C] -_081713C6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817138C - - thumb_func_start sub_81713D0 -sub_81713D0: @ 81713D0 - push {r4,r5,lr} - adds r4, r0, 0 - movs r5, 0 - ldrh r0, [r4, 0x34] - movs r1, 0xFF - ands r1, r0 - cmp r1, 0 - beq _081713E6 - cmp r1, 0x1 - beq _0817145A - b _08171486 -_081713E6: - movs r1, 0x38 - ldrsh r0, [r4, r1] - movs r2, 0x36 - ldrsh r1, [r4, r2] - bl Cos - negs r0, r0 - strh r0, [r4, 0x26] - ldrh r1, [r4, 0x38] - adds r1, 0x4 - ldrh r2, [r4, 0x34] - lsls r0, r2, 16 - asrs r0, 24 - adds r1, r0 - strh r1, [r4, 0x38] - lsls r1, 16 - asrs r1, 16 - cmp r1, 0x3F - ble _08171486 - ldrh r0, [r4, 0x36] - subs r0, 0xA - strh r0, [r4, 0x36] - ldr r1, =0x00000101 - adds r0, r2, r1 - strh r0, [r4, 0x34] - lsls r0, 16 - asrs r0, 24 - cmp r0, 0x4 - bne _08171422 - movs r5, 0x1 -_08171422: - cmp r0, 0x2 - beq _08171442 - cmp r0, 0x2 - bgt _08171434 - cmp r0, 0x1 - beq _0817143A - b _08171452 - .pool -_08171434: - cmp r0, 0x3 - beq _0817144A - b _08171452 -_0817143A: - movs r0, 0x38 - bl PlaySE - b _08171486 -_08171442: - movs r0, 0x39 - bl PlaySE - b _08171486 -_0817144A: - movs r0, 0x3A - bl PlaySE - b _08171486 -_08171452: - movs r0, 0x3B - bl PlaySE - b _08171486 -_0817145A: - movs r2, 0x38 - ldrsh r0, [r4, r2] - movs r2, 0x36 - ldrsh r1, [r4, r2] - bl Cos - negs r0, r0 - strh r0, [r4, 0x26] - ldrh r1, [r4, 0x38] - subs r1, 0x4 - ldrh r2, [r4, 0x34] - lsls r0, r2, 16 - asrs r0, 24 - subs r1, r0 - strh r1, [r4, 0x38] - lsls r1, 16 - cmp r1, 0 - bgt _08171486 - strh r5, [r4, 0x38] - ldr r0, =0xffffff00 - ands r0, r2 - strh r0, [r4, 0x34] -_08171486: - cmp r5, 0 - beq _081714CA - movs r5, 0 - strh r5, [r4, 0x34] - movs r0, 0x40 - movs r1, 0x28 - bl Cos - ldrh r1, [r4, 0x22] - adds r0, r1 - strh r0, [r4, 0x22] - strh r5, [r4, 0x26] - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - ldrb r0, [r0, 0x8] - cmp r0, 0 - bne _081714C0 - strh r5, [r4, 0x38] - ldr r0, =sub_81717B4 - str r0, [r4, 0x1C] - b _081714CA - .pool -_081714C0: - ldr r0, =sub_81714D4 - str r0, [r4, 0x1C] - movs r0, 0x1 - strh r0, [r4, 0x36] - strh r5, [r4, 0x38] -_081714CA: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81713D0 - - thumb_func_start sub_81714D4 -sub_81714D4: @ 81714D4 - push {r4,r5,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x34] - adds r0, 0x1 - movs r5, 0 - strh r0, [r4, 0x34] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1F - bne _08171510 - strh r5, [r4, 0x34] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - strh r5, [r0, 0xC] - ldr r0, =sub_8171520 - str r0, [r4, 0x1C] - movs r0, 0x17 - bl PlaySE -_08171510: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81714D4 - - thumb_func_start sub_8171520 -sub_8171520: @ 8171520 - push {r4-r6,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x34] - movs r1, 0xFF - ands r1, r0 - cmp r1, 0x6 - bls _08171530 - b _08171768 -_08171530: - lsls r0, r1, 2 - ldr r1, =_08171540 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08171540: - .4byte _0817155C - .4byte _081715AE - .4byte _081715F4 - .4byte _08171654 - .4byte _081716A4 - .4byte _08171708 - .4byte _08171768 -_0817155C: - ldr r1, =gBattleSpritesDataPtr - ldr r5, [r1] - ldr r2, [r5, 0x8] - ldrh r3, [r2, 0xC] - movs r6, 0xC - ldrsh r0, [r2, r6] - adds r6, r1, 0 - cmp r0, 0xFF - ble _08171584 - ldrh r0, [r4, 0x36] - ldrh r1, [r4, 0x24] - adds r0, r1 - strh r0, [r4, 0x24] - ldr r1, [r5, 0x8] - ldrb r0, [r1, 0xC] - strh r0, [r1, 0xC] - b _0817158A - .pool -_08171584: - adds r0, r3, 0 - adds r0, 0xB0 - strh r0, [r2, 0xC] -_0817158A: - ldrh r0, [r4, 0x38] - adds r0, 0x1 - movs r3, 0 - strh r0, [r4, 0x38] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - ldrh r0, [r4, 0x38] - adds r0, 0x7 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xE - bhi _081715AC - b _081717AE -_081715AC: - b _08171644 -_081715AE: - ldrh r0, [r4, 0x38] - adds r0, 0x1 - strh r0, [r4, 0x38] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - bne _08171660 - movs r0, 0 - strh r0, [r4, 0x38] - ldrh r0, [r4, 0x36] - negs r0, r0 - strh r0, [r4, 0x36] - ldrh r0, [r4, 0x34] - adds r0, 0x1 - strh r0, [r4, 0x34] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - movs r6, 0x36 - ldrsh r0, [r4, r6] - cmp r0, 0 - bge _081715EA - adds r0, r4, 0 - movs r1, 0x2 - bl ChangeSpriteAffineAnim - b _081717AE -_081715EA: - adds r0, r4, 0 - movs r1, 0x1 - bl ChangeSpriteAffineAnim - b _081717AE -_081715F4: - ldr r1, =gBattleSpritesDataPtr - ldr r5, [r1] - ldr r2, [r5, 0x8] - ldrh r3, [r2, 0xC] - movs r6, 0xC - ldrsh r0, [r2, r6] - adds r6, r1, 0 - cmp r0, 0xFF - ble _0817161C - ldrh r0, [r4, 0x36] - ldrh r1, [r4, 0x24] - adds r0, r1 - strh r0, [r4, 0x24] - ldr r1, [r5, 0x8] - ldrb r0, [r1, 0xC] - strh r0, [r1, 0xC] - b _08171622 - .pool -_0817161C: - adds r0, r3, 0 - adds r0, 0xB0 - strh r0, [r2, 0xC] -_08171622: - ldrh r0, [r4, 0x38] - adds r0, 0x1 - movs r3, 0 - strh r0, [r4, 0x38] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - ldrh r0, [r4, 0x38] - adds r0, 0xC - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x18 - bhi _08171644 - b _081717AE -_08171644: - ldr r0, [r6] - ldr r0, [r0, 0x8] - strh r3, [r0, 0xC] - ldrh r0, [r4, 0x34] - adds r0, 0x1 - strh r0, [r4, 0x34] - strh r3, [r4, 0x38] - b _081717AE -_08171654: - ldrh r0, [r4, 0x38] - adds r1, r0, 0x1 - strh r1, [r4, 0x38] - lsls r0, 16 - cmp r0, 0 - bge _0817166E -_08171660: - adds r0, r4, 0 - adds r0, 0x2C - ldrb r1, [r0] - movs r2, 0x80 - orrs r1, r2 - strb r1, [r0] - b _081717AE -_0817166E: - movs r0, 0 - strh r0, [r4, 0x38] - ldrh r0, [r4, 0x36] - negs r0, r0 - strh r0, [r4, 0x36] - ldrh r0, [r4, 0x34] - adds r0, 0x1 - strh r0, [r4, 0x34] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - movs r6, 0x36 - ldrsh r0, [r4, r6] - cmp r0, 0 - bge _0817169C - adds r0, r4, 0 - movs r1, 0x2 - bl ChangeSpriteAffineAnim - b _081716A4 -_0817169C: - adds r0, r4, 0 - movs r1, 0x1 - bl ChangeSpriteAffineAnim -_081716A4: - ldr r1, =gBattleSpritesDataPtr - ldr r5, [r1] - ldr r2, [r5, 0x8] - ldrh r3, [r2, 0xC] - movs r6, 0xC - ldrsh r0, [r2, r6] - adds r6, r1, 0 - cmp r0, 0xFF - ble _081716CC - ldrh r0, [r4, 0x36] - ldrh r1, [r4, 0x24] - adds r0, r1 - strh r0, [r4, 0x24] - ldr r1, [r5, 0x8] - ldrb r0, [r1, 0xC] - strh r0, [r1, 0xC] - b _081716D2 - .pool -_081716CC: - adds r0, r3, 0 - adds r0, 0xB0 - strh r0, [r2, 0xC] -_081716D2: - ldrh r0, [r4, 0x38] - adds r0, 0x1 - movs r3, 0 - strh r0, [r4, 0x38] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - ldrh r0, [r4, 0x38] - adds r0, 0x4 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x8 - bls _081717AE - ldr r0, [r6] - ldr r0, [r0, 0x8] - strh r3, [r0, 0xC] - ldrh r0, [r4, 0x34] - adds r0, 0x1 - strh r0, [r4, 0x34] - strh r3, [r4, 0x38] - ldrh r0, [r4, 0x36] - negs r0, r0 - strh r0, [r4, 0x36] - b _081717AE -_08171708: - movs r6, 0x80 - lsls r6, 1 - adds r0, r6, 0 - ldrh r1, [r4, 0x34] - adds r0, r1 - strh r0, [r4, 0x34] - lsls r0, 16 - asrs r1, r0, 24 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - ldrb r0, [r0, 0x8] - cmp r1, r0 - bne _08171740 - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - ldr r0, =sub_81717B4 - str r0, [r4, 0x1C] - b _081717AE - .pool -_08171740: - cmp r0, 0x4 - bne _08171754 - cmp r1, 0x3 - bne _08171754 - ldr r0, =sub_81717D8 - str r0, [r4, 0x1C] - b _0817175A - .pool -_08171754: - ldrh r0, [r4, 0x34] - adds r0, 0x1 - strh r0, [r4, 0x34] -_0817175A: - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - b _081717AE -_08171768: - ldrh r0, [r4, 0x38] - adds r0, 0x1 - strh r0, [r4, 0x38] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1F - bne _081717AE - movs r0, 0 - strh r0, [r4, 0x38] - ldrh r1, [r4, 0x34] - ldr r0, =0xffffff00 - ands r0, r1 - strh r0, [r4, 0x34] - adds r0, r4, 0 - movs r1, 0x3 - bl StartSpriteAffineAnim - movs r6, 0x36 - ldrsh r0, [r4, r6] - cmp r0, 0 - bge _081717A0 - adds r0, r4, 0 - movs r1, 0x2 - bl StartSpriteAffineAnim - b _081717A8 - .pool -_081717A0: - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim -_081717A8: - movs r0, 0x17 - bl PlaySE -_081717AE: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8171520 - - thumb_func_start sub_81717B4 -sub_81717B4: @ 81717B4 - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0x38] - adds r0, 0x1 - strh r0, [r1, 0x38] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1F - bne _081717CE - movs r0, 0 - strh r0, [r1, 0x38] - ldr r0, =sub_8171AE4 - str r0, [r1, 0x1C] -_081717CE: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81717B4 - - thumb_func_start sub_81717D8 -sub_81717D8: @ 81717D8 - adds r3, r0, 0 - adds r3, 0x2C - ldrb r1, [r3] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r3] - ldr r1, =sub_81717F8 - str r1, [r0, 0x1C] - movs r1, 0 - strh r1, [r0, 0x34] - strh r1, [r0, 0x36] - strh r1, [r0, 0x38] - bx lr - .pool - thumb_func_end sub_81717D8 - - thumb_func_start sub_81717F8 -sub_81717F8: @ 81717F8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r6, r0, 0 - ldr r7, =gBattleAnimTarget - ldrh r0, [r6, 0x36] - adds r0, 0x1 - movs r1, 0 - mov r8, r1 - strh r0, [r6, 0x36] - lsls r0, 16 - asrs r1, r0, 16 - cmp r1, 0x28 - bne _0817183C - movs r0, 0xFE - bl PlaySE - ldrb r1, [r6, 0x5] - lsrs r1, 4 - movs r0, 0x80 - lsls r0, 9 - lsls r0, r1 - movs r1, 0x6 - movs r2, 0 - bl BlendPalettes - adds r0, r6, 0 - bl sub_81719EC - b _081718BC - .pool -_0817183C: - cmp r1, 0x3C - bne _0817185A - ldrb r1, [r6, 0x5] - lsrs r1, 4 - movs r0, 0x80 - lsls r0, 9 - lsls r0, r1 - mov r1, r8 - str r1, [sp] - movs r1, 0x2 - movs r2, 0x6 - movs r3, 0 - bl BeginNormalPaletteFade - b _081718BC -_0817185A: - cmp r1, 0x5F - bne _08171880 - ldr r0, =gDoingBattleAnim - movs r1, 0 - strb r1, [r0] - movs r0, 0x1 - bl UpdateOamPriorityInAllHealthboxes - bl m4aMPlayAllStop - ldr r0, =0x00000213 - bl PlaySE - b _081718BC - .pool -_08171880: - ldr r0, =0x0000013b - cmp r1, r0 - bne _081718BC - ldr r5, =gSprites - ldr r4, =gBattlerSpriteIds - ldrb r0, [r7] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrb r0, [r0, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldrb r0, [r7] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - bl DestroySprite - mov r0, r8 - strh r0, [r6, 0x2E] - ldr r0, =sub_81718D8 - str r0, [r6, 0x1C] -_081718BC: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81717F8 - - thumb_func_start sub_81718D8 -sub_81718D8: @ 81718D8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08171944 - cmp r0, 0x1 - bgt _081718F0 - cmp r0, 0 - beq _081718F6 - b _0817198A -_081718F0: - cmp r0, 0x2 - beq _08171976 - b _0817198A -_081718F6: - strh r0, [r4, 0x30] - strh r0, [r4, 0x32] - ldrb r1, [r4, 0x1] - movs r0, 0xD - negs r0, r0 - ands r0, r1 - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4, 0x1] - movs r1, 0xFD - lsls r1, 6 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - ldr r0, [r4, 0x14] - ldrh r0, [r0, 0x2] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x10 - movs r1, 0x1 - lsls r1, r0 - ldr r0, =0x00007fff - str r0, [sp] - adds r0, r1, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _08171982 - .pool -_08171944: - ldrh r0, [r4, 0x30] - adds r1, r0, 0x1 - strh r1, [r4, 0x30] - lsls r0, 16 - cmp r0, 0 - ble _081719B0 - movs r0, 0 - strh r0, [r4, 0x30] - ldrh r2, [r4, 0x32] - adds r2, 0x1 - strh r2, [r4, 0x32] - lsls r1, r2, 8 - movs r0, 0x10 - subs r0, r2 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r1, 0x32 - ldrsh r0, [r4, r1] - cmp r0, 0x10 - bne _081719B0 - b _08171982 -_08171976: - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] -_08171982: - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - b _081719B0 -_0817198A: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _081719B0 - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - strh r5, [r4, 0x2E] - ldr r0, =sub_81719C0 - str r0, [r4, 0x1C] -_081719B0: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81718D8 - - thumb_func_start sub_81719C0 -sub_81719C0: @ 81719C0 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x2E] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _081719D8 - ldr r0, =0x0000ffff - strh r0, [r4, 0x2E] - b _081719E4 - .pool -_081719D8: - adds r0, r4, 0 - bl FreeSpriteOamMatrix - adds r0, r4, 0 - bl DestroySprite -_081719E4: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81719C0 - - thumb_func_start sub_81719EC -sub_81719EC: @ 81719EC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r6, r0, 0 - adds r1, r6, 0 - adds r1, 0x43 - ldrb r0, [r1] - cmp r0, 0 - beq _08171A0C - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - b _08171A14 -_08171A0C: - movs r0, 0 - mov r8, r0 - movs r0, 0x1 - strb r0, [r1] -_08171A14: - movs r0, 0x4 - bl sub_8171D60 - movs r7, 0 - ldr r2, =gSprites - mov r9, r2 - movs r0, 0x1C - add r0, r9 - mov r10, r0 -_08171A26: - movs r2, 0x20 - ldrsh r1, [r6, r2] - movs r0, 0x22 - ldrsh r2, [r6, r0] - ldr r0, =gUnknown_085E5250 - mov r3, r8 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08171A82 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - mov r2, r9 - adds r5, r4, r2 - movs r0, 0x18 - strh r0, [r5, 0x2E] - ldr r0, =gUnknown_085E5088 - lsls r1, r7, 2 - adds r1, r0 - movs r0, 0 - ldrsb r0, [r1, r0] - ldrh r2, [r6, 0x20] - adds r0, r2 - strh r0, [r5, 0x32] - movs r0, 0x1 - ldrsb r0, [r1, r0] - ldrh r2, [r6, 0x22] - adds r0, r2 - strh r0, [r5, 0x36] - movs r0, 0x2 - ldrsb r0, [r1, r0] - strh r0, [r5, 0x38] - adds r0, r5, 0 - bl InitAnimArcTranslation - add r4, r10 - ldr r0, =sub_8171AAC - str r0, [r4] - ldr r0, =gUnknown_085E51B4 - ldrb r1, [r0, 0x4] - adds r0, r5, 0 - bl StartSpriteAnim -_08171A82: - adds r7, 0x1 - cmp r7, 0x2 - bls _08171A26 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81719EC - - thumb_func_start sub_8171AAC -sub_8171AAC: @ 8171AAC - push {r4,lr} - adds r4, r0, 0 - adds r3, r4, 0 - adds r3, 0x3E - ldrb r2, [r3] - lsrs r1, r2, 2 - movs r0, 0x1 - eors r1, r0 - ands r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - adds r0, r4, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _08171ADC - adds r0, r4, 0 - bl DestroySprite -_08171ADC: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8171AAC - - thumb_func_start sub_8171AE4 -sub_8171AE4: @ 8171AE4 - push {r4-r6,lr} - sub sp, 0x4 - adds r4, r0, 0 - movs r1, 0x1 - bl StartSpriteAnim - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAffineAnim - ldr r0, =sub_8171BAC - str r0, [r4, 0x1C] - ldr r0, =gLastUsedItem - ldrh r0, [r0] - bl ItemIdToBallId - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0xB - bgt _08171B36 - cmp r5, 0 - blt _08171B36 - ldrh r0, [r4, 0x20] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x22] - subs r1, 0x5 - lsls r1, 24 - lsrs r1, 24 - str r5, [sp] - movs r2, 0x1 - movs r3, 0x1C - bl LaunchBallStarsTask - ldr r0, =gBattleAnimTarget - ldrb r1, [r0] - movs r0, 0x1 - movs r2, 0xE - adds r3, r5, 0 - bl LaunchBallFadeMonTask -_08171B36: - ldr r6, =gSprites - ldr r5, =gBattlerSpriteIds - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - adds r0, r5 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - ldrb r0, [r4] - adds r0, r5 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldrb r0, [r4] - adds r0, r5 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - bl AnimateSprite - ldrb r0, [r4] - adds r0, r5 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x80 - lsls r1, 5 - strh r1, [r0, 0x30] - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171AE4 - - thumb_func_start sub_8171BAC -sub_8171BAC: @ 8171BAC - push {r4-r7,lr} - adds r7, r0, 0 - movs r5, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08171BCA - adds r2, r7, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] -_08171BCA: - ldr r4, =gSprites - ldr r3, =gBattlerSpriteIds - ldr r2, =gBattleAnimTarget - ldrb r0, [r2] - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r4 - adds r0, r1, 0 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _08171C04 - adds r0, r1, 0 - movs r1, 0 - bl StartSpriteAffineAnim - movs r5, 0x1 - b _08171C24 - .pool -_08171C04: - ldr r6, =0xfffffee0 - adds r0, r6, 0 - ldrh r6, [r1, 0x30] - adds r0, r6 - strh r0, [r1, 0x30] - ldrb r0, [r2] - adds r0, r3 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrh r0, [r1, 0x30] - lsls r0, 16 - asrs r0, 24 - strh r0, [r1, 0x26] -_08171C24: - adds r0, r7, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08171C8A - cmp r5, 0 - beq _08171C8A - ldr r4, =gSprites - ldr r3, =gBattlerSpriteIds - ldr r2, =gBattleAnimTarget - ldrb r0, [r2] - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r6, 0 - movs r5, 0 - strh r5, [r0, 0x26] - ldrb r0, [r2] - adds r0, r3 - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r4 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - ldrb r1, [r0, 0x9] - lsls r1, 30 - adds r2, 0x3E - lsrs r1, 31 - lsls r1, 2 - ldrb r3, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2] - strh r5, [r7, 0x2E] - ldr r0, =sub_81719C0 - str r0, [r7, 0x1C] - ldr r0, =gDoingBattleAnim - strb r6, [r0] - movs r0, 0x1 - bl UpdateOamPriorityInAllHealthboxes -_08171C8A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171BAC - - thumb_func_start sub_8171CAC -sub_8171CAC: @ 8171CAC - push {r4,lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x24] - ldrh r1, [r2, 0x20] - adds r0, r1 - movs r1, 0 - strh r0, [r2, 0x20] - ldrh r0, [r2, 0x26] - ldrh r3, [r2, 0x22] - adds r0, r3 - strh r0, [r2, 0x22] - strh r1, [r2, 0x26] - strh r1, [r2, 0x24] - ldr r4, =sub_8171CE8 - movs r3, 0 - movs r1, 0x5 - adds r0, r2, 0 - adds r0, 0x38 -_08171CD0: - strh r3, [r0] - subs r0, 0x2 - subs r1, 0x1 - cmp r1, 0 - bge _08171CD0 - str r4, [r2, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171CAC - - thumb_func_start sub_8171CE8 -sub_8171CE8: @ 8171CE8 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x80 - lsls r0, 4 - adds r2, r0, 0 - ldrh r1, [r4, 0x2E] - adds r2, r1 - movs r0, 0xD0 - lsls r0, 3 - adds r3, r0, 0 - ldrh r1, [r4, 0x30] - adds r3, r1 - lsls r1, r3, 16 - asrs r1, 24 - ldrh r0, [r4, 0x24] - subs r0, r1 - strh r0, [r4, 0x24] - lsls r0, r2, 16 - asrs r0, 24 - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - movs r0, 0xFF - ands r2, r0 - strh r2, [r4, 0x2E] - ands r3, r0 - strh r3, [r4, 0x30] - movs r2, 0x22 - ldrsh r0, [r4, r2] - movs r2, 0x26 - ldrsh r1, [r4, r2] - adds r0, r1 - cmp r0, 0xA0 - bgt _08171D3E - movs r1, 0x20 - ldrsh r0, [r4, r1] - movs r2, 0x24 - ldrsh r1, [r4, r2] - adds r0, r1 - movs r1, 0x8 - negs r1, r1 - cmp r0, r1 - bge _08171D52 -_08171D3E: - movs r0, 0 - strh r0, [r4, 0x2E] - ldr r0, =sub_81719C0 - str r0, [r4, 0x1C] - ldr r1, =gDoingBattleAnim - movs r0, 0 - strb r0, [r1] - movs r0, 0x1 - bl UpdateOamPriorityInAllHealthboxes -_08171D52: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171CE8 - - thumb_func_start sub_8171D60 -sub_8171D60: @ 8171D60 - push {r4,r5,lr} - lsls r0, 24 - ldr r1, =gUnknown_085E5094 - lsrs r5, r0, 21 - adds r4, r5, r1 - ldrh r0, [r4, 0x6] - bl GetSpriteTileStartByTag - lsls r0, 16 - ldr r1, =0xffff0000 - cmp r0, r1 - bne _08171D86 - adds r0, r4, 0 - bl LoadCompressedObjectPicUsingHeap - ldr r0, =gUnknown_085E50F4 - adds r0, r5, r0 - bl LoadCompressedObjectPaletteUsingHeap -_08171D86: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171D60 - - thumb_func_start LaunchBallStarsTask -LaunchBallStarsTask: @ 8171D98 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - adds r6, r0, 0 - mov r8, r1 - mov r9, r2 - mov r10, r3 - ldr r5, [sp, 0x1C] - lsls r6, 24 - lsrs r6, 24 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - mov r1, r9 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - mov r0, r10 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - lsls r5, 24 - lsrs r5, 24 - adds r0, r5, 0 - bl sub_8171D60 - ldr r1, =gUnknown_085E51C0 - lsls r0, r5, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x5 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - strh r6, [r0, 0xA] - mov r1, r8 - strh r1, [r0, 0xC] - mov r1, r9 - strh r1, [r0, 0xE] - mov r1, r10 - strh r1, [r0, 0x10] - strh r5, [r0, 0x26] - movs r0, 0xF - bl PlaySE - adds r0, r4, 0 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end LaunchBallStarsTask - - thumb_func_start sub_8171E20 -sub_8171E20: @ 8171E20 - push {lr} - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08171E3E - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r1, [r0, 0x8] - ldrb r0, [r1, 0xA] - adds r0, 0x1 - strb r0, [r1, 0xA] -_08171E3E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171E20 - - thumb_func_start sub_8171E50 -sub_8171E50: @ 8171E50 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r1, =gTasks - lsls r0, 2 - add r0, r8 - lsls r0, 3 - adds r6, r0, r1 - ldrh r0, [r6, 0x26] - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - movs r2, 0x8 - ldrsh r0, [r6, r2] - adds r2, r1, 0 - cmp r0, 0xF - bgt _08171F48 - ldrb r1, [r6, 0xA] - ldrb r2, [r6, 0xC] - ldrb r4, [r6, 0xE] - mov r9, r4 - ldrb r3, [r6, 0x10] - ldr r4, [sp] - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 3 - ldr r4, =gUnknown_085E51F0 - adds r0, r4 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - cmp r0, 0x40 - beq _08171EEC - bl sub_8171E20 - mov r0, r10 - lsls r4, r0, 4 - add r4, r10 - lsls r4, 2 - ldr r5, =gSprites - adds r7, r4, r5 - ldr r0, =gUnknown_085E51B4 - ldr r1, [sp] - adds r0, r1, r0 - ldrb r1, [r0] - adds r0, r7, 0 - bl StartSpriteAnim - adds r5, 0x1C - adds r4, r5 - ldr r0, =sub_8171F68 - str r0, [r4] - movs r0, 0x3 - mov r2, r9 - ands r2, r0 - lsls r2, 2 - ldrb r1, [r7, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r1 - orrs r0, r2 - strb r0, [r7, 0x5] - ldrb r0, [r6, 0x8] - cmp r0, 0x7 - bls _08171EE8 - subs r0, 0x8 - lsls r0, 24 - lsrs r0, 24 -_08171EE8: - lsls r0, 5 - strh r0, [r7, 0x2E] -_08171EEC: - ldr r0, =gTasks - mov r4, r8 - lsls r1, r4, 2 - add r1, r8 - lsls r1, 3 - adds r1, r0 - movs r2, 0x8 - ldrsh r1, [r1, r2] - adds r2, r0, 0 - cmp r1, 0xF - bne _08171F48 - ldr r0, =gMain - ldr r4, =0x00000439 - adds r0, r4 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08171F22 - ldr r0, =gSprites - mov r2, r10 - lsls r1, r2, 4 - add r1, r10 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_08171F22: - mov r0, r8 - bl DestroyTask - b _08171F58 - .pool -_08171F48: - mov r4, r8 - lsls r0, r4, 2 - add r0, r8 - lsls r0, 3 - adds r0, r2 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] -_08171F58: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8171E50 - - thumb_func_start sub_8171F68 -sub_8171F68: @ 8171F68 - push {lr} - adds r1, r0, 0 - ldrh r2, [r1, 0x30] - movs r3, 0x30 - ldrsh r0, [r1, r3] - cmp r0, 0 - bne _08171F80 - ldr r0, =sub_8171F88 - str r0, [r1, 0x1C] - b _08171F84 - .pool -_08171F80: - subs r0, r2, 0x1 - strh r0, [r1, 0x30] -_08171F84: - pop {r0} - bx r0 - thumb_func_end sub_8171F68 - - thumb_func_start sub_8171F88 -sub_8171F88: @ 8171F88 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r2, 0x30 - ldrsh r1, [r4, r2] - bl Sin - strh r0, [r4, 0x24] - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r2, 0x30 - ldrsh r1, [r4, r2] - bl Cos - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x30] - adds r0, 0x2 - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x32 - bne _08171FBC - adds r0, r4, 0 - bl sub_8172944 -_08171FBC: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8171F88 - - thumb_func_start sub_8171FC4 -sub_8171FC4: @ 8171FC4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r0, =gTasks - mov r2, r9 - lsls r1, r2, 2 - add r1, r9 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x26] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldrb r3, [r1, 0xA] - str r3, [sp] - ldrb r0, [r1, 0xC] - str r0, [sp, 0x4] - ldrb r2, [r1, 0xE] - str r2, [sp, 0x8] - ldrb r1, [r1, 0x10] - str r1, [sp, 0xC] - movs r7, 0 - ldr r3, =gSprites - mov r10, r3 - mov r1, r8 - lsls r0, r1, 1 - add r0, r8 - lsls r0, 3 - str r0, [sp, 0x10] -_0817200A: - ldr r0, =gUnknown_085E51F0 - ldr r2, [sp, 0x10] - adds r0, r2, r0 - ldr r1, [sp] - ldr r2, [sp, 0x4] - ldr r3, [sp, 0xC] - bl CreateSprite - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _0817206A - bl sub_8171E20 - lsls r4, r6, 4 - adds r4, r6 - lsls r4, 2 - mov r3, r10 - adds r5, r4, r3 - ldr r0, =gUnknown_085E51B4 - add r0, r8 - ldrb r1, [r0] - adds r0, r5, 0 - bl StartSpriteAnim - ldr r0, =gSprites + 0x1C - adds r4, r0 - ldr r0, =sub_8172508 - str r0, [r4] - movs r0, 0x3 - ldr r2, [sp, 0x8] - ands r2, r0 - lsls r2, 2 - ldrb r0, [r5, 0x5] - movs r3, 0xD - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x5] - lsls r0, r7, 5 - strh r0, [r5, 0x2E] - movs r0, 0xA - strh r0, [r5, 0x36] - movs r0, 0x2 - strh r0, [r5, 0x38] - movs r0, 0x1 - strh r0, [r5, 0x3A] -_0817206A: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x7 - bls _0817200A - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08172092 - ldr r0, =gSprites - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_08172092: - mov r0, r9 - bl DestroyTask - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8171FC4 - - thumb_func_start sub_81720C8 -sub_81720C8: @ 81720C8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r0, =gTasks - mov r2, r9 - lsls r1, r2, 2 - add r1, r9 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x26] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldrb r3, [r1, 0xA] - str r3, [sp] - ldrb r0, [r1, 0xC] - str r0, [sp, 0x4] - ldrb r2, [r1, 0xE] - str r2, [sp, 0x8] - ldrb r1, [r1, 0x10] - str r1, [sp, 0xC] - movs r7, 0 - ldr r3, =gSprites - mov r10, r3 - mov r1, r8 - lsls r0, r1, 1 - add r0, r8 - lsls r0, 3 - str r0, [sp, 0x10] -_0817210E: - ldr r0, =gUnknown_085E51F0 - ldr r2, [sp, 0x10] - adds r0, r2, r0 - ldr r1, [sp] - ldr r2, [sp, 0x4] - ldr r3, [sp, 0xC] - bl CreateSprite - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _0817216E - bl sub_8171E20 - lsls r4, r6, 4 - adds r4, r6 - lsls r4, 2 - mov r3, r10 - adds r5, r4, r3 - ldr r0, =gUnknown_085E51B4 - add r0, r8 - ldrb r1, [r0] - adds r0, r5, 0 - bl StartSpriteAnim - ldr r0, =gSprites + 0x1C - adds r4, r0 - ldr r0, =sub_8172508 - str r0, [r4] - movs r0, 0x3 - ldr r2, [sp, 0x8] - ands r2, r0 - lsls r2, 2 - ldrb r0, [r5, 0x5] - movs r3, 0xD - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x5] - lsls r0, r7, 5 - strh r0, [r5, 0x2E] - movs r0, 0xA - strh r0, [r5, 0x36] - movs r0, 0x1 - strh r0, [r5, 0x38] - movs r0, 0x2 - strh r0, [r5, 0x3A] -_0817216E: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x7 - bls _0817210E - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08172196 - ldr r0, =gSprites - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_08172196: - mov r0, r9 - bl DestroyTask - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81720C8 - - thumb_func_start sub_81721CC -sub_81721CC: @ 81721CC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r1, =gTasks - lsls r0, 2 - add r0, r9 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x26] - lsls r1, 24 - lsrs r1, 24 - ldrb r2, [r0, 0xA] - str r2, [sp] - ldrb r3, [r0, 0xC] - str r3, [sp, 0x4] - ldrb r2, [r0, 0xE] - str r2, [sp, 0x8] - ldrb r0, [r0, 0x10] - str r0, [sp, 0xC] - movs r7, 0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - str r0, [sp, 0x10] - ldr r3, =gSprites - mov r8, r3 - ldr r0, =gUnknown_085E51B4 - adds r1, r0 - mov r10, r1 -_08172212: - ldr r0, =gUnknown_085E51F0 - ldr r1, [sp, 0x10] - adds r0, r1, r0 - ldr r1, [sp] - ldr r2, [sp, 0x4] - ldr r3, [sp, 0xC] - bl CreateSprite - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _0817226E - bl sub_8171E20 - lsls r4, r6, 4 - adds r4, r6 - lsls r4, 2 - mov r2, r8 - adds r5, r4, r2 - mov r3, r10 - ldrb r1, [r3] - adds r0, r5, 0 - bl StartSpriteAnim - ldr r0, =gSprites + 0x1C - adds r4, r0 - ldr r0, =sub_8172508 - str r0, [r4] - movs r0, 0x3 - ldr r2, [sp, 0x8] - ands r2, r0 - lsls r2, 2 - ldrb r0, [r5, 0x5] - movs r3, 0xD - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x5] - lsls r0, r7, 5 - strh r0, [r5, 0x2E] - movs r0, 0x4 - strh r0, [r5, 0x36] - movs r0, 0x1 - strh r0, [r5, 0x38] - strh r0, [r5, 0x3A] -_0817226E: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x7 - bls _08172212 - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08172296 - ldr r0, =gSprites - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_08172296: - mov r0, r9 - bl DestroyTask - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81721CC - - thumb_func_start sub_81722CC -sub_81722CC: @ 81722CC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r0, =gTasks - mov r2, r9 - lsls r1, r2, 2 - add r1, r9 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x26] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldrb r3, [r1, 0xA] - str r3, [sp] - ldrb r0, [r1, 0xC] - str r0, [sp, 0x4] - ldrb r2, [r1, 0xE] - str r2, [sp, 0x8] - ldrb r1, [r1, 0x10] - str r1, [sp, 0xC] - movs r7, 0 - ldr r3, =gSprites - mov r10, r3 - mov r1, r8 - lsls r0, r1, 1 - add r0, r8 - lsls r0, 3 - str r0, [sp, 0x10] -_08172312: - ldr r0, =gUnknown_085E51F0 - ldr r2, [sp, 0x10] - adds r0, r2, r0 - ldr r1, [sp] - ldr r2, [sp, 0x4] - ldr r3, [sp, 0xC] - bl CreateSprite - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _08172376 - bl sub_8171E20 - lsls r4, r6, 4 - adds r4, r6 - lsls r4, 2 - mov r3, r10 - adds r5, r4, r3 - ldr r0, =gUnknown_085E51B4 - add r0, r8 - ldrb r1, [r0] - adds r0, r5, 0 - bl StartSpriteAnim - ldr r0, =gSprites + 0x1C - adds r4, r0 - ldr r0, =sub_8172508 - str r0, [r4] - movs r0, 0x3 - ldr r2, [sp, 0x8] - ands r2, r0 - lsls r2, 2 - ldrb r0, [r5, 0x5] - movs r3, 0xD - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x5] - lsls r0, r7, 1 - adds r0, r7 - lsls r0, 3 - adds r0, r7 - strh r0, [r5, 0x2E] - movs r0, 0x5 - strh r0, [r5, 0x36] - movs r0, 0x1 - strh r0, [r5, 0x38] - strh r0, [r5, 0x3A] -_08172376: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x9 - bls _08172312 - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0817239E - ldr r0, =gSprites - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_0817239E: - mov r0, r9 - bl DestroyTask - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81722CC - - thumb_func_start sub_81723D4 -sub_81723D4: @ 81723D4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r1, =gTasks - lsls r2, r0, 2 - adds r0, r2, r0 - lsls r0, 3 - adds r3, r0, r1 - ldrh r1, [r3, 0x16] - movs r4, 0x16 - ldrsh r0, [r3, r4] - cmp r0, 0 - beq _08172404 - subs r0, r1, 0x1 - strh r0, [r3, 0x16] - b _081724D6 - .pool -_08172404: - ldrh r0, [r3, 0x26] - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r3, 0xA] - str r1, [sp] - ldrb r4, [r3, 0xC] - str r4, [sp, 0x4] - ldrb r1, [r3, 0xE] - str r1, [sp, 0x8] - ldrb r3, [r3, 0x10] - str r3, [sp, 0xC] - movs r7, 0 - str r2, [sp, 0x14] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 3 - str r1, [sp, 0x10] - ldr r3, =gSprites - mov r9, r3 - ldr r1, =gUnknown_085E51B4 - adds r0, r1 - mov r10, r0 -_08172430: - ldr r0, =gUnknown_085E51F0 - ldr r4, [sp, 0x10] - adds r0, r4, r0 - ldr r1, [sp] - ldr r2, [sp, 0x4] - ldr r3, [sp, 0xC] - bl CreateSprite - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _0817248C - bl sub_8171E20 - lsls r4, r6, 4 - adds r4, r6 - lsls r4, 2 - mov r0, r9 - adds r5, r4, r0 - mov r3, r10 - ldrb r1, [r3] - adds r0, r5, 0 - bl StartSpriteAnim - ldr r0, =gSprites + 0x1C - adds r4, r0 - ldr r0, =sub_8172508 - str r0, [r4] - movs r0, 0x3 - ldr r2, [sp, 0x8] - ands r2, r0 - lsls r2, 2 - ldrb r0, [r5, 0x5] - movs r3, 0xD - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x5] - lsls r0, r7, 5 - strh r0, [r5, 0x2E] - movs r0, 0x8 - strh r0, [r5, 0x36] - movs r0, 0x2 - strh r0, [r5, 0x38] - strh r0, [r5, 0x3A] -_0817248C: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x7 - bls _08172430 - ldr r0, =gTasks - ldr r1, [sp, 0x14] - add r1, r8 - lsls r1, 3 - adds r1, r0 - movs r0, 0x8 - strh r0, [r1, 0x16] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - lsls r0, 16 - asrs r2, r0, 16 - cmp r2, 0x2 - bne _081724D6 - ldr r0, =gMain - ldr r4, =0x00000439 - adds r0, r4 - ldrb r1, [r0] - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _081724D0 - ldr r0, =gSprites - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_081724D0: - mov r0, r8 - bl DestroyTask -_081724D6: - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81723D4 - - thumb_func_start sub_8172508 -sub_8172508: @ 8172508 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r2, 0x30 - ldrsh r1, [r4, r2] - bl Sin - strh r0, [r4, 0x24] - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r2, 0x32 - ldrsh r1, [r4, r2] - bl Cos - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x36] - ldrh r1, [r4, 0x2E] - adds r0, r1 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x2E] - ldrh r0, [r4, 0x38] - ldrh r2, [r4, 0x30] - adds r0, r2 - strh r0, [r4, 0x30] - ldrh r0, [r4, 0x3A] - ldrh r1, [r4, 0x32] - adds r0, r1 - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x34] - adds r0, 0x1 - strh r0, [r4, 0x34] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x33 - bne _08172558 - adds r0, r4, 0 - bl sub_8172944 -_08172558: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8172508 - - thumb_func_start sub_8172560 -sub_8172560: @ 8172560 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r1, =gTasks - lsls r0, 2 - add r0, r9 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x26] - lsls r1, 24 - lsrs r1, 24 - ldrb r2, [r0, 0xA] - str r2, [sp] - ldrb r3, [r0, 0xC] - str r3, [sp, 0x4] - ldrb r2, [r0, 0xE] - str r2, [sp, 0x8] - ldrb r0, [r0, 0x10] - str r0, [sp, 0xC] - movs r7, 0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - str r0, [sp, 0x10] - ldr r3, =gSprites - mov r8, r3 - ldr r0, =gUnknown_085E51B4 - adds r1, r0 - mov r10, r1 -_081725A6: - ldr r0, =gUnknown_085E51F0 - ldr r1, [sp, 0x10] - adds r0, r1, r0 - ldr r1, [sp] - ldr r2, [sp, 0x4] - ldr r3, [sp, 0xC] - bl CreateSprite - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _081725FE - bl sub_8171E20 - lsls r4, r6, 4 - adds r4, r6 - lsls r4, 2 - mov r2, r8 - adds r5, r4, r2 - mov r3, r10 - ldrb r1, [r3] - adds r0, r5, 0 - bl StartSpriteAnim - ldr r0, =gSprites + 0x1C - adds r4, r0 - ldr r0, =sub_817265C - str r0, [r4] - movs r0, 0x3 - ldr r2, [sp, 0x8] - ands r2, r0 - lsls r2, 2 - ldrb r0, [r5, 0x5] - movs r3, 0xD - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x5] - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 2 - adds r0, r7 - strh r0, [r5, 0x2E] -_081725FE: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0xB - bls _081725A6 - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08172626 - ldr r0, =gSprites - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_08172626: - mov r0, r9 - bl DestroyTask - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172560 - - thumb_func_start sub_817265C -sub_817265C: @ 817265C - push {r4,r5,lr} - adds r5, r0, 0 - movs r1, 0x2E - ldrsh r0, [r5, r1] - movs r2, 0x30 - ldrsh r1, [r5, r2] - bl Sin - strh r0, [r5, 0x24] - movs r0, 0x2E - ldrsh r4, [r5, r0] - movs r2, 0x32 - ldrsh r1, [r5, r2] - adds r0, r4, 0 - bl Sin - adds r1, r0, 0 - lsls r1, 16 - asrs r1, 16 - adds r0, r4, 0 - bl Cos - strh r0, [r5, 0x26] - ldrh r0, [r5, 0x2E] - adds r0, 0x6 - movs r1, 0xFF - ands r0, r1 - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x30] - adds r0, 0x1 - strh r0, [r5, 0x30] - ldrh r0, [r5, 0x32] - adds r0, 0x1 - strh r0, [r5, 0x32] - ldrh r0, [r5, 0x34] - adds r0, 0x1 - strh r0, [r5, 0x34] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x33 - bne _081726B4 - adds r0, r5, 0 - bl sub_8172944 -_081726B4: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_817265C - - thumb_func_start sub_81726BC -sub_81726BC: @ 81726BC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - ldr r0, =gTasks - ldr r2, [sp] - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x26] - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldrb r3, [r1, 0xA] - str r3, [sp, 0x4] - ldrb r0, [r1, 0xC] - str r0, [sp, 0x8] - ldrb r2, [r1, 0xE] - str r2, [sp, 0xC] - ldrb r1, [r1, 0x10] - str r1, [sp, 0x10] - movs r3, 0 - mov r8, r3 - mov r1, r9 - lsls r0, r1, 1 - add r0, r9 - lsls r0, 3 - str r0, [sp, 0x14] -_08172700: - movs r7, 0 - movs r2, 0x1 - add r2, r8 - mov r10, r2 -_08172708: - ldr r0, =gUnknown_085E51F0 - ldr r3, [sp, 0x14] - adds r0, r3, r0 - ldr r1, [sp, 0x4] - ldr r2, [sp, 0x8] - ldr r3, [sp, 0x10] - bl CreateSprite - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _08172790 - bl sub_8171E20 - lsls r4, r6, 4 - adds r4, r6 - lsls r4, 2 - ldr r0, =gSprites - adds r5, r4, r0 - ldr r0, =gUnknown_085E51B4 - add r0, r9 - ldrb r1, [r0] - adds r0, r5, 0 - bl StartSpriteAnim - ldr r1, =gSprites + 0x1C - adds r4, r1 - ldr r0, =sub_8172508 - str r0, [r4] - movs r0, 0x3 - ldr r1, [sp, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r0, [r5, 0x5] - movs r3, 0xD - negs r3, r3 - adds r2, r3, 0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x5] - lsls r0, r7, 5 - strh r0, [r5, 0x2E] - movs r0, 0x8 - strh r0, [r5, 0x36] - mov r0, r8 - cmp r0, 0 - bne _08172788 - movs r0, 0x2 - strh r0, [r5, 0x38] - movs r0, 0x1 - b _0817278E - .pool -_08172788: - movs r0, 0x1 - strh r0, [r5, 0x38] - movs r0, 0x2 -_0817278E: - strh r0, [r5, 0x3A] -_08172790: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x7 - bls _08172708 - mov r1, r10 - lsls r0, r1, 24 - lsrs r0, 24 - mov r8, r0 - cmp r0, 0x1 - bls _08172700 - ldr r0, =gMain - ldr r2, =0x00000439 - adds r0, r2 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _081727C4 - ldr r0, =gSprites - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_081727C4: - ldr r0, [sp] - bl DestroyTask - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81726BC - - thumb_func_start sub_81727E8 -sub_81727E8: @ 81727E8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r1, =gTasks - lsls r0, 2 - add r0, r9 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x26] - lsls r1, 24 - lsrs r1, 24 - ldrb r2, [r0, 0xA] - str r2, [sp] - ldrb r3, [r0, 0xC] - str r3, [sp, 0x4] - ldrb r2, [r0, 0xE] - str r2, [sp, 0x8] - ldrb r0, [r0, 0x10] - str r0, [sp, 0xC] - movs r7, 0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - str r0, [sp, 0x10] - ldr r3, =gSprites - mov r8, r3 - ldr r0, =gUnknown_085E51B4 - adds r1, r0 - mov r10, r1 -_0817282E: - ldr r0, =gUnknown_085E51F0 - ldr r1, [sp, 0x10] - adds r0, r1, r0 - ldr r1, [sp] - ldr r2, [sp, 0x4] - ldr r3, [sp, 0xC] - bl CreateSprite - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _08172880 - bl sub_8171E20 - lsls r4, r6, 4 - adds r4, r6 - lsls r4, 2 - mov r2, r8 - adds r5, r4, r2 - mov r3, r10 - ldrb r1, [r3] - adds r0, r5, 0 - bl StartSpriteAnim - ldr r0, =gSprites + 0x1C - adds r4, r0 - ldr r0, =sub_81728E0 - str r0, [r4] - movs r0, 0x3 - ldr r2, [sp, 0x8] - ands r2, r0 - lsls r2, 2 - ldrb r0, [r5, 0x5] - movs r3, 0xD - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x5] - lsls r0, r7, 5 - strh r0, [r5, 0x2E] -_08172880: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x7 - bls _0817282E - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _081728A8 - ldr r0, =gSprites - lsls r1, r6, 4 - adds r1, r6 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] -_081728A8: - mov r0, r9 - bl DestroyTask - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81727E8 - - thumb_func_start sub_81728E0 -sub_81728E0: @ 81728E0 - push {r4,r5,lr} - adds r5, r0, 0 - movs r1, 0x2E - ldrsh r0, [r5, r1] - movs r2, 0x30 - ldrsh r1, [r5, r2] - bl Sin - strh r0, [r5, 0x24] - movs r0, 0x2E - ldrsh r4, [r5, r0] - ldrh r1, [r5, 0x2E] - movs r0, 0x3F - ands r0, r1 - movs r2, 0x32 - ldrsh r1, [r5, r2] - bl Sin - adds r1, r0, 0 - lsls r1, 16 - asrs r1, 16 - adds r0, r4, 0 - bl Cos - strh r0, [r5, 0x26] - ldrh r0, [r5, 0x2E] - adds r0, 0xA - movs r1, 0xFF - ands r0, r1 - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x30] - adds r0, 0x1 - strh r0, [r5, 0x30] - ldrh r0, [r5, 0x32] - adds r0, 0x1 - strh r0, [r5, 0x32] - ldrh r0, [r5, 0x34] - adds r0, 0x1 - strh r0, [r5, 0x34] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x33 - bne _0817293C - adds r0, r5, 0 - bl sub_8172944 -_0817293C: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81728E0 - - thumb_func_start sub_8172944 -sub_8172944: @ 8172944 - push {r4-r7,lr} - adds r7, r0, 0 - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08172970 - movs r1, 0x3C - ldrsh r0, [r7, r1] - cmp r0, 0x1 - bne _081729CA - adds r0, r7, 0 - bl DestroySpriteAndFreeResources - b _081729E2 - .pool -_08172970: - ldr r2, =gBattleSpritesDataPtr - ldr r0, [r2] - ldr r1, [r0, 0x8] - ldrb r0, [r1, 0xA] - subs r0, 0x1 - strb r0, [r1, 0xA] - ldr r0, [r2] - ldr r0, [r0, 0x8] - ldrb r0, [r0, 0xA] - cmp r0, 0 - bne _081729DC - movs r4, 0 - ldr r5, =gUnknown_085E51C0 - b _08172998 - .pool -_08172994: - adds r5, 0x4 - adds r4, 0x1 -_08172998: - cmp r4, 0xB - bgt _081729AA - ldr r0, [r5] - bl FuncIsActiveTask - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08172994 -_081729AA: - cmp r4, 0xC - bne _081729CA - movs r6, 0 - ldr r5, =gUnknown_085E5094 - ldr r4, =gUnknown_085E50F4 -_081729B4: - ldrh r0, [r5, 0x6] - bl FreeSpriteTilesByTag - ldrh r0, [r4, 0x4] - bl FreeSpritePaletteByTag - adds r5, 0x8 - adds r4, 0x8 - adds r6, 0x1 - cmp r6, 0xB - ble _081729B4 -_081729CA: - adds r0, r7, 0 - bl DestroySprite - b _081729E2 - .pool -_081729DC: - adds r0, r7, 0 - bl DestroySprite -_081729E2: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8172944 - - thumb_func_start LaunchBallFadeMonTask -LaunchBallFadeMonTask: @ 81729E8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - adds r4, r0, 0 - mov r9, r2 - lsls r4, 24 - lsrs r4, 24 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r3, 24 - lsrs r7, r3, 24 - ldr r0, =sub_8172AB0 - movs r1, 0x5 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r1, =gTasks - lsls r0, 2 - add r0, r8 - lsls r0, 3 - adds r5, r0, r1 - strh r7, [r5, 0x26] - strh r6, [r5, 0xE] - mov r0, r9 - strh r0, [r5, 0x1C] - mov r1, r9 - lsrs r0, r1, 16 - strh r0, [r5, 0x1E] - cmp r4, 0 - bne _08172A58 - lsls r0, r6, 20 - movs r2, 0x80 - lsls r2, 17 - adds r0, r2 - lsrs r0, 16 - ldr r2, =gUnknown_085E5310 - lsls r1, r7, 1 - adds r1, r2 - ldrh r3, [r1] - movs r1, 0x10 - movs r2, 0 - bl BlendPalette - movs r0, 0x1 - strh r0, [r5, 0xA] - b _08172A7E - .pool -_08172A58: - lsls r0, r6, 20 - movs r1, 0x80 - lsls r1, 17 - adds r0, r1 - lsrs r0, 16 - ldr r2, =gUnknown_085E5310 - lsls r1, r7, 1 - adds r1, r2 - ldrh r3, [r1] - movs r1, 0x10 - movs r2, 0x10 - bl BlendPalette - movs r0, 0x10 - strh r0, [r5, 0x8] - ldr r0, =0x0000ffff - strh r0, [r5, 0xA] - ldr r0, =sub_8172B40 - str r0, [r5] -_08172A7E: - ldr r0, =0x00007fff - str r0, [sp] - mov r0, r9 - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - mov r0, r8 - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end LaunchBallFadeMonTask - - thumb_func_start sub_8172AB0 -sub_8172AB0: @ 8172AB0 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - adds r5, r0, 0 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r1, r0, 24 - movs r2, 0xC - ldrsh r0, [r4, r2] - cmp r0, 0x10 - bgt _08172B08 - movs r2, 0xE - ldrsh r0, [r4, r2] - lsls r0, 20 - movs r2, 0x80 - lsls r2, 17 - adds r0, r2 - lsrs r0, 16 - ldrb r2, [r4, 0x8] - ldr r3, =gUnknown_085E5310 - lsls r1, 1 - adds r1, r3 - ldrh r3, [r1] - movs r1, 0x10 - bl BlendPalette - ldrh r0, [r4, 0xA] - ldrh r1, [r4, 0x8] - adds r0, r1 - strh r0, [r4, 0x8] - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - b _08172B30 - .pool -_08172B08: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08172B30 - ldrh r0, [r4, 0x1C] - ldrh r1, [r4, 0x1E] - lsls r1, 16 - orrs r0, r1 - ldr r1, =0x00007fff - str r1, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - adds r0, r5, 0 - bl DestroyTask -_08172B30: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172AB0 - - thumb_func_start sub_8172B40 -sub_8172B40: @ 8172B40 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08172B78 - ldr r0, =gTasks - lsls r4, r2, 2 - adds r4, r2 - lsls r4, 3 - adds r4, r0 - ldrh r0, [r4, 0x1C] - ldrh r1, [r4, 0x1E] - lsls r1, 16 - orrs r0, r1 - ldr r1, =0x00007fff - str r1, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =sub_8172B90 - str r0, [r4] -_08172B78: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172B40 - - thumb_func_start sub_8172B90 -sub_8172B90: @ 8172B90 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r4, r0, r1 - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r1, r0, 24 - movs r3, 0xC - ldrsh r0, [r4, r3] - cmp r0, 0x10 - bgt _08172BE4 - movs r2, 0xE - ldrsh r0, [r4, r2] - lsls r0, 20 - movs r3, 0x80 - lsls r3, 17 - adds r0, r3 - lsrs r0, 16 - ldrb r2, [r4, 0x8] - ldr r3, =gUnknown_085E5310 - lsls r1, 1 - adds r1, r3 - ldrh r3, [r1] - movs r1, 0x10 - bl BlendPalette - ldrh r0, [r4, 0xA] - ldrh r1, [r4, 0x8] - adds r0, r1 - strh r0, [r4, 0x8] - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - b _08172BEA - .pool -_08172BE4: - adds r0, r2, 0 - bl DestroyTask -_08172BEA: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8172B90 - - thumb_func_start sub_8172BF0 -sub_8172BF0: @ 8172BF0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r7, r0, 24 - movs r0, 0 - mov r8, r0 - ldr r0, =gBattlerSpriteIds - ldr r3, =gBattleAnimAttacker - ldrb r2, [r3] - adds r0, r2, r0 - ldrb r6, [r0] - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r5, r0, r1 - movs r1, 0x1C - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _08172CC8 - cmp r0, 0x1 - bgt _08172C30 - cmp r0, 0 - beq _08172C36 - b _08172D8A - .pool -_08172C30: - cmp r0, 0x2 - beq _08172CDA - b _08172D8A -_08172C36: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0] - strh r0, [r5, 0x1E] - movs r2, 0xA0 - lsls r2, 3 - adds r0, r2, 0 - ldrh r4, [r5, 0x8] - adds r0, r4 - strh r0, [r5, 0x8] - ldrb r0, [r3] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08172C78 - ldr r2, =gSprites - lsls r3, r6, 4 - adds r1, r3, r6 - lsls r1, 2 - adds r1, r2 - ldrh r0, [r5, 0x8] - lsls r0, 16 - asrs r0, 24 - ldrh r4, [r1, 0x24] - adds r0, r4 - strh r0, [r1, 0x24] - adds r4, r3, 0 - b _08172C90 - .pool -_08172C78: - ldr r3, =gSprites - lsls r4, r6, 4 - adds r2, r4, r6 - lsls r2, 2 - adds r2, r3 - ldrh r1, [r5, 0x8] - lsls r1, 16 - asrs r1, 24 - ldrh r0, [r2, 0x24] - subs r0, r1 - strh r0, [r2, 0x24] - adds r2, r3, 0 -_08172C90: - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r3, r0, r1 - ldrb r0, [r3, 0x8] - strh r0, [r3, 0x8] - adds r0, r4, r6 - lsls r0, 2 - adds r0, r2 - movs r2, 0x20 - ldrsh r1, [r0, r2] - movs r4, 0x24 - ldrsh r0, [r0, r4] - adds r1, r0 - adds r1, 0x20 - movs r0, 0x98 - lsls r0, 1 - cmp r1, r0 - bls _08172D8A - ldrh r0, [r3, 0x1C] - adds r0, 0x1 - strh r0, [r3, 0x1C] - b _08172D8A - .pool -_08172CC8: - ldrb r1, [r5, 0x1E] - adds r0, r2, 0 - adds r2, r6, 0 - bl LoadBattleMonGfxAndAnimate - ldrh r0, [r5, 0x1C] - adds r0, 0x1 - strh r0, [r5, 0x1C] - b _08172D8A -_08172CDA: - movs r1, 0xA0 - lsls r1, 3 - adds r0, r1, 0 - ldrh r2, [r5, 0x8] - adds r0, r2 - strh r0, [r5, 0x8] - ldrb r0, [r3] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08172D10 - ldr r0, =gSprites - lsls r3, r6, 4 - adds r2, r3, r6 - lsls r2, 2 - adds r2, r0 - ldrh r1, [r5, 0x8] - lsls r1, 16 - asrs r1, 24 - ldrh r0, [r2, 0x24] - subs r0, r1 - strh r0, [r2, 0x24] - adds r4, r3, 0 - b _08172D28 - .pool -_08172D10: - ldr r0, =gSprites - lsls r2, r6, 4 - adds r1, r2, r6 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r5, 0x8] - lsls r0, 16 - asrs r0, 24 - ldrh r3, [r1, 0x24] - adds r0, r3 - strh r0, [r1, 0x24] - adds r4, r2, 0 -_08172D28: - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldrb r1, [r0, 0x8] - strh r1, [r0, 0x8] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - beq _08172D68 - ldr r0, =gSprites - adds r1, r4, r6 - lsls r1, 2 - adds r1, r0 - movs r4, 0x24 - ldrsh r0, [r1, r4] - cmp r0, 0 - bgt _08172D7E - movs r0, 0 - strh r0, [r1, 0x24] - b _08172D84 - .pool -_08172D68: - ldr r0, =gSprites - adds r1, r4, r6 - lsls r1, 2 - adds r1, r0 - movs r3, 0x24 - ldrsh r0, [r1, r3] - cmp r0, 0 - blt _08172D7E - strh r2, [r1, 0x24] - movs r4, 0x1 - mov r8, r4 -_08172D7E: - mov r0, r8 - cmp r0, 0 - beq _08172D8A -_08172D84: - adds r0, r7, 0 - bl DestroyAnimVisualTask -_08172D8A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172BF0 - - thumb_func_start sub_8172D98 -sub_8172D98: @ 8172D98 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x26 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08172E14 - cmp r0, 0x1 - bgt _08172DC0 - cmp r0, 0 - beq _08172DC6 - b _08172E84 - .pool -_08172DC0: - cmp r0, 0x2 - beq _08172E4E - b _08172E84 -_08172DC6: - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl sub_80A8364 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08172DE8 - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - b _08172DF0 - .pool -_08172DE8: - ldr r1, =0x00003f44 - movs r0, 0x50 - bl SetGpuReg -_08172DF0: - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x26] - adds r0, 0x1 - strh r0, [r1, 0x26] - b _08172E84 - .pool -_08172E14: - ldrh r0, [r4, 0xA] - adds r1, r0, 0x1 - strh r1, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _08172E84 - movs r0, 0 - strh r0, [r4, 0xA] - ldrh r2, [r4, 0x8] - adds r2, 0x1 - strh r2, [r4, 0x8] - lsls r1, r2, 8 - movs r0, 0x10 - subs r0, r2 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x10 - bne _08172E84 - ldrh r0, [r4, 0x26] - adds r0, 0x1 - strh r0, [r4, 0x26] - b _08172E84 -_08172E4E: - ldr r1, =gBattlerSpriteIds - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - adds r0, r1 - ldrb r1, [r0] - ldr r2, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x4] - lsls r1, 22 - lsrs r1, 17 - ldr r0, =0x06010000 - adds r1, r0 - movs r2, 0x80 - lsls r2, 4 - movs r0, 0 - movs r3, 0x1 - bl RequestDma3Fill - ldrb r0, [r4] - bl ClearBehindSubstituteBit - adds r0, r5, 0 - bl DestroyAnimVisualTask -_08172E84: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172D98 - - thumb_func_start sub_8172E9C -sub_8172E9C: @ 8172E9C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gBattleAnimArgs - ldr r1, =gBattleSpritesDataPtr - ldr r2, [r1] - ldr r1, =gBattleAnimAttacker - ldrb r1, [r1] - ldr r2, [r2] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - lsls r1, 29 - lsrs r1, 31 - strh r1, [r3, 0xE] - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172E9C - - thumb_func_start sub_8172ED0 -sub_8172ED0: @ 8172ED0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gBattleAnimTarget - ldr r1, =gEffectBattler - ldrb r1, [r1] - strb r1, [r2] - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172ED0 - - thumb_func_start sub_8172EF0 -sub_8172EF0: @ 8172EF0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r4, r1, 0 - lsls r0, 24 - lsrs r6, r0, 24 - movs r0, 0 - mov r8, r0 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r1, [r0, 0x4] - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0] - movs r2, 0x80 - orrs r1, r2 - strb r1, [r0] - adds r0, r4, 0 - movs r1, 0x1 - bl GetMonData - adds r5, r0, 0 - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - adds r4, r0, 0 - adds r0, r6, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _08172FC8 - lsrs r0, r5, 16 - ldr r7, =0x0000ffff - ands r5, r7 - eors r0, r5 - lsrs r1, r4, 16 - eors r0, r1 - ands r4, r7 - eors r0, r4 - cmp r0, 0x7 - bhi _08172F4E - movs r0, 0x1 - mov r8, r0 -_08172F4E: - mov r0, r8 - cmp r0, 0 - beq _08172FC8 - ldr r0, =0x000027f9 - bl GetSpriteTileStartByTag - lsls r0, 16 - lsrs r0, 16 - cmp r0, r7 - bne _08172F6E - ldr r0, =gBattleAnimPicTable + 0x748 - bl LoadCompressedObjectPicUsingHeap - ldr r0, =gBattleAnimPaletteTable + 0x748 - bl LoadCompressedObjectPaletteUsingHeap -_08172F6E: - ldr r5, =sub_8172FEC - adds r0, r5, 0 - movs r1, 0xA - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r5, 0 - movs r1, 0xA - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gTasks - lsls r2, r4, 2 - adds r2, r4 - lsls r2, 3 - adds r2, r3 - movs r4, 0 - strh r6, [r2, 0x8] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r3 - strh r6, [r1, 0x8] - strh r4, [r2, 0xA] - movs r0, 0x1 - strh r0, [r1, 0xA] - b _08172FDE - .pool -_08172FC8: - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r1, [r0, 0x4] - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x1] - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0, 0x1] -_08172FDE: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172EF0 - - thumb_func_start sub_8172FEC -sub_8172FEC: @ 8172FEC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r4, r0, r1 - ldrh r1, [r4, 0x22] - movs r2, 0x22 - ldrsh r0, [r4, r2] - cmp r0, 0x3B - bgt _08173018 - adds r0, r1, 0x1 - strh r0, [r4, 0x22] - b _08173190 - .pool -_08173018: - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - ldrb r0, [r0, 0xA] - cmp r0, 0 - beq _08173026 - b _08173190 -_08173026: - ldrh r0, [r4, 0x1C] - adds r1, r0, 0x1 - strh r1, [r4, 0x1C] - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - cmp r1, 0 - beq _0817303A - b _08173190 -_0817303A: - ldrb r0, [r4, 0x8] - mov r8, r0 - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r5, r0, 24 - mov r0, r8 - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r2, r0, 24 - movs r1, 0x1E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08173074 - ldr r0, =gUnknown_085CE388 - adds r1, r5, 0 - movs r3, 0x5 - bl CreateSprite - lsls r0, 24 - lsrs r5, r0, 24 - b _081730D6 - .pool -_08173074: - cmp r0, 0 - blt _081730A8 - cmp r0, 0x3 - bgt _081730A8 - ldr r0, =gUnknown_085CE3A0 - adds r1, r5, 0 - movs r3, 0x5 - bl CreateSprite - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gSprites - lsls r2, r5, 4 - adds r2, r5 - lsls r2, 2 - adds r2, r0 - ldrh r3, [r2, 0x4] - lsls r1, r3, 22 - lsrs r1, 22 - adds r1, 0x4 - b _081730C8 - .pool -_081730A8: - ldr r0, =gUnknown_085CE3A0 - adds r1, r5, 0 - movs r3, 0x5 - bl CreateSprite - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gSprites - lsls r2, r5, 4 - adds r2, r5 - lsls r2, 2 - adds r2, r0 - ldrh r3, [r2, 0x4] - lsls r1, r3, 22 - lsrs r1, 22 - adds r1, 0x5 -_081730C8: - ldr r4, =0x000003ff - adds r0, r4, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r1 - strh r0, [r2, 0x4] -_081730D6: - ldr r2, =gTasks - lsls r1, r7, 2 - adds r0, r1, r7 - lsls r0, 3 - adds r6, r0, r2 - movs r2, 0xA - ldrsh r0, [r6, r2] - mov r9, r1 - cmp r0, 0 - bne _08173118 - ldr r1, =gSprites - lsls r2, r5, 4 - adds r0, r2, r5 - lsls r0, 2 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_81731FC - str r1, [r0] - adds r4, r2, 0 - b _08173160 - .pool -_08173118: - ldr r3, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x1C - adds r0, r1, r0 - ldr r2, =sub_8173250 - str r2, [r0] - adds r1, r3 - ldr r0, =0x0000ffe0 - strh r0, [r1, 0x24] - movs r0, 0x20 - strh r0, [r1, 0x26] - adds r1, 0x3E - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] - movs r1, 0x1E - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _08173160 - mov r0, r8 - bl GetBattlerSide - lsls r0, 24 - movs r1, 0x3F - cmp r0, 0 - bne _08173156 - movs r1, 0xC0 -_08173156: - lsls r1, 24 - asrs r1, 24 - movs r0, 0x66 - bl PlaySE12WithPanning -_08173160: - ldr r1, =gSprites - adds r0, r4, r5 - lsls r0, 2 - adds r0, r1 - strh r7, [r0, 0x2E] - ldr r1, =gTasks - mov r2, r9 - adds r0, r2, r7 - lsls r0, 3 - adds r1, r0, r1 - ldrh r0, [r1, 0x1E] - adds r0, 0x1 - strh r0, [r1, 0x1E] - cmp r5, 0x40 - beq _08173184 - ldrh r0, [r1, 0x20] - adds r0, 0x1 - strh r0, [r1, 0x20] -_08173184: - movs r4, 0x1E - ldrsh r0, [r1, r4] - cmp r0, 0x5 - bne _08173190 - ldr r0, =sub_81731B0 - str r0, [r1] -_08173190: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8172FEC - - thumb_func_start sub_81731B0 -sub_81731B0: @ 81731B0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - adds r3, r0, 0 - ldr r1, =gTasks - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - adds r1, r0, r1 - movs r2, 0x20 - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _081731F0 - movs r2, 0xA - ldrsh r0, [r1, r2] - cmp r0, 0x1 - bne _081731EA - ldrb r1, [r1, 0x8] - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r2, [r0, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x1] - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0, 0x1] -_081731EA: - adds r0, r3, 0 - bl DestroyTask -_081731F0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81731B0 - - thumb_func_start sub_81731FC -sub_81731FC: @ 81731FC - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x30 - ldrsh r0, [r4, r1] - movs r1, 0x18 - bl Sin - strh r0, [r4, 0x24] - movs r1, 0x30 - ldrsh r0, [r4, r1] - movs r1, 0x18 - bl Cos - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x30] - adds r0, 0xC - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xFF - ble _08173246 - ldr r2, =gTasks - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x1 - strh r1, [r0, 0x20] - adds r0, r4, 0 - bl FreeSpriteOamMatrix - adds r0, r4, 0 - bl DestroySprite -_08173246: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81731FC - - thumb_func_start sub_8173250 -sub_8173250: @ 8173250 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x30] - movs r2, 0x30 - ldrsh r0, [r4, r2] - cmp r0, 0x3 - bgt _08173264 - adds r0, r1, 0x1 - strh r0, [r4, 0x30] - b _081732A6 -_08173264: - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - ldrh r1, [r4, 0x24] - adds r1, 0x5 - strh r1, [r4, 0x24] - ldrh r0, [r4, 0x26] - subs r0, 0x5 - strh r0, [r4, 0x26] - lsls r1, 16 - asrs r1, 16 - cmp r1, 0x20 - ble _081732A6 - ldr r2, =gTasks - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x1 - strh r1, [r0, 0x20] - adds r0, r4, 0 - bl FreeSpriteOamMatrix - adds r0, r4, 0 - bl DestroySprite -_081732A6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173250 - - thumb_func_start sub_81732B0 -sub_81732B0: @ 81732B0 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gBattleAnimPicTable + 0x868 - bl LoadCompressedObjectPicUsingHeap - ldr r0, =gBattleAnimPaletteTable + 0x868 - bl LoadCompressedObjectPaletteUsingHeap - ldr r0, =0x0000281d - bl IndexOfSpritePaletteTag - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81732B0 - - thumb_func_start sub_81732E4 -sub_81732E4: @ 81732E4 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =0x0000281d - adds r0, r5, 0 - bl FreeSpriteTilesByTag - adds r0, r5, 0 - bl FreeSpritePaletteByTag - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81732E4 - - thumb_func_start sub_817330C -sub_817330C: @ 817330C - push {r4,r5,lr} - adds r4, r0, 0 - movs r1, 0 - bl InitAnimSpritePos - movs r0, 0x1E - strh r0, [r4, 0x2E] - movs r0, 0x1 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - ldr r5, =gBattleAnimArgs - lsrs r0, 24 - ldrh r1, [r5, 0x4] - adds r0, r1 - strh r0, [r4, 0x32] - movs r0, 0x1 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r5, [r5, 0x6] - adds r0, r5 - strh r0, [r4, 0x36] - ldr r0, =0x0000ffe0 - strh r0, [r4, 0x38] - adds r0, r4, 0 - bl InitAnimArcTranslation - ldr r2, =gSprites - ldr r1, =gBattlerSpriteIds - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, 0x1C - adds r0, r2 - ldr r1, =sub_8039E84 - str r1, [r0] - ldr r0, =sub_817339C - str r0, [r4, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817330C - - thumb_func_start sub_817339C -sub_817339C: @ 817339C - push {lr} - adds r3, r0, 0 - ldr r2, =gSprites - ldr r1, =gBattlerSpriteIds - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x2B - ldrb r0, [r0] - cmp r0, 0x1 - bne _081733C0 - ldr r0, =sub_81733D4 - str r0, [r3, 0x1C] -_081733C0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_817339C - - thumb_func_start sub_81733D4 -sub_81733D4: @ 81733D4 - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _081733F6 - movs r0, 0 - strh r0, [r4, 0x2E] - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r0, =sub_8173400 - str r0, [r4, 0x1C] -_081733F6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81733D4 - - thumb_func_start sub_8173400 -sub_8173400: @ 8173400 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gSprites - ldr r3, =gBattlerSpriteIds - ldr r2, =gBattleAnimAttacker - ldrb r0, [r2] - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 27 - cmp r0, 0 - bge _08173448 - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - cmp r0, 0 - ble _08173448 - ldrb r0, [r2] - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r1, 0 - bl StartSpriteAnim - adds r0, r4, 0 - bl DestroyAnimSprite -_08173448: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173400 - - thumb_func_start sub_817345C -sub_817345C: @ 817345C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - beq _08173478 - cmp r0, 0x1 - beq _0817348C - b _081734A0 - .pool -_08173478: - movs r0, 0 - bl GetBattlerAtPosition - ldr r1, =gBattleAnimAttacker - strb r0, [r1] - movs r0, 0x1 - b _08173498 - .pool -_0817348C: - movs r0, 0x1 - bl GetBattlerAtPosition - ldr r1, =gBattleAnimAttacker - strb r0, [r1] - movs r0, 0 -_08173498: - bl GetBattlerAtPosition - ldr r1, =gBattleAnimTarget - strb r0, [r1] -_081734A0: - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817345C - - thumb_func_start AnimTask_GetTrappedMoveAnimId -AnimTask_GetTrappedMoveAnimId: @ 81734B4 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - ldrh r1, [r0] - cmp r1, 0x53 - bne _081734D4 - ldr r1, =gBattleAnimArgs - movs r0, 0x1 - b _0817350C - .pool -_081734D4: - cmp r1, 0xFA - bne _081734E4 - ldr r1, =gBattleAnimArgs - movs r0, 0x2 - b _0817350C - .pool -_081734E4: - cmp r1, 0x80 - bne _081734F4 - ldr r1, =gBattleAnimArgs - movs r0, 0x3 - b _0817350C - .pool -_081734F4: - movs r0, 0xA4 - lsls r0, 1 - cmp r1, r0 - bne _08173508 - ldr r1, =gBattleAnimArgs - movs r0, 0x4 - b _0817350C - .pool -_08173508: - ldr r1, =gBattleAnimArgs - movs r0, 0 -_0817350C: - strh r0, [r1] - adds r0, r2, 0 - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_GetTrappedMoveAnimId - - thumb_func_start sub_817351C -sub_817351C: @ 817351C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gBattleAnimAttacker - ldr r1, =gBattleSpritesDataPtr - ldr r2, [r1] - ldr r1, [r2, 0x8] - ldrh r1, [r1] - strb r1, [r3] - ldr r3, =gBattleAnimTarget - ldr r1, [r2, 0x8] - ldrh r1, [r1] - lsrs r1, 8 - strb r1, [r3] - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_817351C - - .align 2, 0 @ Don't pad with nop. diff --git a/common_syms/battle_anim_8170478.txt b/common_syms/battle_anim_8170478.txt new file mode 100755 index 000000000..2fc194df7 --- /dev/null +++ b/common_syms/battle_anim_8170478.txt @@ -0,0 +1,3 @@ +gUnknown_030062DC +gUnknown_030062E0 +gUnknown_030062E4 diff --git a/data/battle_anim_8170478.s b/data/battle_anim_8170478.s deleted file mode 100644 index 74bdce846..000000000 --- a/data/battle_anim_8170478.s +++ /dev/null @@ -1,157 +0,0 @@ -#include "constants/battle_anim.h" - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -gUnknown_085E5088:: @ 85E5088 - .byte 0x0a, 0x02, 0xfd, 0x00, 0x0f, 0x00, 0xfc, 0x00 - .byte 0xf6, 0x02, 0xfc, 0x00 - - .align 2 -gUnknown_085E5094:: @ 85E5094 - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6ec - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6ed - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6ee - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6ef - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6f0 - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6f1 - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6f2 - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6f3 - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6f4 - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6f5 - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6f6 - obj_tiles gBattleAnimSpriteSheet_Particles, 0x0100, 0xd6f7 - - .align 2 -gUnknown_085E50F4:: @ 85E50F4 - obj_pal gBattleAnimSpritePalette_136, 0xd6ec - obj_pal gBattleAnimSpritePalette_136, 0xd6ed - obj_pal gBattleAnimSpritePalette_136, 0xd6ee - obj_pal gBattleAnimSpritePalette_136, 0xd6ef - obj_pal gBattleAnimSpritePalette_136, 0xd6f0 - obj_pal gBattleAnimSpritePalette_136, 0xd6f1 - obj_pal gBattleAnimSpritePalette_136, 0xd6f2 - obj_pal gBattleAnimSpritePalette_136, 0xd6f3 - obj_pal gBattleAnimSpritePalette_136, 0xd6f4 - obj_pal gBattleAnimSpritePalette_136, 0xd6f5 - obj_pal gBattleAnimSpritePalette_136, 0xd6f6 - obj_pal gBattleAnimSpritePalette_136, 0xd6f7 - - .align 2 -gUnknown_085E5154:: @ 85E5154 - .2byte 0x0000, 0x0001, 0x0001, 0x0001 - .2byte 0x0002, 0x0001, 0x0000, 0x0041 - .2byte 0x0002, 0x0001, 0x0001, 0x0001 - .2byte 0xfffe, 0x0000 - - .align 2 -gUnknown_085E5170:: @ 85E5170 - .2byte 0x0003, 0x0001, 0xffff, 0x0000 - - .align 2 -gUnknown_085E5178:: @ 85E5178 - .2byte 0x0004, 0x0001, 0xffff, 0x0000 - - .align 2 -gUnknown_085E5180:: @ 85E5180 - .2byte 0x0005, 0x0001, 0xffff, 0x0000 - - .align 2 -gUnknown_085E5188:: @ 85E5188 - .2byte 0x0006, 0x0004, 0x0007, 0x0004 - .2byte 0xfffe, 0x0000 - - .align 2 -gUnknown_085E5194:: @ 85E5194 - .2byte 0x0007, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_085E519C:: @ 85E519C - .4byte gUnknown_085E5154 - .4byte gUnknown_085E5170 - .4byte gUnknown_085E5178 - .4byte gUnknown_085E5180 - .4byte gUnknown_085E5188 - .4byte gUnknown_085E5194 - - .align 2 -gUnknown_085E51B4:: @ 85E51B4 - .byte 0x00, 0x00, 0x00, 0x05, 0x01, 0x02, 0x02, 0x03 - .byte 0x05, 0x05, 0x04, 0x04 - - .align 2 -gUnknown_085E51C0:: @ 85E51C0 - .4byte sub_8171E50 - .4byte sub_81723D4 - .4byte sub_81721CC - .4byte sub_81722CC - .4byte sub_81726BC - .4byte sub_81721CC - .4byte sub_81720C8 - .4byte sub_81722CC - .4byte sub_8172560 - .4byte sub_8171FC4 - .4byte sub_81723D4 - .4byte sub_81727E8 - - .align 2 -gUnknown_085E51F0:: @ 85E51F0 - spr_template 0xd6ec, 0xd6ec, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6ed, 0xd6ed, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6ee, 0xd6ee, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6ef, 0xd6ef, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_085E5250:: @ 85E5250 - spr_template 0xd6f0, 0xd6f0, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6f1, 0xd6f1, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6f2, 0xd6f2, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6f3, 0xd6f3, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6f4, 0xd6f4, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6f5, 0xd6f5, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6f6, 0xd6f6, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 - spr_template 0xd6f7, 0xd6f7, gUnknown_08524904, gUnknown_085E519C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_085E5310:: @ 85E5310 - .2byte 0x7adf, 0x7af0, 0x53d7, 0x3fff, 0x7297, 0x67f5, 0x7b2c, 0x2b7e - .2byte 0x431f, 0x7bdd, 0x2a3f, 0x293f, 0x0000, 0x0201, 0x0403, 0x0101 - .2byte 0x0100, 0x0503, 0x0506, 0x0004 - - .align 2 -gBattleAnimSpriteTemplate_85E5338:: @ 85E5338 - spr_template ANIM_TAG_UNUSED_RED_BRICK, ANIM_TAG_UNUSED_RED_BRICK, gUnknown_0852490C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_817330C - - .align 2 -gUnknown_085E5350:: @ 8535350 - .2byte 0x0040, 0x0001, 0xffff, 0x0000 - - .align 2 -gUnknown_085E5358:: @ 8535358 - .4byte gUnknown_085E5350 - - .align 2 - spr_template ANIM_TAG_ROCKS, ANIM_TAG_ROCKS, gUnknown_08524914, gUnknown_085E5358, NULL, gDummySpriteAffineAnimTable, sub_817330C - diff --git a/include/battle.h b/include/battle.h index 9e67e8ec5..c06bdaad5 100644 --- a/include/battle.h +++ b/include/battle.h @@ -599,8 +599,7 @@ struct BattleAnimationInfo u8 field_9_x80:1; u8 field_A; u8 field_B; - u8 field_C; - u8 field_D; + s16 field_C; u8 field_E; u8 field_F; }; diff --git a/include/battle_anim.h b/include/battle_anim.h index 541c165e7..fffdabe06 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -131,6 +131,7 @@ void sub_80A805C(struct Task *task, u8 a2, s16 a3, s16 a4, s16 a5, s16 a6, u16 a u8 sub_80A80C8(struct Task *task); void sub_80A8EE4(struct Sprite *); void sub_80A67F4(struct Sprite *); +void sub_80A6D48(u32 bgId, const void *src); enum { @@ -168,8 +169,8 @@ void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId); // battle_anim_8170478.s u8 ItemIdToBallId(u16 itemId); -u8 LaunchBallStarsTask(u8 x, u8 y, u8 kindOfStars, u8 arg3, u8 ballId); -u8 LaunchBallFadeMonTask(bool8 unFadeLater, u8 battlerId, u32 arg2, u8 ballId); +u8 AnimateBallOpenParticles(u8 x, u8 y, u8 priority, u8 subpriority, u8 ballId); +u8 LaunchBallFadeMonTask(bool8 unFadeLater, u8 battlerId, u32 selectedPalettes, u8 ballId); // battle_anim_utility_funcs.s void sub_8116EB4(u8); @@ -223,4 +224,7 @@ extern const struct OamData gUnknown_0852493C; extern const struct OamData gUnknown_08524A5C; extern const struct OamData gUnknown_08524A74; +extern const struct CompressedSpriteSheet gBattleAnimPicTable[]; +extern const struct CompressedSpritePalette gBattleAnimPaletteTable[]; + #endif // GUARD_BATTLE_ANIM_H diff --git a/include/global.h b/include/global.h index 33a31bf4d..58b338f9e 100644 --- a/include/global.h +++ b/include/global.h @@ -61,6 +61,12 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) +// Extracts the upper 16 bits of a 32-bit number +#define HIHALF(n) (((n) & 0xFFFF0000) >> 16) + +// Extracts the lower 16 bits of a 32-bit number +#define LOHALF(n) ((n) & 0xFFFF) + // There are many quirks in the source code which have overarching behavioral differences from // a number of other files. For example, diploma.c seems to declare rodata before each use while // other files declare out of order and must be at the beginning. There are also a number of diff --git a/include/graphics.h b/include/graphics.h index e2889ed86..33a26068b 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4233,6 +4233,7 @@ extern const u32 gBattleAnimSpriteSheet_132[]; extern const u32 gBattleAnimSpriteSheet_133[]; extern const u32 gBattleAnimSpriteSheet_134[]; extern const u32 gBattleAnimSpriteSheet_135[]; +extern const u32 gBattleAnimSpriteSheet_Particles[]; extern const u32 gBattleAnimSpriteSheet_136[]; extern const u32 gBattleAnimSpriteSheet_137[]; extern const u32 gBattleAnimSpriteSheet_138[]; @@ -4748,4 +4749,9 @@ extern const u32 gCableCarDoor_Gfx[]; extern const u32 gCableCarCord_Gfx[]; extern const u16 gCableCar_Pal[]; +// Battle Anim +extern const u32 gUnknown_08C2DDA4[]; +extern const u32 gUnknown_08C2EA50[]; +extern const u32 gUnknown_08C2EA9C[]; + #endif //GUARD_GRAPHICS_H diff --git a/ld_script.txt b/ld_script.txt index 80c614471..1413941f1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -238,7 +238,7 @@ SECTIONS { src/intro.o(.text); src/reset_save_heap.o(.text); src/field_region_map.o(.text); - asm/battle_anim_8170478.o(.text); + src/battle_anim_8170478.o(.text); src/hall_of_fame.o(.text); src/credits.o(.text); src/lottery_corner.o(.text); @@ -549,7 +549,7 @@ SECTIONS { src/player_pc.o(.rodata); src/intro.o(.rodata); src/field_region_map.o(.rodata); - data/battle_anim_8170478.o(.rodata); + src/battle_anim_8170478.o(.rodata); src/hall_of_fame.o(.rodata); src/credits.o(.rodata); src/lottery_corner.o(.rodata); diff --git a/src/battle_anim.c b/src/battle_anim.c index 95c6f7b3c..5e62c0957 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -26,8 +26,6 @@ extern struct MusicPlayerInfo gMPlayInfo_SE2; extern const u16 gMovesWithQuietBGM[]; extern const u8 *const gBattleAnims_Moves[]; -extern const struct CompressedSpriteSheet gBattleAnimPicTable[]; -extern const struct CompressedSpritePalette gBattleAnimPaletteTable[]; extern const struct BattleAnimBackground gBattleAnimBackgroundTable[]; // this file's functions diff --git a/src/battle_anim_8170478.c b/src/battle_anim_8170478.c new file mode 100755 index 000000000..6c91ff934 --- /dev/null +++ b/src/battle_anim_8170478.c @@ -0,0 +1,2267 @@ +#include "global.h" +#include "battle.h" +#include "battle_anim.h" +#include "battle_controllers.h" +#include "battle_interface.h" +#include "decompress.h" +#include "dma3.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "m4a.h" +#include "main.h" +#include "palette.h" +#include "pokeball.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "util.h" +#include "constants/rgb.h" +#include "constants/items.h" +#include "constants/songs.h" + +// iwram +int gUnknown_030062DC; +u16 gUnknown_030062E0; +u16 gUnknown_030062E4; + +static void sub_8170660(u8); +static void sub_8170A38(u8); +static void sub_8170EF0(u8); +static void sub_8171104(struct Sprite *); +static void sub_8171030(u8); +static void sub_81710A8(u8); +static void sub_8171134(struct Sprite *); +static void sub_8171CAC(struct Sprite *); +static void sub_81711E8(struct Sprite *); +static void sub_8171240(struct Sprite *); +static void sub_817138C(struct Sprite *); +static void sub_81713D0(struct Sprite *); +static void sub_81717B4(struct Sprite *); +static void sub_81714D4(struct Sprite *); +static void sub_8171520(struct Sprite *); +static void sub_81717D8(struct Sprite *); +static void sub_8171AE4(struct Sprite *); +static void sub_81717F8(struct Sprite *); +static void sub_81719EC(struct Sprite *); +static void sub_81718D8(struct Sprite *); +static void sub_81719C0(struct Sprite *); +static void sub_8171D60(u8); +static void sub_8171AAC(struct Sprite *); +static void sub_8171BAC(struct Sprite *); +static void sub_8171CE8(struct Sprite *); +static void PokeBallOpenParticleAnimation_Step1(struct Sprite *); +static void PokeBallOpenParticleAnimation_Step2(struct Sprite *); +static void DestroyBallOpenAnimationParticle(struct Sprite *); +static void FanOutBallOpenParticles_Step1(struct Sprite *); +static void RepeatBallOpenParticleAnimation_Step1(struct Sprite *); +static void PremierBallOpenParticleAnimation_Step1(struct Sprite *); +static void sub_8172AB0(u8); +static void sub_8172B40(u8); +static void sub_8172B90(u8); +static void sub_8172FEC(u8); +static void sub_81731FC(struct Sprite *); +static void sub_8173250(struct Sprite *); +static void sub_81731B0(u8); +static void sub_817339C(struct Sprite *); +static void sub_81733D4(struct Sprite *); +static void sub_8173400(struct Sprite *); +static void PokeBallOpenParticleAnimation(u8); +static void GreatBallOpenParticleAnimation(u8); +static void SafariBallOpenParticleAnimation(u8); +static void UltraBallOpenParticleAnimation(u8); +static void MasterBallOpenParticleAnimation(u8); +static void DiveBallOpenParticleAnimation(u8); +static void RepeatBallOpenParticleAnimation(u8); +static void TimerBallOpenParticleAnimation(u8); +static void PremierBallOpenParticleAnimation(u8); +static void sub_817330C(struct Sprite *); + +struct BallCaptureSuccessStarData +{ + s8 xOffset; + s8 yOffset; + s8 unk2; +}; + +static const struct BallCaptureSuccessStarData sBallCaptureSuccessStarData[] = +{ + { + .xOffset = 10, + .yOffset = 2, + .unk2 = -3, + }, + { + .xOffset = 15, + .yOffset = 0, + .unk2 = -4, + }, + { + .xOffset = -10, + .yOffset = 2, + .unk2 = -4, + }, +}; + +const struct CompressedSpriteSheet gBallOpenParticleSpritesheets[] = +{ + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6EC}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6ED}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6EE}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6EF}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6F0}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6F1}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6F2}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6F3}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6F4}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6F5}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6F6}, + {gBattleAnimSpriteSheet_Particles, 0x100, 0xD6F7}, +}; + +const struct CompressedSpritePalette gBallOpenParticlePalettes[] = +{ + {gBattleAnimSpritePalette_136, 0xD6EC}, + {gBattleAnimSpritePalette_136, 0xD6ED}, + {gBattleAnimSpritePalette_136, 0xD6EE}, + {gBattleAnimSpritePalette_136, 0xD6EF}, + {gBattleAnimSpritePalette_136, 0xD6F0}, + {gBattleAnimSpritePalette_136, 0xD6F1}, + {gBattleAnimSpritePalette_136, 0xD6F2}, + {gBattleAnimSpritePalette_136, 0xD6F3}, + {gBattleAnimSpritePalette_136, 0xD6F4}, + {gBattleAnimSpritePalette_136, 0xD6F5}, + {gBattleAnimSpritePalette_136, 0xD6F6}, + {gBattleAnimSpritePalette_136, 0xD6F7}, +}; + +const union AnimCmd gUnknown_085E5154[] = +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_FRAME(1, 1), + ANIMCMD_FRAME(2, 1), + ANIMCMD_FRAME(0, 1, .hFlip = TRUE), + ANIMCMD_FRAME(2, 1), + ANIMCMD_FRAME(1, 1), + ANIMCMD_JUMP(0), +}; + +const union AnimCmd gUnknown_085E5170[] = +{ + ANIMCMD_FRAME(3, 1), + ANIMCMD_END, +}; + +const union AnimCmd gUnknown_085E5178[] = +{ + ANIMCMD_FRAME(4, 1), + ANIMCMD_END, +}; + +const union AnimCmd gUnknown_085E5180[] = +{ + ANIMCMD_FRAME(5, 1), + ANIMCMD_END, +}; + +const union AnimCmd gUnknown_085E5188[] = +{ + ANIMCMD_FRAME(6, 4), + ANIMCMD_FRAME(7, 4), + ANIMCMD_JUMP(0), +}; + +const union AnimCmd gUnknown_085E5194[] = +{ + ANIMCMD_FRAME(7, 4), + ANIMCMD_END, +}; + +const union AnimCmd *const gUnknown_085E519C[] = +{ + gUnknown_085E5154, + gUnknown_085E5170, + gUnknown_085E5178, + gUnknown_085E5180, + gUnknown_085E5188, + gUnknown_085E5194, +}; + +const u8 gBallOpenParticleAnimNums[] = +{ + 0, + 0, + 0, + 5, + 1, + 2, + 2, + 3, + 5, + 5, + 4, + 4, +}; + +const TaskFunc gBallOpenParticleAnimationFuncs[] = +{ + PokeBallOpenParticleAnimation, + GreatBallOpenParticleAnimation, + SafariBallOpenParticleAnimation, + UltraBallOpenParticleAnimation, + MasterBallOpenParticleAnimation, + SafariBallOpenParticleAnimation, + DiveBallOpenParticleAnimation, + UltraBallOpenParticleAnimation, + RepeatBallOpenParticleAnimation, + TimerBallOpenParticleAnimation, + GreatBallOpenParticleAnimation, + PremierBallOpenParticleAnimation, +}; + +const struct SpriteTemplate gUnknown_085E51F0[] = +{ + { + .tileTag = 55020, + .paletteTag = 55020, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55021, + .paletteTag = 55021, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55022, + .paletteTag = 55022, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55023, + .paletteTag = 55023, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55024, + .paletteTag = 55024, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55025, + .paletteTag = 55025, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55026, + .paletteTag = 55026, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55027, + .paletteTag = 55027, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55028, + .paletteTag = 55028, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55029, + .paletteTag = 55029, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55030, + .paletteTag = 55030, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 55031, + .paletteTag = 55031, + .oam = &gUnknown_08524904, + .anims = gUnknown_085E519C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, +}; + +const u16 gUnknown_085E5310[] = +{ + RGB(31, 22, 30), + RGB(16, 23, 30), + RGB(23, 30, 20), + RGB(31, 31, 15), + RGB(23, 20, 28), + RGB(21, 31, 25), + RGB(12, 25, 30), + RGB(30, 27, 10), + RGB(31, 24, 16), + RGB(29, 30, 30), + RGB(31, 17, 10), + RGB(31, 9, 10), + RGB(0, 0, 0), + RGB(1, 16, 0), + RGB(3, 0, 1), + RGB(1, 8, 0), + RGB(0, 8, 0), + RGB(3, 8, 1), + RGB(6, 8, 1), + RGB(4, 0, 0), +}; + +const struct SpriteTemplate gBattleAnimSpriteTemplate_85E5338 = +{ + .tileTag = ANIM_TAG_UNUSED_RED_BRICK, + .paletteTag = ANIM_TAG_UNUSED_RED_BRICK, + .oam = &gUnknown_0852490C, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_817330C, +}; + +const union AnimCmd gUnknown_085E5350[] = +{ + ANIMCMD_FRAME(64, 1), + ANIMCMD_END, +}; + +const union AnimCmd *const gUnknown_085E5358[] = { + gUnknown_085E5350, +}; + +const struct SpriteTemplate gBattleAnimSpriteTemplate_085E535C = +{ + .tileTag = ANIM_TAG_ROCKS, + .paletteTag = ANIM_TAG_ROCKS, + .oam = &gUnknown_08524914, + .anims = gUnknown_085E5358, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_817330C, +}; + +extern const struct SpriteTemplate gUnknown_085CE388; +extern const struct SpriteTemplate gUnknown_085CE3A0; + +void unref_sub_8170478(u8 taskId) +{ + struct UnknownAnimStruct2 unknownStruct; + u8 healthBoxSpriteId; + u8 battler; + u8 spriteId1, spriteId2, spriteId3, spriteId4; + + battler = gBattleAnimAttacker; + gBattle_WIN0H = 0; + gBattle_WIN0V = 0; + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 0); + SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 0); + SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 1); + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); + + healthBoxSpriteId = gHealthboxSpriteIds[battler]; + spriteId1 = gSprites[healthBoxSpriteId].oam.affineParam; + spriteId2 = gSprites[healthBoxSpriteId].data[5]; + spriteId3 = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy); + spriteId4 = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy); + gSprites[healthBoxSpriteId].oam.priority = 1; + gSprites[spriteId1].oam.priority = 1; + gSprites[spriteId2].oam.priority = 1; + gSprites[spriteId3] = gSprites[healthBoxSpriteId]; + gSprites[spriteId4] = gSprites[spriteId1]; + gSprites[spriteId3].oam.objMode = ST_OAM_OBJ_WINDOW; + gSprites[spriteId4].oam.objMode = ST_OAM_OBJ_WINDOW; + gSprites[spriteId3].callback = SpriteCallbackDummy; + gSprites[spriteId4].callback = SpriteCallbackDummy; + + sub_80A6B30(&unknownStruct); + sub_80A6D48(unknownStruct.bgId, gUnknown_08C2EA9C); + sub_80A6CC0(unknownStruct.bgId, gUnknown_08C2EA50, unknownStruct.tilesOffset); + LoadCompressedPalette(gUnknown_08C2DDA4, unknownStruct.unk8 << 4, 32); + + gBattle_BG1_X = -gSprites[spriteId3].pos1.x + 32; + gBattle_BG1_Y = -gSprites[spriteId3].pos1.y - 32; + gTasks[taskId].data[1] = 640; + gTasks[taskId].data[0] = spriteId3; + gTasks[taskId].data[2] = spriteId4; + gTasks[taskId].func = sub_8170660; +} + +static void sub_8170660(u8 taskId) +{ + u8 spriteId1, spriteId2; + u8 battler; + + battler = gBattleAnimAttacker; + gTasks[taskId].data[13] += gTasks[taskId].data[1]; + gBattle_BG1_Y += (u16)gTasks[taskId].data[13] >> 8; + gTasks[taskId].data[13] &= 0xFF; + + switch (gTasks[taskId].data[15]) + { + case 0: + if (gTasks[taskId].data[11]++ > 1) + { + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[12]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); + if (gTasks[taskId].data[12] == 8) + gTasks[taskId].data[15]++; + } + break; + case 1: + if (++gTasks[taskId].data[10] == 30) + gTasks[taskId].data[15]++; + break; + case 2: + if (gTasks[taskId].data[11]++ > 1) + { + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[12]--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); + if (gTasks[taskId].data[12] == 0) + { + sub_80A477C(0); + gBattle_WIN0H = 0; + gBattle_WIN0V = 0; + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + if (!IsContest()) + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0); + + SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) ^ DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0)); + DestroySprite(&gSprites[gTasks[taskId].data[0]]); + DestroySprite(&gSprites[gTasks[taskId].data[2]]); + SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 0); + spriteId1 = gSprites[gHealthboxSpriteIds[battler]].oam.affineParam; + spriteId2 = gSprites[gHealthboxSpriteIds[battler]].data[5]; + gSprites[gHealthboxSpriteIds[battler]].oam.priority = 1; + gSprites[spriteId1].oam.priority = 1; + gSprites[spriteId2].oam.priority = 1; + DestroyAnimVisualTask(taskId); + } + } + break; + } +} + +static void sub_8170834(u8 *paletteId1, u8 *paletteId2, u8 battler) +{ + u8 healthBoxSpriteId; + u8 spriteId1, spriteId2; + u16 offset1, offset2; + + healthBoxSpriteId = gHealthboxSpriteIds[battler]; + spriteId1 = gSprites[healthBoxSpriteId].oam.affineParam; + spriteId2 = gSprites[healthBoxSpriteId].data[5]; + *paletteId1 = AllocSpritePalette(0xD709); + *paletteId2 = AllocSpritePalette(0xD70A); + + offset1 = (gSprites[healthBoxSpriteId].oam.paletteNum * 16) + 0x100; + offset2 = (gSprites[spriteId2].oam.paletteNum * 16) + 0x100; + LoadPalette(&gPlttBufferUnfaded[offset1], *paletteId1 * 16 + 0x100, 0x20); + LoadPalette(&gPlttBufferUnfaded[offset2], *paletteId2 * 16 + 0x100, 0x20); + + gSprites[healthBoxSpriteId].oam.paletteNum = *paletteId1; + gSprites[spriteId1].oam.paletteNum = *paletteId1; + gSprites[spriteId2].oam.paletteNum = *paletteId2; +} + +void sub_8170920(u8 taskId) +{ + u8 paletteId1, paletteId2; + sub_8170834(&paletteId1, &paletteId2, gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); +} + +static void sub_817094C(u8 battler) +{ + u8 healthBoxSpriteId; + u8 spriteId1, spriteId2; + u8 paletteId1, paletteId2; + + healthBoxSpriteId = gHealthboxSpriteIds[battler]; + spriteId1 = gSprites[healthBoxSpriteId].oam.affineParam; + spriteId2 = gSprites[healthBoxSpriteId].data[5]; + + FreeSpritePaletteByTag(0xD709); + FreeSpritePaletteByTag(0xD70A); + paletteId1 = IndexOfSpritePaletteTag(0xD6FF); + paletteId2 = IndexOfSpritePaletteTag(0xD704); + gSprites[healthBoxSpriteId].oam.paletteNum = paletteId1; + gSprites[spriteId1].oam.paletteNum = paletteId1; + gSprites[spriteId2].oam.paletteNum = paletteId2; +} + +void sub_81709EC(u8 taskId) +{ + sub_817094C(gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); +} + +void sub_8170A0C(u8 taskId) +{ + gTasks[taskId].data[10] = gBattleAnimArgs[0]; + gTasks[taskId].data[11] = gBattleAnimArgs[1]; + gTasks[taskId].func = sub_8170A38; +} + +static void sub_8170A38(u8 taskId) +{ + u8 paletteNum; + int paletteOffset, colorOffset; + + gTasks[taskId].data[0]++; + if (gTasks[taskId].data[0]++ >= gTasks[taskId].data[11]) + { + gTasks[taskId].data[0] = 0; + paletteNum = IndexOfSpritePaletteTag(0xD709); + colorOffset = gTasks[taskId].data[10] == 0 ? 6 : 2; + switch (gTasks[taskId].data[1]) + { + case 0: + gTasks[taskId].data[2] += 2; + if (gTasks[taskId].data[2] > 16) + gTasks[taskId].data[2] = 16; + + paletteOffset = paletteNum * 16 + 0x100; + BlendPalette(paletteOffset + colorOffset, 1, gTasks[taskId].data[2], RGB(20, 27, 31)); + if (gTasks[taskId].data[2] == 16) + gTasks[taskId].data[1]++; + break; + case 1: + gTasks[taskId].data[2] -= 2; + if (gTasks[taskId].data[2] < 0) + gTasks[taskId].data[2] = 0; + + paletteOffset = paletteNum * 16 + 0x100; + BlendPalette(paletteOffset + colorOffset, 1, gTasks[taskId].data[2], RGB(20, 27, 31)); + if (gTasks[taskId].data[2] == 0) + DestroyAnimVisualTask(taskId); + break; + } + } +} + +void sub_8170B04(u8 taskId) +{ + u8 spriteId; + + spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; + switch (gTasks[taskId].data[0]) + { + case 0: + sub_80A7270(spriteId, 0); + gTasks[taskId].data[10] = 0x100; + gTasks[taskId].data[0]++; + break; + case 1: + gTasks[taskId].data[10] += 0x30; + obj_id_set_rotscale(spriteId, gTasks[taskId].data[10], gTasks[taskId].data[10], 0); + sub_80A7E6C(spriteId); + if (gTasks[taskId].data[10] >= 0x2D0) + gTasks[taskId].data[0]++; + break; + case 2: + sub_80A7344(spriteId); + gSprites[spriteId].invisible = 1; + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_8170BB0(u8 taskId) +{ + u8 spriteId; + u16 ball; + u8 ballId; + u8 x, y; + u8 priority, subpriority; + u32 selectedPalettes; + + spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) + ball = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_POKEBALL); + else + ball = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_POKEBALL); + + ballId = ItemIdToBallId(ball); + switch (gTasks[taskId].data[0]) + { + case 0: + x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0); + y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1); + priority = gSprites[spriteId].oam.priority; + subpriority = gSprites[spriteId].subpriority; + gTasks[taskId].data[10] = AnimateBallOpenParticles(x, y + 32, priority, subpriority, ballId); + selectedPalettes = sub_80A75AC(1, 0, 0, 0, 0, 0, 0); + gTasks[taskId].data[11] = LaunchBallFadeMonTask(0, gBattleAnimAttacker, selectedPalettes, ballId); + gTasks[taskId].data[0]++; + break; + case 1: + if (!gTasks[gTasks[taskId].data[10]].isActive && !gTasks[gTasks[taskId].data[11]].isActive) + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_8170CFC(u8 taskId) +{ + u8 ballId = ItemIdToBallId(gLastUsedItem); + LoadBallGfx(ballId); + DestroyAnimVisualTask(taskId); +} + +void sub_8170D24(u8 taskId) +{ + u8 ballId = ItemIdToBallId(gLastUsedItem); + FreeBallGfx(ballId); + DestroyAnimVisualTask(taskId); +} + +void AnimTask_IsBallBlockedByTrainer(u8 taskId) +{ + if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_TRAINER_BLOCK) + gBattleAnimArgs[7] = -1; + else + gBattleAnimArgs[7] = 0; + + DestroyAnimVisualTask(taskId); +} + +u8 ItemIdToBallId(u16 ballItem) +{ + switch (ballItem) + { + case ITEM_MASTER_BALL: + return 4; + case ITEM_ULTRA_BALL: + return 3; + case ITEM_GREAT_BALL: + return 1; + case ITEM_SAFARI_BALL: + return 2; + case ITEM_NET_BALL: + return 5; + case ITEM_DIVE_BALL: + return 6; + case ITEM_NEST_BALL: + return 7; + case ITEM_REPEAT_BALL: + return 8; + case ITEM_TIMER_BALL: + return 9; + case ITEM_LUXURY_BALL: + return 10; + case ITEM_PREMIER_BALL: + return 11; + case ITEM_POKE_BALL: + default: + return 0; + } +} + +void sub_8170E04(u8 taskId) +{ + u8 ballId; + u8 spriteId; + + ballId = ItemIdToBallId(gLastUsedItem); + spriteId = CreateSprite(&gBallSpriteTemplates[ballId], 32, 80, 29); + gSprites[spriteId].data[0] = 34; + gSprites[spriteId].data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, 0); + gSprites[spriteId].data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 1) - 16; + gSprites[spriteId].callback = sub_8171104; + gBattleSpritesDataPtr->animationData->field_9_x2 = gSprites[gBattlerSpriteIds[gBattleAnimTarget]].invisible; + gTasks[taskId].data[0] = spriteId; + gTasks[taskId].func = sub_8170EF0; +} + +static void sub_8170EF0(u8 taskId) +{ + u8 spriteId = gTasks[taskId].data[0]; + if ((u16)gSprites[spriteId].data[0] == 0xFFFF) + DestroyAnimVisualTask(taskId); +} + +void sub_8170F2C(u8 taskId) +{ + int x, y; + u8 ballId; + u8 subpriority; + u8 spriteId; + + if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) + { + x = 32; + y = 11; + } + else + { + x = 23; + y = 5; + } + + ballId = ItemIdToBallId(gLastUsedItem); + subpriority = sub_80A82E4(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) + 1; + spriteId = CreateSprite(&gBallSpriteTemplates[ballId], x + 32, y | 80, subpriority); + gSprites[spriteId].data[0] = 34; + gSprites[spriteId].data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, 0); + gSprites[spriteId].data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 1) - 16; + gSprites[spriteId].callback = SpriteCallbackDummy; + gSprites[gBattlerSpriteIds[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]].callback = sub_8039E84; + gTasks[taskId].data[0] = spriteId; + gTasks[taskId].func = sub_8171030; +} + +static void sub_8171030(u8 taskId) +{ + if (gSprites[gBattlerSpriteIds[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]].animCmdIndex == 1) + { + PlaySE12WithPanning(SE_NAGERU, 0); + gSprites[gTasks[taskId].data[0]].callback = sub_8171104; + CreateTask(sub_81710A8, 10); + gTasks[taskId].func = sub_8170EF0; + } +} + +static void sub_81710A8(u8 taskId) +{ + if (gSprites[gBattlerSpriteIds[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]].animEnded) + { + StartSpriteAnim(&gSprites[gBattlerSpriteIds[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]], 0); + DestroyTask(taskId); + } +} + +static void sub_8171104(struct Sprite *sprite) +{ + u16 temp = sprite->data[1]; + u16 temp2 = sprite->data[2]; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = temp; + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = temp2; + sprite->data[5] = -40; + InitAnimArcTranslation(sprite); + sprite->callback = sub_8171134; +} + +static void sub_8171134(struct Sprite *sprite) +{ + int i; + u8 ballId; + int ballId2; // extra var needed to match + + if (TranslateAnimArc(sprite)) + { + if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_TRAINER_BLOCK) + { + sprite->callback = sub_8171CAC; + } + else + { + StartSpriteAnim(sprite, 1); + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + + for (i = 0; i < 8; i++) + sprite->data[i] = 0; + + sprite->data[5] = 0; + sprite->callback = sub_81711E8; + ballId = ItemIdToBallId(gLastUsedItem); + ballId2 = ballId; + if (ballId2 > 11) + return; + if (ballId2 < 0) + return; + + AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballId); + LaunchBallFadeMonTask(0, gBattleAnimTarget, 14, ballId); + } + } +} + +static void sub_81711E8(struct Sprite *sprite) +{ + if (++sprite->data[5] == 10) + { + sprite->data[5] = CreateTask(TaskDummy, 50); + sprite->callback = sub_8171240; + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].data[1] = 0; + } +} + +static void sub_8171240(struct Sprite *sprite) +{ + u8 spriteId; + u8 taskId; + + spriteId = gBattlerSpriteIds[gBattleAnimTarget]; + taskId = sprite->data[5]; + + if (++gTasks[taskId].data[1] == 11) + PlaySE(SE_SUIKOMU); + + switch (gTasks[taskId].data[0]) + { + case 0: + sub_80A7270(spriteId, 0); + gTasks[taskId].data[10] = 256; + gUnknown_030062DC = 28; + gUnknown_030062E4 = (gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y) - (sprite->pos1.y + sprite->pos2.y); + gUnknown_030062E0 = (u32)(gUnknown_030062E4 * 256) / 28; + gTasks[taskId].data[2] = gUnknown_030062E0; + gTasks[taskId].data[0]++; + break; + case 1: + gTasks[taskId].data[10] += 0x20; + obj_id_set_rotscale(spriteId, gTasks[taskId].data[10], gTasks[taskId].data[10], 0); + gTasks[taskId].data[3] += gTasks[taskId].data[2]; + gSprites[spriteId].pos2.y = -gTasks[taskId].data[3] >> 8; + if (gTasks[taskId].data[10] >= 0x480) + gTasks[taskId].data[0]++; + break; + case 2: + sub_80A7344(spriteId); + gSprites[spriteId].invisible = 1; + gTasks[taskId].data[0]++; + break; + default: + if (gTasks[taskId].data[1] > 10) + { + DestroyTask(taskId); + StartSpriteAnim(sprite, 2); + sprite->data[5] = 0; + sprite->callback = sub_817138C; + } + break; + } +} + +static void sub_817138C(struct Sprite *sprite) +{ + int angle; + + if (sprite->animEnded) + { + sprite->data[3] = 0; + sprite->data[4] = 40; + sprite->data[5] = 0; + angle = 0; + sprite->pos1.y += Cos(angle, 40); + sprite->pos2.y = -Cos(angle, sprite->data[4]); + sprite->callback = sub_81713D0; + } +} + +static void sub_81713D0(struct Sprite *sprite) +{ + bool8 lastBounce; + int bounceCount; + + lastBounce = 0; + + switch (sprite->data[3] & 0xFF) + { + case 0: + sprite->pos2.y = -Cos(sprite->data[5], sprite->data[4]); + sprite->data[5] += (sprite->data[3] >> 8) + 4; + if (sprite->data[5] >= 64) + { + sprite->data[4] -= 10; + sprite->data[3] += 257; + + bounceCount = sprite->data[3] >> 8; + if (bounceCount == 4) + lastBounce = 1; + + // Play a different sound effect for each pokeball bounce. + switch (bounceCount) + { + case 1: + PlaySE(SE_KON); + break; + case 2: + PlaySE(SE_KON2); + break; + case 3: + PlaySE(SE_KON3); + break; + default: + PlaySE(SE_KON4); + break; + } + } + break; + case 1: + sprite->pos2.y = -Cos(sprite->data[5], sprite->data[4]); + sprite->data[5] -= (sprite->data[3] >> 8) + 4; + if (sprite->data[5] <= 0) + { + sprite->data[5] = 0; + sprite->data[3] &= -0x100; + } + break; + } + + if (lastBounce) + { + sprite->data[3] = 0; + sprite->pos1.y += Cos(64, 40); + sprite->pos2.y = 0; + if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_NO_SHAKES) + { + sprite->data[5] = 0; + sprite->callback = sub_81717B4; + } + else + { + sprite->callback = sub_81714D4; + sprite->data[4] = 1; + sprite->data[5] = 0; + } + } +} + +static void sub_81714D4(struct Sprite *sprite) +{ + if (++sprite->data[3] == 31) + { + sprite->data[3] = 0; + sprite->affineAnimPaused = 1; + StartSpriteAffineAnim(sprite, 1); + gBattleSpritesDataPtr->animationData->field_C = 0; + sprite->callback = sub_8171520; + PlaySE(SE_BOWA); + } +} + +static void sub_8171520(struct Sprite *sprite) +{ + s8 state; + u16 var0; + + switch (sprite->data[3] & 0xFF) + { + case 0: + if (gBattleSpritesDataPtr->animationData->field_C > 0xFF) + { + sprite->pos2.x += sprite->data[4]; + gBattleSpritesDataPtr->animationData->field_C &= 0xFF; + } + else + { + gBattleSpritesDataPtr->animationData->field_C += 0xB0; + } + + sprite->data[5]++; + sprite->affineAnimPaused = 0; + var0 = sprite->data[5] + 7; + if (var0 > 14) + { + gBattleSpritesDataPtr->animationData->field_C = 0; + sprite->data[3]++; + sprite->data[5] = 0; + } + break; + case 1: + if (++sprite->data[5] == 1) + { + sprite->data[5] = 0; + sprite->data[4] = -sprite->data[4]; + sprite->data[3]++; + sprite->affineAnimPaused = 0; + if (sprite->data[4] < 0) + ChangeSpriteAffineAnim(sprite, 2); + else + ChangeSpriteAffineAnim(sprite, 1); + } + else + { + sprite->affineAnimPaused = 1; + } + break; + case 2: + if (gBattleSpritesDataPtr->animationData->field_C > 0xFF) + { + sprite->pos2.x += sprite->data[4]; + gBattleSpritesDataPtr->animationData->field_C &= 0xFF; + } + else + { + gBattleSpritesDataPtr->animationData->field_C += 0xB0; + } + + sprite->data[5]++; + sprite->affineAnimPaused = 0; + var0 = sprite->data[5] + 12; + if (var0 > 24) + { + gBattleSpritesDataPtr->animationData->field_C = 0; + sprite->data[3]++; + sprite->data[5] = 0; + } + break; + case 3: + if (sprite->data[5]++ < 0) + { + sprite->affineAnimPaused = 1; + break; + } + + sprite->data[5] = 0; + sprite->data[4] = -sprite->data[4]; + sprite->data[3]++; + sprite->affineAnimPaused = 0; + if (sprite->data[4] < 0) + ChangeSpriteAffineAnim(sprite, 2); + else + ChangeSpriteAffineAnim(sprite, 1); + // fall through + case 4: + if (gBattleSpritesDataPtr->animationData->field_C > 0xFF) + { + sprite->pos2.x += sprite->data[4]; + gBattleSpritesDataPtr->animationData->field_C &= 0xFF; + } + else + { + gBattleSpritesDataPtr->animationData->field_C += 0xB0; + } + + sprite->data[5]++; + sprite->affineAnimPaused = 0; + var0 = sprite->data[5] + 4; + if (var0 > 8) + { + gBattleSpritesDataPtr->animationData->field_C = 0; + sprite->data[3]++; + sprite->data[5] = 0; + sprite->data[4] = -sprite->data[4]; + } + break; + case 5: + sprite->data[3] += 0x100; + state = sprite->data[3] >> 8; + if (state == gBattleSpritesDataPtr->animationData->ballThrowCaseId) + { + sprite->affineAnimPaused = 1; + sprite->callback = sub_81717B4; + } + else + { + if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_3_SHAKES_SUCCESS && state == 3) + { + sprite->callback = sub_81717D8; + sprite->affineAnimPaused = 1; + } + else + { + sprite->data[3]++; + sprite->affineAnimPaused = 1; + } + } + break; + case 6: + default: + if (++sprite->data[5] == 31) + { + sprite->data[5] = 0; + sprite->data[3] &= -0x100; + StartSpriteAffineAnim(sprite, 3); + if (sprite->data[4] < 0) + StartSpriteAffineAnim(sprite, 2); + else + StartSpriteAffineAnim(sprite, 1); + + PlaySE(SE_BOWA); + } + break; + } +} + +static void sub_81717B4(struct Sprite *sprite) +{ + if (++sprite->data[5] == 31) + { + sprite->data[5] = 0; + sprite->callback = sub_8171AE4; + } +} + +static void sub_81717D8(struct Sprite *sprite) +{ + sprite->animPaused = 1; + sprite->callback = sub_81717F8; + sprite->data[3] = 0; + sprite->data[4] = 0; + sprite->data[5] = 0; +} + +static void sub_81717F8(struct Sprite *sprite) +{ + u8 *battler = &gBattleAnimTarget; + + sprite->data[4]++; + if (sprite->data[4] == 40) + { + PlaySE(SE_RG_GETTING); + BlendPalettes(0x10000 << sprite->oam.paletteNum, 6, RGB(0, 0, 0)); + sub_81719EC(sprite); + } + else if (sprite->data[4] == 60) + { + BeginNormalPaletteFade(0x10000 << sprite->oam.paletteNum, 2, 6, 0, RGB(0, 0, 0)); + } + else if (sprite->data[4] == 95) + { + gDoingBattleAnim = 0; + UpdateOamPriorityInAllHealthboxes(1); + m4aMPlayAllStop(); + PlaySE(MUS_RG_FAN6); + } + else if (sprite->data[4] == 315) + { + FreeOamMatrix(gSprites[gBattlerSpriteIds[*battler]].oam.matrixNum); + DestroySprite(&gSprites[gBattlerSpriteIds[*battler]]); + sprite->data[0] = 0; + sprite->callback = sub_81718D8; + } +} + +static void sub_81718D8(struct Sprite *sprite) +{ + u8 paletteIndex; + + switch (sprite->data[0]) + { + case 0: + sprite->data[1] = 0; + sprite->data[2] = 0; + sprite->oam.objMode = ST_OAM_OBJ_BLEND; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + paletteIndex = IndexOfSpritePaletteTag(sprite->template->paletteTag); + BeginNormalPaletteFade(1 << (paletteIndex + 0x10), 0, 0, 16, RGB(31, 31, 31)); + sprite->data[0]++; + break; + case 1: + if (sprite->data[1]++ > 0) + { + sprite->data[1] = 0; + sprite->data[2]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16 - sprite->data[2], sprite->data[2])); + if (sprite->data[2] == 16) + sprite->data[0]++; + } + break; + case 2: + sprite->invisible = 1; + sprite->data[0]++; + break; + default: + if (!gPaletteFade.active) + { + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + sprite->data[0] = 0; + sprite->callback = sub_81719C0; + } + break; + } +} + +static void sub_81719C0(struct Sprite *sprite) +{ + if (sprite->data[0] == 0) + { + sprite->data[0] = -1; + } + else + { + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } +} + +static void sub_81719EC(struct Sprite *sprite) +{ + u32 i; + u8 subpriority; + + if (sprite->subpriority) + { + subpriority = sprite->subpriority - 1; + } + else + { + subpriority = 0; + sprite->subpriority = 1; + } + + sub_8171D60(4); + for (i = 0; i < 3; i++) + { + u8 spriteId = CreateSprite(&gUnknown_085E51F0[4], sprite->pos1.x, sprite->pos1.y, subpriority); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].data[0] = 24; + gSprites[spriteId].data[2] = sprite->pos1.x + sBallCaptureSuccessStarData[i].xOffset; + gSprites[spriteId].data[4] = sprite->pos1.y + sBallCaptureSuccessStarData[i].yOffset; + gSprites[spriteId].data[5] = sBallCaptureSuccessStarData[i].unk2; + InitAnimArcTranslation(&gSprites[spriteId]); + gSprites[spriteId].callback = sub_8171AAC; + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[4]); + } + } +} + +static void sub_8171AAC(struct Sprite *sprite) +{ + sprite->invisible = !sprite->invisible; + if (TranslateAnimArc(sprite)) + DestroySprite(sprite); +} + +// fakematching. I think the return type of ItemIdToBallId() +// is wrong because of the weird required casting. +static void sub_8171AE4(struct Sprite *sprite) +{ + u8 ballId; + int ballId2; // extra var needed to match + + StartSpriteAnim(sprite, 1); + StartSpriteAffineAnim(sprite, 0); + sprite->callback = sub_8171BAC; + + ballId = ItemIdToBallId(gLastUsedItem); + ballId2 = ballId; + if (ballId2 > 11) + goto LABEL; + if (ballId2 < 0) + goto LABEL; + + AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballId); + LaunchBallFadeMonTask(1, gBattleAnimTarget, 14, ballId); + + LABEL: + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].invisible = 0; + StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattleAnimTarget]], 1); + AnimateSprite(&gSprites[gBattlerSpriteIds[gBattleAnimTarget]]); + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].data[1] = 0x1000; +} + +static void sub_8171BAC(struct Sprite *sprite) +{ + int next = FALSE; + + if (sprite->animEnded) + sprite->invisible = 1; + + if (gSprites[gBattlerSpriteIds[gBattleAnimTarget]].affineAnimEnded) + { + StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattleAnimTarget]], 0); + next = TRUE; + } + else + { + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].data[1] -= 288; + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].pos2.y = gSprites[gBattlerSpriteIds[gBattleAnimTarget]].data[1] >> 8; + } + + if (sprite->animEnded && next) + { + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].pos2.y = 0; + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].invisible = gBattleSpritesDataPtr->animationData->field_9_x2; + sprite->data[0] = 0; + sprite->callback = sub_81719C0; + gDoingBattleAnim = 0; + UpdateOamPriorityInAllHealthboxes(1); + } +} + +static void sub_8171CAC(struct Sprite *sprite) +{ + int i; + + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + for (i = 0; i < 6; i++) + sprite->data[i] = 0; + + sprite->callback = sub_8171CE8; +} + +static void sub_8171CE8(struct Sprite *sprite) +{ + s16 var0 = sprite->data[0] + 0x800; + s16 var1 = sprite->data[1] + 0x680; + sprite->pos2.x -= var1 >> 8; + sprite->pos2.y += var0 >> 8; + sprite->data[0] = (sprite->data[0] + 0x800) & 0xFF; + sprite->data[1] = (sprite->data[1] + 0x680) & 0xFF; + + if (sprite->pos1.y + sprite->pos2.y > 160 + || sprite->pos1.x + sprite->pos2.x < -8) + { + sprite->data[0] = 0; + sprite->callback = sub_81719C0; + gDoingBattleAnim = 0; + UpdateOamPriorityInAllHealthboxes(1); + } +} + +static void sub_8171D60(u8 ballId) +{ + u8 taskId; + + if (GetSpriteTileStartByTag(gBallOpenParticleSpritesheets[ballId].tag) == 0xFFFF) + { + LoadCompressedObjectPicUsingHeap(&gBallOpenParticleSpritesheets[ballId]); + LoadCompressedObjectPaletteUsingHeap(&gBallOpenParticlePalettes[ballId]); + } +} + +u8 AnimateBallOpenParticles(u8 x, u8 y, u8 priority, u8 subpriority, u8 ballId) +{ + u8 taskId; + + sub_8171D60(ballId); + taskId = CreateTask(gBallOpenParticleAnimationFuncs[ballId], 5); + gTasks[taskId].data[1] = x; + gTasks[taskId].data[2] = y; + gTasks[taskId].data[3] = priority; + gTasks[taskId].data[4] = subpriority; + gTasks[taskId].data[15] = ballId; + PlaySE(SE_BOWA2); + + return taskId; +} + +void sub_8171E20(void) +{ + if (gMain.inBattle) + gBattleSpritesDataPtr->animationData->field_A++; +} + +static void PokeBallOpenParticleAnimation(u8 taskId) +{ + u8 spriteId; + u8 x, y; + u8 priority, subpriority; + u8 ballId; + u8 var0; + + ballId = gTasks[taskId].data[15]; + if (gTasks[taskId].data[0] < 16) + { + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = PokeBallOpenParticleAnimation_Step1; + gSprites[spriteId].oam.priority = priority; + + var0 = (u8)gTasks[taskId].data[0]; + if (var0 >= 8) + var0 -= 8; + + gSprites[spriteId].data[0] = var0 * 32; + } + + if (gTasks[taskId].data[0] == 15) + { + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); + return; + } + } + + gTasks[taskId].data[0]++; +} + +static void PokeBallOpenParticleAnimation_Step1(struct Sprite *sprite) +{ + if (sprite->data[1] == 0) + sprite->callback = PokeBallOpenParticleAnimation_Step2; + else + sprite->data[1]--; +} + +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) + DestroyBallOpenAnimationParticle(sprite); +} + +static void TimerBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 10; + gSprites[spriteId].data[5] = 2; + gSprites[spriteId].data[6] = 1; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +static void DiveBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 10; + gSprites[spriteId].data[5] = 1; + gSprites[spriteId].data[6] = 2; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +// Also used for Net Ball +static void SafariBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 4; + gSprites[spriteId].data[5] = 1; + gSprites[spriteId].data[6] = 1; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +// Also used for Nest Ball +static void UltraBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 10; i++) + { + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 25; + gSprites[spriteId].data[4] = 5; + gSprites[spriteId].data[5] = 1; + gSprites[spriteId].data[6] = 1; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +// Also used for Luxury Ball +static void GreatBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + if (gTasks[taskId].data[7]) + { + gTasks[taskId].data[7]--; + } + else + { + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 8; + gSprites[spriteId].data[5] = 2; + gSprites[spriteId].data[6] = 2; + } + } + + gTasks[taskId].data[7] = 8; + if (++gTasks[taskId].data[0] == 2) + { + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); + } + } +} + +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]); + sprite->data[0] = (sprite->data[0] + sprite->data[4]) & 0xFF; + sprite->data[1] += sprite->data[5]; + sprite->data[2] += sprite->data[6]; + if (++sprite->data[3] == 51) + DestroyBallOpenAnimationParticle(sprite); +} + +static void RepeatBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 12; i++) + { + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = RepeatBallOpenParticleAnimation_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 21; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +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])); + sprite->data[0] = (sprite->data[0] + 6) & 0xFF; + sprite->data[1]++; + sprite->data[2]++; + if (++sprite->data[3] == 51) + DestroyBallOpenAnimationParticle(sprite); +} + +static void MasterBallOpenParticleAnimation(u8 taskId) +{ + u8 i, j; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (j = 0; j < 2; j++) + { + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 8; + + if (j == 0) + { + gSprites[spriteId].data[5] = 2; + gSprites[spriteId].data[6] = 1; + } + else + { + gSprites[spriteId].data[5] = 1; + gSprites[spriteId].data[6] = 2; + } + } + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +static void PremierBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gUnknown_085E51F0[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_8171E20(); + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[ballId]); + gSprites[spriteId].callback = PremierBallOpenParticleAnimation_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +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])); + sprite->data[0] = (sprite->data[0] + 10) & 0xFF; + sprite->data[1]++; + sprite->data[2]++; + if (++sprite->data[3] == 51) + DestroyBallOpenAnimationParticle(sprite); +} + +static void DestroyBallOpenAnimationParticle(struct Sprite *sprite) +{ + int i, j; + int temp; + + if (!gMain.inBattle) + { + temp = sprite->data[7]; // temp var needed to match + if (temp == 1) + DestroySpriteAndFreeResources(sprite); + else + DestroySprite(sprite); + } + else + { + gBattleSpritesDataPtr->animationData->field_A--; + if (gBattleSpritesDataPtr->animationData->field_A == 0) + { + for (i = 0; i < 12; i++) + { + if (FuncIsActiveTask(gBallOpenParticleAnimationFuncs[i]) == TRUE) + break; + } + + if (i == 12) + { + for (j = 0; j < 12; j++) + { + FreeSpriteTilesByTag(gBallOpenParticleSpritesheets[j].tag); + FreeSpritePaletteByTag(gBallOpenParticlePalettes[j].tag); + } + } + + DestroySprite(sprite); + } + else + { + DestroySprite(sprite); + } + } +} + +u8 LaunchBallFadeMonTask(u8 unfadeLater, u8 battler, u32 selectedPalettes, u8 ballId) +{ + u8 taskId; + + taskId = CreateTask(sub_8172AB0, 5); + gTasks[taskId].data[15] = ballId; + gTasks[taskId].data[3] = battler; + gTasks[taskId].data[10] = selectedPalettes; + gTasks[taskId].data[11] = selectedPalettes >> 16; + + if (!unfadeLater) + { + BlendPalette(battler * 16 + 0x100, 16, 0, gUnknown_085E5310[ballId]); + gTasks[taskId].data[1] = 1; + } + else + { + BlendPalette(battler * 16 + 0x100, 16, 16, gUnknown_085E5310[ballId]); + gTasks[taskId].data[0] = 16; + gTasks[taskId].data[1] = -1; + gTasks[taskId].func = sub_8172B40; + } + + BeginNormalPaletteFade(selectedPalettes, 0, 0, 16, RGB(31, 31, 31)); + return taskId; +} + +static void sub_8172AB0(u8 taskId) +{ + u8 ballId = gTasks[taskId].data[15]; + + if (gTasks[taskId].data[2] <= 16) + { + BlendPalette(gTasks[taskId].data[3] * 16 + 0x100, 16, gTasks[taskId].data[0], gUnknown_085E5310[ballId]); + gTasks[taskId].data[0] += gTasks[taskId].data[1]; + gTasks[taskId].data[2]++; + } + else if (!gPaletteFade.active) + { + u32 selectedPalettes = (u16)gTasks[taskId].data[10] | ((u16)gTasks[taskId].data[11] << 16); + BeginNormalPaletteFade(selectedPalettes, 0, 16, 0, RGB(31, 31, 31)); + DestroyTask(taskId); + } +} + +static void sub_8172B40(u8 taskId) +{ + if (!gPaletteFade.active) + { + u32 selectedPalettes = (u16)gTasks[taskId].data[10] | ((u16)gTasks[taskId].data[11] << 16); + BeginNormalPaletteFade(selectedPalettes, 0, 16, 0, RGB(31, 31, 31)); + gTasks[taskId].func = sub_8172B90; + } +} + +static void sub_8172B90(u8 taskId) +{ + u8 ballId = gTasks[taskId].data[15]; + + if (gTasks[taskId].data[2] <= 16) + { + BlendPalette(gTasks[taskId].data[3] * 16 + 0x100, 16, gTasks[taskId].data[0], gUnknown_085E5310[ballId]); + gTasks[taskId].data[0] += gTasks[taskId].data[1]; + gTasks[taskId].data[2]++; + } + else + { + DestroyTask(taskId); + } +} + +void sub_8172BF0(u8 taskId) +{ + u8 spriteId; + u32 x; + u32 done; + + done = FALSE; + spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; + switch (gTasks[taskId].data[10]) + { + case 0: + gTasks[taskId].data[11] = gBattleAnimArgs[0]; + gTasks[taskId].data[0] += 0x500; + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gSprites[spriteId].pos2.x += gTasks[taskId].data[0] >> 8; + else + gSprites[spriteId].pos2.x -= gTasks[taskId].data[0] >> 8; + + gTasks[taskId].data[0] &= 0xFF; + x = gSprites[spriteId].pos1.x + gSprites[spriteId].pos2.x + 32; + if (x > 304) + gTasks[taskId].data[10]++; + break; + case 1: + LoadBattleMonGfxAndAnimate(gBattleAnimAttacker, gTasks[taskId].data[11], spriteId); + gTasks[taskId].data[10]++; + break; + case 2: + gTasks[taskId].data[0] += 0x500; + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gSprites[spriteId].pos2.x -= gTasks[taskId].data[0] >> 8; + else + gSprites[spriteId].pos2.x += gTasks[taskId].data[0] >> 8; + + gTasks[taskId].data[0] &= 0xFF; + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + { + if (gSprites[spriteId].pos2.x <= 0) + { + gSprites[spriteId].pos2.x = 0; + // done = FALSE; // fakematching--can't get the tail merge correct + goto DONE; + } + } + else + { + if (gSprites[spriteId].pos2.x >= 0) + { + gSprites[spriteId].pos2.x = 0; + done = TRUE; + } + } + + if (done) + { + DONE: + DestroyAnimVisualTask(taskId); + } + break; + } +} + +void sub_8172D98(u8 taskId) +{ + u8 spriteId; + + switch (gTasks[taskId].data[15]) + { + case 0: + if (sub_80A8364(gBattleAnimAttacker) == B_POSITION_OPPONENT_LEFT) + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + else + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + gTasks[taskId].data[15]++; + break; + case 1: + if (gTasks[taskId].data[1]++ > 1) + { + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[0]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16 - gTasks[taskId].data[0], gTasks[taskId].data[0])); + if (gTasks[taskId].data[0] == 16) + gTasks[taskId].data[15]++; + } + break; + case 2: + spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; + RequestDma3Fill(0, (void *)OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * TILE_SIZE_4BPP, 0x800, 1); + ClearBehindSubstituteBit(gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_8172E9C(u8 taskId) +{ + gBattleAnimArgs[7] = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].behindSubstitute; + DestroyAnimVisualTask(taskId); +} + +void sub_8172ED0(u8 taskId) +{ + gBattleAnimTarget = gEffectBattler; + DestroyAnimVisualTask(taskId); +} + +void sub_8172EF0(u8 battler, struct Pokemon *mon) +{ + int isShiny; + u32 otId, personality; + u32 shinyValue; + u8 taskId1, taskId2; + + isShiny = 0; + gBattleSpritesDataPtr->healthBoxesData[battler].flag_x80 = 1; + otId = GetMonData(mon, MON_DATA_OT_ID); + personality = GetMonData(mon, MON_DATA_PERSONALITY); + + if (IsBattlerSpriteVisible(battler)) + { + shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); + if (shinyValue < 8) + isShiny = TRUE; + + if (isShiny) + { + if (GetSpriteTileStartByTag(0x27F9) == 0xFFFF) + { + LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[233]); + LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[233]); + } + + taskId1 = CreateTask(sub_8172FEC, 10); + taskId2 = CreateTask(sub_8172FEC, 10); + gTasks[taskId1].data[0] = battler; + gTasks[taskId2].data[0] = battler; + gTasks[taskId1].data[1] = 0; + gTasks[taskId2].data[1] = 1; + return; + } + } + + gBattleSpritesDataPtr->healthBoxesData[battler].field_1_x1 = 1; +} + +static void sub_8172FEC(u8 taskId) +{ + u8 battler; + u8 x, y; + u8 spriteId; + u16 counter; + s16 state; + u8 pan; + + if (gTasks[taskId].data[13] < 60) + { + gTasks[taskId].data[13]++; + return; + } + + if (gBattleSpritesDataPtr->animationData->field_A) + return; + + counter = gTasks[taskId].data[10]++; + if (counter & 3) + return; + + battler = gTasks[taskId].data[0]; + x = GetBattlerSpriteCoord(battler, 0); + y = GetBattlerSpriteCoord(battler, 1); + state = gTasks[taskId].data[11]; + if (state == 0) + { + spriteId = CreateSprite(&gUnknown_085CE388, x, y, 5); + } + else if (state >= 0 && gTasks[taskId].data[11] < 4) + { + spriteId = CreateSprite(&gUnknown_085CE3A0, x, y, 5); + gSprites[spriteId].oam.tileNum += 4; + } + else + { + spriteId = CreateSprite(&gUnknown_085CE3A0, x, y, 5); + gSprites[spriteId].oam.tileNum += 5; + } + + if (gTasks[taskId].data[1] == 0) + { + gSprites[spriteId].callback = sub_81731FC; + } + else + { + gSprites[spriteId].callback = sub_8173250; + gSprites[spriteId].pos2.x = -32; + gSprites[spriteId].pos2.y = 32; + gSprites[spriteId].invisible = 1; + if (gTasks[taskId].data[11] == 0) + { + if (GetBattlerSide(battler) == B_SIDE_PLAYER) + pan = 192; + else + pan = 63; + + PlaySE12WithPanning(SE_REAPOKE, pan); + } + } + + gSprites[spriteId].data[0] = taskId; + gTasks[taskId].data[11]++; + if (spriteId != MAX_SPRITES) + gTasks[taskId].data[12]++; + + if (gTasks[taskId].data[11] == 5) + gTasks[taskId].func = sub_81731B0; +} + +static void sub_81731B0(u8 taskId) +{ + u8 battler; + + if (gTasks[taskId].data[12] == 0) + { + if (gTasks[taskId].data[1] == 1) + { + battler = gTasks[taskId].data[0]; + gBattleSpritesDataPtr->healthBoxesData[battler].field_1_x1 = 1; + } + + DestroyTask(taskId); + } +} + +static void sub_81731FC(struct Sprite *sprite) +{ + sprite->pos2.x = Sin(sprite->data[1], 24); + sprite->pos2.y = Cos(sprite->data[1], 24); + sprite->data[1] += 12; + if (sprite->data[1] > 0xFF) + { + gTasks[sprite->data[0]].data[12]--; + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } +} + +static void sub_8173250(struct Sprite *sprite) +{ + if (sprite->data[1] < 4) + { + sprite->data[1]++; + } + else + { + sprite->invisible = 0; + sprite->pos2.x += 5; + sprite->pos2.y -= 5; + if (sprite->pos2.x > 32) + { + gTasks[sprite->data[0]].data[12]--; + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } + } +} + +void sub_81732B0(u8 taskId) +{ + u8 paletteIndex; + + LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[269]); + LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[269]); + paletteIndex = IndexOfSpritePaletteTag(0x281D); // unused + DestroyAnimVisualTask(taskId); +} + +void sub_81732E4(u8 taskId) +{ + FreeSpriteTilesByTag(0x281D); + FreeSpritePaletteByTag(0x281D); + DestroyAnimVisualTask(taskId); +} + +static void sub_817330C(struct Sprite *sprite) +{ + InitAnimSpritePos(sprite, 0); + sprite->data[0] = 30; + sprite->data[2] = GetBattlerSpriteCoord(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), 0) + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), 1) + gBattleAnimArgs[3]; + sprite->data[5] = -32; + InitAnimArcTranslation(sprite); + gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].callback = sub_8039E84; + sprite->callback = sub_817339C; +} + +static void sub_817339C(struct Sprite *sprite) +{ + if (gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].animCmdIndex == 1) + sprite->callback = sub_81733D4; +} + +static void sub_81733D4(struct Sprite *sprite) +{ + if (TranslateAnimArc(sprite)) + { + sprite->data[0] = 0; + sprite->invisible = 1; + sprite->callback = sub_8173400; + } +} + +static void sub_8173400(struct Sprite *sprite) +{ + if (gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].animEnded) + { + if (++sprite->data[0] > 0) + { + StartSpriteAnim(&gSprites[gBattlerSpriteIds[gBattleAnimAttacker]], 0); + DestroyAnimSprite(sprite); + } + } +} + +void sub_817345C(u8 taskId) +{ + switch (gBattleAnimArgs[0]) + { + case 0: + gBattleAnimAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + gBattleAnimTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + break; + case 1: + gBattleAnimAttacker = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + gBattleAnimTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + break; + } + + DestroyAnimVisualTask(taskId); +} + +void AnimTask_GetTrappedMoveAnimId(u8 taskId) +{ + if (gBattleSpritesDataPtr->animationData->animArg == 83) + gBattleAnimArgs[0] = 1; + else if (gBattleSpritesDataPtr->animationData->animArg == 250) + gBattleAnimArgs[0] = 2; + else if (gBattleSpritesDataPtr->animationData->animArg == 128) + gBattleAnimArgs[0] = 3; + else if (gBattleSpritesDataPtr->animationData->animArg == 328) + gBattleAnimArgs[0] = 4; + else + gBattleAnimArgs[0] = 0; + + DestroyAnimVisualTask(taskId); +} + +void sub_817351C(u8 taskId) +{ + gBattleAnimAttacker = gBattleSpritesDataPtr->animationData->animArg; + gBattleAnimTarget = gBattleSpritesDataPtr->animationData->animArg >> 8; + DestroyAnimVisualTask(taskId); +} diff --git a/src/battle_intro.c b/src/battle_intro.c index 91e7c8ea0..736e35a87 100644 --- a/src/battle_intro.c +++ b/src/battle_intro.c @@ -250,12 +250,7 @@ static void BattleIntroSlide2(u8 taskId) if (gTasks[taskId].data[1] == 4) { - u16 *bg1Y = &gBattle_BG1_Y; - int cos = Cos2(gTasks[taskId].data[6]); - if (cos < 0) - cos += 0x1FF; - *bg1Y = (cos >> 9) - 8; - + gBattle_BG1_Y = Cos2(gTasks[taskId].data[6]) / 512 - 8; if (gTasks[taskId].data[6] < 180) gTasks[taskId].data[6] += 4; else diff --git a/src/pokeball.c b/src/pokeball.c index ad839e6af..82d2f2cea 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -426,7 +426,7 @@ static void SpriteCB_TestBallThrow(struct Sprite *sprite) sprite->pos2.y = 0; sprite->data[5] = 0; ballId = ItemIdToBallId(GetBattlerPokeballItemId(opponentBattler)); - LaunchBallStarsTask(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, ballId); + AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, ballId); sprite->data[0] = LaunchBallFadeMonTask(FALSE, opponentBattler, 14, ballId); sprite->sBattler = opponentBattler; sprite->data[7] = noOfShakes; @@ -737,7 +737,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) StartSpriteAnim(sprite, 1); ballId = ItemIdToBallId(GetBattlerPokeballItemId(battlerId)); - LaunchBallStarsTask(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, ballId); + AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, ballId); sprite->data[0] = LaunchBallFadeMonTask(1, sprite->sBattler, 14, ballId); sprite->callback = HandleBallAnimEnd; @@ -985,9 +985,9 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite) #undef sBattler -static u8 LaunchBallStarsTaskForPokeball(u8 x, u8 y, u8 kindOfStars, u8 d) +static u8 AnimateBallOpenParticlesForPokeball(u8 x, u8 y, u8 kindOfStars, u8 d) { - return LaunchBallStarsTask(x, y, kindOfStars, d, BALL_POKE); + return AnimateBallOpenParticles(x, y, kindOfStars, d, BALL_POKE); } static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 battlerId, u32 arg2) @@ -1036,7 +1036,7 @@ static void sub_8076524(struct Sprite *sprite) r5 = 0; StartSpriteAnim(sprite, 1); - LaunchBallStarsTaskForPokeball(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r5); + AnimateBallOpenParticlesForPokeball(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r5); sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, battlerId, r4); sprite->callback = sub_80765E0; gSprites[r7].invisible = FALSE; @@ -1129,7 +1129,7 @@ static void sub_80767D4(struct Sprite *sprite) r6 = 0; StartSpriteAnim(sprite, 1); - LaunchBallStarsTaskForPokeball(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r6); + AnimateBallOpenParticlesForPokeball(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r6); sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, r8, r5); sprite->callback = sub_807687C; StartSpriteAffineAnim(&gSprites[r7], 2); diff --git a/src/pokemon.c b/src/pokemon.c index eec995050..22b92870c 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -45,12 +45,6 @@ struct SpeciesItem u16 item; }; -// Extracts the upper 16 bits of a 32-bit number -#define HIHALF(n) (((n) & 0xFFFF0000) >> 16) - -// Extracts the lower 16 bits of a 32-bit number -#define LOHALF(n) ((n) & 0xFFFF) - extern const struct OamData gUnknown_0831ACB0; extern const struct OamData gUnknown_0831ACA8; extern const struct SpriteFrameImage gUnknown_082FF3A8[]; @@ -6707,12 +6701,6 @@ const u32 *GetMonFrontSpritePal(struct Pokemon *mon) return GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality); } -// Extracts the upper 16 bits of a 32-bit number -#define HIHALF(n) (((n) & 0xFFFF0000) >> 16) - -// Extracts the lower 16 bits of a 32-bit number -#define LOHALF(n) ((n) & 0xFFFF) - const u32 *GetFrontSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 personality) { u32 shinyValue; diff --git a/sym_common.txt b/sym_common.txt index e8d1654c0..bb84ec06e 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -77,16 +77,7 @@ gDexCryScreenState: @ 30061EC .include "save.o" .include "battle_tower.o" .include "intro.o" - -gUnknown_030062DC: @ 30062DC - .space 0x4 - -gUnknown_030062E0: @ 30062E0 - .space 0x4 - -gUnknown_030062E4: @ 30062E4 - .space 0x4 - + .include "battle_anim_8170478.o" .include "battle_factory_screen.o" .include "apprentice.o"