diff --git a/asm/normal.s b/asm/normal.s deleted file mode 100644 index 3ee1308c9..000000000 --- a/asm/normal.s +++ /dev/null @@ -1,1876 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_811572C -sub_811572C: @ 811572C - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gBattleAnimArgs - ldrh r0, [r5] - ldrh r1, [r4, 0x20] - adds r0, r1 - strh r0, [r4, 0x20] - ldrh r0, [r5, 0x2] - ldrh r1, [r4, 0x22] - adds r0, r1 - strh r0, [r4, 0x22] - ldrh r0, [r5, 0x4] - strh r0, [r4, 0x2E] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - beq _0811576C - ldrh r0, [r5, 0x6] - negs r0, r0 - strh r0, [r4, 0x30] - movs r0, 0x1 - strh r0, [r4, 0x36] - b _0811577A - .pool -_0811576C: - ldrh r0, [r5, 0x6] - strh r0, [r4, 0x30] - strh r1, [r4, 0x36] - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim -_0811577A: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x8] - strh r0, [r4, 0x34] - ldr r1, =sub_8115798 - str r1, [r4, 0x1C] - adds r0, r4, 0 - bl _call_via_r1 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811572C - - thumb_func_start sub_8115798 -sub_8115798: @ 8115798 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r1, 0x1E - bl Cos - strh r0, [r4, 0x24] - movs r2, 0x2E - ldrsh r0, [r4, r2] - movs r1, 0xA - bl Sin - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x2E] - cmp r0, 0x7F - bhi _081157CA - ldrb r0, [r4, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r0 - movs r0, 0x4 - orrs r1, r0 - strb r1, [r4, 0x5] - b _081157D2 -_081157CA: - ldrb r0, [r4, 0x5] - movs r1, 0xC - orrs r0, r1 - strb r0, [r4, 0x5] -_081157D2: - ldrh r0, [r4, 0x30] - ldrh r1, [r4, 0x2E] - adds r0, r1 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x2E] - ldrh r0, [r4, 0x32] - adds r0, 0x1 - strh r0, [r4, 0x32] - lsls r0, 16 - asrs r0, 16 - movs r2, 0x34 - ldrsh r1, [r4, r2] - cmp r0, r1 - bne _081157F6 - adds r0, r4, 0 - bl DestroyAnimSprite -_081157F6: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8115798 - - thumb_func_start sub_81157FC -sub_81157FC: @ 81157FC - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - ldr r4, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r4, r1] - bl sub_811583C - movs r1, 0x2 - ldrsb r1, [r4, r1] - ldrb r2, [r4, 0x4] - ldrb r3, [r4, 0x6] - ldrh r4, [r4, 0x8] - str r4, [sp] - bl BeginNormalPaletteFade - adds r2, r5, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r0, =sub_8115884 - str r0, [r5, 0x1C] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81157FC - - thumb_func_start sub_811583C -sub_811583C: @ 811583C - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0xC - lsls r0, 16 - lsrs r0, 16 - movs r4, 0x1 - mov r8, r0 - mov r1, r8 - ands r1, r4 - mov r8, r1 - lsls r0, 16 - asrs r1, r0, 17 - ands r1, r4 - asrs r2, r0, 18 - ands r2, r4 - asrs r3, r0, 19 - ands r3, r4 - asrs r6, r0, 20 - ands r6, r4 - asrs r5, r0, 21 - ands r5, r4 - asrs r0, 22 - ands r0, r4 - str r6, [sp] - str r5, [sp, 0x4] - str r0, [sp, 0x8] - mov r0, r8 - bl sub_80A75AC - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_811583C - - thumb_func_start sub_8115884 -sub_8115884: @ 8115884 - push {lr} - adds r2, r0, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0811589A - adds r0, r2, 0 - bl DestroyAnimSprite -_0811589A: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115884 - - thumb_func_start sub_81158A4 -sub_81158A4: @ 81158A4 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimArgs - ldrh r0, [r4, 0x2] - strh r0, [r5, 0x2E] - strh r0, [r5, 0x30] - ldrh r0, [r4, 0x4] - strh r0, [r5, 0x32] - ldrh r0, [r4, 0x6] - strh r0, [r5, 0x34] - ldrh r0, [r4, 0x8] - strh r0, [r5, 0x36] - ldrh r0, [r4, 0xA] - strh r0, [r5, 0x38] - ldrh r0, [r4, 0xC] - strh r0, [r5, 0x3A] - ldrh r0, [r4] - strh r0, [r5, 0x3C] - movs r1, 0x3C - ldrsh r0, [r5, r1] - bl sub_811583C - ldrb r1, [r4, 0x8] - ldrh r2, [r4, 0x6] - bl BlendPalettes - adds r2, r5, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r0, =sub_81158F8 - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81158A4 - - thumb_func_start sub_81158F8 -sub_81158F8: @ 81158F8 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x2E] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - ble _0811590C - subs r0, r1, 0x1 - strh r0, [r4, 0x2E] - b _0811597C -_0811590C: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0811597C - movs r1, 0x32 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08115930 - ldr r0, =sub_8115984 - str r0, [r4, 0x1C] - b _0811597C - .pool -_08115930: - movs r2, 0x3C - ldrsh r0, [r4, r2] - bl sub_811583C - adds r3, r0, 0 - ldrh r1, [r4, 0x30] - movs r0, 0x80 - lsls r0, 1 - ands r0, r1 - cmp r0, 0 - beq _08115956 - ldrh r1, [r4, 0x36] - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r4, 0x34] - adds r0, r3, 0 - bl BlendPalettes - b _08115964 -_08115956: - ldrh r1, [r4, 0x3A] - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r4, 0x38] - adds r0, r3, 0 - bl BlendPalettes -_08115964: - ldrh r0, [r4, 0x30] - movs r2, 0x80 - lsls r2, 1 - adds r1, r2, 0 - eors r0, r1 - strh r0, [r4, 0x30] - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x2E] - ldrh r0, [r4, 0x32] - subs r0, 0x1 - strh r0, [r4, 0x32] -_0811597C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81158F8 - - thumb_func_start sub_8115984 -sub_8115984: @ 8115984 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081159AA - movs r1, 0x3C - ldrsh r0, [r4, r1] - bl sub_811583C - movs r1, 0 - movs r2, 0 - bl BlendPalettes - adds r0, r4, 0 - bl DestroyAnimSprite -_081159AA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115984 - - thumb_func_start sub_81159B4 -sub_81159B4: @ 81159B4 - push {r4,lr} - adds r4, r0, 0 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1] - ldrh r2, [r4, 0x20] - adds r0, r2 - movs r2, 0 - strh r0, [r4, 0x20] - ldrh r0, [r1, 0x2] - ldrh r1, [r4, 0x22] - adds r0, r1 - strh r0, [r4, 0x22] - strh r2, [r4, 0x2E] - movs r0, 0xA - strh r0, [r4, 0x30] - movs r0, 0x8 - strh r0, [r4, 0x32] - movs r0, 0x28 - strh r0, [r4, 0x34] - movs r0, 0x70 - strh r0, [r4, 0x36] - strh r2, [r4, 0x38] - ldr r1, =move_anim_8074EE0 - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - ldr r1, =sub_80A634C - str r1, [r4, 0x1C] - adds r0, r4, 0 - bl _call_via_r1 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81159B4 - - thumb_func_start sub_8115A04 -sub_8115A04: @ 8115A04 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldr r3, =gBattleAnimArgs - ldrh r1, [r3] - movs r5, 0 - strh r1, [r4, 0x8] - ldrh r1, [r3, 0x2] - strh r1, [r4, 0xA] - ldrh r1, [r3, 0x4] - strh r1, [r4, 0xC] - ldrh r1, [r3, 0x6] - strh r1, [r4, 0xE] - ldrh r2, [r3, 0x8] - strh r2, [r4, 0x10] - ldrh r1, [r3, 0xA] - strh r1, [r4, 0x12] - strh r5, [r4, 0x18] - lsls r2, 24 - lsrs r2, 24 - movs r1, 0 - bl sub_8115A54 - ldr r0, =sub_8115AA4 - str r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115A04 - - thumb_func_start sub_8115A54 -sub_8115A54: @ 8115A54 - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - bl sub_811583C - movs r1, 0xA - ldrsb r1, [r4, r1] - ldrh r2, [r4, 0x12] - str r2, [sp] - adds r2, r5, 0 - adds r3, r6, 0 - bl BeginNormalPaletteFade - ldrh r0, [r4, 0xC] - subs r0, 0x1 - strh r0, [r4, 0xC] - ldrh r0, [r4, 0x18] - movs r1, 0x1 - eors r0, r1 - strh r0, [r4, 0x18] - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115A54 - - thumb_func_start sub_8115AA4 -sub_8115AA4: @ 8115AA4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r3, r0, 24 - adds r4, r3, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08115B06 - ldr r1, =gTasks - lsls r2, r3, 2 - adds r0, r2, r3 - lsls r0, 3 - adds r3, r0, r1 - movs r5, 0xC - ldrsh r0, [r3, r5] - adds r6, r1, 0 - adds r5, r2, 0 - cmp r0, 0 - ble _08115B00 - movs r1, 0x18 - ldrsh r0, [r3, r1] - cmp r0, 0 - bne _08115AE4 - ldrb r1, [r3, 0xE] - ldrb r2, [r3, 0x10] - b _08115AE8 - .pool -_08115AE4: - ldrb r1, [r3, 0x10] - ldrb r2, [r3, 0xE] -_08115AE8: - adds r0, r5, r4 - lsls r0, 3 - adds r0, r6 - movs r3, 0xC - ldrsh r0, [r0, r3] - cmp r0, 0x1 - bne _08115AF8 - movs r2, 0 -_08115AF8: - adds r0, r4, 0 - bl sub_8115A54 - b _08115B06 -_08115B00: - adds r0, r4, 0 - bl DestroyAnimVisualTask -_08115B06: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8115AA4 - - thumb_func_start sub_8115B0C -sub_8115B0C: @ 8115B0C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0 - ldr r3, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r3 - ldr r2, =gBattleAnimArgs - ldrh r1, [r2] - strh r1, [r0, 0x8] - ldrh r1, [r2, 0x2] - strh r1, [r0, 0xA] - ldrh r1, [r2, 0x4] - strh r1, [r0, 0xC] - ldrh r1, [r2, 0x6] - strh r1, [r0, 0xE] - ldrh r1, [r2, 0x8] - strh r1, [r0, 0x10] - ldrh r1, [r2, 0xA] - strh r1, [r0, 0x12] - strh r5, [r0, 0x18] - movs r4, 0 - ldr r0, =gBattlersCount - ldrb r1, [r0] - mov r9, r3 - mov r8, r2 - cmp r5, r1 - bge _08115B74 - ldr r0, =gBattleAnimAttacker - ldrb r3, [r0] - ldr r7, =gBattleAnimTarget - movs r0, 0x1 - mov r12, r0 - adds r2, r1, 0 -_08115B5A: - cmp r4, r3 - beq _08115B6E - ldrb r1, [r7] - cmp r4, r1 - beq _08115B6E - adds r1, r4, 0 - adds r1, 0x10 - mov r0, r12 - lsls r0, r1 - orrs r5, r0 -_08115B6E: - adds r4, 0x1 - cmp r4, r2 - blt _08115B5A -_08115B74: - mov r2, r8 - movs r1, 0 - ldrsh r0, [r2, r1] - cmp r0, 0x1 - bne _08115B82 - movs r0, 0xE - orrs r5, r0 -_08115B82: - lsls r4, r6, 2 - adds r4, r6 - lsls r4, 3 - add r4, r9 - lsrs r0, r5, 16 - strh r0, [r4, 0x1A] - movs r0, 0xFF - ands r5, r0 - strh r5, [r4, 0x1C] - ldrb r2, [r4, 0x10] - adds r0, r6, 0 - movs r1, 0 - bl sub_8115BC8 - ldr r0, =sub_8115C18 - str r0, [r4] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115B0C - - thumb_func_start sub_8115BC8 -sub_8115BC8: @ 8115BC8 - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r1, 0 - adds r3, r2, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r3, 24 - lsrs r3, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldrh r0, [r4, 0x1A] - lsls r0, 16 - ldrh r1, [r4, 0x1C] - orrs r0, r1 - movs r1, 0xA - ldrsb r1, [r4, r1] - ldrh r2, [r4, 0x12] - str r2, [sp] - adds r2, r5, 0 - bl BeginNormalPaletteFade - ldrh r0, [r4, 0xC] - subs r0, 0x1 - strh r0, [r4, 0xC] - ldrh r0, [r4, 0x18] - movs r1, 0x1 - eors r0, r1 - strh r0, [r4, 0x18] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115BC8 - - thumb_func_start sub_8115C18 -sub_8115C18: @ 8115C18 - push {r4-r6,lr} - lsls r0, 24 - lsrs r3, r0, 24 - adds r4, r3, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08115C7A - ldr r1, =gTasks - lsls r2, r3, 2 - adds r0, r2, r3 - lsls r0, 3 - adds r3, r0, r1 - movs r5, 0xC - ldrsh r0, [r3, r5] - adds r6, r1, 0 - adds r5, r2, 0 - cmp r0, 0 - ble _08115C74 - movs r1, 0x18 - ldrsh r0, [r3, r1] - cmp r0, 0 - bne _08115C58 - ldrb r1, [r3, 0xE] - ldrb r2, [r3, 0x10] - b _08115C5C - .pool -_08115C58: - ldrb r1, [r3, 0x10] - ldrb r2, [r3, 0xE] -_08115C5C: - adds r0, r5, r4 - lsls r0, 3 - adds r0, r6 - movs r3, 0xC - ldrsh r0, [r0, r3] - cmp r0, 0x1 - bne _08115C6C - movs r2, 0 -_08115C6C: - adds r0, r4, 0 - bl sub_8115BC8 - b _08115C7A -_08115C74: - adds r0, r4, 0 - bl DestroyAnimVisualTask -_08115C7A: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8115C18 - - thumb_func_start sub_8115C80 -sub_8115C80: @ 8115C80 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldr r3, =gBattleAnimArgs - ldrh r1, [r3] - movs r5, 0 - strh r1, [r4, 0x8] - ldrh r1, [r3, 0x2] - strh r1, [r4, 0xA] - ldrh r1, [r3, 0x4] - strh r1, [r4, 0xC] - ldrh r1, [r3, 0x6] - strh r1, [r4, 0xE] - ldrh r2, [r3, 0x8] - strh r2, [r4, 0x10] - ldrh r1, [r3, 0xA] - strh r1, [r4, 0x12] - strh r5, [r4, 0x18] - lsls r2, 24 - lsrs r2, 24 - movs r1, 0 - bl sub_8115CD0 - ldr r0, =sub_8115D2C - str r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115C80 - - thumb_func_start sub_8115CD0 -sub_8115CD0: @ 8115CD0 - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldrh r0, [r4, 0x8] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x10 - movs r2, 0x1 - lsls r2, r0 - movs r1, 0xA - ldrsb r1, [r4, r1] - ldrh r0, [r4, 0x12] - str r0, [sp] - adds r0, r2, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl BeginNormalPaletteFade - ldrh r0, [r4, 0xC] - subs r0, 0x1 - strh r0, [r4, 0xC] - ldrh r0, [r4, 0x18] - movs r1, 0x1 - eors r0, r1 - strh r0, [r4, 0x18] - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115CD0 - - thumb_func_start sub_8115D2C -sub_8115D2C: @ 8115D2C - push {r4-r6,lr} - lsls r0, 24 - lsrs r3, r0, 24 - adds r4, r3, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08115D8E - ldr r1, =gTasks - lsls r2, r3, 2 - adds r0, r2, r3 - lsls r0, 3 - adds r3, r0, r1 - movs r5, 0xC - ldrsh r0, [r3, r5] - adds r6, r1, 0 - adds r5, r2, 0 - cmp r0, 0 - ble _08115D88 - movs r1, 0x18 - ldrsh r0, [r3, r1] - cmp r0, 0 - bne _08115D6C - ldrb r1, [r3, 0xE] - ldrb r2, [r3, 0x10] - b _08115D70 - .pool -_08115D6C: - ldrb r1, [r3, 0x10] - ldrb r2, [r3, 0xE] -_08115D70: - adds r0, r5, r4 - lsls r0, 3 - adds r0, r6 - movs r3, 0xC - ldrsh r0, [r0, r3] - cmp r0, 0x1 - bne _08115D80 - movs r2, 0 -_08115D80: - adds r0, r4, 0 - bl sub_8115CD0 - b _08115D8E -_08115D88: - adds r0, r4, 0 - bl DestroyAnimVisualTask -_08115D8E: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8115D2C - - thumb_func_start sub_8115D94 -sub_8115D94: @ 8115D94 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldr r5, =gBattleAnimArgs - ldrh r0, [r5, 0x2] - strh r0, [r4, 0x8] - ldrh r0, [r5, 0x2] - strh r0, [r4, 0xA] - ldrh r0, [r5, 0x4] - strh r0, [r4, 0xC] - ldrh r0, [r5, 0x6] - strh r0, [r4, 0xE] - ldrh r0, [r5, 0x8] - strh r0, [r4, 0x10] - ldrh r0, [r5, 0xA] - strh r0, [r4, 0x12] - ldrh r0, [r5, 0xC] - strh r0, [r4, 0x14] - ldrh r0, [r5] - strh r0, [r4, 0x16] - ldrh r0, [r5] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x10 - movs r1, 0x1 - lsls r1, r0 - ldrb r3, [r5, 0x8] - ldrh r0, [r5, 0x6] - str r0, [sp] - adds r0, r1, 0 - movs r1, 0 - adds r2, r3, 0 - bl BeginNormalPaletteFade - ldr r0, =sub_8115E00 - str r0, [r4] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115D94 - - thumb_func_start sub_8115E00 -sub_8115E00: @ 8115E00 - push {r4,r5,lr} - sub sp, 0x4 - 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, 0x8] - movs r2, 0x8 - ldrsh r0, [r4, r2] - cmp r0, 0 - ble _08115E28 - subs r0, r1, 0x1 - strh r0, [r4, 0x8] - b _08115EAC - .pool -_08115E28: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08115EAC - movs r3, 0xC - ldrsh r0, [r4, r3] - cmp r0, 0 - bne _08115E4C - ldr r0, =sub_8115EB8 - str r0, [r4] - b _08115EAC - .pool -_08115E4C: - ldrh r0, [r4, 0x16] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x10 - movs r2, 0x1 - lsls r2, r0 - ldrh r1, [r4, 0xA] - movs r0, 0x80 - lsls r0, 1 - ands r0, r1 - cmp r0, 0 - beq _08115E7A - ldrb r3, [r4, 0x10] - ldrh r0, [r4, 0xE] - str r0, [sp] - adds r0, r2, 0 - movs r1, 0 - adds r2, r3, 0 - bl BeginNormalPaletteFade - b _08115E8A -_08115E7A: - ldrb r3, [r4, 0x14] - ldrh r0, [r4, 0x12] - str r0, [sp] - adds r0, r2, 0 - movs r1, 0 - adds r2, r3, 0 - bl BeginNormalPaletteFade -_08115E8A: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0xA] - movs r3, 0x80 - lsls r3, 1 - adds r2, r3, 0 - eors r0, r2 - strh r0, [r1, 0xA] - movs r2, 0xFF - ands r0, r2 - strh r0, [r1, 0x8] - ldrh r0, [r1, 0xC] - subs r0, 0x1 - strh r0, [r1, 0xC] -_08115EAC: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115E00 - - thumb_func_start sub_8115EB8 -sub_8115EB8: @ 8115EB8 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _08115EFE - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrh r0, [r0, 0x16] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x10 - movs r1, 0x1 - lsls r1, r0 - str r5, [sp] - adds r0, r1, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl BeginNormalPaletteFade - adds r0, r4, 0 - bl DestroyAnimVisualTask -_08115EFE: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115EB8 - - thumb_func_start sub_8115F10 -sub_8115F10: @ 8115F10 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r2, 0 - ldr r0, =gBattleAnimAttacker - ldrb r6, [r0] - ldr r0, =gBattleAnimTarget - ldrb r7, [r0] - ldr r4, =gBattleAnimArgs - ldrh r1, [r4] - movs r5, 0x80 - lsls r5, 1 - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _08115F4A - str r2, [sp] - str r2, [sp, 0x4] - str r2, [sp, 0x8] - movs r0, 0x1 - movs r1, 0 - movs r3, 0 - bl sub_80A75AC - adds r2, r0, 0 -_08115F4A: - ldrh r1, [r4, 0x2] - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _08115F5C - movs r0, 0x80 - lsls r0, 9 - lsls r0, r6 - orrs r2, r0 -_08115F5C: - ldrh r1, [r4, 0x4] - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _08115F6E - movs r0, 0x80 - lsls r0, 9 - lsls r0, r7 - orrs r2, r0 -_08115F6E: - adds r0, r2, 0 - bl InvertPlttBuffer - mov r0, r8 - bl DestroyAnimVisualTask - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115F10 - - thumb_func_start sub_8115F94 -sub_8115F94: @ 8115F94 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r5, 0 - ldr r1, =gTasks - lsls r0, 2 - add r0, r8 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08115FD6 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1] - strh r0, [r4, 0xC] - ldrh r0, [r1, 0x2] - strh r0, [r4, 0xE] - ldrh r0, [r1, 0x4] - strh r0, [r4, 0x10] - ldrh r0, [r1, 0x6] - strh r0, [r4, 0xA] - ldrh r0, [r1, 0x8] - strh r0, [r4, 0x12] - ldrh r0, [r1, 0xA] - strh r0, [r4, 0x14] - ldrh r0, [r1, 0xC] - strh r0, [r4, 0x16] -_08115FD6: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - mov r9, r0 - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - mov r10, r0 - ldrh r1, [r4, 0xC] - movs r7, 0x80 - lsls r7, 1 - adds r0, r7, 0 - ands r0, r1 - cmp r0, 0 - beq _08115FF8 - ldr r5, =0x0000ffff -_08115FF8: - movs r6, 0x1 - adds r0, r6, 0 - ands r0, r1 - cmp r0, 0 - beq _08116028 - ldr r2, =gSprites - ldr r0, =gHealthboxSpriteIds - add r0, r9 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, 0x14 - adds r0, r2 - ldr r0, [r0] - ldrh r0, [r0, 0x2] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - adds r1, r6, 0 - lsls r1, r0 - lsls r1, 16 - orrs r5, r1 -_08116028: - ldrh r1, [r4, 0xE] - adds r0, r7, 0 - ands r0, r1 - cmp r0, 0 - beq _0811603C - adds r0, r6, 0 - mov r2, r9 - lsls r0, r2 - lsls r0, 16 - orrs r5, r0 -_0811603C: - ldrh r1, [r4, 0x10] - adds r0, r7, 0 - ands r0, r1 - cmp r0, 0 - beq _08116050 - adds r0, r6, 0 - mov r1, r10 - lsls r0, r1 - lsls r0, 16 - orrs r5, r0 -_08116050: - movs r1, 0x12 - ldrsb r1, [r4, r1] - movs r2, 0x14 - ldrsb r2, [r4, r2] - movs r3, 0x16 - ldrsb r3, [r4, r3] - adds r0, r5, 0 - bl TintPlttBuffer - movs r2, 0x8 - ldrsh r1, [r4, r2] - movs r2, 0xA - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _0811607A - adds r0, r5, 0 - bl UnfadePlttBuffer - mov r0, r8 - bl DestroyAnimVisualTask -_0811607A: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8115F94 - - thumb_func_start sub_81160A4 -sub_81160A4: @ 81160A4 - push {r4,lr} - adds r4, r0, 0 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleAnimArgs - ldrh r0, [r1] - negs r0, r0 - strh r0, [r4, 0x2E] - ldrh r0, [r1, 0x2] - strh r0, [r4, 0x30] - strh r0, [r4, 0x32] - ldrh r0, [r1, 0x4] - strh r0, [r4, 0x34] - movs r2, 0x6 - ldrsh r0, [r1, r2] - cmp r0, 0x1 - beq _081160EC - cmp r0, 0x1 - bgt _081160DC - cmp r0, 0 - beq _081160E2 - b _08116104 - .pool -_081160DC: - cmp r0, 0x2 - beq _081160F4 - b _08116104 -_081160E2: - ldr r1, =gBattle_BG3_X - b _081160F6 - .pool -_081160EC: - ldr r1, =gBattle_BG3_Y - b _081160F6 - .pool -_081160F4: - ldr r1, =gSpriteCoordOffsetX -_081160F6: - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - b _0811610C - .pool -_08116104: - ldr r1, =gSpriteCoordOffsetY - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 -_0811610C: - movs r0, 0x3A - ldrsh r1, [r4, r0] - movs r2, 0x3C - ldrsh r0, [r4, r2] - lsls r0, 16 - orrs r1, r0 - ldrh r0, [r1] - strh r0, [r4, 0x36] - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x6] - strh r0, [r4, 0x38] - subs r0, 0x2 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bhi _08116130 - bl sub_81161F4 -_08116130: - ldr r0, =sub_8116148 - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81160A4 - - thumb_func_start sub_8116148 -sub_8116148: @ 8116148 - push {r4-r7,lr} - adds r3, r0, 0 - ldrh r1, [r3, 0x34] - movs r2, 0x34 - ldrsh r0, [r3, r2] - cmp r0, 0 - ble _0811618A - subs r0, r1, 0x1 - strh r0, [r3, 0x34] - ldrh r1, [r3, 0x30] - movs r2, 0x30 - ldrsh r0, [r3, r2] - cmp r0, 0 - ble _0811616A - subs r0, r1, 0x1 - strh r0, [r3, 0x30] - b _081161E2 -_0811616A: - ldrh r0, [r3, 0x32] - strh r0, [r3, 0x30] - movs r0, 0x3A - ldrsh r1, [r3, r0] - movs r2, 0x3C - ldrsh r0, [r3, r2] - lsls r0, 16 - orrs r1, r0 - ldrh r0, [r3, 0x2E] - ldrh r2, [r1] - adds r0, r2 - strh r0, [r1] - ldrh r0, [r3, 0x2E] - negs r0, r0 - strh r0, [r3, 0x2E] - b _081161E2 -_0811618A: - movs r0, 0x3A - ldrsh r1, [r3, r0] - movs r2, 0x3C - ldrsh r0, [r3, r2] - lsls r0, 16 - orrs r1, r0 - ldrh r0, [r3, 0x36] - strh r0, [r1] - ldrh r0, [r3, 0x38] - subs r0, 0x2 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bhi _081161DC - movs r4, 0 - ldr r5, =gBattlersCount - ldrb r0, [r5] - cmp r4, r0 - bcs _081161DC - ldr r2, =gSprites - mov r12, r2 - ldr r6, =gBattlerSpriteIds - movs r7, 0x3 - negs r7, r7 -_081161BA: - adds r0, r4, r6 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r12 - adds r1, 0x3E - ldrb r2, [r1] - adds r0, r7, 0 - ands r0, r2 - strb r0, [r1] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - ldrb r0, [r5] - cmp r4, r0 - bcc _081161BA -_081161DC: - adds r0, r3, 0 - bl DestroyAnimSprite -_081161E2: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116148 - - thumb_func_start sub_81161F4 -sub_81161F4: @ 81161F4 - push {r4-r6,lr} - ldr r6, =gSprites - ldr r4, =gBattlerSpriteIds - ldr r5, =gBattleAnimAttacker - ldrb r0, [r5] - adds r0, r4 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - adds r1, 0x3E - ldrb r3, [r1] - movs r2, 0x3 - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - strb r0, [r1] - ldr r3, =gBattleAnimTarget - ldrb r0, [r3] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - ands r2, r1 - strb r2, [r0] - ldr r0, =gBattleAnimArgs - movs r1, 0x8 - ldrsh r0, [r0, r1] - cmp r0, 0x2 - bne _0811627C - ldrb r0, [r5] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r0] - ldrb r0, [r3] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - b _08116298 - .pool -_0811627C: - cmp r0, 0 - bne _08116284 - ldrb r0, [r5] - b _08116286 -_08116284: - ldrb r0, [r3] -_08116286: - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x2 -_08116298: - orrs r1, r2 - strb r1, [r0] - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81161F4 - - thumb_func_start sub_81162A4 -sub_81162A4: @ 81162A4 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r2, r0, 2 - adds r2, r0 - lsls r2, 3 - adds r2, r1 - ldr r3, =gBattleAnimArgs - ldrh r1, [r3] - strh r1, [r2, 0x8] - ldrh r1, [r3, 0x2] - strh r1, [r2, 0xA] - ldrh r1, [r3, 0x4] - strh r1, [r2, 0xC] - ldrh r1, [r3, 0x6] - strh r1, [r2, 0xE] - ldrh r1, [r3, 0x6] - strh r1, [r2, 0x18] - ldr r4, =gBattle_BG3_X - ldrh r1, [r3] - strh r1, [r4] - ldr r4, =gBattle_BG3_Y - ldrh r1, [r3, 0x2] - strh r1, [r4] - ldr r1, =sub_81162F8 - str r1, [r2] - bl _call_via_r1 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81162A4 - - thumb_func_start sub_81162F8 -sub_81162F8: @ 81162F8 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r3, r0, r1 - ldrh r2, [r3, 0xE] - movs r4, 0xE - ldrsh r0, [r3, r4] - mov r12, r1 - cmp r0, 0 - bne _0811637E - ldr r0, =gBattle_BG3_X - ldrh r2, [r0] - movs r7, 0x8 - ldrsh r1, [r3, r7] - adds r6, r0, 0 - cmp r2, r1 - bne _08116330 - ldrh r0, [r3, 0x8] - negs r0, r0 - b _08116332 - .pool -_08116330: - ldrh r0, [r3, 0x8] -_08116332: - strh r0, [r6] - ldr r2, =gBattle_BG3_Y - ldrh r3, [r2] - lsls r1, r5, 2 - adds r0, r1, r5 - lsls r0, 3 - mov r7, r12 - adds r4, r0, r7 - movs r7, 0xA - ldrsh r0, [r4, r7] - cmn r3, r0 - bne _08116354 - movs r0, 0 - b _08116358 - .pool -_08116354: - ldrh r0, [r4, 0xA] - negs r0, r0 -_08116358: - strh r0, [r2] - adds r0, r1, r5 - lsls r0, 3 - add r0, r12 - ldrh r1, [r0, 0x18] - strh r1, [r0, 0xE] - ldrh r1, [r0, 0xC] - subs r1, 0x1 - strh r1, [r0, 0xC] - lsls r1, 16 - asrs r1, 16 - cmp r1, 0 - bne _08116382 - strh r1, [r6] - strh r1, [r2] - adds r0, r5, 0 - bl DestroyAnimVisualTask - b _08116382 -_0811637E: - subs r0, r2, 0x1 - strh r0, [r3, 0xE] -_08116382: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81162F8 - - thumb_func_start sub_8116388 -sub_8116388: @ 8116388 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimArgs - ldrb r1, [r4, 0x6] - bl StartSpriteAffineAnim - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081163AC - adds r0, r5, 0 - movs r1, 0x1 - bl InitAnimSpritePos - b _081163B4 - .pool -_081163AC: - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80A6980 -_081163B4: - ldr r0, =sub_80A67BC - str r0, [r5, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116388 - - thumb_func_start sub_81163D0 -sub_81163D0: @ 81163D0 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimArgs - ldrb r1, [r4, 0x6] - bl StartSpriteAffineAnim - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081163F4 - adds r0, r5, 0 - movs r1, 0x1 - bl InitAnimSpritePos - b _081163FC - .pool -_081163F4: - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80A6980 -_081163FC: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x8] - strh r0, [r5, 0x2E] - ldr r0, =sub_80A67BC - str r0, [r5, 0x1C] - ldr r1, =sub_810E2C8 - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81163D0 - - thumb_func_start sub_8116420 -sub_8116420: @ 8116420 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08116444 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08116444 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x2] - negs r0, r0 - strh r0, [r1, 0x2] -_08116444: - adds r0, r4, 0 - bl sub_8116388 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116420 - - thumb_func_start sub_8116458 -sub_8116458: @ 8116458 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gBattleAnimArgs - movs r0, 0x2 - ldrsh r1, [r5, r0] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - bne _08116474 - bl Random2 - movs r1, 0x3 - ands r1, r0 - strh r1, [r5, 0x2] -_08116474: - ldrb r1, [r5, 0x2] - adds r0, r4, 0 - bl StartSpriteAffineAnim - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _08116494 - adds r0, r4, 0 - movs r1, 0 - bl InitAnimSpritePos - b _0811649C - .pool -_08116494: - adds r0, r4, 0 - movs r1, 0 - bl sub_80A6980 -_0811649C: - bl Random2 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x30 - bl __umodsi3 - ldr r1, =0x0000ffe8 - adds r0, r1 - ldrh r1, [r4, 0x24] - adds r0, r1 - strh r0, [r4, 0x24] - bl Random2 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x18 - bl __umodsi3 - ldr r1, =0x0000fff4 - adds r0, r1 - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - ldr r1, =move_anim_8074EE0 - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =sub_80A67BC - str r0, [r4, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116458 - - thumb_func_start sub_81164F0 -sub_81164F0: @ 81164F0 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gBattleAnimArgs - ldrb r0, [r5] - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x2E] - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x24] - ldrh r0, [r0, 0x20] - adds r1, r0 - strh r1, [r4, 0x20] - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x26] - ldrh r0, [r0, 0x22] - adds r1, r0 - strh r1, [r4, 0x22] - ldrh r0, [r5, 0x2] - strh r0, [r4, 0x24] - ldrh r0, [r5, 0x4] - strh r0, [r4, 0x26] - ldrb r1, [r5, 0x6] - adds r0, r4, 0 - bl StartSpriteAffineAnim - ldr r1, =move_anim_8074EE0 - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =sub_80A67BC - str r0, [r4, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81164F0 - - thumb_func_start sub_8116560 -sub_8116560: @ 8116560 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0x4 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _0811657C - adds r0, r4, 0 - movs r1, 0x1 - bl InitAnimSpritePos - b _08116584 - .pool -_0811657C: - adds r0, r4, 0 - movs r1, 0x1 - bl sub_80A6980 -_08116584: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x6] - strh r0, [r4, 0x2E] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =WaitAnimForDuration - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116560 - - thumb_func_start sub_81165A8 -sub_81165A8: @ 81165A8 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimArgs - ldrb r1, [r4, 0x6] - bl StartSpriteAffineAnim - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081165CC - adds r0, r5, 0 - movs r1, 0x1 - bl InitAnimSpritePos - b _081165D4 - .pool -_081165CC: - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80A6980 -_081165D4: - ldr r0, =sub_81165E4 - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81165A8 - - thumb_func_start sub_81165E4 -sub_81165E4: @ 81165E4 - push {lr} - adds r3, r0, 0 - movs r0, 0x3E - adds r0, r3 - mov r12, r0 - ldrb r2, [r0] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - mov r1, r12 - strb r0, [r1] - ldrh r0, [r3, 0x2E] - adds r1, r0, 0x1 - strh r1, [r3, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xC - ble _0811661A - adds r0, r3, 0 - bl DestroyAnimSprite -_0811661A: - pop {r0} - bx r0 - thumb_func_end sub_81165E4 - - .align 2, 0 diff --git a/include/battle_anim.h b/include/battle_anim.h index 16e9de0ac..c3601bbd9 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -123,6 +123,7 @@ u8 sub_80A89C8(int, u8, int); void sub_80A6D60(struct UnknownAnimStruct2*, const void*, u32); void sub_80A6CC0(u32, const void*, u32); void sub_80A6DAC(bool8); +void sub_80A634C(struct Sprite *); enum { @@ -166,7 +167,7 @@ u8 LaunchBallFadeMonTask(bool8 unFadeLater, u8 battlerId, u32 arg2, u8 ballId); // battle_anim_utility_funcs.s void sub_8116EB4(u8); -u32 sub_811583C(s16); +u32 UnpackSelectedBattleAnimPalettes(s16); u8 GetBattlerSpriteFinal_Y(u8, u16, u8); diff --git a/ld_script.txt b/ld_script.txt index df26da50d..628475264 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -172,7 +172,7 @@ SECTIONS { src/dragon.o(.text); asm/dark.o(.text); src/ground.o(.text); - asm/normal.o(.text); + src/normal.o(.text); src/battle_anim_utility_funcs.o(.text); asm/battle_intro.o(.text); src/bike.o(.text); diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index 11cf46ab5..6dfebe77f 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -47,7 +47,7 @@ const u8 gUnknown_0859741E[] = {0x08, 0x0a, 0x0c, 0x0e}; void sub_8116620(u8 taskId) { - u32 selectedPalettes = sub_811583C(gBattleAnimArgs[0]); + u32 selectedPalettes = UnpackSelectedBattleAnimPalettes(gBattleAnimArgs[0]); selectedPalettes |= sub_80A76C4((gBattleAnimArgs[0] >> 7) & 1, (gBattleAnimArgs[0] >> 8) & 1, (gBattleAnimArgs[0] >> 9) & 1, @@ -62,7 +62,7 @@ void sub_8116664(u8 taskId) u8 animBattlers[2]; animBattlers[1] = 0xFF; - selectedPalettes = sub_811583C(1); + selectedPalettes = UnpackSelectedBattleAnimPalettes(1); switch (gBattleAnimArgs[0]) { case 2: @@ -105,7 +105,7 @@ void sub_8116664(u8 taskId) void AnimTask_SetCamouflageBlend(u8 taskId) { - u32 selectedPalettes = sub_811583C(gBattleAnimArgs[0]); + u32 selectedPalettes = UnpackSelectedBattleAnimPalettes(gBattleAnimArgs[0]); switch (gBattleTerrain) { case BATTLE_TERRAIN_GRASS: diff --git a/src/normal.c b/src/normal.c index a4ed5edca..3de8b1157 100644 --- a/src/normal.c +++ b/src/normal.c @@ -1,19 +1,42 @@ #include "global.h" #include "battle_anim.h" +#include "palette.h" +#include "random.h" +#include "task.h" +#include "trig.h" #include "constants/rgb.h" -extern void sub_811572C(struct Sprite *); -extern void sub_81157FC(struct Sprite *); -extern void sub_81158A4(struct Sprite *); -extern void sub_81159B4(struct Sprite *); -extern void sub_81160A4(struct Sprite *); -extern void sub_8116388(struct Sprite *); -extern void sub_8116420(struct Sprite *); -extern void sub_8116458(struct Sprite *); -extern void sub_81164F0(struct Sprite *); -extern void sub_8116560(struct Sprite *); -extern void sub_81165A8(struct Sprite *); -extern void sub_81163D0(struct Sprite *); +void AnimConfusionDuck(struct Sprite *); +void AnimSimplePaletteBlend(struct Sprite *); +u32 UnpackSelectedBattleAnimPalettes(s16); +void sub_81158A4(struct Sprite *); +void sub_81159B4(struct Sprite *); +void sub_81160A4(struct Sprite *); +void sub_8116388(struct Sprite *); +void sub_8116420(struct Sprite *); +void sub_8116458(struct Sprite *); +void sub_81164F0(struct Sprite *); +void sub_8116560(struct Sprite *); +void sub_81165A8(struct Sprite *); +static void AnimConfusionDuckStep(struct Sprite *); +static void AnimSimplePaletteBlendStep(struct Sprite *); +static void sub_81158F8(struct Sprite *); +static void sub_8115984(struct Sprite *); +static void sub_8115A54(u8, u8, u8); +static void sub_8115AA4(u8); +static void sub_8115BC8(u8, u8, u8); +static void sub_8115C18(u8); +static void sub_8115CD0(u8, u8, u8); +static void sub_8115D2C(u8); +static void sub_8115E00(u8); +static void sub_8115EB8(u8); +static void sub_8116148(struct Sprite *); +static void sub_81161F4(void); +static void sub_81162F8(u8); +static void sub_81163D0(struct Sprite *); +static void sub_81165E4(struct Sprite *); + +extern void sub_810E2C8(struct Sprite *); const union AnimCmd gUnknown_0859722C[] = { @@ -47,7 +70,7 @@ const struct SpriteTemplate gConfusionDuckSpriteTemplate = .anims = gUnknown_08597254, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_811572C, + .callback = AnimConfusionDuck, }; const struct SpriteTemplate gSimplePaletteBlendSpriteTemplate = @@ -58,7 +81,7 @@ const struct SpriteTemplate gSimplePaletteBlendSpriteTemplate = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_81157FC, + .callback = AnimSimplePaletteBlend, }; const struct SpriteTemplate gComplexPaletteBlendSpriteTemplate = @@ -231,3 +254,717 @@ const struct SpriteTemplate gUnknown_08597400 = .affineAnims = gUnknown_08597348, .callback = sub_81163D0, }; + +// Moves a spinning duck around the mon's head. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: initial wave offset +// arg 3: wave period (higher means faster wave) +// arg 4: duration +void AnimConfusionDuck(struct Sprite *sprite) +{ + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->data[0] = gBattleAnimArgs[2]; + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + { + sprite->data[1] = -gBattleAnimArgs[3]; + sprite->data[4] = 1; + } + else + { + sprite->data[1] = gBattleAnimArgs[3]; + sprite->data[4] = 0; + StartSpriteAnim(sprite, 1); + } + + sprite->data[3] = gBattleAnimArgs[4]; + sprite->callback = AnimConfusionDuckStep; + sprite->callback(sprite); +} + +static void AnimConfusionDuckStep(struct Sprite *sprite) +{ + sprite->pos2.x = Cos(sprite->data[0], 30); + sprite->pos2.y = Sin(sprite->data[0], 10); + + if ((u16)sprite->data[0] < 128) + sprite->oam.priority = 1; + else + sprite->oam.priority = 3; + + sprite->data[0] = (sprite->data[0] + sprite->data[1]) & 0xFF; + if (++sprite->data[2] == sprite->data[3]) + DestroyAnimSprite(sprite); +} + +// Performs a simple color blend on a specified sprite. +// arg 0: palette selector +// arg 1: delay +// arg 2: start blend amount +// arg 3: end blend amount +// arg 4: blend color +void AnimSimplePaletteBlend(struct Sprite *sprite) +{ + u32 selectedPalettes = UnpackSelectedBattleAnimPalettes(gBattleAnimArgs[0]); + BeginNormalPaletteFade(selectedPalettes, gBattleAnimArgs[1], gBattleAnimArgs[2], gBattleAnimArgs[3], gBattleAnimArgs[4]); + sprite->invisible = 1; + sprite->callback = AnimSimplePaletteBlendStep; +} + +// Unpacks a bitfield and returns a bitmask of its selected palettes. +// Bits 0-6 of the selector parameter result in the following palettes being selected: +// 0: battle background palettes (BG palettes 1, 2, and 3) +// 1: gBattleAnimAttacker OBJ palette +// 2: gBattleAnimTarget OBJ palette +// 3: gBattleAnimAttacker partner OBJ palette +// 4: gBattleAnimTarget partner OBJ palette +// 5: BG palette 4 +// 6: BG palette 5 +u32 UnpackSelectedBattleAnimPalettes(s16 selector) +{ + u8 arg0 = selector & 1; + u8 arg1 = (selector >> 1) & 1; + u8 arg2 = (selector >> 2) & 1; + u8 arg3 = (selector >> 3) & 1; + u8 arg4 = (selector >> 4) & 1; + u8 arg5 = (selector >> 5) & 1; + u8 arg6 = (selector >> 6) & 1; + return sub_80A75AC(arg0, arg1, arg2, arg3, arg4, arg5, arg6); +} + +static void AnimSimplePaletteBlendStep(struct Sprite *sprite) +{ + if (!gPaletteFade.active) + DestroyAnimSprite(sprite); +} + +void sub_81158A4(struct Sprite *sprite) +{ + u32 selectedPalettes; + + sprite->data[0] = gBattleAnimArgs[1]; + sprite->data[1] = gBattleAnimArgs[1]; + sprite->data[2] = gBattleAnimArgs[2]; + sprite->data[3] = gBattleAnimArgs[3]; + sprite->data[4] = gBattleAnimArgs[4]; + sprite->data[5] = gBattleAnimArgs[5]; + sprite->data[6] = gBattleAnimArgs[6]; + sprite->data[7] = gBattleAnimArgs[0]; + + selectedPalettes = UnpackSelectedBattleAnimPalettes(sprite->data[7]); + BlendPalettes(selectedPalettes, gBattleAnimArgs[4], gBattleAnimArgs[3]); + sprite->invisible = 1; + sprite->callback = sub_81158F8; +} + +static void sub_81158F8(struct Sprite *sprite) +{ + u32 selectedPalettes; + + if (sprite->data[0] > 0) + { + sprite->data[0]--; + return; + } + + if (gPaletteFade.active) + return; + + if (sprite->data[2] == 0) + { + sprite->callback = sub_8115984; + return; + } + + selectedPalettes = UnpackSelectedBattleAnimPalettes(sprite->data[7]); + if (sprite->data[1] & 0x100) + BlendPalettes(selectedPalettes, sprite->data[4], sprite->data[3]); + else + BlendPalettes(selectedPalettes, sprite->data[6], sprite->data[5]); + + sprite->data[1] ^= 0x100; + sprite->data[0] = sprite->data[1] & 0xFF; + sprite->data[2]--; +} + +static void sub_8115984(struct Sprite *sprite) +{ + u32 selectedPalettes; + + if (!gPaletteFade.active) + { + selectedPalettes = UnpackSelectedBattleAnimPalettes(sprite->data[7]); + BlendPalettes(selectedPalettes, 0, 0); + DestroyAnimSprite(sprite); + } +} + +void sub_81159B4(struct Sprite *sprite) +{ + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->data[0] = 0; + sprite->data[1] = 10; + sprite->data[2] = 8; + sprite->data[3] = 40; + sprite->data[4] = 112; + sprite->data[5] = 0; + StoreSpriteCallbackInData6(sprite, move_anim_8074EE0); + sprite->callback = sub_80A634C; + sprite->callback(sprite); +} + +void sub_8115A04(u8 taskId) +{ + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + gTasks[taskId].data[1] = gBattleAnimArgs[1]; + gTasks[taskId].data[2] = gBattleAnimArgs[2]; + gTasks[taskId].data[3] = gBattleAnimArgs[3]; + gTasks[taskId].data[4] = gBattleAnimArgs[4]; + gTasks[taskId].data[5] = gBattleAnimArgs[5]; + gTasks[taskId].data[8] = 0; + sub_8115A54(taskId, 0, gTasks[taskId].data[4]); + gTasks[taskId].func = sub_8115AA4; +} + +static void sub_8115A54(u8 taskId, u8 initialBlendAmount, u8 targetBlendAmount) +{ + u32 selectedPalettes = UnpackSelectedBattleAnimPalettes(gTasks[taskId].data[0]); + BeginNormalPaletteFade( + selectedPalettes, + gTasks[taskId].data[1], + initialBlendAmount, + targetBlendAmount, + gTasks[taskId].data[5]); + + gTasks[taskId].data[2]--; + gTasks[taskId].data[8] ^= 1; +} + +static void sub_8115AA4(u8 taskId) +{ + u8 initialBlendAmount, targetBlendAmount; + if (!gPaletteFade.active) + { + if (gTasks[taskId].data[2] > 0) + { + if (gTasks[taskId].data[8] == 0) + { + initialBlendAmount = gTasks[taskId].data[3]; + targetBlendAmount = gTasks[taskId].data[4]; + } + else + { + initialBlendAmount = gTasks[taskId].data[4]; + targetBlendAmount = gTasks[taskId].data[3]; + } + + if (gTasks[taskId].data[2] == 1) + targetBlendAmount = 0; + + sub_8115A54(taskId, initialBlendAmount, targetBlendAmount); + } + else + { + DestroyAnimVisualTask(taskId); + } + } +} + +void sub_8115B0C(u8 taskId) +{ + int battler; + u32 selectedPalettes = 0; + + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + gTasks[taskId].data[1] = gBattleAnimArgs[1]; + gTasks[taskId].data[2] = gBattleAnimArgs[2]; + gTasks[taskId].data[3] = gBattleAnimArgs[3]; + gTasks[taskId].data[4] = gBattleAnimArgs[4]; + gTasks[taskId].data[5] = gBattleAnimArgs[5]; + gTasks[taskId].data[8] = 0; + + for (battler = 0; battler < gBattlersCount; battler++) + { + if (battler != gBattleAnimAttacker && battler != gBattleAnimTarget) + selectedPalettes |= 1 << (battler + 16); + } + + if (gBattleAnimArgs[0] == 1) + selectedPalettes |= 0xE; + + gTasks[taskId].data[9] = selectedPalettes >> 16; + gTasks[taskId].data[10] = selectedPalettes & 0xFF; + sub_8115BC8(taskId, 0, gTasks[taskId].data[4]); + gTasks[taskId].func = sub_8115C18; +} + +static void sub_8115BC8(u8 taskId, u8 initialBlendAmount, u8 targetBlendAmount) +{ + u32 selectedPalettes = ((u16)gTasks[taskId].data[9] << 16) | (u16)gTasks[taskId].data[10]; + BeginNormalPaletteFade( + selectedPalettes, + gTasks[taskId].data[1], + initialBlendAmount, + targetBlendAmount, + gTasks[taskId].data[5]); + + gTasks[taskId].data[2]--; + gTasks[taskId].data[8] ^= 1; +} + +static void sub_8115C18(u8 taskId) +{ + u8 initialBlendAmount, targetBlendAmount; + if (!gPaletteFade.active) + { + if (gTasks[taskId].data[2] > 0) + { + if (gTasks[taskId].data[8] == 0) + { + initialBlendAmount = gTasks[taskId].data[3]; + targetBlendAmount = gTasks[taskId].data[4]; + } + else + { + initialBlendAmount = gTasks[taskId].data[4]; + targetBlendAmount = gTasks[taskId].data[3]; + } + + if (gTasks[taskId].data[2] == 1) + targetBlendAmount = 0; + + sub_8115BC8(taskId, initialBlendAmount, targetBlendAmount); + } + else + { + DestroyAnimVisualTask(taskId); + } + } +} + +void sub_8115C80(u8 taskId) +{ + u8 paletteIndex; + + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + gTasks[taskId].data[1] = gBattleAnimArgs[1]; + gTasks[taskId].data[2] = gBattleAnimArgs[2]; + gTasks[taskId].data[3] = gBattleAnimArgs[3]; + gTasks[taskId].data[4] = gBattleAnimArgs[4]; + gTasks[taskId].data[5] = gBattleAnimArgs[5]; + gTasks[taskId].data[8] = 0; + + sub_8115CD0(taskId, 0, gTasks[taskId].data[4]); + gTasks[taskId].func = sub_8115D2C; +} + +static void sub_8115CD0(u8 taskId, u8 initialBlendAmount, u8 targetBlendAmount) +{ + u8 paletteIndex = IndexOfSpritePaletteTag(gTasks[taskId].data[0]); + BeginNormalPaletteFade( + 1 << (paletteIndex + 16), + gTasks[taskId].data[1], + initialBlendAmount, + targetBlendAmount, + gTasks[taskId].data[5]); + + gTasks[taskId].data[2]--; + gTasks[taskId].data[8] ^= 1; +} + +static void sub_8115D2C(u8 taskId) +{ + u8 initialBlendAmount, targetBlendAmount; + if (!gPaletteFade.active) + { + if (gTasks[taskId].data[2] > 0) + { + if (gTasks[taskId].data[8] == 0) + { + initialBlendAmount = gTasks[taskId].data[3]; + targetBlendAmount = gTasks[taskId].data[4]; + } + else + { + initialBlendAmount = gTasks[taskId].data[4]; + targetBlendAmount = gTasks[taskId].data[3]; + } + + if (gTasks[taskId].data[2] == 1) + targetBlendAmount = 0; + + sub_8115CD0(taskId, initialBlendAmount, targetBlendAmount); + } + else + { + DestroyAnimVisualTask(taskId); + } + } +} + +void sub_8115D94(u8 taskId) +{ + u8 paletteIndex; + + gTasks[taskId].data[0] = gBattleAnimArgs[1]; + gTasks[taskId].data[1] = gBattleAnimArgs[1]; + gTasks[taskId].data[2] = gBattleAnimArgs[2]; + gTasks[taskId].data[3] = gBattleAnimArgs[3]; + gTasks[taskId].data[4] = gBattleAnimArgs[4]; + gTasks[taskId].data[5] = gBattleAnimArgs[5]; + gTasks[taskId].data[6] = gBattleAnimArgs[6]; + gTasks[taskId].data[7] = gBattleAnimArgs[0]; + + paletteIndex = IndexOfSpritePaletteTag(gBattleAnimArgs[0]); + BeginNormalPaletteFade( + 1 << (paletteIndex + 16), + 0, + gBattleAnimArgs[4], + gBattleAnimArgs[4], + gBattleAnimArgs[3]); + + gTasks[taskId].func = sub_8115E00; +} + +static void sub_8115E00(u8 taskId) +{ + u32 selectedPalettes; + + if (gTasks[taskId].data[0] > 0) + { + gTasks[taskId].data[0]--; + return; + } + + if (gPaletteFade.active) + return; + + if (gTasks[taskId].data[2] == 0) + { + gTasks[taskId].func = sub_8115EB8; + return; + } + + selectedPalettes = 1 << (IndexOfSpritePaletteTag(gTasks[taskId].data[7]) + 16); + if (gTasks[taskId].data[1] & 0x100) + { + BeginNormalPaletteFade( + selectedPalettes, + 0, + gTasks[taskId].data[4], + gTasks[taskId].data[4], + gTasks[taskId].data[3]); + } + else + { + BeginNormalPaletteFade( + selectedPalettes, + 0, + gTasks[taskId].data[6], + gTasks[taskId].data[6], + gTasks[taskId].data[5]); + } + + gTasks[taskId].data[1] ^= 0x100; + gTasks[taskId].data[0] = gTasks[taskId].data[1] & 0xFF; + gTasks[taskId].data[2]--; +} + +static void sub_8115EB8(u8 taskId) +{ + u32 selectedPalettes; + + if (!gPaletteFade.active) + { + selectedPalettes = 1 << (IndexOfSpritePaletteTag(gTasks[taskId].data[7]) + 16); + BeginNormalPaletteFade(selectedPalettes, 0, 0, 0, RGB(0, 0, 0)); + DestroyAnimVisualTask(taskId); + } +} + +void sub_8115F10(u8 taskId) +{ + u32 selectedPalettes = 0; + u8 attackerBattler = gBattleAnimAttacker; + u8 targetBattler = gBattleAnimTarget; + + if (gBattleAnimArgs[0] & 0x100) + selectedPalettes = sub_80A75AC(1, 0, 0, 0, 0, 0, 0); + + if (gBattleAnimArgs[1] & 0x100) + selectedPalettes |= (0x10000 << attackerBattler); + + if (gBattleAnimArgs[2] & 0x100) + selectedPalettes |= (0x10000 << targetBattler); + + InvertPlttBuffer(selectedPalettes); + DestroyAnimVisualTask(taskId); +} + +void sub_8115F94(u8 taskId) +{ + u8 attackerBattler; + u8 targetBattler; + u8 paletteIndex; + u32 selectedPalettes = 0; + + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[2] = gBattleAnimArgs[0]; + gTasks[taskId].data[3] = gBattleAnimArgs[1]; + gTasks[taskId].data[4] = gBattleAnimArgs[2]; + gTasks[taskId].data[1] = gBattleAnimArgs[3]; + gTasks[taskId].data[5] = gBattleAnimArgs[4]; + gTasks[taskId].data[6] = gBattleAnimArgs[5]; + gTasks[taskId].data[7] = gBattleAnimArgs[6]; + } + + gTasks[taskId].data[0]++; + attackerBattler = gBattleAnimAttacker; + targetBattler = gBattleAnimTarget; + + if (gTasks[taskId].data[2] & 0x100) + selectedPalettes = 0x0000FFFF; + + if (gTasks[taskId].data[2] & 0x1) + { + paletteIndex = IndexOfSpritePaletteTag(gSprites[gHealthboxSpriteIds[attackerBattler]].template->paletteTag); + selectedPalettes |= (1 << paletteIndex) << 16; + } + + if (gTasks[taskId].data[3] & 0x100) + selectedPalettes |= (1 << attackerBattler) << 16; + + if (gTasks[taskId].data[4] & 0x100) + selectedPalettes |= (1 << targetBattler) << 16; + + TintPlttBuffer(selectedPalettes, gTasks[taskId].data[5], gTasks[taskId].data[6], gTasks[taskId].data[7]); + if (gTasks[taskId].data[0] == gTasks[taskId].data[1]) + { + UnfadePlttBuffer(selectedPalettes); + DestroyAnimVisualTask(taskId); + } +} + +void sub_81160A4(struct Sprite *sprite) +{ + u16 var0; + + sprite->invisible = 1; + sprite->data[0] = -gBattleAnimArgs[0]; + sprite->data[1] = gBattleAnimArgs[1]; + sprite->data[2] = gBattleAnimArgs[1]; + sprite->data[3] = gBattleAnimArgs[2]; + + switch (gBattleAnimArgs[3]) + { + case 0: + StoreSpriteCallbackInData6(sprite, (void *)&gBattle_BG3_X); + break; + case 1: + StoreSpriteCallbackInData6(sprite, (void *)&gBattle_BG3_Y); + break; + case 2: + StoreSpriteCallbackInData6(sprite, (void *)&gSpriteCoordOffsetX); + break; + default: + StoreSpriteCallbackInData6(sprite, (void *)&gSpriteCoordOffsetY); + break; + } + + sprite->data[4] = *(u16 *)(sprite->data[6] | (sprite->data[7] << 16)); + sprite->data[5] = gBattleAnimArgs[3]; + var0 = sprite->data[5] - 2; + if (var0 < 2) + sub_81161F4(); + + sprite->callback = sub_8116148; +} + +static void sub_8116148(struct Sprite *sprite) +{ + u8 i; + u16 var0; + + if (sprite->data[3] > 0) + { + sprite->data[3]--; + if (sprite->data[1] > 0) + { + sprite->data[1]--; + } + else + { + sprite->data[1] = sprite->data[2]; + *(u16 *)(sprite->data[6] | (sprite->data[7] << 16)) += sprite->data[0]; + sprite->data[0] = -sprite->data[0]; + } + } + else + { + *(u16 *)(sprite->data[6] | (sprite->data[7] << 16)) = sprite->data[4]; + var0 = sprite->data[5] - 2; + if (var0 < 2) + { + for (i = 0; i < gBattlersCount; i++) + gSprites[gBattlerSpriteIds[i]].coordOffsetEnabled = 0; + } + + DestroyAnimSprite(sprite); + } +} + +static void sub_81161F4(void) +{ + gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].coordOffsetEnabled = 0; + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].coordOffsetEnabled = 0; + + if (gBattleAnimArgs[4] == 2) + { + gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].coordOffsetEnabled = 1; + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].coordOffsetEnabled = 1; + } + else + { + if (gBattleAnimArgs[4] == 0) + gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].coordOffsetEnabled = 1; + else + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].coordOffsetEnabled = 1; + } +} + +void sub_81162A4(u8 taskId) +{ + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + gTasks[taskId].data[1] = gBattleAnimArgs[1]; + gTasks[taskId].data[2] = gBattleAnimArgs[2]; + gTasks[taskId].data[3] = gBattleAnimArgs[3]; + gTasks[taskId].data[8] = gBattleAnimArgs[3]; + gBattle_BG3_X = gBattleAnimArgs[0]; + gBattle_BG3_Y = gBattleAnimArgs[1]; + gTasks[taskId].func = sub_81162F8; + gTasks[taskId].func(taskId); +} + +static void sub_81162F8(u8 taskId) +{ + if (gTasks[taskId].data[3] == 0) + { + if (gBattle_BG3_X == gTasks[taskId].data[0]) + gBattle_BG3_X = -gTasks[taskId].data[0]; + else + gBattle_BG3_X = gTasks[taskId].data[0]; + + if (gBattle_BG3_Y == -gTasks[taskId].data[1]) + gBattle_BG3_Y = 0; + else + gBattle_BG3_Y = -gTasks[taskId].data[1]; + + gTasks[taskId].data[3] = gTasks[taskId].data[8]; + if (--gTasks[taskId].data[2] == 0) + { + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; + DestroyAnimVisualTask(taskId); + } + } + else + { + gTasks[taskId].data[3]--; + } +} + +void sub_8116388(struct Sprite *sprite) +{ + StartSpriteAffineAnim(sprite, gBattleAnimArgs[3]); + if (gBattleAnimArgs[2] == 0) + InitAnimSpritePos(sprite, 1); + else + sub_80A6980(sprite, TRUE); + + sprite->callback = sub_80A67BC; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +static void sub_81163D0(struct Sprite *sprite) +{ + StartSpriteAffineAnim(sprite, gBattleAnimArgs[3]); + if (gBattleAnimArgs[2] == 0) + InitAnimSpritePos(sprite, 1); + else + sub_80A6980(sprite, TRUE); + + sprite->data[0] = gBattleAnimArgs[4]; + sprite->callback = sub_80A67BC; + StoreSpriteCallbackInData6(sprite, sub_810E2C8); +} + +void sub_8116420(struct Sprite *sprite) +{ + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER && !IsContest()) + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + + sub_8116388(sprite); +} + +void sub_8116458(struct Sprite *sprite) +{ + if (gBattleAnimArgs[1] == -1) + gBattleAnimArgs[1] = Random2() & 3; + + StartSpriteAffineAnim(sprite, gBattleAnimArgs[1]); + if (gBattleAnimArgs[0] == 0) + InitAnimSpritePos(sprite, 0); + else + sub_80A6980(sprite, FALSE); + + sprite->pos2.x += (Random2() % 48) - 24; + sprite->pos2.y += (Random2() % 24) - 12; + + StoreSpriteCallbackInData6(sprite, move_anim_8074EE0); + sprite->callback = sub_80A67BC; +} + +void sub_81164F0(struct Sprite *sprite) +{ + sprite->data[0] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]); + sprite->pos1.x = gSprites[sprite->data[0]].pos1.x + gSprites[sprite->data[0]].pos2.x; + sprite->pos1.y = gSprites[sprite->data[0]].pos1.y + gSprites[sprite->data[0]].pos2.y; + sprite->pos2.x = gBattleAnimArgs[1]; + sprite->pos2.y = gBattleAnimArgs[2]; + StartSpriteAffineAnim(sprite, gBattleAnimArgs[3]); + StoreSpriteCallbackInData6(sprite, move_anim_8074EE0); + sprite->callback = sub_80A67BC; +} + +void sub_8116560(struct Sprite *sprite) +{ + if (gBattleAnimArgs[2] == 0) + InitAnimSpritePos(sprite, 1); + else + sub_80A6980(sprite, TRUE); + + sprite->data[0] = gBattleAnimArgs[3]; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); + sprite->callback = WaitAnimForDuration; +} + +void sub_81165A8(struct Sprite *sprite) +{ + StartSpriteAffineAnim(sprite, gBattleAnimArgs[3]); + if (gBattleAnimArgs[2] == 0) + InitAnimSpritePos(sprite, 1); + else + sub_80A6980(sprite, TRUE); + + sprite->callback = sub_81165E4; +} + +static void sub_81165E4(struct Sprite *sprite) +{ + sprite->invisible ^= 1; + if (sprite->data[0]++ > 12) + DestroyAnimSprite(sprite); +}