From 61343d50698e035834eb276b48189d4db0a4b9b8 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 7 Oct 2018 15:39:46 +0200 Subject: [PATCH] Decompile battle_anim_80A9C70 --- asm/battle_anim_80A9C70.s | 930 ----------------------------------- data/battle_anim_80A9C70.s | 17 - include/battle_anim.h | 8 + ld_script.txt | 3 +- src/battle_anim_80A9C70.c | 360 ++++++++++++++ src/battle_script_commands.c | 25 +- 6 files changed, 383 insertions(+), 960 deletions(-) delete mode 100644 asm/battle_anim_80A9C70.s create mode 100644 src/battle_anim_80A9C70.c diff --git a/asm/battle_anim_80A9C70.s b/asm/battle_anim_80A9C70.s deleted file mode 100644 index f43b36452..000000000 --- a/asm/battle_anim_80A9C70.s +++ /dev/null @@ -1,930 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - thumb_func_start sub_80A9C70 -sub_80A9C70: @ 80A9C70 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gBattlerSpriteIds - adds r0, r4, r0 - ldrb r6, [r0] - ldr r0, =sub_80A9DB4 - movs r1, 0xA - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, =gBattleAnimPicTable + 0x440 - bl LoadCompressedObjectPicUsingHeap - ldr r0, =gBattleAnimPaletteTable + 0x440 - bl LoadCompressedObjectPaletteUsingHeap - ldr r1, =gTasks - mov r2, r8 - lsls r0, r2, 2 - add r0, r8 - lsls r0, 3 - adds r1, r0, r1 - strh r4, [r1, 0x8] - cmp r5, 0 - beq _080A9D30 - movs r0, 0x1F - strh r0, [r1, 0xA] - movs r5, 0 - lsls r0, r6, 4 - ldr r7, =gSprites - adds r0, r6 - lsls r0, 2 - adds r6, r0, r7 -_080A9CC4: - movs r0, 0x20 - ldrsh r1, [r6, r0] - ldrh r2, [r6, 0x22] - adds r2, 0x20 - lsls r2, 16 - asrs r2, 16 - ldr r0, =gUnknown_0853EF60 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - adds r3, r0, r7 - lsls r0, r5, 1 - adds r0, r5 - lsls r1, r0, 4 - adds r0, r1 - strh r0, [r3, 0x2E] - movs r0, 0xFF - lsls r0, 8 - strh r0, [r3, 0x30] - adds r2, r3, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - cmp r5, 0x4 - bls _080A9D08 - movs r0, 0x15 - strh r0, [r3, 0x3A] -_080A9D08: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x9 - bls _080A9CC4 - b _080A9D90 - .pool -_080A9D30: - movs r0, 0xF8 - lsls r0, 7 - strh r0, [r1, 0xA] - movs r5, 0 - lsls r0, r6, 4 - ldr r7, =gSprites - adds r0, r6 - lsls r0, 2 - adds r6, r0, r7 -_080A9D42: - movs r2, 0x20 - ldrsh r1, [r6, r2] - ldrh r2, [r6, 0x22] - subs r2, 0x20 - lsls r2, 16 - asrs r2, 16 - ldr r0, =gUnknown_0853EF60 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - adds r3, r0, r7 - lsls r0, r5, 1 - adds r0, r5 - lsls r1, r0, 4 - adds r0, r1 - strh r0, [r3, 0x2E] - movs r0, 0x80 - lsls r0, 1 - strh r0, [r3, 0x30] - adds r2, r3, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - cmp r5, 0x4 - bls _080A9D86 - movs r0, 0x15 - strh r0, [r3, 0x3A] -_080A9D86: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x9 - bls _080A9D42 -_080A9D90: - ldr r0, =gSprites - lsls r1, r4, 4 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x3C] - mov r0, r8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80A9C70 - - thumb_func_start sub_80A9DB4 -sub_80A9DB4: @ 80A9DB4 - 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 - ldrh r1, [r4, 0xC] - movs r2, 0xC - ldrsh r0, [r4, r2] - cmp r0, 0x2 - bne _080A9E3A - movs r0, 0 - strh r0, [r4, 0xC] - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 20 - movs r2, 0x80 - lsls r2, 17 - adds r0, r2 - lsrs r0, 16 - ldrb r2, [r4, 0x10] - ldrh r3, [r4, 0xA] - movs r1, 0x10 - bl BlendPalette - ldrh r2, [r4, 0x12] - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _080A9E10 - ldrh r0, [r4, 0x10] - adds r0, 0x1 - strh r0, [r4, 0x10] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x8 - ble _080A9E3E - movs r0, 0x1 - eors r0, r2 - strh r0, [r4, 0x12] - b _080A9E3E - .pool -_080A9E10: - ldrh r1, [r4, 0x10] - subs r0, r1, 0x1 - strh r0, [r4, 0x10] - lsls r0, 16 - cmp r0, 0 - bge _080A9E3E - strh r1, [r4, 0x10] - movs r0, 0x1 - eors r0, r2 - strh r0, [r4, 0x12] - ldrh r0, [r4, 0xE] - adds r0, 0x1 - strh r0, [r4, 0xE] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - bne _080A9E3E - adds r0, r5, 0 - bl DestroyTask - b _080A9E3E -_080A9E3A: - adds r0, r1, 0x1 - strh r0, [r4, 0xC] -_080A9E3E: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80A9DB4 - - thumb_func_start sub_80A9E44 -sub_80A9E44: @ 80A9E44 - push {lr} - adds r2, r0, 0 - ldrh r1, [r2, 0x3A] - movs r3, 0x3A - ldrsh r0, [r2, r3] - cmp r0, 0 - bne _080A9E70 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x5 - negs r1, r1 - ands r1, r0 - strb r1, [r3] - ldr r1, =sub_80A9E78 - str r1, [r2, 0x1C] - adds r0, r2, 0 - bl _call_via_r1 - b _080A9E74 - .pool -_080A9E70: - subs r0, r1, 0x1 - strh r0, [r2, 0x3A] -_080A9E74: - pop {r0} - bx r0 - thumb_func_end sub_80A9E44 - - thumb_func_start sub_80A9E78 -sub_80A9E78: @ 80A9E78 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r1, 0x20 - bl Cos - strh r0, [r4, 0x24] - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r1, 0x8 - bl Sin - strh r0, [r4, 0x26] - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0x7F - bgt _080A9EA4 - adds r1, r4, 0 - adds r1, 0x43 - movs r0, 0x1D - b _080A9EAA -_080A9EA4: - adds r1, r4, 0 - adds r1, 0x43 - movs r0, 0x1F -_080A9EAA: - strb r0, [r1] - ldrh r0, [r4, 0x2E] - adds r0, 0x8 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x2E] - ldrh r0, [r4, 0x30] - ldrh r1, [r4, 0x38] - adds r0, r1 - strh r0, [r4, 0x38] - lsls r0, 16 - asrs r0, 24 - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x32] - adds r0, 0x1 - strh r0, [r4, 0x32] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x34 - bne _080A9EEC - movs r1, 0x3C - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080A9EE6 - adds r0, r4, 0 - bl DestroySpriteAndFreeResources - b _080A9EEC -_080A9EE6: - adds r0, r4, 0 - bl DestroySprite -_080A9EEC: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80A9E78 - - thumb_func_start sub_80A9EF4 -sub_80A9EF4: @ 80A9EF4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 8 - ldr r1, =0xffe00000 - adds r0, r1 - lsrs r5, r0, 16 - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 8 - ldr r1, =0xffdc0000 - adds r0, r1 - lsrs r4, r0, 16 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _080A9F32 - lsls r0, r5, 16 - ldr r1, =0xfffa0000 - adds r0, r1 - lsrs r5, r0, 16 -_080A9F32: - movs r1, 0xFD - lsls r1, 6 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - ldr r0, =gUnknown_0853EF48 - lsls r1, r5, 16 - asrs r1, 16 - lsls r2, r4, 16 - asrs r2, 16 - movs r3, 0x4 - bl CreateSprite - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =0x0000271a - bl GetSpriteTileStartByTag - lsls r0, 16 - ldr r1, =0xffff0000 - cmp r0, r1 - bne _080A9F7C - 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] -_080A9F7C: - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - ldr r1, =gUnknown_0853EF40 - bl SetSubspriteTables - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - strh r4, [r0, 0x26] - ldr r1, =sub_80A9FD0 - str r1, [r0] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A9EF4 - - thumb_func_start sub_80A9FD0 -sub_80A9FD0: @ 80A9FD0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrh r0, [r1, 0xA] - adds r0, 0x1 - adds r2, r0, 0 - strh r0, [r1, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - bne _080AA004 - ldr r0, =sub_80AA020 - str r0, [r1] - movs r0, 0 - strh r0, [r1, 0xA] - b _080AA01A - .pool -_080AA004: - lsls r0, r2, 24 - lsrs r0, 24 - movs r1, 0x10 - subs r1, r0 - lsls r1, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg -_080AA01A: - pop {r0} - bx r0 - thumb_func_end sub_80A9FD0 - - thumb_func_start sub_80AA020 -sub_80AA020: @ 80AA020 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x0000271a - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r5, r0, r1 - ldrh r0, [r5, 0xA] - adds r1, r0, 0x1 - strh r1, [r5, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xD - ble _080AA0B0 - ldrh r0, [r5, 0xC] - adds r0, 0x1 - movs r6, 0 - strh r0, [r5, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3 - bne _080AA0B0 - ldr r3, =gPlttBufferFaded - lsls r2, 4 - mov r12, r2 - ldr r1, =0x0000010d - add r1, r12 - lsls r1, 1 - adds r1, r3 - ldrh r4, [r1] - movs r2, 0x87 - lsls r2, 1 - add r2, r12 - lsls r2, 1 - adds r2, r3 - ldrh r0, [r2] - strh r0, [r1] - ldr r0, =0x0000010f - add r0, r12 - lsls r0, 1 - adds r0, r3 - ldrh r1, [r0] - strh r1, [r2] - strh r4, [r0] - strh r6, [r5, 0xC] - ldrh r0, [r5, 0xE] - adds r0, 0x1 - strh r0, [r5, 0xE] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3 - bne _080AA0B0 - strh r6, [r5, 0xE] - strh r6, [r5, 0xA] - ldrh r0, [r5, 0x10] - adds r0, 0x1 - strh r0, [r5, 0x10] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - bne _080AA0B0 - movs r0, 0x9 - strh r0, [r5, 0xA] - ldr r0, =sub_80AA0D0 - str r0, [r5] -_080AA0B0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80AA020 - - thumb_func_start sub_80AA0D0 -sub_80AA0D0: @ 80AA0D0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r2, r1, r2 - ldrh r0, [r2, 0xA] - subs r0, 0x1 - adds r3, r0, 0 - strh r0, [r2, 0xA] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - bne _080AA108 - ldr r0, =sub_80AA124 - str r0, [r2] - movs r0, 0 - strh r0, [r2, 0xA] - b _080AA11E - .pool -_080AA108: - lsls r0, r3, 24 - lsrs r0, 24 - movs r1, 0x10 - subs r1, r0 - lsls r1, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg -_080AA11E: - pop {r0} - bx r0 - thumb_func_end sub_80AA0D0 - - thumb_func_start sub_80AA124 -sub_80AA124: @ 80AA124 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r1, r0, r1 - ldrh r0, [r1, 0xA] - adds r0, 0x1 - strh r0, [r1, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x25 - bne _080AA16C - ldrh r0, [r1, 0x26] - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - adds r0, r4, 0 - bl FreeSpriteOamMatrix - adds r0, r4, 0 - bl DestroySprite - b _080AA186 - .pool -_080AA16C: - cmp r0, 0x27 - bne _080AA186 - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - adds r0, r4, 0 - bl DestroyAnimVisualTask -_080AA186: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80AA124 - - thumb_func_start AnimTask_StatsChange -AnimTask_StatsChange: @ 80AA18C - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - movs r3, 0 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x8] - ldrh r0, [r0] - subs r0, 0xF - cmp r0, 0x2B - bls _080AA1A4 - b _080AA328 -_080AA1A4: - lsls r0, 2 - ldr r1, =_080AA1B8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080AA1B8: - .4byte _080AA268 - .4byte _080AA26E - .4byte _080AA274 - .4byte _080AA27A - .4byte _080AA280 - .4byte _080AA286 - .4byte _080AA28C - .4byte _080AA292 - .4byte _080AA298 - .4byte _080AA29E - .4byte _080AA2A4 - .4byte _080AA2AA - .4byte _080AA2B0 - .4byte _080AA2B6 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA2BC - .4byte _080AA2C0 - .4byte _080AA2C4 - .4byte _080AA2C8 - .4byte _080AA2CC - .4byte _080AA2D0 - .4byte _080AA2D4 - .4byte _080AA2D8 - .4byte _080AA2E0 - .4byte _080AA2E8 - .4byte _080AA2F0 - .4byte _080AA2F8 - .4byte _080AA300 - .4byte _080AA308 - .4byte _080AA328 - .4byte _080AA328 - .4byte _080AA310 - .4byte _080AA314 - .4byte _080AA318 - .4byte _080AA320 -_080AA268: - movs r5, 0 - movs r2, 0 - b _080AA330 -_080AA26E: - movs r5, 0 - movs r2, 0x1 - b _080AA330 -_080AA274: - movs r5, 0 - movs r2, 0x3 - b _080AA330 -_080AA27A: - movs r5, 0 - movs r2, 0x5 - b _080AA330 -_080AA280: - movs r5, 0 - movs r2, 0x6 - b _080AA330 -_080AA286: - movs r5, 0 - movs r2, 0x2 - b _080AA330 -_080AA28C: - movs r5, 0 - movs r2, 0x4 - b _080AA330 -_080AA292: - movs r5, 0x1 - movs r2, 0 - b _080AA330 -_080AA298: - movs r5, 0x1 - movs r2, 0x1 - b _080AA330 -_080AA29E: - movs r5, 0x1 - movs r2, 0x3 - b _080AA330 -_080AA2A4: - movs r5, 0x1 - movs r2, 0x5 - b _080AA330 -_080AA2AA: - movs r5, 0x1 - movs r2, 0x6 - b _080AA330 -_080AA2B0: - movs r5, 0x1 - movs r2, 0x2 - b _080AA330 -_080AA2B6: - movs r5, 0x1 - movs r2, 0x4 - b _080AA330 -_080AA2BC: - movs r5, 0 - b _080AA2DA -_080AA2C0: - movs r5, 0 - b _080AA2E2 -_080AA2C4: - movs r5, 0 - b _080AA2EA -_080AA2C8: - movs r5, 0 - b _080AA2F2 -_080AA2CC: - movs r5, 0 - b _080AA2FA -_080AA2D0: - movs r5, 0 - b _080AA302 -_080AA2D4: - movs r5, 0 - b _080AA30A -_080AA2D8: - movs r5, 0x1 -_080AA2DA: - movs r2, 0 - movs r3, 0x1 - b _080AA330 -_080AA2E0: - movs r5, 0x1 -_080AA2E2: - movs r2, 0x1 - movs r3, 0x1 - b _080AA330 -_080AA2E8: - movs r5, 0x1 -_080AA2EA: - movs r2, 0x3 - movs r3, 0x1 - b _080AA330 -_080AA2F0: - movs r5, 0x1 -_080AA2F2: - movs r2, 0x5 - movs r3, 0x1 - b _080AA330 -_080AA2F8: - movs r5, 0x1 -_080AA2FA: - movs r2, 0x6 - movs r3, 0x1 - b _080AA330 -_080AA300: - movs r5, 0x1 -_080AA302: - movs r2, 0x2 - movs r3, 0x1 - b _080AA330 -_080AA308: - movs r5, 0x1 -_080AA30A: - movs r2, 0x4 - movs r3, 0x1 - b _080AA330 -_080AA310: - movs r5, 0 - b _080AA31A -_080AA314: - movs r5, 0 - b _080AA322 -_080AA318: - movs r5, 0x1 -_080AA31A: - movs r2, 0xFF - movs r3, 0 - b _080AA330 -_080AA320: - movs r5, 0x1 -_080AA322: - movs r2, 0xFF - movs r3, 0x1 - b _080AA330 -_080AA328: - adds r0, r4, 0 - bl DestroyAnimVisualTask - b _080AA352 -_080AA330: - ldr r0, =gBattleAnimArgs - movs r1, 0 - strh r5, [r0] - strh r2, [r0, 0x2] - strh r1, [r0, 0x4] - strh r1, [r0, 0x6] - strh r3, [r0, 0x8] - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_8116EB4 - str r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 -_080AA352: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_StatsChange - - thumb_func_start LaunchStatusAnimation -LaunchStatusAnimation: @ 80AA364 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r1, 24 - lsrs r1, 24 - ldr r0, =gBattleAnimAttacker - strb r4, [r0] - ldr r0, =gBattleAnimTarget - strb r4, [r0] - ldr r0, =gBattleAnims_StatusConditions - movs r2, 0 - bl LaunchBattleAnimation - ldr r0, =task0A_80788BC - movs r1, 0xA - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r4, [r1, 0x8] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end LaunchStatusAnimation - - thumb_func_start task0A_80788BC -task0A_80788BC: @ 80AA3B4 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gAnimScriptCallback - ldr r0, [r0] - bl _call_via_r0 - ldr r0, =gAnimScriptActive - ldrb r0, [r0] - cmp r0, 0 - bne _080AA3F6 - ldr r0, =gBattleSpritesDataPtr - ldr r2, [r0] - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0x8 - ldrsh r0, [r0, r1] - ldr r2, [r2, 0x4] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r2, [r1] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - adds r0, r4, 0 - bl DestroyTask -_080AA3F6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task0A_80788BC - - .align 2, 0 @ Don't pad with nop. diff --git a/data/battle_anim_80A9C70.s b/data/battle_anim_80A9C70.s index 56486b8b7..892984c64 100644 --- a/data/battle_anim_80A9C70.s +++ b/data/battle_anim_80A9C70.s @@ -86,20 +86,3 @@ gUnknown_0853EF14:: @ 853EF14 .align 2 gUnknown_0853EF18:: @ 853EF18 spr_template 0x2714, 0x2714, gUnknown_085249CC, gUnknown_0853EEF8, NULL, gUnknown_0853EF14, sub_80A8A6C - - .align 2 -gUnknown_0853EF30:: @ 853EF30 - .byte 0xf0, 0xf0, 0x0c, 0x80, 0xf0, 0x30, 0x0d, 0x84, 0x30, 0xf0, 0x0e, 0x86, 0x30, 0x30, 0x08, 0x88 - - .align 2 -gUnknown_0853EF40:: @ 853EF40 - .4byte 0x00000004, gUnknown_0853EF30 - - .align 2 -gUnknown_0853EF48:: @ 853EF48 - spr_template 0x271a, 0x271a, gUnknown_08524A3C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_0853EF60:: @ 853EF60 - spr_template 0x2798, 0x2798, gUnknown_08524904, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80A9E44 - diff --git a/include/battle_anim.h b/include/battle_anim.h index c8a2779d8..2b5b3e20c 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -105,6 +105,14 @@ u8 sub_80A82E4(u8 battlerId); u8 GetSubstituteSpriteDefault_Y(u8 battlerId); // battle_anim_80A9C70.s +#define STAT_ANIM_PLUS1 15 +#define STAT_ANIM_PLUS2 39 +#define STAT_ANIM_MINUS1 22 +#define STAT_ANIM_MINUS2 46 +#define STAT_ANIM_MULTIPLE_PLUS1 55 +#define STAT_ANIM_MULTIPLE_PLUS2 56 +#define STAT_ANIM_MULTIPLE_MINUS1 57 +#define STAT_ANIM_MULTIPLE_MINUS2 58 void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId); // battle_anim_8170478.s diff --git a/ld_script.txt b/ld_script.txt index 1896b4fc9..6221f0501 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -114,7 +114,7 @@ SECTIONS { src/battle_anim_80A5C6C.o(.text); src/task.o(.text); src/reshow_battle_screen.o(.text); - asm/battle_anim_80A9C70.o(.text); + src/battle_anim_80A9C70.o(.text); src/title_screen.o(.text); asm/field_screen.o(.text); src/battle_setup.o(.text); @@ -423,6 +423,7 @@ SECTIONS { src/battle_anim_80A5C6C.o(.rodata); data/map_events.o(.rodata); data/battle_anim_80A9C70.o(.rodata); + src/battle_anim_80A9C70.o(.rodata); src/title_screen.o(.rodata); data/field_screen.o(.rodata); src/battle_setup.o(.rodata); diff --git a/src/battle_anim_80A9C70.c b/src/battle_anim_80A9C70.c new file mode 100644 index 000000000..1f8a53993 --- /dev/null +++ b/src/battle_anim_80A9C70.c @@ -0,0 +1,360 @@ +#include "global.h" +#include "battle.h" +#include "battle_anim.h" +#include "constants/battle_anim.h" +#include "constants/rgb.h" +#include "blend_palette.h" +#include "decompress.h" +#include "palette.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "gpu_regs.h" + +extern const struct CompressedSpriteSheet gBattleAnimPicTable[]; +extern const struct CompressedSpritePalette gBattleAnimPaletteTable[]; +extern const u8 *const gBattleAnims_StatusConditions[]; +extern const struct OamData gUnknown_08524904; +extern const struct OamData gUnknown_08524A3C; + +extern void sub_8116EB4(u8 taskId); + +// This file's functions. +static void sub_80A9DB4(u8 taskId); +static void sub_80A9FD0(u8 taskId); +static void sub_80AA020(u8 taskId); +static void sub_80AA0D0(u8 taskId); +static void sub_80AA124(u8 taskId); +static void Task_DoStatusAnimation(u8 taskId); +static void sub_80A9E44(struct Sprite *sprite); +static void sub_80A9E78(struct Sprite *sprite); + +// const rom data +static const struct Subsprite gUnknown_0853EF30[] = +{ + {.x = -16, .y = -16, .shape = ST_OAM_SQUARE, .size = 3, .tileOffset = 0, .priority = 2}, + {.x = -16, .y = 48, .shape = ST_OAM_H_RECTANGLE, .size = 3, .tileOffset = 64, .priority = 2}, + {.x = 48, .y = -16, .shape = ST_OAM_V_RECTANGLE, .size = 3, .tileOffset = 96, .priority = 2}, + {.x = 48, .y = 48, .shape = ST_OAM_SQUARE, .size = 2, .tileOffset = 128, .priority = 2}, +}; + +static const struct SubspriteTable gUnknown_0853EF40[] = +{ + {ARRAY_COUNT(gUnknown_0853EF30), gUnknown_0853EF30}, +}; + +static const struct SpriteTemplate gUnknown_0853EF48 = +{ + .tileTag = ANIM_TAG_ICE_CUBE, + .paletteTag = ANIM_TAG_ICE_CUBE, + .oam = &gUnknown_08524A3C, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +static const struct SpriteTemplate gUnknown_0853EF60 = +{ + .tileTag = ANIM_TAG_136, + .paletteTag = ANIM_TAG_136, + .oam = &gUnknown_08524904, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80A9E44, +}; + +// code +u8 sub_80A9C70(u8 battlerId, bool8 b) +{ + u8 battlerSpriteId = gBattlerSpriteIds[battlerId]; + u8 taskId = CreateTask(sub_80A9DB4, 10); + u8 spriteId2; + u8 i; + + LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_136)]); + LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_136)]); + gTasks[taskId].data[0] = battlerId; + if (b) + { + gTasks[taskId].data[1] = RGB_RED; + for (i = 0; i < 10; i++) + { + spriteId2 = CreateSprite(&gUnknown_0853EF60, gSprites[battlerSpriteId].pos1.x, gSprites[battlerSpriteId].pos1.y + 32, 0); + gSprites[spriteId2].data[0] = i * 51; + gSprites[spriteId2].data[1] = -256; + gSprites[spriteId2].invisible = TRUE; + if (i > 4) + gSprites[spriteId2].data[6] = 21; + } + } + else + { + gTasks[taskId].data[1] = RGB_BLUE; + for (i = 0; i < 10; i++) + { + spriteId2 = CreateSprite(&gUnknown_0853EF60, gSprites[battlerSpriteId].pos1.x, gSprites[battlerSpriteId].pos1.y - 32, 0); + gSprites[spriteId2].data[0] = i * 51; + gSprites[spriteId2].data[1] = 256; + gSprites[spriteId2].invisible = TRUE; + if (i > 4) + gSprites[spriteId2].data[6] = 21; + } + } + gSprites[spriteId2].data[7] = 1; + return taskId; +} + +static void sub_80A9DB4(u8 taskId) +{ + if (gTasks[taskId].data[2] == 2) + { + gTasks[taskId].data[2] = 0; + BlendPalette(0x100 + gTasks[taskId].data[0] * 16, 16, gTasks[taskId].data[4], gTasks[taskId].data[1]); + if (gTasks[taskId].data[5] == 0) + { + gTasks[taskId].data[4]++; + if (gTasks[taskId].data[4] > 8) + gTasks[taskId].data[5] ^= 1; + } + else + { + u16 var = gTasks[taskId].data[4]; + + gTasks[taskId].data[4]--; + if (gTasks[taskId].data[4] < 0) + { + gTasks[taskId].data[4] = var; + gTasks[taskId].data[5] ^= 1; + gTasks[taskId].data[3]++; + if (gTasks[taskId].data[3] == 2) + DestroyTask(taskId); + } + } + } + else + { + gTasks[taskId].data[2]++; + } +} + +static void sub_80A9E44(struct Sprite *sprite) +{ + if (sprite->data[6] == 0) + { + sprite->invisible = FALSE; + sprite->callback = sub_80A9E78; + sub_80A9E78(sprite); + } + else + { + sprite->data[6]--; + } +} + +static void sub_80A9E78(struct Sprite *sprite) +{ + sprite->pos2.x = Cos(sprite->data[0], 32); + sprite->pos2.y = Sin(sprite->data[0], 8); + if (sprite->data[0] < 128) + sprite->subpriority = 29; + else + sprite->subpriority = 31; + sprite->data[0] = (sprite->data[0] + 8) & 0xFF; + sprite->data[5] += sprite->data[1]; + sprite->pos2.y += sprite->data[5] >> 8; + sprite->data[2]++; + if (sprite->data[2] == 52) + { + if (sprite->data[7]) + DestroySpriteAndFreeResources(sprite); + else + DestroySprite(sprite); + } +} + +void sub_80A9EF4(u8 taskId) +{ + s16 x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) - 32; + s16 y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_3) - 36; + u8 spriteId; + + if (IsContest()) + x -= 6; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + spriteId = CreateSprite(&gUnknown_0853EF48, x, y, 4); + if (GetSpriteTileStartByTag(ANIM_TAG_ICE_CUBE) == 0xFFFF) + gSprites[spriteId].invisible = TRUE; + SetSubspriteTables(&gSprites[spriteId], gUnknown_0853EF40); + gTasks[taskId].data[15] = spriteId; + gTasks[taskId].func = sub_80A9FD0; +} + +static void sub_80A9FD0(u8 taskId) +{ + gTasks[taskId].data[1]++; + if (gTasks[taskId].data[1] == 10) + { + gTasks[taskId].func = sub_80AA020; + gTasks[taskId].data[1] = 0; + } + else + { + u8 var = gTasks[taskId].data[1]; + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(var, 16 - var)); + } +} + +static void sub_80AA020(u8 taskId) +{ + u8 palIndex = IndexOfSpritePaletteTag(ANIM_TAG_ICE_CUBE); + + if (gTasks[taskId].data[1]++ > 13) + { + gTasks[taskId].data[2]++; + if (gTasks[taskId].data[2] == 3) + { + u16 temp; + + temp = gPlttBufferFaded[0x100 + palIndex * 16 + 13]; + gPlttBufferFaded[0x100 + palIndex * 16 + 13] = gPlttBufferFaded[0x100 + palIndex * 16 + 14]; + gPlttBufferFaded[0x100 + palIndex * 16 + 14] = gPlttBufferFaded[0x100 + palIndex * 16 + 15]; + gPlttBufferFaded[0x100 + palIndex * 16 + 15] = temp; + + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3]++; + if (gTasks[taskId].data[3] == 3) + { + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[4]++; + if (gTasks[taskId].data[4] == 2) + { + gTasks[taskId].data[1] = 9; + gTasks[taskId].func = sub_80AA0D0; + } + } + } + } +} + +static void sub_80AA0D0(u8 taskId) +{ + gTasks[taskId].data[1]--; + if (gTasks[taskId].data[1] == -1) + { + gTasks[taskId].func = sub_80AA124; + gTasks[taskId].data[1] = 0; + } + else + { + u8 var = gTasks[taskId].data[1]; + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(var, 16 - var)); + } +} + +static void sub_80AA124(u8 taskId) +{ + gTasks[taskId].data[1]++; + if (gTasks[taskId].data[1] == 37) + { + u8 spriteId = gTasks[taskId].data[15]; + + FreeSpriteOamMatrix(&gSprites[spriteId]); + DestroySprite(&gSprites[spriteId]); + } + else if (gTasks[taskId].data[1] == 39) + { + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + DestroyAnimVisualTask(taskId); + } +} + +#define CASE(by, stat) case (STAT_ANIM_##by + stat - 1) + +void AnimTask_StatsChange(u8 taskId) +{ + bool16 goesDown = FALSE; + s16 animStatId = 0; + bool16 sharply = FALSE; + + switch (gBattleSpritesDataPtr->animationData->animArg) + { + CASE(PLUS1, STAT_ATK): goesDown = FALSE; animStatId = 0; break; + CASE(PLUS1, STAT_DEF): goesDown = FALSE; animStatId = 1; break; + CASE(PLUS1, STAT_SPEED): goesDown = FALSE; animStatId = 3; break; + CASE(PLUS1, STAT_SPATK): goesDown = FALSE; animStatId = 5; break; + CASE(PLUS1, STAT_SPDEF): goesDown = FALSE; animStatId = 6; break; + CASE(PLUS1, STAT_ACC): goesDown = FALSE; animStatId = 2; break; + CASE(PLUS1, STAT_EVASION): goesDown = FALSE; animStatId = 4; break; + + CASE(MINUS1, STAT_ATK): goesDown = TRUE; animStatId = 0; break; + CASE(MINUS1, STAT_DEF): goesDown = TRUE; animStatId = 1; break; + CASE(MINUS1, STAT_SPEED): goesDown = TRUE; animStatId = 3; break; + CASE(MINUS1, STAT_SPATK): goesDown = TRUE; animStatId = 5; break; + CASE(MINUS1, STAT_SPDEF): goesDown = TRUE; animStatId = 6; break; + CASE(MINUS1, STAT_ACC): goesDown = TRUE; animStatId = 2; break; + CASE(MINUS1, STAT_EVASION): goesDown = TRUE; animStatId = 4; break; + + CASE(PLUS2, STAT_ATK): goesDown = FALSE; animStatId = 0; sharply = TRUE; break; + CASE(PLUS2, STAT_DEF): goesDown = FALSE; animStatId = 1; sharply = TRUE; break; + CASE(PLUS2, STAT_SPEED): goesDown = FALSE; animStatId = 3; sharply = TRUE; break; + CASE(PLUS2, STAT_SPATK): goesDown = FALSE; animStatId = 5; sharply = TRUE; break; + CASE(PLUS2, STAT_SPDEF): goesDown = FALSE; animStatId = 6; sharply = TRUE; break; + CASE(PLUS2, STAT_ACC): goesDown = FALSE; animStatId = 2; sharply = TRUE; break; + CASE(PLUS2, STAT_EVASION): goesDown = FALSE; animStatId = 4; sharply = TRUE; break; + + CASE(MINUS2, STAT_ATK): goesDown = TRUE; animStatId = 0; sharply = TRUE; break; + CASE(MINUS2, STAT_DEF): goesDown = TRUE; animStatId = 1; sharply = TRUE; break; + CASE(MINUS2, STAT_SPEED): goesDown = TRUE; animStatId = 3; sharply = TRUE; break; + CASE(MINUS2, STAT_SPATK): goesDown = TRUE; animStatId = 5; sharply = TRUE; break; + CASE(MINUS2, STAT_SPDEF): goesDown = TRUE; animStatId = 6; sharply = TRUE; break; + CASE(MINUS2, STAT_ACC): goesDown = TRUE; animStatId = 2; sharply = TRUE; break; + CASE(MINUS2, STAT_EVASION): goesDown = TRUE; animStatId = 4; sharply = TRUE; break; + + case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = 0xFF; sharply = FALSE; break; + case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = 0xFF; sharply = TRUE; break; + case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = 0xFF; sharply = FALSE; break; + case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = 0xFF; sharply = TRUE; break; + + default: + DestroyAnimVisualTask(taskId); + return; + } + + gBattleAnimArgs[0] = goesDown; + gBattleAnimArgs[1] = animStatId; + gBattleAnimArgs[2] = 0; + gBattleAnimArgs[3] = 0; + gBattleAnimArgs[4] = sharply; + gTasks[taskId].func = sub_8116EB4; + sub_8116EB4(taskId); +} + +#undef CASE + +void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId) +{ + u8 taskId; + + gBattleAnimAttacker = battlerId; + gBattleAnimTarget = battlerId; + LaunchBattleAnimation(gBattleAnims_StatusConditions, statusAnimId, 0); + taskId = CreateTask(Task_DoStatusAnimation, 10); + gTasks[taskId].data[0] = battlerId; +} + +static void Task_DoStatusAnimation(u8 taskId) +{ + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].data[0]].statusAnimActive = FALSE; + DestroyTask(taskId); + } +} diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 10b432d8e..0422c11e3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3,6 +3,7 @@ #include "constants/battle_move_effects.h" #include "constants/battle_script_commands.h" #include "battle_message.h" +#include "battle_anim.h" #include "battle_ai_script_commands.h" #include "battle_scripts.h" #include "constants/moves.h" @@ -4381,16 +4382,16 @@ static void atk47_setgraphicalstatchangevalues(void) switch (GET_STAT_BUFF_VALUE2(gBattleScripting.statChanger)) { case SET_STAT_BUFF_VALUE(1): // +1 - value = 0xF; + value = STAT_ANIM_PLUS1; break; case SET_STAT_BUFF_VALUE(2): // +2 - value = 0x27; + value = STAT_ANIM_PLUS2; break; case SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE: // -1 - value = 0x16; + value = STAT_ANIM_MINUS1; break; case SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE: // -2 - value = 0x2E; + value = STAT_ANIM_MINUS2; break; } gBattleScripting.animArg1 = GET_STAT_BUFF_ID(gBattleScripting.statChanger) + value - 1; @@ -4412,9 +4413,9 @@ static void atk48_playstatchangeanimation(void) { s16 startingStatAnimId; if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) - startingStatAnimId = 0x2D; + startingStatAnimId = STAT_ANIM_MINUS2 - 1; else - startingStatAnimId = 0x15; + startingStatAnimId = STAT_ANIM_MINUS1 - 1; while (statsToCheck != 0) { @@ -4447,18 +4448,18 @@ static void atk48_playstatchangeanimation(void) if (changeableStatsCount > 1) // more than one stat, so the color is gray { if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) - statAnimId = 0x3A; + statAnimId = STAT_ANIM_MULTIPLE_MINUS2; else - statAnimId = 0x39; + statAnimId = STAT_ANIM_MULTIPLE_MINUS1; } } else // goes up { s16 startingStatAnimId; if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) - startingStatAnimId = 0x26; + startingStatAnimId = STAT_ANIM_PLUS2 - 1; else - startingStatAnimId = 0xE; + startingStatAnimId = STAT_ANIM_PLUS1 - 1; while (statsToCheck != 0) { @@ -4473,9 +4474,9 @@ static void atk48_playstatchangeanimation(void) if (changeableStatsCount > 1) // more than one stat, so the color is gray { if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) - statAnimId = 0x38; + statAnimId = STAT_ANIM_MULTIPLE_PLUS2; else - statAnimId = 0x37; + statAnimId = STAT_ANIM_MULTIPLE_PLUS1; } }