From f1213ebb4bb02d17994f212d47a301e82e530cad Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 24 Dec 2018 09:51:15 -0600 Subject: [PATCH 1/3] Decompile dark.c --- asm/dark.s | 2199 ----------------------------------------- asm/psychic.s | 4 +- include/battle_anim.h | 2 +- include/graphics.h | 4 + ld_script.txt | 2 +- src/battle_anim.c | 10 +- src/dark.c | 820 ++++++++++++++- 7 files changed, 829 insertions(+), 2212 deletions(-) delete mode 100644 asm/dark.s diff --git a/asm/dark.s b/asm/dark.s deleted file mode 100644 index bb46b0fa9..000000000 --- a/asm/dark.s +++ /dev/null @@ -1,2199 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_81136E8 -sub_81136E8: @ 81136E8 - 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 r0, r1 - ldr r1, =gBattleAnimArgs - ldrh r1, [r1] - strh r1, [r0, 0x8] - ldr r1, =gBattleAnimAttacker - ldrb r4, [r1] - movs r1, 0x10 - strh r1, [r0, 0xA] - movs r0, 0x52 - bl SetGpuReg - adds r0, r4, 0 - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08113734 - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - b _0811373C - .pool -_08113734: - ldr r1, =0x00003f44 - movs r0, 0x50 - bl SetGpuReg -_0811373C: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_811375C - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81136E8 - - thumb_func_start sub_811375C -sub_811375C: @ 811375C - push {r4-r7,lr} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r6, r0, r1 - ldrh r0, [r6, 0xA] - lsrs r4, r0, 8 - lsls r0, 24 - lsrs r1, r0, 24 - movs r2, 0xC - ldrsh r0, [r6, r2] - ldrb r2, [r6, 0x8] - cmp r0, r2 - bne _081137D8 - adds r4, 0x1 - lsls r4, 24 - lsrs r4, 24 - subs r0, r1, 0x1 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r4, 8 - orrs r1, r0 - movs r5, 0 - strh r1, [r6, 0xA] - ldrh r1, [r6, 0xA] - movs r0, 0x52 - bl SetGpuReg - strh r5, [r6, 0xC] - cmp r4, 0x10 - bne _081137DE - 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, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - adds r0, r7, 0 - bl DestroyAnimVisualTask - b _081137DE - .pool -_081137D8: - ldrh r0, [r6, 0xC] - adds r0, 0x1 - strh r0, [r6, 0xC] -_081137DE: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_811375C - - thumb_func_start sub_81137E4 -sub_81137E4: @ 81137E4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r2, r0, 2 - adds r2, r0 - lsls r2, 3 - adds r2, r1 - ldr r0, =gBattleAnimArgs - ldrh r0, [r0] - strh r0, [r2, 0x8] - movs r1, 0x80 - lsls r1, 5 - strh r1, [r2, 0xA] - ldr r0, =sub_811381C - str r0, [r2] - movs r0, 0x52 - bl SetGpuReg - pop {r0} - bx r0 - .pool - thumb_func_end sub_81137E4 - - thumb_func_start sub_811381C -sub_811381C: @ 811381C - push {r4-r7,lr} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r6, r0, r1 - ldrh r0, [r6, 0xA] - lsrs r4, r0, 8 - lsls r0, 24 - lsrs r1, r0, 24 - movs r2, 0xC - ldrsh r0, [r6, r2] - ldrb r2, [r6, 0x8] - cmp r0, r2 - bne _0811387C - subs r4, 0x1 - lsls r4, 24 - lsrs r4, 24 - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r4, 8 - orrs r1, r0 - movs r5, 0 - strh r1, [r6, 0xA] - ldrh r1, [r6, 0xA] - movs r0, 0x52 - bl SetGpuReg - strh r5, [r6, 0xC] - cmp r4, 0 - bne _08113882 - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - adds r0, r7, 0 - bl DestroyAnimVisualTask - b _08113882 - .pool -_0811387C: - ldrh r0, [r6, 0xC] - adds r0, 0x1 - strh r0, [r6, 0xC] -_08113882: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_811381C - - thumb_func_start sub_8113888 -sub_8113888: @ 8113888 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081138BC - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - b _081138C4 - .pool -_081138BC: - ldr r1, =0x00003f44 - movs r0, 0x50 - bl SetGpuReg -_081138C4: - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8113888 - - thumb_func_start sub_81138D4 -sub_81138D4: @ 81138D4 - push {r4-r6,lr} - adds r4, r0, 0 - ldr r6, =gBattleAnimTarget - ldrb r0, [r6] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x30] - ldr r5, =gBattleAnimAttacker - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x32] - ldrb r0, [r6] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x34] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x36] - movs r0, 0x7E - strh r0, [r4, 0x2E] - adds r0, r4, 0 - bl InitSpriteDataForLinearTranslation - ldrh r0, [r4, 0x30] - negs r0, r0 - strh r0, [r4, 0x34] - ldrh r0, [r4, 0x32] - negs r0, r0 - strh r0, [r4, 0x36] - ldr r0, =0x0000ffd8 - strh r0, [r4, 0x3A] - ldr r1, =sub_8113950 - str r1, [r4, 0x1C] - adds r0, r4, 0 - bl _call_via_r1 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81138D4 - - thumb_func_start sub_8113950 -sub_8113950: @ 8113950 - push {r4-r6,lr} - adds r4, r0, 0 - ldrh r5, [r4, 0x30] - ldrh r0, [r4, 0x34] - adds r2, r5, r0 - strh r2, [r4, 0x34] - ldrh r3, [r4, 0x32] - ldrh r6, [r4, 0x36] - adds r1, r3, r6 - strh r1, [r4, 0x36] - lsls r0, r2, 16 - asrs r0, 24 - strh r0, [r4, 0x24] - lsls r0, r1, 16 - asrs r0, 24 - strh r0, [r4, 0x26] - movs r6, 0x3C - ldrsh r0, [r4, r6] - cmp r0, 0 - bne _08113992 - adds r0, r2, r5 - strh r0, [r4, 0x34] - adds r1, r3 - strh r1, [r4, 0x36] - lsls r0, 16 - asrs r0, 24 - strh r0, [r4, 0x24] - lsls r1, 16 - asrs r1, 24 - strh r1, [r4, 0x26] - ldrh r0, [r4, 0x2E] - subs r0, 0x1 - strh r0, [r4, 0x2E] -_08113992: - movs r1, 0x38 - ldrsh r0, [r4, r1] - movs r2, 0x3A - ldrsh r1, [r4, r2] - bl Sin - ldrh r6, [r4, 0x26] - adds r0, r6 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x38] - adds r0, 0x3 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x38] - cmp r0, 0x7F - ble _081139C2 - movs r0, 0 - strh r0, [r4, 0x38] - ldrh r0, [r4, 0x3A] - adds r0, 0x14 - strh r0, [r4, 0x3A] - ldrh r0, [r4, 0x3C] - adds r0, 0x1 - strh r0, [r4, 0x3C] -_081139C2: - ldrh r0, [r4, 0x2E] - subs r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - cmp r0, 0 - bne _081139D4 - adds r0, r4, 0 - bl DestroyAnimSprite -_081139D4: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8113950 - - thumb_func_start sub_81139DC -sub_81139DC: @ 81139DC - 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] - ldrb r1, [r5, 0x4] - adds r0, r4, 0 - bl StartSpriteAffineAnim - ldrh r0, [r5, 0x6] - strh r0, [r4, 0x2E] - ldrh r0, [r5, 0x8] - strh r0, [r4, 0x30] - ldrh r0, [r5, 0xA] - strh r0, [r4, 0x32] - ldr r0, =sub_8113A18 - str r0, [r4, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81139DC - - thumb_func_start sub_8113A18 -sub_8113A18: @ 8113A18 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x2E] - ldrh r1, [r2, 0x36] - adds r0, r1 - strh r0, [r2, 0x36] - ldrh r1, [r2, 0x30] - ldrh r3, [r2, 0x38] - adds r1, r3 - strh r1, [r2, 0x38] - lsls r0, 16 - asrs r0, 24 - strh r0, [r2, 0x24] - lsls r1, 16 - asrs r1, 24 - strh r1, [r2, 0x26] - ldrh r0, [r2, 0x34] - adds r0, 0x1 - strh r0, [r2, 0x34] - lsls r0, 16 - asrs r0, 16 - movs r3, 0x32 - ldrsh r1, [r2, r3] - cmp r0, r1 - bne _08113A4E - ldr r0, =sub_8113A58 - str r0, [r2, 0x1C] -_08113A4E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8113A18 - - thumb_func_start sub_8113A58 -sub_8113A58: @ 8113A58 - push {lr} - adds r3, r0, 0 - ldrh r1, [r3, 0x36] - ldrh r0, [r3, 0x2E] - subs r1, r0 - strh r1, [r3, 0x36] - ldrh r0, [r3, 0x38] - ldrh r2, [r3, 0x30] - subs r0, r2 - strh r0, [r3, 0x38] - lsls r1, 16 - asrs r1, 24 - strh r1, [r3, 0x24] - lsls r0, 16 - asrs r0, 24 - strh r0, [r3, 0x26] - ldrh r0, [r3, 0x34] - subs r0, 0x1 - strh r0, [r3, 0x34] - lsls r0, 16 - cmp r0, 0 - bne _08113A8A - adds r0, r3, 0 - bl DestroySpriteAndMatrix -_08113A8A: - pop {r0} - bx r0 - thumb_func_end sub_8113A58 - - thumb_func_start sub_8113A90 -sub_8113A90: @ 8113A90 - push {r4-r7,lr} - adds r4, r0, 0 - ldr r0, =gBattleAnimArgs - movs r2, 0 - ldrsh r1, [r0, r2] - adds r3, r0, 0 - cmp r1, 0 - bne _08113AAC - ldr r0, =gBattleAnimAttacker - b _08113AAE - .pool -_08113AAC: - ldr r0, =gBattleAnimTarget -_08113AAE: - ldrb r5, [r0] - movs r6, 0x14 - ldrh r2, [r4, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - adds r1, 0x4 - ldr r7, =0x000003ff - adds r0, r7, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r4, 0x4] - movs r1, 0x2 - ldrsh r0, [r3, r1] - cmp r0, 0x1 - beq _08113B0C - cmp r0, 0x1 - bgt _08113AE8 - cmp r0, 0 - beq _08113AF2 - b _08113B60 - .pool -_08113AE8: - cmp r0, 0x2 - beq _08113B26 - cmp r0, 0x3 - beq _08113B3E - b _08113B60 -_08113AF2: - adds r0, r5, 0 - movs r1, 0x5 - bl sub_80A861C - subs r0, 0x8 - strh r0, [r4, 0x20] - adds r0, r5, 0 - movs r1, 0x2 - bl sub_80A861C - adds r0, 0x8 - strh r0, [r4, 0x22] - b _08113B60 -_08113B0C: - adds r0, r5, 0 - movs r1, 0x5 - bl sub_80A861C - subs r0, 0xE - strh r0, [r4, 0x20] - adds r0, r5, 0 - movs r1, 0x2 - bl sub_80A861C - adds r0, 0x10 - strh r0, [r4, 0x22] - b _08113B60 -_08113B26: - adds r0, r5, 0 - movs r1, 0x4 - bl sub_80A861C - adds r0, 0x8 - strh r0, [r4, 0x20] - adds r0, r5, 0 - movs r1, 0x2 - bl sub_80A861C - adds r0, 0x8 - b _08113B54 -_08113B3E: - adds r0, r5, 0 - movs r1, 0x4 - bl sub_80A861C - adds r0, 0xE - strh r0, [r4, 0x20] - adds r0, r5, 0 - movs r1, 0x2 - bl sub_80A861C - adds r0, 0x10 -_08113B54: - strh r0, [r4, 0x22] - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - movs r6, 0xEC -_08113B60: - movs r0, 0x20 - strh r0, [r4, 0x2E] - lsls r0, r6, 24 - asrs r0, 24 - ldrh r2, [r4, 0x20] - adds r0, r2 - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x22] - adds r0, 0xC - strh r0, [r4, 0x36] - ldr r0, =0x0000fff4 - strh r0, [r4, 0x38] - adds r0, r4, 0 - bl InitAnimArcTranslation - ldr r0, =sub_8113B90 - str r0, [r4, 0x1C] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8113A90 - - thumb_func_start sub_8113B90 -sub_8113B90: @ 8113B90 - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _08113BA4 - adds r0, r4, 0 - bl DestroySpriteAndMatrix -_08113BA4: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8113B90 - - thumb_func_start sub_8113BAC -sub_8113BAC: @ 8113BAC - push {r4-r7,lr} - sub sp, 0x1C - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r5, r1, r0 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x1F - movs r6, 0 - strh r0, [r5, 0x16] - ldrb r0, [r4] - movs r1, 0x2 - bl sub_80A861C - subs r0, 0x7 - strh r0, [r5, 0x14] - ldrh r1, [r5, 0x16] - strh r1, [r5, 0x12] - strh r0, [r5, 0x10] - subs r1, r0 - lsls r1, 8 - strh r1, [r5, 0x22] - ldrb r0, [r4] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - adds r1, r0, 0 - subs r1, 0x20 - strh r1, [r5, 0x24] - adds r0, 0x20 - strh r0, [r5, 0x26] - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _08113C1C - ldr r0, =0x0000fff4 - b _08113C1E - .pool -_08113C1C: - ldr r0, =0x0000ffc0 -_08113C1E: - strh r0, [r5, 0x18] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0xE] - cmp r0, 0x1 - bne _08113C80 - add r4, sp, 0xC - adds r0, r4, 0 - bl sub_80A6B30 - ldr r0, =gBattle_BG1_Y - ldrh r0, [r0] - strh r0, [r5, 0x1C] - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - ldrb r1, [r4, 0x8] - lsls r1, 4 - movs r0, 0 - movs r2, 0x20 - bl FillPalette - ldr r0, =0x04000016 - str r0, [sp] - movs r7, 0x2 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08113CB0 - ldr r1, =gBattle_BG2_X - b _08113CAA - .pool -_08113C80: - ldr r0, =gBattle_BG2_Y - ldrh r0, [r0] - strh r0, [r5, 0x1C] - ldr r1, =0x00003f44 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0 - movs r1, 0x90 - movs r2, 0x20 - bl FillPalette - ldr r0, =0x0400001a - str r0, [sp] - movs r7, 0x4 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08113CB0 - ldr r1, =gBattle_BG1_X -_08113CAA: - ldrh r0, [r1] - adds r0, 0xF0 - strh r0, [r1] -_08113CB0: - ldr r0, =0xa2600001 - str r0, [sp, 0x4] - mov r2, sp - movs r1, 0 - movs r0, 0x1 - strb r0, [r2, 0x8] - mov r0, sp - strb r1, [r0, 0x9] - strh r1, [r5, 0x1E] - movs r0, 0x10 - strh r0, [r5, 0x20] - strh r1, [r5, 0x8] - strh r1, [r5, 0xA] - strh r1, [r5, 0xC] - movs r0, 0x3 - bl sub_8114374 - movs r3, 0 - ldr r4, =gScanlineEffectRegBuffers - movs r0, 0xF0 - lsls r0, 3 - adds r6, r4, r0 -_08113CDC: - lsls r1, r3, 1 - adds r2, r1, r4 - ldrh r0, [r5, 0x1C] - strh r0, [r2] - adds r1, r6 - ldrh r0, [r5, 0x1C] - strh r0, [r1] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x6F - bls _08113CDC - ldr r0, [sp] - ldr r1, [sp, 0x4] - ldr r2, [sp, 0x8] - bl ScanlineEffect_SetParams - movs r0, 0x3F - eors r7, r0 - movs r1, 0xFC - lsls r1, 6 - adds r0, r1, 0 - orrs r7, r0 - movs r0, 0x4A - adds r1, r7, 0 - bl SetGpuReg - ldr r1, =0x00003f3f - movs r0, 0x48 - bl SetGpuReg - ldr r2, =gBattle_WIN0H - ldrh r0, [r5, 0x24] - lsls r0, 8 - ldrh r1, [r5, 0x26] - orrs r0, r1 - strh r0, [r2] - ldr r1, =gBattle_WIN0V - movs r0, 0xA0 - strh r0, [r1] - ldr r0, =sub_8113D60 - str r0, [r5] - add sp, 0x1C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8113BAC - - thumb_func_start sub_8113D60 -sub_8113D60: @ 8113D60 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x4 - bls _08113D7A - b _08113E72 -_08113D7A: - lsls r0, 2 - ldr r1, =_08113D8C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08113D8C: - .4byte _08113DA0 - .4byte _08113E02 - .4byte _08113E1C - .4byte _08113E58 - .4byte _08113E6C -_08113DA0: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _08113E72 - movs r0, 0 - strh r0, [r4, 0xA] - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08113DD0 - ldrh r1, [r4, 0x1E] - movs r2, 0x1E - ldrsh r0, [r4, r2] - cmp r0, 0xC - beq _08113DDE - adds r0, r1, 0x1 - strh r0, [r4, 0x1E] - b _08113DDE -_08113DD0: - ldrh r1, [r4, 0x20] - movs r2, 0x20 - ldrsh r0, [r4, r2] - cmp r0, 0x8 - beq _08113DDE - subs r0, r1, 0x1 - strh r0, [r4, 0x20] -_08113DDE: - ldrh r1, [r4, 0x20] - lsls r1, 8 - ldrh r0, [r4, 0x1E] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r1, 0x1E - ldrsh r0, [r4, r1] - cmp r0, 0xC - bne _08113E72 - movs r2, 0x20 - ldrsh r0, [r4, r2] - cmp r0, 0x8 - bne _08113E72 - b _08113E5E -_08113E02: - ldrh r0, [r4, 0x10] - subs r0, 0x8 - strh r0, [r4, 0x10] - adds r0, r4, 0 - bl sub_8114244 - movs r0, 0x10 - ldrsh r1, [r4, r0] - movs r2, 0x18 - ldrsh r0, [r4, r2] - cmp r1, r0 - bge _08113E72 - b _08113E5E -_08113E1C: - ldrh r0, [r4, 0x10] - subs r0, 0x8 - strh r0, [r4, 0x10] - adds r0, r4, 0 - bl sub_8114244 - ldrh r1, [r4, 0x24] - adds r1, 0x4 - strh r1, [r4, 0x24] - ldrh r0, [r4, 0x26] - subs r2, r0, 0x4 - strh r2, [r4, 0x26] - lsls r1, 16 - lsls r0, r2, 16 - cmp r1, r0 - blt _08113E3E - strh r2, [r4, 0x24] -_08113E3E: - ldr r3, =gBattle_WIN0H - ldrh r2, [r4, 0x24] - lsls r0, r2, 8 - ldrh r1, [r4, 0x26] - orrs r0, r1 - strh r0, [r3] - lsls r2, 16 - lsls r1, 16 - cmp r2, r1 - bne _08113E72 - b _08113E5E - .pool -_08113E58: - ldr r1, =gScanlineEffect - movs r0, 0x3 - strb r0, [r1, 0x15] -_08113E5E: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08113E72 - .pool -_08113E6C: - adds r0, r2, 0 - bl DestroyAnimVisualTask -_08113E72: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8113D60 - - thumb_func_start sub_8113E78 -sub_8113E78: @ 8113E78 - push {r4-r7,lr} - sub sp, 0x1C - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks - adds r5, r0, r1 - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0x4 - bls _08113E94 - b _081140A6 -_08113E94: - lsls r0, 2 - ldr r1, =_08113EA8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08113EA8: - .4byte _08113EBC - .4byte _08113F40 - .4byte _08113F84 - .4byte _08113FF0 - .4byte _08114058 -_08113EBC: - bl IsContest - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08113EF8 - ldr r0, =gBattle_WIN0H - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_WIN0V - strh r1, [r0] - ldr r4, =0x00003f3f - movs r0, 0x48 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x4A - adds r1, r4, 0 - bl SetGpuReg - adds r0, r6, 0 - bl DestroyAnimVisualTask - b _081140A6 - .pool -_08113EF8: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0xE] - cmp r0, 0x1 - bne _08113F24 - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =gBattle_BG2_X - b _08113F2E - .pool -_08113F24: - ldr r1, =0x00003f44 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =gBattle_BG1_X -_08113F2E: - ldrh r0, [r1] - adds r0, 0xF0 - strh r0, [r1] - b _08114044 - .pool -_08113F40: - movs r1, 0xE - ldrsh r0, [r5, r1] - cmp r0, 0x1 - bne _08113F68 - mov r0, sp - bl sub_80A6B30 - ldr r0, =gBattle_BG1_Y - ldrh r0, [r0] - strh r0, [r5, 0x1C] - mov r0, sp - ldrb r1, [r0, 0x8] - lsls r1, 4 - movs r0, 0 - movs r2, 0x20 - bl FillPalette - b _08113F78 - .pool -_08113F68: - ldr r0, =gBattle_BG2_Y - ldrh r0, [r0] - strh r0, [r5, 0x1C] - movs r0, 0 - movs r1, 0x90 - movs r2, 0x20 - bl FillPalette -_08113F78: - movs r0, 0x3 - bl sub_8114374 - b _08114044 - .pool -_08113F84: - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x1F - movs r6, 0 - strh r0, [r5, 0x16] - ldrb r0, [r4] - movs r1, 0x2 - bl sub_80A861C - subs r0, 0x7 - strh r0, [r5, 0x14] - ldrh r1, [r5, 0x16] - subs r1, r0 - lsls r1, 8 - strh r1, [r5, 0x22] - ldrb r0, [r4] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - subs r1, r0, 0x4 - strh r1, [r5, 0x24] - adds r0, 0x4 - strh r0, [r5, 0x26] - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _08113FD8 - ldr r0, =0x0000fff4 - b _08113FDA - .pool -_08113FD8: - ldr r0, =0x0000ffc0 -_08113FDA: - strh r0, [r5, 0x18] - ldrh r0, [r5, 0x18] - strh r0, [r5, 0x10] - strh r0, [r5, 0x12] - movs r0, 0xC - strh r0, [r5, 0x1E] - movs r0, 0x8 - strh r0, [r5, 0x20] - b _08114044 - .pool -_08113FF0: - movs r1, 0xE - ldrsh r0, [r5, r1] - cmp r0, 0x1 - bne _08114000 - ldr r0, =0x04000016 - b _08114002 - .pool -_08114000: - ldr r0, =0x0400001a -_08114002: - str r0, [sp, 0x10] - movs r3, 0 - add r4, sp, 0x10 - ldr r6, =gScanlineEffectRegBuffers - movs r0, 0xF0 - lsls r0, 3 - adds r7, r6, r0 -_08114010: - lsls r1, r3, 1 - adds r2, r1, r6 - ldrh r0, [r5, 0x1C] - adds r0, 0x9F - subs r0, r3 - strh r0, [r2] - adds r1, r7 - ldrh r0, [r5, 0x1C] - adds r0, 0x9F - subs r0, r3 - strh r0, [r1] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x6F - bls _08114010 - ldr r1, =0xa2600001 - str r1, [r4, 0x4] - movs r2, 0 - movs r0, 0x1 - strb r0, [r4, 0x8] - strb r2, [r4, 0x9] - ldr r0, [sp, 0x10] - ldr r2, [r4, 0x8] - bl ScanlineEffect_SetParams -_08114044: - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - b _081140A6 - .pool -_08114058: - movs r1, 0xE - ldrsh r0, [r5, r1] - cmp r0, 0x1 - bne _08114070 - ldr r1, =0x00003f3d - movs r0, 0x4A - bl SetGpuReg - b _08114078 - .pool -_08114070: - ldr r1, =0x00003f3b - movs r0, 0x4A - bl SetGpuReg -_08114078: - ldr r1, =0x00003f3f - movs r0, 0x48 - bl SetGpuReg - ldr r2, =gBattle_WIN0H - ldrh r0, [r5, 0x24] - lsls r0, 8 - ldrh r1, [r5, 0x26] - orrs r0, r1 - strh r0, [r2] - ldr r1, =gBattle_WIN0V - movs r0, 0xA0 - strh r0, [r1] - movs r0, 0 - strh r0, [r5, 0x8] - strh r0, [r5, 0xA] - strh r0, [r5, 0xC] - ldr r1, =0x0000080c - movs r0, 0x52 - bl SetGpuReg - ldr r0, =sub_81140C8 - str r0, [r5] -_081140A6: - add sp, 0x1C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8113E78 - - thumb_func_start sub_81140C8 -sub_81140C8: @ 81140C8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x4 - bls _081140E2 - b _08114232 -_081140E2: - lsls r0, 2 - ldr r1, =_081140F4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081140F4: - .4byte _08114108 - .4byte _08114134 - .4byte _0811419C - .4byte _081141FE - .4byte _08114210 -_08114108: - ldrh r0, [r4, 0x12] - adds r0, 0x8 - strh r0, [r4, 0x12] - lsls r0, 16 - asrs r0, 16 - ldrh r2, [r4, 0x16] - movs r3, 0x16 - ldrsh r1, [r4, r3] - cmp r0, r1 - blt _0811411E - strh r2, [r4, 0x12] -_0811411E: - adds r0, r4, 0 - bl sub_8114244 - movs r0, 0x12 - ldrsh r1, [r4, r0] - movs r2, 0x16 - ldrsh r0, [r4, r2] - cmp r1, r0 - beq _08114132 - b _08114232 -_08114132: - b _08114204 -_08114134: - movs r3, 0x26 - ldrsh r0, [r4, r3] - movs r2, 0x24 - ldrsh r1, [r4, r2] - subs r0, r1 - cmp r0, 0x3F - bgt _08114150 - ldrh r0, [r4, 0x24] - subs r0, 0x4 - strh r0, [r4, 0x24] - ldrh r0, [r4, 0x26] - adds r0, 0x4 - strh r0, [r4, 0x26] - b _08114154 -_08114150: - movs r0, 0x1 - strh r0, [r4, 0xA] -_08114154: - ldr r2, =gBattle_WIN0H - ldrh r0, [r4, 0x24] - lsls r0, 8 - ldrh r1, [r4, 0x26] - orrs r0, r1 - strh r0, [r2] - ldrh r0, [r4, 0x10] - adds r0, 0x8 - strh r0, [r4, 0x10] - lsls r0, 16 - asrs r0, 16 - ldrh r2, [r4, 0x14] - movs r3, 0x14 - ldrsh r1, [r4, r3] - cmp r0, r1 - blt _08114176 - strh r2, [r4, 0x10] -_08114176: - adds r0, r4, 0 - bl sub_8114244 - movs r0, 0x10 - ldrsh r1, [r4, r0] - movs r2, 0x14 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _08114232 - movs r3, 0xA - ldrsh r0, [r4, r3] - cmp r0, 0 - beq _08114232 - movs r0, 0 - strh r0, [r4, 0xA] - b _08114204 - .pool -_0811419C: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _08114232 - movs r0, 0 - strh r0, [r4, 0xA] - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081141CC - ldrh r1, [r4, 0x1E] - movs r2, 0x1E - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _081141DA - subs r0, r1, 0x1 - strh r0, [r4, 0x1E] - b _081141DA -_081141CC: - ldrh r1, [r4, 0x20] - movs r3, 0x20 - ldrsh r0, [r4, r3] - cmp r0, 0xF - bgt _081141DA - adds r0, r1, 0x1 - strh r0, [r4, 0x20] -_081141DA: - ldrh r1, [r4, 0x20] - lsls r1, 8 - ldrh r0, [r4, 0x1E] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r1, 0x1E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08114232 - movs r2, 0x20 - ldrsh r0, [r4, r2] - cmp r0, 0x10 - bne _08114232 - b _08114204 -_081141FE: - ldr r1, =gScanlineEffect - movs r0, 0x3 - strb r0, [r1, 0x15] -_08114204: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08114232 - .pool -_08114210: - ldr r0, =gBattle_WIN0H - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_WIN0V - strh r1, [r0] - ldr r4, =0x00003f3f - movs r0, 0x48 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x4A - adds r1, r4, 0 - bl SetGpuReg - adds r0, r5, 0 - bl DestroyAnimVisualTask -_08114232: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81140C8 - - thumb_func_start sub_8114244 -sub_8114244: @ 8114244 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - ldrh r0, [r6, 0x12] - ldrh r4, [r6, 0x10] - subs r0, r4 - lsls r0, 16 - asrs r1, r0, 16 - cmp r1, 0 - beq _08114338 - movs r2, 0x22 - ldrsh r0, [r6, r2] - bl __divsi3 - mov r8, r0 - movs r3, 0x14 - ldrsh r0, [r6, r3] - lsls r5, r0, 8 - lsls r0, r4, 16 - movs r4, 0 - cmp r0, 0 - ble _081142A4 - ldr r0, =gScanlineEffectRegBuffers - mov r12, r0 - ldr r7, =gScanlineEffect -_08114278: - lsls r2, r4, 16 - asrs r2, 16 - lsls r3, r2, 1 - ldrb r1, [r7, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r3, r0 - add r3, r12 - adds r1, r2, 0 - subs r1, 0x9F - ldrh r0, [r6, 0x1C] - subs r0, r1 - strh r0, [r3] - adds r2, 0x1 - lsls r2, 16 - lsrs r4, r2, 16 - asrs r2, 16 - movs r1, 0x10 - ldrsh r0, [r6, r1] - cmp r2, r0 - blt _08114278 -_081142A4: - ldrh r4, [r6, 0x10] - lsls r3, r4, 16 - asrs r1, r3, 16 - movs r2, 0x12 - ldrsh r0, [r6, r2] - cmp r1, r0 - bgt _081142EE - ldr r0, =gScanlineEffectRegBuffers - mov r12, r0 - ldr r7, =gScanlineEffect -_081142B8: - asrs r4, r3, 16 - cmp r4, 0 - blt _081142DA - asrs r1, r5, 8 - subs r1, r4 - lsls r3, r4, 1 - ldrb r2, [r7, 0x14] - lsls r0, r2, 4 - subs r0, r2 - lsls r0, 7 - adds r3, r0 - add r3, r12 - lsls r1, 16 - asrs r1, 16 - ldrh r2, [r6, 0x1C] - adds r1, r2 - strh r1, [r3] -_081142DA: - add r5, r8 - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - lsls r3, r4, 16 - asrs r1, r3, 16 - movs r2, 0x12 - ldrsh r0, [r6, r2] - cmp r1, r0 - ble _081142B8 -_081142EE: - movs r3, 0x1C - ldrsh r0, [r6, r3] - adds r0, 0x9F - lsls r2, r4, 16 - asrs r1, r2, 16 - subs r5, r0, r1 - movs r3, 0x16 - ldrsh r0, [r6, r3] - cmp r1, r0 - bge _08114366 - ldr r7, =gScanlineEffectRegBuffers - ldr r4, =gScanlineEffect -_08114306: - asrs r3, r2, 16 - cmp r3, 0 - blt _0811431E - lsls r2, r3, 1 - ldrb r1, [r4, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r7 - strh r5, [r2] - subs r5, 0x1 -_0811431E: - adds r0, r3, 0x1 - lsls r2, r0, 16 - asrs r1, r2, 16 - movs r3, 0x16 - ldrsh r0, [r6, r3] - cmp r1, r0 - blt _08114306 - b _08114366 - .pool -_08114338: - movs r1, 0x1C - ldrsh r0, [r6, r1] - adds r5, r0, 0 - adds r5, 0x9F - movs r4, 0 - ldr r3, =gScanlineEffectRegBuffers - movs r2, 0xF0 - lsls r2, 3 - adds r6, r3, r2 -_0811434A: - lsls r0, r4, 16 - asrs r0, 16 - lsls r2, r0, 1 - adds r1, r2, r3 - strh r5, [r1] - adds r2, r6 - strh r5, [r2] - subs r5, 0x1 - adds r0, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - asrs r0, 16 - cmp r0, 0x6F - ble _0811434A -_08114366: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114244 - - thumb_func_start sub_8114374 -sub_8114374: @ 8114374 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - movs r4, 0 - ldr r7, =gSprites - movs r1, 0x3 - ands r0, r1 - lsls r5, r0, 2 - movs r0, 0xD - negs r0, r0 - adds r6, r0, 0 -_0811438A: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _081143AA - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r0, [r1, 0x5] - ands r0, r6 - orrs r0, r5 - strb r0, [r1, 0x5] -_081143AA: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x3 - bls _0811438A - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114374 - - thumb_func_start sub_81143C0 -sub_81143C0: @ 81143C0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r6, =gBattleAnimAttacker - ldrb r0, [r6] - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - eors r0, r1 - negs r1, r0 - orrs r1, r0 - lsrs r4, r1, 31 - ldrb r0, [r6] - adds r1, r4, 0 - movs r2, 0x1 - bl sub_80A438C - ldr r0, =gSprites - mov r9, r0 - ldr r0, =gBattlerSpriteIds - mov r8, r0 - ldrb r0, [r6] - add r0, r8 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r9 - adds r1, 0x3E - ldrb r2, [r1] - movs r7, 0x5 - negs r7, r7 - adds r0, r7, 0 - ands r0, r2 - strb r0, [r1] - ldrb r0, [r6] - movs r5, 0x2 - eors r0, r5 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0811444E - ldrb r0, [r6] - eors r0, r5 - movs r1, 0x1 - eors r4, r1 - adds r1, r4, 0 - movs r2, 0x1 - bl sub_80A438C - ldrb r0, [r6] - eors r0, r5 - add r0, r8 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - adds r0, 0x3E - ldrb r2, [r0] - adds r1, r7, 0 - ands r1, r2 - strb r1, [r0] -_0811444E: - mov r0, r10 - bl DestroyAnimVisualTask - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81143C0 - - thumb_func_start sub_8114470 -sub_8114470: @ 8114470 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - eors r0, r1 - negs r1, r0 - orrs r1, r0 - lsrs r5, r1, 31 - adds r0, r5, 0 - bl sub_80A477C - ldrb r1, [r4] - movs r0, 0x2 - eors r0, r1 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _081144AC - movs r0, 0x1 - eors r5, r0 - adds r0, r5, 0 - bl sub_80A477C -_081144AC: - adds r0, r6, 0 - bl DestroyAnimVisualTask - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114470 - - thumb_func_start sub_81144BC -sub_81144BC: @ 81144BC - push {r4,lr} - adds r4, r0, 0 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1] - ldrh r2, [r4, 0x20] - adds r0, r2 - strh r0, [r4, 0x20] - ldrh r0, [r1, 0x2] - ldrh r2, [r4, 0x22] - adds r0, r2 - strh r0, [r4, 0x22] - ldrb r1, [r1, 0x4] - adds r0, r4, 0 - bl StartSpriteAnim - ldr r0, =RunStoredCallbackWhenAnimEnds - str r0, [r4, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81144BC - - thumb_func_start sub_81144F8 -sub_81144F8: @ 81144F8 - push {r4-r7,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r7, r0, 24 - movs r6, 0 - ldr r0, =gBattle_WIN0H - strh r6, [r0] - ldr r0, =gBattle_WIN0V - strh r6, [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 - ldr r1, =0x00000c08 - 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 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0811455C - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0x1 - bl SetAnimBgAttribute -_0811455C: - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _081145D6 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _081145D6 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - beq _0811458C - ldrb r0, [r4] - bl GetBattlerPosition - lsls r0, 24 - cmp r0, 0 - bne _081145D6 -_0811458C: - ldrb r0, [r4] - movs r5, 0x2 - eors r0, r5 - bl IsBattlerSpriteVisible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081145D6 - ldr r3, =gSprites - ldr r1, =gBattlerSpriteIds - ldrb r0, [r4] - eors r0, r5 - adds r0, r1 - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r3 - ldrb r3, [r2, 0x5] - lsls r1, r3, 28 - lsrs r1, 30 - subs r1, 0x1 - movs r0, 0x3 - ands r1, r0 - lsls r1, 2 - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0x1 - bl SetAnimBgAttribute - movs r6, 0x1 -_081145D6: - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _08114614 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x18] - ldrh r5, [r0] - b _0811465C - .pool -_08114614: - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08114640 - ldr r1, =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - b _08114650 - .pool -_08114640: - ldr r1, =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty -_08114650: - adds r0, r1 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 -_0811465C: - movs r0, 0 - bl GetAnimBattlerSpriteId - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_80A89C8 - lsls r0, 24 - lsrs r5, r0, 24 - mov r0, sp - bl sub_80A6B30 - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gUnknown_08C1D210 - bl sub_80A6D48 - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gUnknown_08C1D0AC - mov r2, sp - ldrh r2, [r2, 0xA] - bl sub_80A6CC0 - ldr r0, =gUnknown_08C1D1E8 - mov r1, sp - ldrb r1, [r1, 0x8] - lsls r1, 4 - movs r2, 0x20 - bl LoadCompressedPalette - ldr r2, =gBattle_BG1_X - ldr r0, =gSprites - lsls r1, r4, 4 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r1, 0x20] - negs r0, r0 - adds r0, 0x60 - strh r0, [r2] - ldr r2, =gBattle_BG1_Y - ldrh r0, [r1, 0x22] - negs r0, r0 - adds r0, 0x20 - strh r0, [r2] - ldrb r0, [r1, 0x5] - lsrs r0, 4 - adds r0, 0x10 - adds r1, r0, 0 - ldr r2, =gBattleAnimArgs - movs r3, 0x2 - ldrsh r0, [r2, r3] - cmp r0, 0 - bne _08114708 - adds r0, r1, 0 - movs r1, 0 - bl SetGreyscaleOrOriginalPalette - b _08114714 - .pool -_08114708: - lsls r0, r1, 4 - ldrh r3, [r2, 0x4] - movs r1, 0x10 - movs r2, 0xB - bl BlendPalette -_08114714: - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - strh r5, [r0, 0x8] - ldr r2, =gBattleAnimArgs - ldrh r1, [r2] - strh r1, [r0, 0xA] - ldrh r1, [r2, 0x2] - strh r1, [r0, 0xC] - ldrh r1, [r2, 0x4] - strh r1, [r0, 0xE] - strh r6, [r0, 0x14] - ldr r1, =sub_8114748 - str r1, [r0] - add sp, 0x10 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81144F8 - - thumb_func_start sub_8114748 -sub_8114748: @ 8114748 - push {r4-r6,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - adds r6, r0, 0 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r4, r0, r1 - ldrh r0, [r4, 0x1C] - adds r0, 0x4 - movs r5, 0 - strh r0, [r4, 0x1C] - ldr r2, =gBattle_BG1_X - ldrh r3, [r2] - subs r1, r3, 0x4 - strh r1, [r2] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x80 - beq _08114776 - b _08114886 -_08114776: - strh r5, [r4, 0x1C] - adds r0, r3, 0 - adds r0, 0x7C - strh r0, [r2] - ldrh r0, [r4, 0x1E] - adds r0, 0x1 - strh r0, [r4, 0x1E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - bne _08114824 - movs r0, 0 - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r5 - ldrb r0, [r1, 0x5] - lsrs r0, 4 - adds r0, 0x10 - adds r1, r0, 0 - movs r2, 0xA - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _081147B8 - adds r0, r1, 0 - movs r1, 0x1 - bl SetGreyscaleOrOriginalPalette -_081147B8: - movs r0, 0x8 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - bl DestroySprite - mov r0, sp - bl sub_80A6B30 - mov r0, sp - ldrb r0, [r0, 0x9] - bl sub_80A6C68 - movs r1, 0x14 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _08114886 - ldr r2, =gBattlerSpriteIds - ldr r0, =gBattleAnimAttacker - ldrb r1, [r0] - movs r0, 0x2 - eors r0, r1 - adds r0, r2 - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r5 - ldrb r3, [r2, 0x5] - lsls r1, r3, 28 - lsrs r1, 30 - adds r1, 0x1 - movs r0, 0x3 - ands r1, r0 - lsls r1, 2 - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - b _08114886 - .pool -_08114824: - cmp r0, 0x3 - bne _08114886 - ldr r0, =gBattle_WIN0H - strh r5, [r0] - ldr r0, =gBattle_WIN0V - strh r5, [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 _08114856 - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0 - bl SetAnimBgAttribute -_08114856: - 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 - adds r0, r6, 0 - bl DestroyAnimVisualTask -_08114886: - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114748 - - thumb_func_start sub_811489C -sub_811489C: @ 811489C - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r0, =gBattleAnimArgs - movs r2, 0 - ldrsh r1, [r0, r2] - adds r2, r0, 0 - cmp r1, 0x7 - bhi _08114900 - lsls r0, r1, 2 - ldr r1, =_081148C4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081148C4: - .4byte _081148E4 - .4byte _081148E4 - .4byte _081148E4 - .4byte _081148E4 - .4byte _081148F0 - .4byte _081148F4 - .4byte _081148F8 - .4byte _081148FC -_081148E4: - ldrb r0, [r2] - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r2, r0, 24 - b _08114902 -_081148F0: - movs r4, 0 - b _08114908 -_081148F4: - movs r4, 0x2 - b _08114908 -_081148F8: - movs r4, 0x1 - b _08114908 -_081148FC: - movs r4, 0x3 - b _08114908 -_08114900: - movs r2, 0xFF -_08114902: - movs r0, 0 - cmp r0, 0 - beq _0811492E -_08114908: - adds r0, r4, 0 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0811492C - ldr r0, =gBattlerSpriteIds - adds r0, r4, r0 - ldrb r2, [r0] - b _0811492E - .pool -_0811492C: - movs r2, 0xFF -_0811492E: - cmp r2, 0xFF - beq _0811494A - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0, 0x5] - lsrs r0, 4 - adds r0, 0x10 - ldr r1, =gBattleAnimArgs - ldrb r1, [r1, 0x2] - bl SetGreyscaleOrOriginalPalette -_0811494A: - adds r0, r5, 0 - bl DestroyAnimVisualTask - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811489C - - thumb_func_start sub_8114960 -sub_8114960: @ 8114960 - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r2, =gAnimMoveTurn - ldrb r0, [r2] - cmp r0, 0x1 - bhi _08114974 - ldr r1, =gBattleAnimArgs - movs r0, 0 - strh r0, [r1, 0xE] -_08114974: - ldrb r0, [r2] - cmp r0, 0x2 - bne _08114980 - ldr r1, =gBattleAnimArgs - movs r0, 0x1 - strh r0, [r1, 0xE] -_08114980: - adds r0, r3, 0 - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_8114960 - - .align 2, 0 diff --git a/asm/psychic.s b/asm/psychic.s index a900d3fcc..1eb21f53c 100644 --- a/asm/psychic.s +++ b/asm/psychic.s @@ -62,7 +62,7 @@ _0810F22E: adds r0, r4, 0 adds r1, r6, 0 movs r2, 0 - bl sub_80A438C + bl MoveBattlerSpriteToBG _0810F264: movs r0, 0x2 adds r4, r0, 0 @@ -77,7 +77,7 @@ _0810F264: adds r0, r4, 0 adds r1, r6, 0 movs r2, 0 - bl sub_80A438C + bl MoveBattlerSpriteToBG _0810F284: mov r0, r8 cmp r0, 0 diff --git a/include/battle_anim.h b/include/battle_anim.h index a8138b4ff..56e8702b4 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -58,7 +58,7 @@ void DestroyAnimSprite(struct Sprite *sprite); void DestroyAnimVisualTask(u8 taskId); void DestroyAnimSoundTask(u8 taskId); bool8 IsBattlerSpriteVisible(u8 battlerId); -void sub_80A438C(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible); +void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible); bool8 IsContest(void); s8 BattleAnimAdjustPanning(s8 pan); s8 BattleAnimAdjustPanning2(s8 pan); diff --git a/include/graphics.h b/include/graphics.h index cc829b5a9..d9b0de08e 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4720,6 +4720,10 @@ extern const u32 gBattleAnimBackgroundTilemap_17[]; extern const u32 gBattleAnimBackgroundTilemap_20[]; extern const u32 gBattleAnimBackgroundTilemap_21[]; +extern const u32 gUnknown_08C1D0AC[]; +extern const u32 gUnknown_08C1D1E8[]; +extern const u32 gUnknown_08C1D210[]; + extern const u32 gUnknown_08C20668[]; extern const u32 gUnknown_08C20684[]; extern const u32 gBattleStatMask_Gfx[]; diff --git a/ld_script.txt b/ld_script.txt index 0fab767d4..df5c1c577 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -170,7 +170,7 @@ SECTIONS { src/rock.o(.text); src/ghost.o(.text); src/dragon.o(.text); - asm/dark.o(.text); + src/dark.o(.text); src/ground.o(.text); src/normal.o(.text); src/battle_anim_utility_funcs.o(.text); diff --git a/src/battle_anim.c b/src/battle_anim.c index 2d211c411..d1550f31e 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -1870,7 +1870,7 @@ static void ScriptCmd_monbg(void) else toBG_2 = TRUE; - sub_80A438C(battlerId, toBG_2, FALSE); + MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE); taskId = CreateTask(sub_80A40F4, 10); gAnimVisualTaskCount++; gTasks[taskId].data[t1_MONBG_BATTLER] = battlerId; @@ -1889,7 +1889,7 @@ static void ScriptCmd_monbg(void) else toBG_2 = TRUE; - sub_80A438C(battlerId, toBG_2, FALSE); + MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE); taskId = CreateTask(sub_80A40F4, 10); gAnimVisualTaskCount++; gTasks[taskId].data[0] = battlerId; @@ -1922,7 +1922,7 @@ bool8 IsBattlerSpriteVisible(u8 battlerId) return FALSE; } -void sub_80A438C(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) +void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) { struct UnknownAnimStruct2 unknownStruct; u8 battlerSpriteId; @@ -2194,7 +2194,7 @@ static void ScriptCmd_monbg_22(void) else toBG_2 = TRUE; - sub_80A438C(battlerId, toBG_2, FALSE); + MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE); } battlerId ^= BIT_FLANK; @@ -2206,7 +2206,7 @@ static void ScriptCmd_monbg_22(void) else toBG_2 = TRUE; - sub_80A438C(battlerId, toBG_2, FALSE); + MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE); } sBattleAnimScriptPtr++; diff --git a/src/dark.c b/src/dark.c index d4a4f0b8a..efa6e9498 100644 --- a/src/dark.c +++ b/src/dark.c @@ -1,11 +1,29 @@ #include "global.h" #include "battle_anim.h" +#include "contest.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "palette.h" +#include "scanline_effect.h" +#include "trig.h" +#include "util.h" #include "constants/rgb.h" -extern void sub_81138D4(struct Sprite *); -extern void sub_81139DC(struct Sprite *); -extern void sub_8113A90(struct Sprite *); -extern void sub_81144BC(struct Sprite *); +void sub_81138D4(struct Sprite *); +void sub_81139DC(struct Sprite *); +void sub_8113A90(struct Sprite *); +void sub_81144BC(struct Sprite *); +static void sub_811375C(u8); +static void sub_811381C(u8); +static void sub_8113950(struct Sprite *); +static void sub_8113A18(struct Sprite *); +static void sub_8113A58(struct Sprite *); +static void sub_8113B90(struct Sprite *); +static void sub_8113D60(u8); +static void sub_81140C8(u8); +static void sub_8114244(struct Task *); +static void sub_8114374(u8); +static void sub_8114748(u8); const struct SpriteTemplate gUnknown_08596FC8 = { @@ -167,3 +185,797 @@ const struct SpriteTemplate gBattleAnimSpriteTemplate_8597138 = .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_81144BC, }; + +void sub_81136E8(u8 taskId) +{ + int battler; + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + battler = gBattleAnimAttacker; + gTasks[taskId].data[1] = 16; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + if (GetBattlerSpriteBGPriorityRank(battler) == 1) + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1); + else + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG2); + + gTasks[taskId].func = sub_811375C; +} + +static void sub_811375C(u8 taskId) +{ + u8 blendA = gTasks[taskId].data[1] >> 8; + u8 blendB = gTasks[taskId].data[1]; + if (gTasks[taskId].data[2] == (u8)gTasks[taskId].data[0]) + { + blendA++; + blendB--; + gTasks[taskId].data[1] = BLDALPHA_BLEND(blendB, blendA); + SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].data[1]); + gTasks[taskId].data[2] = 0; + if (blendA == 16) + { + gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].invisible = 1; + DestroyAnimVisualTask(taskId); + } + } + else + { + gTasks[taskId].data[2]++; + } +} + +void sub_81137E4(u8 taskId) +{ + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + gTasks[taskId].data[1] = BLDALPHA_BLEND(0, 16); + gTasks[taskId].func = sub_811381C; + SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].data[1]); +} + +static void sub_811381C(u8 taskId) +{ + u8 blendA = gTasks[taskId].data[1] >> 8; + u8 blendB = gTasks[taskId].data[1]; + if (gTasks[taskId].data[2] == (u8)gTasks[taskId].data[0]) + { + blendA--; + blendB++; + gTasks[taskId].data[1] = (blendA << 8) | blendB; + SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].data[1]); + gTasks[taskId].data[2] = 0; + if (blendA == 0) + { + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + DestroyAnimVisualTask(taskId); + } + } + else + { + gTasks[taskId].data[2]++; + } +} + +void sub_8113888(u8 taskId) +{ + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + if (GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) == 1) + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1); + else + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG2); + + DestroyAnimVisualTask(taskId); +} + +void sub_81138D4(struct Sprite *sprite) +{ + sprite->data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + sprite->data[3] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); + sprite->data[0] = 0x7E; + InitSpriteDataForLinearTranslation(sprite); + sprite->data[3] = -sprite->data[1]; + sprite->data[4] = -sprite->data[2]; + sprite->data[6] = 0xFFD8; + sprite->callback = sub_8113950; + sprite->callback(sprite); +} + +static void sub_8113950(struct Sprite *sprite) +{ + sprite->data[3] += sprite->data[1]; + sprite->data[4] += sprite->data[2]; + sprite->pos2.x = sprite->data[3] >> 8; + sprite->pos2.y = sprite->data[4] >> 8; + if (sprite->data[7] == 0) + { + sprite->data[3] += sprite->data[1]; + sprite->data[4] += sprite->data[2]; + sprite->pos2.x = sprite->data[3] >> 8; + sprite->pos2.y = sprite->data[4] >> 8; + sprite->data[0]--; + } + + sprite->pos2.y += Sin(sprite->data[5], sprite->data[6]); + sprite->data[5] = (sprite->data[5] + 3) & 0xFF; + if (sprite->data[5] > 0x7F) + { + sprite->data[5] = 0; + sprite->data[6] += 20; + sprite->data[7]++; + } + + if (--sprite->data[0] == 0) + DestroyAnimSprite(sprite); +} + +void sub_81139DC(struct Sprite *sprite) +{ + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + StartSpriteAffineAnim(sprite, gBattleAnimArgs[2]); + sprite->data[0] = gBattleAnimArgs[3]; + sprite->data[1] = gBattleAnimArgs[4]; + sprite->data[2] = gBattleAnimArgs[5]; + sprite->callback = sub_8113A18; +} + +static void sub_8113A18(struct Sprite *sprite) +{ + sprite->data[4] += sprite->data[0]; + sprite->data[5] += sprite->data[1]; + sprite->pos2.x = sprite->data[4] >> 8; + sprite->pos2.y = sprite->data[5] >> 8; + if (++sprite->data[3] == sprite->data[2]) + sprite->callback = sub_8113A58; +} + +static void sub_8113A58(struct Sprite *sprite) +{ + sprite->data[4] -= sprite->data[0]; + sprite->data[5] -= sprite->data[1]; + sprite->pos2.x = sprite->data[4] >> 8; + sprite->pos2.y = sprite->data[5] >> 8; + if (--sprite->data[3] == 0) + DestroySpriteAndMatrix(sprite); +} + +void sub_8113A90(struct Sprite *sprite) +{ + u8 battler; + s8 xOffset; + + if (gBattleAnimArgs[0] == 0) + battler = gBattleAnimAttacker; + else + battler = gBattleAnimTarget; + + xOffset = 20; + sprite->oam.tileNum += 4; + + switch (gBattleAnimArgs[1]) + { + case 0: + sprite->pos1.x = sub_80A861C(battler, 5) - 8; + sprite->pos1.y = sub_80A861C(battler, 2) + 8; + break; + case 1: + sprite->pos1.x = sub_80A861C(battler, 5) - 14; + sprite->pos1.y = sub_80A861C(battler, 2) + 16; + break; + case 2: + sprite->pos1.x = sub_80A861C(battler, 4) + 8; + sprite->pos1.y = sub_80A861C(battler, 2) + 8; + StartSpriteAffineAnim(sprite, 1); + xOffset = -20; + break; + case 3: + sprite->pos1.x = sub_80A861C(battler, 4) + 14; + sprite->pos1.y = sub_80A861C(battler, 2) + 16; + StartSpriteAffineAnim(sprite, 1); + xOffset = -20; + break; + } + + sprite->data[0] = 32; + sprite->data[2] = sprite->pos1.x + xOffset; + sprite->data[4] = sprite->pos1.y + 12; + sprite->data[5] = -12; + + InitAnimArcTranslation(sprite); + sprite->callback = sub_8113B90; +} + +static void sub_8113B90(struct Sprite *sprite) +{ + if (TranslateAnimArc(sprite)) + DestroySpriteAndMatrix(sprite); +} + +void sub_8113BAC(u8 taskId) +{ + struct ScanlineEffectParams scanlineParams; + struct UnknownAnimStruct2 unknownStruct; + u16 i; + u8 pos; + int var0; + struct Task *task = &gTasks[taskId]; + + task->data[7] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y) + 31; + task->data[6] = sub_80A861C(gBattleAnimAttacker, 2) - 7; + task->data[5] = task->data[7]; + task->data[4] = task->data[6]; + task->data[13] = (task->data[7] - task->data[6]) << 8; + + pos = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X); + task->data[14] = pos - 32; + task->data[15] = pos + 32; + + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) + task->data[8] = -12; + else + task->data[8] = -64; + + task->data[3] = GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker); + if (task->data[3] == 1) + { + sub_80A6B30(&unknownStruct); + task->data[10] = gBattle_BG1_Y; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1); + FillPalette(0, unknownStruct.unk8 << 4, 32); + scanlineParams.dmaDest = ®_BG1VOFS; + var0 = WINOUT_WIN01_BG1; + if (!IsContest()) + gBattle_BG2_X += 240; + } + else + { + task->data[10] = gBattle_BG2_Y; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG2); + FillPalette(0, 144, 32); + scanlineParams.dmaDest = ®_BG2VOFS; + var0 = WINOUT_WIN01_BG2; + if (!IsContest()) + gBattle_BG1_X += 240; + } + + scanlineParams.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + scanlineParams.initState = 1; + scanlineParams.unused9 = 0; + task->data[11] = 0; + task->data[12] = 16; + task->data[0] = 0; + task->data[1] = 0; + task->data[2] = 0; + sub_8114374(3); + for (i = 0; i < 112; i++) + { + gScanlineEffectRegBuffers[0][i] = task->data[10]; + gScanlineEffectRegBuffers[1][i] = task->data[10]; + } + + ScanlineEffect_SetParams(scanlineParams); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | (var0 ^ (WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR))); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); + gBattle_WIN0H = (task->data[14] << 8) | task->data[15]; + gBattle_WIN0V = 160; + + task->func = sub_8113D60; +} + +static void sub_8113D60(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + if (++task->data[1] > 1) + { + task->data[1] = 0; + if (++task->data[2] & 1) + { + if (task->data[11] != 12) + task->data[11]++; + } + else + { + if (task->data[12] != 8) + task->data[12]--; + } + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[11], task->data[12])); + + if (task->data[11] == 12 && task->data[12] == 8) + task->data[0]++; + } + break; + case 1: + task->data[4] -= 8; + sub_8114244(task); + + if (task->data[4] < task->data[8]) + task->data[0]++; + break; + case 2: + task->data[4] -= 8; + sub_8114244(task); + task->data[14] += 4; + task->data[15] -= 4; + + if (task->data[14] >= task->data[15]) + task->data[14] = task->data[15]; + + gBattle_WIN0H = (task->data[14] << 8) | task->data[15]; + + if (task->data[14] == task->data[15]) + task->data[0]++; + break; + case 3: + gScanlineEffect.state = 3; + task->data[0]++; + break; + case 4: + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_8113E78(u8 taskId) +{ + struct UnknownAnimStruct2 unknownStruct; + struct ScanlineEffectParams scanlineParams; + u8 x; + u16 i; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + if (IsContest() == TRUE) + { + 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_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR); + DestroyAnimVisualTask(taskId); + } + else + { + task->data[3] = GetBattlerSpriteBGPriorityRank(gBattleAnimTarget); + if (task->data[3] == 1) + { + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1); + gBattle_BG2_X += 240; + } + else + { + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG2); + gBattle_BG1_X += 240; + } + + task->data[0]++; + } + break; + case 1: + if (task->data[3] == 1) + { + sub_80A6B30(&unknownStruct); + task->data[10] = gBattle_BG1_Y; + FillPalette(0, unknownStruct.unk8 << 4, 32); + } + else + { + task->data[10] = gBattle_BG2_Y; + FillPalette(0, 144, 32); + } + + sub_8114374(3); + task->data[0]++; + break; + case 2: + task->data[7] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y) + 31; + task->data[6] = sub_80A861C(gBattleAnimTarget, 2) - 7; + task->data[13] = (task->data[7] - task->data[6]) << 8; + x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X); + task->data[14] = x - 4; + task->data[15] = x + 4; + + if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) + task->data[8] = -12; + else + task->data[8] = -64; + + task->data[4] = task->data[8]; + task->data[5] = task->data[8]; + task->data[11] = 12; + task->data[12] = 8; + task->data[0]++; + break; + case 3: + if (task->data[3] == 1) + scanlineParams.dmaDest = ®_BG1VOFS; + else + scanlineParams.dmaDest = ®_BG2VOFS; + + for (i = 0; i < 112; i++) + { + gScanlineEffectRegBuffers[0][i] = task->data[10] + (159 - i); + gScanlineEffectRegBuffers[1][i] = task->data[10] + (159 - i); + } + + scanlineParams.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + scanlineParams.initState = 1; + scanlineParams.unused9 = 0; + ScanlineEffect_SetParams(scanlineParams); + task->data[0]++; + break; + case 4: + if (task->data[3] == 1) + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR); + else + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR); + + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); + gBattle_WIN0H = (task->data[14] << 8) | task->data[15]; + gBattle_WIN0V = 160; + + task->data[0] = 0; + task->data[1] = 0; + task->data[2] = 0; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 8)); + task->func = sub_81140C8; + break; + } +} + +static void sub_81140C8(u8 taskId) +{ + u8 pos; + u16 i; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[5] += 8; + if (task->data[5] >= task->data[7]) + task->data[5] = task->data[7]; + + sub_8114244(task); + if (task->data[5] == task->data[7]) + task->data[0]++; + break; + case 1: + if (task->data[15] - task->data[14] < 0x40) + { + task->data[14] -= 4; + task->data[15] += 4; + } + else + { + task->data[1] = 1; + } + + gBattle_WIN0H = (task->data[14] << 8) | task->data[15]; + task->data[4] += 8; + if (task->data[4] >= task->data[6]) + task->data[4] = task->data[6]; + + sub_8114244(task); + if (task->data[4] == task->data[6] && task->data[1]) + { + task->data[1] = 0; + task->data[0]++; + } + break; + case 2: + if (++task->data[1] > 1) + { + task->data[1] = 0; + task->data[2]++; + if (task->data[2] & 1) + { + if (task->data[11]) + task->data[11]--; + } + else + { + if (task->data[12] < 16) + task->data[12]++; + } + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[11], task->data[12])); + if (task->data[11] == 0 && task->data[12] == 16) + task->data[0]++; + } + break; + case 3: + gScanlineEffect.state = 3; + task->data[0]++; + break; + case 4: + 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_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR); + DestroyAnimVisualTask(taskId); + break; + } +} + +static void sub_8114244(struct Task *task) +{ + int var0, var1; + s16 var2; + s16 i; + int var4; + + var2 = task->data[5] - task->data[4]; + if (var2 != 0) + { + var0 = task->data[13] / var2; + var1 = task->data[6] << 8; + + for (i = 0; i < task->data[4]; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[10] - (i - 159); + } + + for (i = task->data[4]; i <= task->data[5]; i++) + { + if (i >= 0) + { + s16 var3 = (var1 >> 8) - i; + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = var3 + task->data[10]; + } + + var1 += var0; + } + + var4 = task->data[10] - (i - 159); + for (i = i; i < task->data[7]; i++) + { + if (i >= 0) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = var4; + var4--; + } + } + } + else + { + var4 = task->data[10] + 159; + for (i = 0; i < 112; i++) + { + gScanlineEffectRegBuffers[0][i] = var4; + gScanlineEffectRegBuffers[1][i] = var4; + var4--; + } + } +} + +static void sub_8114374(u8 priority) +{ + u16 i; + + for (i = 0; i < MAX_BATTLERS_COUNT; i++) + { + u8 spriteId = GetAnimBattlerSpriteId(i); + if (spriteId != 0xFF) + gSprites[spriteId].oam.priority = priority; + } +} + +void sub_81143C0(u8 taskId) +{ + u8 toBG2 = GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) ^ 1 ? 1 : 0; + MoveBattlerSpriteToBG(gBattleAnimAttacker, toBG2, TRUE); + gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].invisible = 0; + + if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker))) + { + MoveBattlerSpriteToBG(gBattleAnimAttacker ^ 2, toBG2 ^ 1, TRUE); + gSprites[gBattlerSpriteIds[gBattleAnimAttacker ^ 2]].invisible = 0; + } + + DestroyAnimVisualTask(taskId); +} + +void sub_8114470(u8 taskId) +{ + u8 toBG2 = GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) ^ 1 ? 1 : 0; + sub_80A477C(toBG2); + + if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker))) + sub_80A477C(toBG2 ^ 1); + + DestroyAnimVisualTask(taskId); +} + +void sub_81144BC(struct Sprite *sprite) +{ + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + StartSpriteAnim(sprite, gBattleAnimArgs[2]); + sprite->callback = RunStoredCallbackWhenAnimEnds; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_81144F8(u8 taskId) +{ + u16 species; + u8 spriteId; + u8 newSpriteId; + u16 paletteNum; + struct UnknownAnimStruct2 unknownStruct; + int var0 = 0; + + gBattle_WIN0H = var0; + gBattle_WIN0V = var0; + 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_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 12)); + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 0); + SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 0); + if (!IsContest()) + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); + + if (IsDoubleBattle() && !IsContest()) + { + if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT) + { + if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)) == TRUE) + { + gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattleAnimAttacker)]].oam.priority--; + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); + var0 = 1; + } + } + } + + if (IsContest()) + { + species = gContestResources->field_18->species; + } + else + { + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES); + else + species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES); + } + + spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); + newSpriteId = sub_80A89C8(gBattleAnimAttacker, spriteId, species); + + sub_80A6B30(&unknownStruct); + sub_80A6D48(unknownStruct.bgId, gUnknown_08C1D210); + sub_80A6CC0(unknownStruct.bgId, gUnknown_08C1D0AC, unknownStruct.tilesOffset); + LoadCompressedPalette(gUnknown_08C1D1E8, unknownStruct.unk8 << 4, 32); + + gBattle_BG1_X = -gSprites[spriteId].pos1.x + 96; + gBattle_BG1_Y = -gSprites[spriteId].pos1.y + 32; + paletteNum = 16 + gSprites[spriteId].oam.paletteNum; + + if (gBattleAnimArgs[1] == 0) + SetGreyscaleOrOriginalPalette(paletteNum, FALSE); + else + BlendPalette(paletteNum * 16, 16, 11, gBattleAnimArgs[2]); + + gTasks[taskId].data[0] = newSpriteId; + gTasks[taskId].data[1] = gBattleAnimArgs[0]; + gTasks[taskId].data[2] = gBattleAnimArgs[1]; + gTasks[taskId].data[3] = gBattleAnimArgs[2]; + gTasks[taskId].data[6] = var0; + gTasks[taskId].func = sub_8114748; +} + +static void sub_8114748(u8 taskId) +{ + struct UnknownAnimStruct2 unknownStruct; + u16 paletteNum; + u8 spriteId; + u8 taskIdCopy = taskId; + + gTasks[taskIdCopy].data[10] += 4; + gBattle_BG1_X -= 4; + if (gTasks[taskIdCopy].data[10] == 128) + { + gTasks[taskIdCopy].data[10] = 0; + gBattle_BG1_X += 128; + gTasks[taskIdCopy].data[11]++; + if (gTasks[taskIdCopy].data[11] == 2) + { + spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); + paletteNum = 16 + gSprites[spriteId].oam.paletteNum; + if (gTasks[taskIdCopy].data[1] == 0) + SetGreyscaleOrOriginalPalette(paletteNum, 1); + + DestroySprite(&gSprites[gTasks[taskIdCopy].data[0]]); + sub_80A6B30(&unknownStruct); + sub_80A6C68(unknownStruct.bgId); + if (gTasks[taskIdCopy].data[6] == 1) + gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattleAnimAttacker)]].oam.priority++; + } + else if (gTasks[taskIdCopy].data[11] == 3) + { + 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_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_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, 0); + DestroyAnimVisualTask(taskId); + } + } +} + +void sub_811489C(u8 taskId) +{ + u8 spriteId; + u8 battler; + bool8 calcSpriteId = FALSE; + u8 position = B_POSITION_PLAYER_LEFT; + + switch (gBattleAnimArgs[0]) + { + case 0: + case 1: + case 2: + case 3: + spriteId = GetAnimBattlerSpriteId(gBattleAnimArgs[0]); + break; + case 4: + position = B_POSITION_PLAYER_LEFT; + calcSpriteId = TRUE; + break; + case 5: + position = B_POSITION_PLAYER_RIGHT; + calcSpriteId = TRUE; + break; + case 6: + position = B_POSITION_OPPONENT_LEFT; + calcSpriteId = TRUE; + break; + case 7: + position = B_POSITION_OPPONENT_RIGHT; + calcSpriteId = TRUE; + break; + default: + spriteId = 0xFF; + break; + } + + if (calcSpriteId) + { + battler = GetBattlerAtPosition(position); + if (IsBattlerSpriteVisible(battler)) + spriteId = gBattlerSpriteIds[battler]; + else + spriteId = 0xFF; + } + + if (spriteId != 0xFF) + SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]); + + DestroyAnimVisualTask(taskId); +} + +void sub_8114960(u8 taskId) +{ + if (gAnimMoveTurn < 2) + gBattleAnimArgs[7] = 0; + + if (gAnimMoveTurn == 2) + gBattleAnimArgs[7] = 1; + + DestroyAnimVisualTask(taskId); +} From c2fdbb0ef7e61f77e458dcf993058947cedbf638 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 24 Dec 2018 10:48:57 -0600 Subject: [PATCH 2/3] Decompile psychic.c --- asm/psychic.s | 2172 ------------------------------------- include/battle_anim.h | 5 +- ld_script.txt | 2 +- src/battle_anim_80A5C6C.c | 2 +- src/psychic.c | 778 ++++++++++++- 5 files changed, 772 insertions(+), 2187 deletions(-) delete mode 100644 asm/psychic.s diff --git a/asm/psychic.s b/asm/psychic.s deleted file mode 100644 index 1eb21f53c..000000000 --- a/asm/psychic.s +++ /dev/null @@ -1,2172 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_810F1EC -sub_810F1EC: @ 810F1EC - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - bl IsContest - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810F212 - mov r0, r8 - cmp r0, 0 - beq _0810F22E -_0810F212: - ldrb r1, [r5, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r1 - movs r1, 0x8 - orrs r0, r1 - strb r0, [r5, 0x5] - adds r1, r5, 0 - adds r1, 0x43 - movs r0, 0xC8 - strb r0, [r1] - mov r1, r8 - cmp r1, 0 - bne _0810F2B8 -_0810F22E: - movs r0, 0x1 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r4, r0, 24 - adds r7, r4, 0 - adds r0, r4, 0 - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - eors r0, r1 - negs r1, r0 - orrs r1, r0 - lsrs r6, r1, 31 - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810F264 - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0 - bl MoveBattlerSpriteToBG -_0810F264: - movs r0, 0x2 - adds r4, r0, 0 - eors r4, r7 - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810F284 - movs r0, 0x1 - eors r6, r0 - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0 - bl MoveBattlerSpriteToBG -_0810F284: - mov r0, r8 - cmp r0, 0 - bne _0810F2B8 - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _0810F2B8 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _0810F2B0 - movs r0, 0x48 - strh r0, [r5, 0x20] - movs r0, 0x50 - b _0810F2F2 - .pool -_0810F2B0: - movs r0, 0xB0 - strh r0, [r5, 0x20] - movs r0, 0x28 - b _0810F2F2 -_0810F2B8: - ldr r6, =gBattleAnimAttacker - ldrb r0, [r6] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810F2CE - ldr r1, =gBattleAnimArgs - ldrh r0, [r1] - negs r0, r0 - strh r0, [r1] -_0810F2CE: - ldrb r0, [r6] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - ldr r4, =gBattleAnimArgs - lsrs r0, 24 - ldrh r1, [r4] - adds r0, r1 - strh r0, [r5, 0x20] - ldrb r0, [r6] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r4, [r4, 0x2] - adds r0, r4 -_0810F2F2: - strh r0, [r5, 0x22] - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x4] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 20 - movs r1, 0x80 - lsls r1, 1 - adds r0, r1 - strh r0, [r5, 0x2E] - mov r0, r8 - cmp r0, 0 - beq _0810F32C - ldrh r0, [r5, 0x22] - adds r0, 0x9 - strh r0, [r5, 0x22] - ldr r1, =sub_810F3C8 - str r1, [r5, 0x1C] - adds r0, r5, 0 - bl _call_via_r1 - b _0810F330 - .pool -_0810F32C: - ldr r0, =sub_810F340 - str r0, [r5, 0x1C] -_0810F330: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F1EC -@ - - thumb_func_start sub_810F340 -sub_810F340: @ 810F340 - push {r4,r5,lr} - adds r5, r0, 0 - movs r0, 0x1 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r4, r0, 24 - movs r1, 0x3C - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _0810F35C - movs r0, 0x1 - strh r0, [r5, 0x3C] - b _0810F3B6 -_0810F35C: - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810F382 - ldr r2, =gSprites - ldr r0, =gBattlerSpriteIds - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_0810F382: - movs r0, 0x2 - eors r4, r0 - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810F3AC - ldr r2, =gSprites - ldr r0, =gBattlerSpriteIds - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_0810F3AC: - ldr r1, =sub_810F3C8 - str r1, [r5, 0x1C] - adds r0, r5, 0 - bl _call_via_r1 -_0810F3B6: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F340 - - thumb_func_start sub_810F3C8 -sub_810F3C8: @ 810F3C8 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x34] - movs r1, 0x10 - subs r1, r0 - lsls r1, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - ldrh r1, [r4, 0x34] - movs r2, 0x34 - ldrsh r0, [r4, r2] - cmp r0, 0xD - bne _0810F3F4 - ldr r0, =sub_810F400 - str r0, [r4, 0x1C] - b _0810F3F8 - .pool -_0810F3F4: - adds r0, r1, 0x1 - strh r0, [r4, 0x34] -_0810F3F8: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810F3C8 - - thumb_func_start sub_810F400 -sub_810F400: @ 810F400 - push {r4-r7,lr} - adds r3, r0, 0 - ldrh r0, [r3, 0x30] - adds r0, 0x1 - strh r0, [r3, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - bne _0810F45E - movs r0, 0 - strh r0, [r3, 0x30] - ldrh r4, [r3, 0x2E] - ldr r1, =gPlttBufferFaded - adds r0, r4, 0 - adds r0, 0x8 - lsls r0, 1 - adds r0, r1 - ldrh r7, [r0] - movs r5, 0x8 - adds r6, r1, 0 - adds r1, r4, 0x7 - lsls r0, r4, 1 - adds r0, r6 - adds r2, r0, 0 - adds r2, 0x10 - lsls r1, 1 - adds r1, r6 -_0810F436: - ldrh r0, [r1] - strh r0, [r2] - subs r1, 0x2 - subs r2, 0x2 - subs r5, 0x1 - cmp r5, 0 - bgt _0810F436 - adds r0, r4, 0x1 - lsls r0, 1 - adds r0, r6 - strh r7, [r0] - ldrh r0, [r3, 0x32] - adds r0, 0x1 - strh r0, [r3, 0x32] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x10 - bne _0810F45E - ldr r0, =sub_810F46C - str r0, [r3, 0x1C] -_0810F45E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F400 - - thumb_func_start sub_810F46C -sub_810F46C: @ 810F46C - push {r4-r6,lr} - adds r5, r0, 0 - ldrh r0, [r5, 0x34] - movs r1, 0x10 - subs r1, r0 - lsls r1, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - ldrh r0, [r5, 0x34] - subs r0, 0x1 - strh r0, [r5, 0x34] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - bne _0810F512 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810F502 - movs r0, 0x1 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810F4D4 - ldr r2, =gSprites - ldr r0, =gBattlerSpriteIds - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] -_0810F4D4: - movs r0, 0x2 - adds r4, r0, 0 - eors r4, r6 - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810F502 - ldr r2, =gSprites - ldr r0, =gBattlerSpriteIds - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] -_0810F502: - adds r2, r5, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r0, =sub_810F524 - str r0, [r5, 0x1C] -_0810F512: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F46C - - thumb_func_start sub_810F524 -sub_810F524: @ 810F524 - push {r4-r6,lr} - adds r6, r0, 0 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810F57C - movs r0, 0x1 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - eors r0, r1 - negs r1, r0 - orrs r1, r0 - lsrs r5, r1, 31 - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810F562 - adds r0, r5, 0 - bl sub_80A477C -_0810F562: - movs r0, 0x2 - eors r4, r0 - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810F57C - movs r0, 0x1 - eors r5, r0 - adds r0, r5, 0 - bl sub_80A477C -_0810F57C: - ldr r0, =DestroyAnimSprite - str r0, [r6, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F524 - - thumb_func_start sub_810F58C -sub_810F58C: @ 810F58C - push {r4-r6,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0810F618 - ldr r5, =gBattleAnimArgs - movs r1, 0x6 - ldrsh r0, [r5, r1] - movs r6, 0 - cmp r0, 0 - bne _0810F5A6 - movs r6, 0x1 -_0810F5A6: - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810F5EE - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _0810F5EE - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _0810F5E0 - ldrh r0, [r5] - movs r1, 0x48 - subs r1, r0 - strh r1, [r4, 0x20] - ldrh r0, [r5, 0x2] - adds r0, 0x50 - strh r0, [r4, 0x22] - b _0810F610 - .pool -_0810F5E0: - ldrh r0, [r5] - adds r0, 0xB0 - strh r0, [r4, 0x20] - ldrh r0, [r5, 0x2] - adds r0, 0x28 - strh r0, [r4, 0x22] - b _0810F610 -_0810F5EE: - ldr r0, =gBattleAnimArgs - movs r1, 0x4 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _0810F608 - adds r0, r4, 0 - adds r1, r6, 0 - bl InitSpritePosToAnimAttacker - b _0810F610 - .pool -_0810F608: - adds r0, r4, 0 - adds r1, r6, 0 - bl InitSpritePosToAnimTarget -_0810F610: - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - b _0810F62C -_0810F618: - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x30 - ands r0, r1 - cmp r0, 0 - beq _0810F62C - adds r0, r4, 0 - bl DestroySpriteAndMatrix -_0810F62C: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_810F58C - - thumb_func_start sub_810F634 -sub_810F634: @ 810F634 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810F684 - adds r0, r5, 0 - movs r1, 0x1 - bl StartSpriteAnim - ldrh r0, [r5, 0x20] - subs r0, 0x28 - strh r0, [r5, 0x20] - ldrh r0, [r5, 0x22] - adds r0, 0xA - strh r0, [r5, 0x22] - ldr r0, =0x0000ffff - b _0810F692 - .pool -_0810F684: - ldrh r0, [r5, 0x20] - adds r0, 0x28 - strh r0, [r5, 0x20] - ldrh r0, [r5, 0x22] - subs r0, 0xA - strh r0, [r5, 0x22] - movs r0, 0x1 -_0810F692: - strh r0, [r5, 0x30] - ldr r1, =DestroyAnimSprite - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =RunStoredCallbackWhenAnimEnds - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F634 - - thumb_func_start sub_810F6B0 -sub_810F6B0: @ 810F6B0 - push {r4-r7,lr} - adds r5, r0, 0 - ldr r6, =gBattleAnimAttacker - ldrb r0, [r6] - movs r1, 0x1 - bl sub_80A861C - lsls r0, 16 - asrs r1, r0, 16 - lsrs r0, 31 - adds r1, r0 - lsls r1, 15 - lsrs r4, r1, 16 - ldrb r0, [r6] - movs r1, 0 - bl sub_80A861C - lsls r0, 16 - asrs r1, r0, 16 - lsrs r0, 31 - adds r1, r0 - asrs r1, 1 - negs r1, r1 - lsls r1, 16 - lsrs r7, r1, 16 - ldrb r0, [r6] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0810F6F6 - lsls r0, r4, 16 - negs r0, r0 - lsrs r4, r0, 16 -_0810F6F6: - ldrb r0, [r6] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - strh r0, [r5, 0x20] - ldrb r0, [r6] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - adds r0, r7 - strh r0, [r5, 0x22] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xF - bgt _0810F722 - movs r0, 0x10 - strh r0, [r5, 0x22] -_0810F722: - ldr r1, =sub_810F740 - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =RunStoredCallbackWhenAnimEnds - str r0, [r5, 0x1C] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F6B0 - - thumb_func_start sub_810F740 -sub_810F740: @ 810F740 - push {r4,lr} - adds r4, r0, 0 - ldrb r1, [r4, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r4, 0x1] - ldr r0, =gUnknown_08596740 - str r0, [r4, 0x10] - movs r0, 0 - strh r0, [r4, 0x2E] - adds r0, r4, 0 - bl InitSpriteAffineAnim - ldr r0, =sub_810F774 - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F740 - - thumb_func_start sub_810F774 -sub_810F774: @ 810F774 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0810F786 - cmp r0, 0x1 - beq _0810F7B4 - b _0810F7CC -_0810F786: - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0810F7CC - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldrb r1, [r4, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - strb r0, [r4, 0x1] - movs r0, 0x12 - strh r0, [r4, 0x30] - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - b _0810F7CC -_0810F7B4: - ldrh r0, [r4, 0x30] - subs r0, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - bne _0810F7CC - adds r0, r4, 0 - bl DestroyAnimSprite -_0810F7CC: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F774 - - thumb_func_start sub_810F7D4 -sub_810F7D4: @ 810F7D4 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks - adds r4, r0 - movs r0, 0 - bl GetAnimBattlerSpriteId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - strh r1, [r4, 0x8] - ldr r2, =gUnknown_0859675C - adds r0, r4, 0 - bl PrepareAffineAnimInTaskData - ldr r0, =sub_810F810 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F7D4 - - thumb_func_start sub_810F810 -sub_810F810: @ 810F810 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks - adds r0, r1 - bl RunAffineAnimFromTaskData - lsls r0, 24 - cmp r0, 0 - bne _0810F830 - adds r0, r4, 0 - bl DestroyAnimVisualTask -_0810F830: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F810 - - thumb_func_start sub_810F83C -sub_810F83C: @ 810F83C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r4, r1, r0 - movs r0, 0 - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - strh r0, [r4, 0x8] - strh r1, [r4, 0xA] - strh r1, [r4, 0xC] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - movs r1, 0x8 - cmp r0, 0 - beq _0810F870 - movs r1, 0x4 -_0810F870: - strh r1, [r4, 0xE] - ldrb r1, [r4, 0x8] - ldr r2, =gUnknown_0859677C - adds r0, r4, 0 - bl PrepareAffineAnimInTaskData - ldr r0, =sub_810F898 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F83C - - thumb_func_start sub_810F898 -sub_810F898: @ 810F898 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0xA - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0810F8BC - cmp r0, 0x1 - beq _0810F8D8 - b _0810F936 - .pool -_0810F8BC: - adds r0, r4, 0 - bl RunAffineAnimFromTaskData - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x13 - ble _0810F936 - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - b _0810F936 -_0810F8D8: - movs r1, 0xE - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0810F900 - ldr r2, =gSprites - movs r0, 0x8 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x26] - subs r1, 0x8 - strh r1, [r0, 0x26] - ldrh r0, [r4, 0xE] - subs r0, 0x1 - strh r0, [r4, 0xE] - b _0810F936 - .pool -_0810F900: - ldr r3, =gSprites - movs r0, 0x8 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - movs r0, 0x8 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - movs r1, 0x88 - lsls r1, 1 - strh r1, [r0, 0x20] - ldrb r0, [r4, 0x8] - bl ResetSpriteRotScale - adds r0, r5, 0 - bl DestroyAnimVisualTask -_0810F936: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F898 - - thumb_func_start sub_810F940 -sub_810F940: @ 810F940 - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r5, r1, r0 - movs r1, 0 - movs r0, 0x10 - strh r0, [r5, 0xE] - strh r1, [r5, 0x10] - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x24] - ldrb r0, [r4] - movs r1, 0x1 - bl sub_80A861C - lsls r0, 16 - asrs r0, 16 - movs r1, 0x3 - bl __divsi3 - lsls r0, 16 - lsrs r6, r0, 16 - ldrb r0, [r4] - movs r1, 0 - bl sub_80A861C - lsls r0, 16 - asrs r0, 16 - movs r1, 0x3 - bl __divsi3 - lsls r0, 16 - lsrs r0, 16 - adds r1, r0, 0 - cmp r0, r6 - bcs _0810F9AA - adds r1, r6, 0 -_0810F9AA: - strh r1, [r5, 0x20] - movs r1, 0xFD - lsls r1, 6 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - ldr r0, =sub_810F9D4 - str r0, [r5] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810F940 - - thumb_func_start sub_810F9D4 -sub_810F9D4: @ 810F9D4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r0, 0x8 - ldrsh r1, [r4, r0] - cmp r1, 0x1 - beq _0810FAD4 - cmp r1, 0x1 - bgt _0810F9FC - cmp r1, 0 - beq _0810FA0A - b _0810FB5A - .pool -_0810F9FC: - cmp r1, 0x2 - bne _0810FA02 - b _0810FB36 -_0810FA02: - cmp r1, 0x3 - bne _0810FA08 - b _0810FB44 -_0810FA08: - b _0810FB5A -_0810FA0A: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x8 - bgt _0810FA1A - b _0810FB5A -_0810FA1A: - strh r1, [r4, 0xA] - ldr r0, =gUnknown_08596794 - movs r2, 0x22 - ldrsh r1, [r4, r2] - movs r3, 0x24 - ldrsh r2, [r4, r3] - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - movs r0, 0xC - ldrsh r1, [r4, r0] - adds r1, 0x8 - lsls r1, 1 - adds r0, r4, 0 - adds r0, 0x8 - adds r0, r1 - strh r2, [r0] - cmp r2, 0x40 - beq _0810FABE - movs r1, 0xC - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _0810FA78 - cmp r0, 0x1 - bgt _0810FA5C - cmp r0, 0 - beq _0810FA66 - b _0810FABE - .pool -_0810FA5C: - cmp r0, 0x2 - beq _0810FA90 - cmp r0, 0x3 - beq _0810FAA8 - b _0810FABE -_0810FA66: - ldr r0, =gSprites - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r4, 0x20] - b _0810FAB6 - .pool -_0810FA78: - ldr r0, =gSprites - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r4, 0x20] - negs r0, r0 - strh r0, [r1, 0x24] - ldrh r0, [r4, 0x20] - b _0810FABC - .pool -_0810FA90: - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - ldrh r1, [r4, 0x20] - strh r1, [r0, 0x24] - ldrh r1, [r4, 0x20] - strh r1, [r0, 0x26] - b _0810FABE - .pool -_0810FAA8: - ldr r0, =gSprites - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r4, 0x20] - negs r0, r0 -_0810FAB6: - strh r0, [r1, 0x24] - ldrh r0, [r4, 0x20] - negs r0, r0 -_0810FABC: - strh r0, [r1, 0x26] -_0810FABE: - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x5 - bne _0810FB5A - b _0810FB36 - .pool -_0810FAD4: - ldrh r0, [r4, 0xA] - ands r1, r0 - cmp r1, 0 - beq _0810FAE4 - ldrh r0, [r4, 0xE] - subs r0, 0x1 - strh r0, [r4, 0xE] - b _0810FAEA -_0810FAE4: - ldrh r0, [r4, 0x10] - adds r0, 0x1 - strh r0, [r4, 0x10] -_0810FAEA: - ldrh r1, [r4, 0x10] - lsls r1, 8 - ldrh r0, [r4, 0xE] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x20 - bne _0810FB5A - movs r5, 0x8 - adds r6, r4, 0 - adds r6, 0x8 -_0810FB10: - lsls r0, r5, 1 - adds r1, r6, r0 - movs r2, 0 - ldrsh r0, [r1, r2] - cmp r0, 0x40 - beq _0810FB2C - adds r1, r0, 0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl DestroySprite -_0810FB2C: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0xC - bls _0810FB10 -_0810FB36: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _0810FB5A - .pool -_0810FB44: - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - adds r0, r5, 0 - bl DestroyAnimVisualTask -_0810FB5A: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_810F9D4 - - - thumb_func_start sub_810FB60 -sub_810FB60: @ 810FB60 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x30 - ldrsh r1, [r4, r0] - movs r2, 0x2E - ldrsh r0, [r4, r2] - subs r0, 0xA - cmp r1, r0 - ble _0810FB8A - ldrh r0, [r4, 0x30] - movs r1, 0x1 - ands r1, r0 - adds r3, r4, 0 - adds r3, 0x3E - lsls r1, 2 - ldrb r2, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] -_0810FB8A: - movs r0, 0x30 - ldrsh r1, [r4, r0] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _0810FB9C - adds r0, r4, 0 - bl DestroyAnimSprite -_0810FB9C: - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810FB60 - - thumb_func_start sub_810FBA8 -sub_810FBA8: @ 810FBA8 - push {r4-r6,lr} - adds r5, r0, 0 - ldr r6, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _0810FBD4 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] -_0810FBD4: - ldrh r0, [r6, 0x2] - strh r0, [r5, 0x2E] - ldr r0, =sub_810FB60 - str r0, [r5, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810FBA8 - - thumb_func_start sub_810FBF0 -sub_810FBF0: @ 810FBF0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r5, r1, r0 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0810FC94 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x1 - bne _0810FC60 - ldr r0, =0x0000fff6 - strh r0, [r5, 0x1C] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x5 - bl sub_80A861C - subs r0, 0x8 - strh r0, [r5, 0x1E] - ldrb r0, [r4] - movs r1, 0x2 - bl sub_80A861C - adds r0, 0x8 - strh r0, [r5, 0x20] - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x5 - bl sub_80A861C - subs r0, 0x8 - strh r0, [r5, 0x22] - ldrb r0, [r4] - movs r1, 0x2 - bl sub_80A861C - adds r0, 0x8 - b _0810FD1E - .pool -_0810FC60: - movs r0, 0xA - strh r0, [r5, 0x1C] - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x4 - bl sub_80A861C - adds r0, 0x8 - strh r0, [r5, 0x1E] - ldrb r0, [r4] - movs r1, 0x3 - bl sub_80A861C - subs r0, 0x8 - strh r0, [r5, 0x20] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x4 - bl sub_80A861C - adds r0, 0x8 - b _0810FD12 - .pool -_0810FC94: - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x1 - bne _0810FCE8 - ldr r0, =0x0000fff6 - strh r0, [r5, 0x1C] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x4 - bl sub_80A861C - adds r0, 0x8 - strh r0, [r5, 0x1E] - ldrb r0, [r4] - movs r1, 0x2 - bl sub_80A861C - adds r0, 0x8 - strh r0, [r5, 0x20] - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x4 - bl sub_80A861C - adds r0, 0x8 - strh r0, [r5, 0x22] - ldrb r0, [r4] - movs r1, 0x2 - bl sub_80A861C - adds r0, 0x8 - b _0810FD1E - .pool -_0810FCE8: - movs r0, 0xA - strh r0, [r5, 0x1C] - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x5 - bl sub_80A861C - subs r0, 0x8 - strh r0, [r5, 0x1E] - ldrb r0, [r4] - movs r1, 0x3 - bl sub_80A861C - subs r0, 0x8 - strh r0, [r5, 0x20] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x5 - bl sub_80A861C - subs r0, 0x8 -_0810FD12: - strh r0, [r5, 0x22] - ldrb r0, [r4] - movs r1, 0x3 - bl sub_80A861C - subs r0, 0x8 -_0810FD1E: - strh r0, [r5, 0x24] - movs r0, 0x6 - strh r0, [r5, 0xA] - ldr r0, =sub_810FD3C - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810FBF0 - - thumb_func_start sub_810FD3C -sub_810FD3C: @ 810FD3C - push {r4,r5,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r5, r0, r1 - movs r0, 0x8 - ldrsh r1, [r5, r0] - cmp r1, 0 - beq _0810FD60 - cmp r1, 0x1 - beq _0810FDD4 - b _0810FDE8 - .pool -_0810FD60: - ldrh r0, [r5, 0xA] - adds r0, 0x1 - strh r0, [r5, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x6 - ble _0810FDE8 - strh r1, [r5, 0xA] - ldr r0, =gUnknown_08596864 - movs r2, 0x1E - ldrsh r1, [r5, r2] - movs r3, 0x20 - ldrsh r2, [r5, r3] - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _0810FDB4 - ldr r0, =gSprites - lsls r4, r1, 4 - adds r4, r1 - lsls r4, 2 - adds r4, r0 - movs r0, 0x10 - strh r0, [r4, 0x2E] - ldrh r0, [r5, 0x22] - strh r0, [r4, 0x32] - ldrh r0, [r5, 0x24] - strh r0, [r4, 0x36] - ldrh r0, [r5, 0x1C] - strh r0, [r4, 0x38] - adds r0, r4, 0 - bl InitAnimArcTranslation - ldrb r0, [r5, 0xC] - movs r1, 0x3 - ands r1, r0 - adds r0, r4, 0 - bl StartSpriteAffineAnim -_0810FDB4: - ldrh r0, [r5, 0xC] - adds r0, 0x1 - strh r0, [r5, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xC - bne _0810FDE8 - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - b _0810FDE8 - .pool -_0810FDD4: - ldrh r0, [r5, 0xA] - adds r0, 0x1 - strh r0, [r5, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x11 - ble _0810FDE8 - adds r0, r2, 0 - bl DestroyAnimVisualTask -_0810FDE8: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_810FD3C - - thumb_func_start sub_810FDF0 -sub_810FDF0: @ 810FDF0 - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _0810FE0E - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - adds r0, r4, 0 - bl DestroySprite -_0810FE0E: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810FDF0 - - thumb_func_start sub_810FE14 -sub_810FE14: @ 810FE14 - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r4, r1, r0 - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerYCoordWithElevation - lsls r0, 24 - lsrs r1, r0, 24 - adds r0, r1, 0 - subs r0, 0x20 - strh r0, [r4, 0x24] - ldr r0, =gBattleAnimArgs - movs r2, 0 - ldrsh r0, [r0, r2] - cmp r0, 0x1 - beq _0810FE6A - cmp r0, 0x1 - bgt _0810FE58 - cmp r0, 0 - beq _0810FE5E - b _0810FE86 - .pool -_0810FE58: - cmp r0, 0x2 - beq _0810FE76 - b _0810FE86 -_0810FE5E: - movs r0, 0x2 - strh r0, [r4, 0x1E] - movs r0, 0x5 - strh r0, [r4, 0x20] - movs r0, 0x40 - b _0810FE7E -_0810FE6A: - movs r0, 0x2 - strh r0, [r4, 0x1E] - movs r0, 0x5 - strh r0, [r4, 0x20] - movs r0, 0xC0 - b _0810FE7E -_0810FE76: - movs r0, 0x4 - strh r0, [r4, 0x1E] - strh r0, [r4, 0x20] - movs r0, 0 -_0810FE7E: - strh r0, [r4, 0x22] - adds r0, r1, 0 - adds r0, 0x20 - strh r0, [r4, 0x26] -_0810FE86: - movs r1, 0x24 - ldrsh r0, [r4, r1] - cmp r0, 0 - bge _0810FE92 - movs r0, 0 - strh r0, [r4, 0x24] -_0810FE92: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSpriteBGPriorityRank - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0810FEB8 - ldr r0, =gBattle_BG1_X - ldrh r0, [r0] - strh r0, [r4, 0x1C] - ldr r0, =0x04000014 - b _0810FEC0 - .pool -_0810FEB8: - ldr r0, =gBattle_BG2_X - ldrh r0, [r0] - strh r0, [r4, 0x1C] - ldr r0, =0x04000018 -_0810FEC0: - str r0, [sp] - ldrh r1, [r4, 0x24] - lsls r3, r1, 16 - asrs r1, r3, 16 - movs r2, 0x24 - ldrsh r0, [r4, r2] - adds r0, 0x40 - cmp r1, r0 - bgt _0810FEFA - ldr r5, =gScanlineEffectRegBuffers - movs r0, 0xF0 - lsls r0, 3 - adds r6, r5, r0 -_0810FEDA: - asrs r3, 16 - lsls r1, r3, 1 - adds r2, r1, r5 - ldrh r0, [r4, 0x1C] - strh r0, [r2] - adds r1, r6 - ldrh r0, [r4, 0x1C] - strh r0, [r1] - adds r3, 0x1 - lsls r3, 16 - asrs r1, r3, 16 - movs r2, 0x24 - ldrsh r0, [r4, r2] - adds r0, 0x40 - cmp r1, r0 - ble _0810FEDA -_0810FEFA: - ldr r0, =0xa2600001 - str r0, [sp, 0x4] - mov r1, sp - movs r2, 0 - movs r0, 0x1 - strb r0, [r1, 0x8] - mov r0, sp - strb r2, [r0, 0x9] - ldr r0, [sp] - ldr r1, [sp, 0x4] - ldr r2, [sp, 0x8] - bl ScanlineEffect_SetParams - ldr r0, =sub_810FF34 - str r0, [r4] - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810FE14 - - thumb_func_start sub_810FF34 -sub_810FF34: @ 810FF34 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r5, r0, r1 - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _0811000E - cmp r0, 0x1 - bgt _0810FF60 - cmp r0, 0 - beq _0810FF66 - b _08110026 - .pool -_0810FF60: - cmp r0, 0x2 - beq _08110020 - b _08110026 -_0810FF66: - ldrh r3, [r5, 0x22] - ldrh r4, [r5, 0x24] - movs r2, 0x24 - ldrsh r1, [r5, r2] - movs r2, 0x26 - ldrsh r0, [r5, r2] - cmp r1, r0 - bgt _0810FFFE - ldr r0, =gSineTable - mov r9, r0 - movs r7, 0x3 - ldr r1, =gScanlineEffectRegBuffers - mov r12, r1 - movs r2, 0xF0 - lsls r2, 3 - add r2, r12 - mov r8, r2 -_0810FF88: - lsls r2, r3, 16 - asrs r0, r2, 15 - add r0, r9 - movs r3, 0 - ldrsh r0, [r0, r3] - movs r3, 0x20 - ldrsh r1, [r5, r3] - asrs r0, r1 - lsls r0, 16 - lsrs r1, r0, 16 - asrs r3, r0, 16 - adds r6, r2, 0 - cmp r3, 0 - ble _0810FFB8 - ldrh r1, [r5, 0xA] - adds r0, r7, 0 - ands r0, r1 - adds r0, r3, r0 - b _0810FFC4 - .pool -_0810FFB8: - cmp r3, 0 - bge _0810FFC8 - ldrh r1, [r5, 0xA] - adds r0, r7, 0 - ands r0, r1 - subs r0, r3, r0 -_0810FFC4: - lsls r0, 16 - lsrs r1, r0, 16 -_0810FFC8: - lsls r2, r4, 16 - asrs r2, 16 - lsls r3, r2, 1 - mov r0, r12 - adds r4, r3, r0 - ldrh r0, [r5, 0x1C] - lsls r1, 16 - asrs r1, 16 - adds r0, r1, r0 - strh r0, [r4] - add r3, r8 - ldrh r0, [r5, 0x1C] - adds r1, r0 - strh r1, [r3] - asrs r0, r6, 16 - ldrh r1, [r5, 0x1E] - adds r0, r1 - lsls r0, 16 - lsrs r3, r0, 16 - adds r2, 0x1 - lsls r2, 16 - lsrs r4, r2, 16 - asrs r2, 16 - movs r1, 0x26 - ldrsh r0, [r5, r1] - cmp r2, r0 - ble _0810FF88 -_0810FFFE: - ldrh r0, [r5, 0xA] - adds r0, 0x1 - strh r0, [r5, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x17 - ble _08110026 - b _08110014 -_0811000E: - ldr r1, =gScanlineEffect - movs r0, 0x3 - strb r0, [r1, 0x15] -_08110014: - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - b _08110026 - .pool -_08110020: - adds r0, r2, 0 - bl DestroyAnimVisualTask -_08110026: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_810FF34 - - thumb_func_start sub_8110034 -sub_8110034: @ 8110034 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r4, r0, 24 - mov r8, r4 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks - adds r7, r0, r1 - bl AllocOamMatrix - lsls r0, 24 - lsrs r5, r0, 24 - mov r10, r5 - adds r6, r5, 0 - cmp r6, 0xFF - bne _0811006C - adds r0, r4, 0 - bl DestroyAnimVisualTask - b _08110116 - .pool -_0811006C: - ldr r1, =gBattleAnimArgs - ldrb r0, [r1] - bl CloneBattlerSpriteWithBlend - lsls r0, 16 - lsrs r1, r0, 16 - mov r9, r1 - asrs r0, 16 - cmp r0, 0 - bge _08110094 - adds r0, r5, 0 - bl FreeOamMatrix - mov r0, r8 - bl DestroyAnimVisualTask - b _08110116 - .pool -_08110094: - ldr r2, =gSprites - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - adds r0, r2, 0 - adds r0, 0x1C - adds r0, r4, r0 - ldr r1, =SpriteCallbackDummy - str r1, [r0] - adds r4, r2 - ldrb r0, [r4, 0x1] - movs r1, 0x3 - orrs r0, r1 - strb r0, [r4, 0x1] - movs r0, 0x1F - ands r6, r0 - lsls r2, r6, 1 - ldrb r1, [r4, 0x3] - movs r0, 0x3F - negs r0, r0 - ands r0, r1 - orrs r0, r2 - strb r0, [r4, 0x3] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - adds r1, r4, 0 - adds r1, 0x43 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - mov r1, r9 - lsls r0, r1, 24 - lsrs r0, 24 - movs r2, 0x80 - lsls r2, 1 - adds r1, r2, 0 - movs r3, 0 - bl SetSpriteRotScale - ldrb r3, [r4, 0x1] - lsrs r1, r3, 6 - ldrb r2, [r4, 0x3] - lsrs r2, 6 - lsls r3, 30 - lsrs r3, 30 - adds r0, r4, 0 - bl CalcCenterToCornerVec - ldr r1, =gBattleAnimArgs - ldrb r0, [r1] - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7, 0x22] - mov r0, r10 - strh r0, [r7, 0x24] - mov r1, r9 - strh r1, [r7, 0x26] - ldr r0, =sub_8110134 - str r0, [r7] -_08110116: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8110034 - - thumb_func_start sub_8110134 -sub_8110134: @ 8110134 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _081101B8 - cmp r0, 0x1 - bgt _0811015C - cmp r0, 0 - beq _08110166 - b _08110238 - .pool -_0811015C: - cmp r0, 0x2 - beq _08110208 - cmp r0, 0x3 - beq _08110228 - b _08110238 -_08110166: - ldrh r0, [r4, 0xA] - adds r0, 0x4 - strh r0, [r4, 0xA] - ldr r1, =gSineTable - movs r2, 0xA - ldrsh r0, [r4, r2] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 16 - asrs r1, 17 - movs r2, 0x80 - lsls r2, 1 - adds r0, r2, 0 - subs r0, r1 - strh r0, [r4, 0xC] - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0xC - ldrsh r2, [r4, r1] - adds r1, r2, 0 - movs r3, 0 - bl SetSpriteRotScale - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x22] - lsls r1, 24 - lsrs r1, 24 - bl SetBattlerSpriteYOffsetFromOtherYScale - movs r2, 0xA - ldrsh r0, [r4, r2] - cmp r0, 0x30 - bne _08110238 - b _0811021A - .pool -_081101B8: - ldrh r0, [r4, 0xA] - subs r0, 0x4 - strh r0, [r4, 0xA] - ldr r1, =gSineTable - movs r2, 0xA - ldrsh r0, [r4, r2] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 16 - asrs r1, 17 - movs r2, 0x80 - lsls r2, 1 - adds r0, r2, 0 - subs r0, r1 - strh r0, [r4, 0xC] - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0xC - ldrsh r2, [r4, r1] - adds r1, r2, 0 - movs r3, 0 - bl SetSpriteRotScale - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x22] - lsls r1, 24 - lsrs r1, 24 - bl SetBattlerSpriteYOffsetFromOtherYScale - movs r2, 0xA - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _08110238 - b _0811021A - .pool -_08110208: - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl obj_delete_but_dont_free_vram -_0811021A: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08110238 - .pool -_08110228: - ldrh r0, [r4, 0x24] - lsls r0, 24 - lsrs r0, 24 - bl FreeOamMatrix - adds r0, r5, 0 - bl DestroyAnimVisualTask -_08110238: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8110134 -@*/ - - thumb_func_start sub_8110240 -sub_8110240: @ 8110240 - push {r4,r5,lr} - adds r5, r0, 0 - movs r1, 0x2E - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _081102B8 - cmp r0, 0x1 - bgt _08110256 - cmp r0, 0 - beq _08110260 - b _08110360 -_08110256: - cmp r0, 0x2 - beq _081102EA - cmp r0, 0x3 - beq _0811034A - b _08110360 -_08110260: - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0811028E - ldrh r0, [r5, 0x22] - adds r0, 0xC - strh r0, [r5, 0x22] -_0811028E: - movs r0, 0x8 - strh r0, [r5, 0x30] - movs r1, 0xFD - lsls r1, 6 - movs r0, 0x50 - bl SetGpuReg - ldrh r0, [r5, 0x30] - movs r1, 0x10 - subs r1, r0 - lsls r1, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - b _081102E2 - .pool -_081102B8: - adds r0, r5, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08110360 - movs r0, 0x40 - negs r0, r0 - bl BattleAnimAdjustPanning - adds r1, r0, 0 - lsls r1, 24 - asrs r1, 24 - movs r0, 0xCB - bl PlaySE12WithPanning - adds r0, r5, 0 - movs r1, 0x1 - bl ChangeSpriteAffineAnim -_081102E2: - ldrh r0, [r5, 0x2E] - adds r0, 0x1 - strh r0, [r5, 0x2E] - b _08110360 -_081102EA: - ldrh r0, [r5, 0x32] - adds r1, r0, 0x1 - strh r1, [r5, 0x32] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _0811032E - movs r0, 0 - strh r0, [r5, 0x32] - ldrh r1, [r5, 0x30] - subs r1, 0x1 - strh r1, [r5, 0x30] - movs r0, 0x10 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r1, 0x30 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _0811032E - ldrh r0, [r5, 0x2E] - adds r0, 0x1 - strh r0, [r5, 0x2E] - adds r2, r5, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] -_0811032E: - movs r0, 0xE0 - lsls r0, 2 - adds r2, r0, 0 - ldrh r1, [r5, 0x34] - adds r2, r1 - lsls r1, r2, 16 - asrs r1, 24 - ldrh r0, [r5, 0x26] - subs r0, r1 - strh r0, [r5, 0x26] - movs r0, 0xFF - ands r2, r0 - strh r2, [r5, 0x34] - b _08110360 -_0811034A: - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - adds r0, r5, 0 - bl DestroyAnimSprite -_08110360: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8110240 - - .align 2, 0 diff --git a/include/battle_anim.h b/include/battle_anim.h index 56e8702b4..248e2a9f5 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -78,8 +78,8 @@ void sub_80A6450(struct Sprite *sprite); void SetAverageBattlerPositions(u8 battlerId, bool8 respectMonPicOffsets, s16 *x, s16 *y); void DestroySpriteAndMatrix(struct Sprite *sprite); void AnimTranslateLinearSimple(struct Sprite *sprite); -void InitSpritePosToAnimAttacker(struct Sprite *sprite, u8 a2); -void InitSpritePosToAnimTarget(struct Sprite *sprite, bool8 a2); +void InitSpritePosToAnimAttacker(struct Sprite *sprite, bool8 respectMonPicOffsets); +void InitSpritePosToAnimTarget(struct Sprite *sprite, bool8 respectMonPicOffsets); void StartAnimLinearTranslation(struct Sprite *sprite); void InitAnimArcTranslation(struct Sprite *sprite); bool8 AnimTranslateLinear(struct Sprite *sprite); @@ -149,6 +149,7 @@ u8 sub_80A8394(u16 species, bool8 isBackpic, u8 a3, s16 x, s16 y, u8 subpriority void sub_80A749C(struct Sprite *sprite); void sub_80A6814(u8 taskId); void sub_80A8610(struct Sprite *sprite); +void SetBattlerSpriteYOffsetFromOtherYScale(u8 spriteId, u8 otherSpriteId); enum { diff --git a/ld_script.txt b/ld_script.txt index df5c1c577..ddba6078b 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -165,7 +165,7 @@ SECTIONS { src/fight.o(.text); src/poison.o(.text); asm/flying.o(.text); - asm/psychic.o(.text); + src/psychic.o(.text); src/bug.o(.text); src/rock.o(.text); src/ghost.o(.text); diff --git a/src/battle_anim_80A5C6C.c b/src/battle_anim_80A5C6C.c index e17dde078..7b9e975c4 100644 --- a/src/battle_anim_80A5C6C.c +++ b/src/battle_anim_80A5C6C.c @@ -788,7 +788,7 @@ void InitSpritePosToAnimTarget(struct Sprite *sprite, bool8 respectMonPicOffsets sprite->pos1.y += gBattleAnimArgs[1]; } -void InitSpritePosToAnimAttacker(struct Sprite *sprite, u8 respectMonPicOffsets) +void InitSpritePosToAnimAttacker(struct Sprite *sprite, bool8 respectMonPicOffsets) { if (!respectMonPicOffsets) { diff --git a/src/psychic.c b/src/psychic.c index efd15f746..371c24ce8 100644 --- a/src/psychic.c +++ b/src/psychic.c @@ -1,18 +1,33 @@ #include "global.h" #include "battle_anim.h" +#include "gpu_regs.h" +#include "palette.h" +#include "sound.h" +#include "scanline_effect.h" +#include "trig.h" #include "constants/rgb.h" +#include "constants/songs.h" -extern void sub_80A77C8(struct Sprite *); -extern void sub_810F1EC(struct Sprite *); -extern void sub_810F1EC(struct Sprite *); -extern void sub_810F58C(struct Sprite *); -extern void TranslateAnimSpriteToTargetMonLocation(struct Sprite *); -extern void sub_810F634(struct Sprite *); -extern void sub_810F6B0(struct Sprite *); -extern void sub_810FBA8(struct Sprite *); -extern void sub_810FDF0(struct Sprite *); -extern void sub_80A77C8(struct Sprite *); -extern void sub_8110240(struct Sprite *); +void sub_810F1EC(struct Sprite *); +void sub_810F58C(struct Sprite *); +void sub_810F634(struct Sprite *); +void sub_810F6B0(struct Sprite *); +void sub_810FBA8(struct Sprite *); +void sub_810FDF0(struct Sprite *); +void sub_8110240(struct Sprite *); +static void sub_810F340(struct Sprite *); +static void sub_810F3C8(struct Sprite *); +static void sub_810F400(struct Sprite *); +static void sub_810F46C(struct Sprite *); +static void sub_810F524(struct Sprite *); +static void sub_810F740(struct Sprite *); +static void sub_810F774(struct Sprite *); +static void sub_810F810(u8); +static void sub_810F898(u8); +static void sub_810F9D4(u8); +static void sub_810FD3C(u8); +static void sub_810FF34(u8); +static void sub_8110134(u8); const union AffineAnimCmd gUnknown_0859652C[] = { @@ -403,3 +418,744 @@ const struct SpriteTemplate gUnknown_08596920 = .affineAnims = gUnknown_08596918, .callback = sub_8110240, }; + +void sub_810F1EC(struct Sprite *sprite) +{ + u8 isContest = IsContest(); + + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER || isContest) + { + sprite->oam.priority = 2; + sprite->subpriority = 200; + } + + if (!isContest) + { + u8 battlerCopy; + u8 battler = battlerCopy = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + u8 rank = GetBattlerSpriteBGPriorityRank(battler); + int var0 = 1; + u8 toBG_2 = (rank ^ var0) != 0; + + if (IsBattlerSpriteVisible(battler)) + MoveBattlerSpriteToBG(battler, toBG_2, FALSE); + + battler = BATTLE_PARTNER(battlerCopy); + if (IsBattlerSpriteVisible(battler)) + MoveBattlerSpriteToBG(battler, toBG_2 ^ var0, FALSE); + } + + if (!isContest && IsDoubleBattle()) + { + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) + { + sprite->pos1.x = 72; + sprite->pos1.y = 80; + } + else + { + sprite->pos1.x = 176; + sprite->pos1.y = 40; + } + } + else + { + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X) + gBattleAnimArgs[0]; + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y) + gBattleAnimArgs[1]; + } + + sprite->data[0] = 256 + IndexOfSpritePaletteTag(gBattleAnimArgs[2]) * 16; + + if (isContest) + { + sprite->pos1.y += 9; + sprite->callback = sub_810F3C8; + sprite->callback(sprite); + } + else + { + sprite->callback = sub_810F340; + } +} + +static void sub_810F340(struct Sprite *sprite) +{ + u8 battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + if (!sprite->data[7]) + { + sprite->data[7] = 1; + return; + } + + if (IsBattlerSpriteVisible(battler)) + gSprites[gBattlerSpriteIds[battler]].invisible = 1; + + battler = BATTLE_PARTNER(battler); + if (IsBattlerSpriteVisible(battler)) + gSprites[gBattlerSpriteIds[battler]].invisible = 1; + + sprite->callback = sub_810F3C8; + sprite->callback(sprite); +} + +static void sub_810F3C8(struct Sprite *sprite) +{ + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(sprite->data[3], 16 - sprite->data[3])); + if (sprite->data[3] == 13) + sprite->callback = sub_810F400; + else + sprite->data[3]++; +} + +static void sub_810F400(struct Sprite *sprite) +{ + u16 color; + u16 startOffset; + int i; + + if (++sprite->data[1] == 2) + { + sprite->data[1] = 0; + startOffset = sprite->data[0]; + color = gPlttBufferFaded[startOffset + 8]; + + for (i = 8; i > 0; i--) + gPlttBufferFaded[startOffset + i] = gPlttBufferFaded[startOffset + i - 1]; + + gPlttBufferFaded[startOffset + 1] = color; + + if (++sprite->data[2] == 16) + sprite->callback = sub_810F46C; + } +} + +static void sub_810F46C(struct Sprite *sprite) +{ + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(sprite->data[3], 16 - sprite->data[3])); + + if (--sprite->data[3] == -1) + { + if (!IsContest()) + { + u8 battlerCopy; + u8 battler = battlerCopy = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + + if (IsBattlerSpriteVisible(battler)) + gSprites[gBattlerSpriteIds[battler]].invisible = 0; + + battler = BATTLE_PARTNER(battlerCopy); + if (IsBattlerSpriteVisible(battler)) + gSprites[gBattlerSpriteIds[battler]].invisible = 0; + } + + sprite->invisible = 1; + sprite->callback = sub_810F524; + } +} + +static void sub_810F524(struct Sprite *sprite) +{ + if (!IsContest()) + { + u8 battlerCopy; + u8 battler = battlerCopy = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + u8 rank = GetBattlerSpriteBGPriorityRank(battler); + int var0 = 1; + u8 toBG_2 = (rank ^ var0) != 0; + + if (IsBattlerSpriteVisible(battler)) + sub_80A477C(toBG_2); + + battler = battlerCopy ^ 2; + if (IsBattlerSpriteVisible(battler)) + sub_80A477C(toBG_2 ^ var0); + } + + sprite->callback = DestroyAnimSprite; +} + +void sub_810F58C(struct Sprite *sprite) +{ + if (sprite->data[0] == 0) + { + int arg3 = gBattleAnimArgs[3]; + bool8 respectMonPicOffsets = FALSE; + if (arg3 == 0) + respectMonPicOffsets = TRUE; + + if (!IsContest() && IsDoubleBattle()) + { + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) + { + sprite->pos1.x = 72 - gBattleAnimArgs[0]; + sprite->pos1.y = gBattleAnimArgs[1] + 80; + } + else + { + sprite->pos1.x = gBattleAnimArgs[0] + 176; + sprite->pos1.y = gBattleAnimArgs[1] + 40; + } + } + else + { + if (gBattleAnimArgs[2] == 0) + InitSpritePosToAnimAttacker(sprite, respectMonPicOffsets); + else + InitSpritePosToAnimTarget(sprite, respectMonPicOffsets); + } + + sprite->data[0]++; + } + else + { + if (sprite->animEnded || sprite->affineAnimEnded) + DestroySpriteAndMatrix(sprite); + } +} + +void sub_810F634(struct Sprite *sprite) +{ + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); + + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + { + StartSpriteAnim(sprite, 1); + sprite->pos1.x -= 40; + sprite->pos1.y += 10; + sprite->data[1] = -1; + } + else + { + sprite->pos1.x += 40; + sprite->pos1.y -= 10; + sprite->data[1] = 1; + } + + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); + sprite->callback = RunStoredCallbackWhenAnimEnds; +} + +void sub_810F6B0(struct Sprite *sprite) +{ + s16 x = sub_80A861C(gBattleAnimAttacker, 1) / 2; + s16 y = sub_80A861C(gBattleAnimAttacker, 0) / -2; + + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT) + x = -x; + + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2) + x; + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3) + y; + + if (sprite->pos1.y < 16) + sprite->pos1.y = 16; + + StoreSpriteCallbackInData6(sprite, sub_810F740); + sprite->callback = RunStoredCallbackWhenAnimEnds; +} + +static void sub_810F740(struct Sprite *sprite) +{ + sprite->oam.affineMode = 1; + sprite->affineAnims = gUnknown_08596740; + sprite->data[0] = 0; + InitSpriteAffineAnim(sprite); + sprite->callback = sub_810F774; +} + +static void sub_810F774(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + if (sprite->affineAnimEnded) + { + FreeOamMatrix(sprite->oam.matrixNum); + sprite->oam.affineMode = 0; + sprite->data[1] = 18; + sprite->data[0]++; + } + break; + case 1: + if (--sprite->data[1] == -1) + DestroyAnimSprite(sprite); + break; + } +} + +void sub_810F7D4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + u8 spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); + task->data[0] = spriteId; + PrepareAffineAnimInTaskData(task, spriteId, gUnknown_0859675C); + task->func = sub_810F810; +} + +static void sub_810F810(u8 taskId) +{ + if (!RunAffineAnimFromTaskData(&gTasks[taskId])) + DestroyAnimVisualTask(taskId); +} + +void sub_810F83C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + u8 spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); + task->data[0] = spriteId; + task->data[1] = 0; + task->data[2] = 0; + task->data[3] = GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER ? 4 : 8; + + PrepareAffineAnimInTaskData(task, task->data[0], gUnknown_0859677C); + task->func = sub_810F898; +} + +static void sub_810F898(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[1]) + { + case 0: + RunAffineAnimFromTaskData(task); + if (++task->data[2] > 19) + task->data[1]++; + break; + case 1: + if (task->data[3] != 0) + { + gSprites[task->data[0]].pos2.y -= 8; + task->data[3]--; + } + else + { + gSprites[task->data[0]].invisible = 1; + gSprites[task->data[0]].pos1.x = 272; + ResetSpriteRotScale(task->data[0]); + DestroyAnimVisualTask(taskId); + } + break; + } +} + +void sub_810F940(u8 taskId) +{ + u16 var0, var1; + + struct Task *task = &gTasks[taskId]; + + task->data[3] = 16; + task->data[4] = 0; + task->data[13] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + task->data[14] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); + + var0 = sub_80A861C(gBattleAnimAttacker, 1) / 3; + var1 = sub_80A861C(gBattleAnimAttacker, 0) / 3; + task->data[12] = var0 > var1 ? var0 : var1; + + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + + task->func = sub_810F9D4; +} + +static void sub_810F9D4(u8 taskId) +{ + u16 i; + u8 spriteId; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + if (++task->data[1] > 8) + { + task->data[1] = 0; + spriteId = CreateSprite(&gUnknown_08596794, task->data[13], task->data[14], 0); + task->data[task->data[2] + 8] = spriteId; + if (spriteId != MAX_SPRITES) + { + switch (task->data[2]) + { + case 0: + gSprites[spriteId].pos2.x = task->data[12]; + gSprites[spriteId].pos2.y = -task->data[12]; + break; + case 1: + gSprites[spriteId].pos2.x = -task->data[12]; + gSprites[spriteId].pos2.y = task->data[12]; + break; + case 2: + gSprites[spriteId].pos2.x = task->data[12]; + gSprites[spriteId].pos2.y = task->data[12]; + break; + case 3: + gSprites[spriteId].pos2.x = -task->data[12]; + gSprites[spriteId].pos2.y = -task->data[12]; + break; + } + } + + if (++task->data[2] == 5) + task->data[0]++; + } + break; + case 1: + if (task->data[1] & 1) + task->data[3]--; + else + task->data[4]++; + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[3], task->data[4])); + if (++task->data[1] == 32) + { + for (i = 8; i < 13; i++) + { + if (task->data[i] != 64) + DestroySprite(&gSprites[task->data[i]]); + } + + task->data[0]++; + } + break; + case 2: + task->data[0]++; + break; + case 3: + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + DestroyAnimVisualTask(taskId); + break; + } +} + +static void sub_810FB60(struct Sprite *sprite) +{ + if (sprite->data[1] > sprite->data[0] - 10) + sprite->invisible = sprite->data[1] & 1; + + if (sprite->data[1] == sprite->data[0]) + DestroyAnimSprite(sprite); + + sprite->data[1]++; +} + +void sub_810FBA8(struct Sprite *sprite) +{ + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); + } + + sprite->data[0] = gBattleAnimArgs[1]; + sprite->callback = sub_810FB60; +} + +void sub_810FBF0(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + if (IsContest()) + { + if (gBattleAnimArgs[0] == 1) + { + task->data[10] = -10; + task->data[11] = sub_80A861C(gBattleAnimTarget, 5) - 8; + task->data[12] = sub_80A861C(gBattleAnimTarget, 2) + 8; + task->data[13] = sub_80A861C(gBattleAnimAttacker, 5) - 8; + task->data[14] = sub_80A861C(gBattleAnimAttacker, 2) + 8; + } + else + { + task->data[10] = 10; + task->data[11] = sub_80A861C(gBattleAnimAttacker, 4) + 8; + task->data[12] = sub_80A861C(gBattleAnimAttacker, 3) - 8; + task->data[13] = sub_80A861C(gBattleAnimTarget, 4) + 8; + task->data[14] = sub_80A861C(gBattleAnimTarget, 3) - 8; + } + } + else + { + if (gBattleAnimArgs[0] == 1) + { + task->data[10] = -10; + task->data[11] = sub_80A861C(gBattleAnimTarget, 4) + 8; + task->data[12] = sub_80A861C(gBattleAnimTarget, 2) + 8; + task->data[13] = sub_80A861C(gBattleAnimAttacker, 4) + 8; + task->data[14] = sub_80A861C(gBattleAnimAttacker, 2) + 8; + } + else + { + task->data[10] = 10; + task->data[11] = sub_80A861C(gBattleAnimAttacker, 5) - 8; + task->data[12] = sub_80A861C(gBattleAnimAttacker, 3) - 8; + task->data[13] = sub_80A861C(gBattleAnimTarget, 5) - 8; + task->data[14] = sub_80A861C(gBattleAnimTarget, 3) - 8; + } + } + + task->data[1] = 6; + task->func = sub_810FD3C; +} + +static void sub_810FD3C(u8 taskId) +{ + u8 spriteId; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + if (++task->data[1] > 6) + { + task->data[1] = 0; + spriteId = CreateSprite(&gUnknown_08596864, task->data[11], task->data[12], 0); + if (spriteId != 64) + { + gSprites[spriteId].data[0] = 16; + gSprites[spriteId].data[2] = task->data[13]; + gSprites[spriteId].data[4] = task->data[14]; + gSprites[spriteId].data[5] = task->data[10]; + + InitAnimArcTranslation(&gSprites[spriteId]); + StartSpriteAffineAnim(&gSprites[spriteId], task->data[2] & 3); + } + + if (++task->data[2] == 12) + task->data[0]++; + } + break; + case 1: + if (++task->data[1] > 17) + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_810FDF0(struct Sprite *sprite) +{ + if (TranslateAnimArc(sprite)) + { + FreeOamMatrix(sprite->oam.matrixNum); + DestroySprite(sprite); + } +} + +void sub_810FE14(u8 taskId) +{ + s16 i; + u8 yOffset; + struct ScanlineEffectParams scanlineParams; + struct Task *task = &gTasks[taskId]; + + yOffset = GetBattlerYCoordWithElevation(gBattleAnimTarget); + task->data[14] = yOffset - 32; + + switch (gBattleAnimArgs[0]) + { + case 0: + task->data[11] = 2; + task->data[12] = 5; + task->data[13] = 64; + task->data[15] = yOffset + 32; + break; + case 1: + task->data[11] = 2; + task->data[12] = 5; + task->data[13] = 192; + task->data[15] = yOffset + 32; + break; + case 2: + task->data[11] = 4; + task->data[12] = 4; + task->data[13] = 0; + task->data[15] = yOffset + 32; + break; + } + + if (task->data[14] < 0) + task->data[14] = 0; + + if (GetBattlerSpriteBGPriorityRank(gBattleAnimTarget) == 1) + { + task->data[10] = gBattle_BG1_X; + scanlineParams.dmaDest = ®_BG1HOFS; + } + else + { + task->data[10] = gBattle_BG2_X; + scanlineParams.dmaDest = ®_BG2HOFS; + } + + i = task->data[14]; + while (i <= task->data[14] + 64) + { + gScanlineEffectRegBuffers[0][i] = task->data[10]; + gScanlineEffectRegBuffers[1][i] = task->data[10]; + i++; + } + + scanlineParams.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + scanlineParams.initState = 1; + scanlineParams.unused9 = 0; + ScanlineEffect_SetParams(scanlineParams); + task->func = sub_810FF34; +} + +static void sub_810FF34(u8 taskId) +{ + s16 sineIndex, i; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + sineIndex = task->data[13]; + i = task->data[14]; + while (i <= task->data[15]) + { + s16 var2 = (gSineTable[sineIndex] >> task->data[12]); + if (var2 > 0) + var2 += (task->data[1] & 3); + else if (var2 < 0) + var2 -= (task->data[1] & 3); + + gScanlineEffectRegBuffers[0][i] = task->data[10] + var2; + gScanlineEffectRegBuffers[1][i] = task->data[10] + var2; + sineIndex += task->data[11]; + i++; + } + + if (++task->data[1] > 23) + task->data[0]++; + break; + case 1: + gScanlineEffect.state = 3; + task->data[0]++; + break; + case 2: + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_8110034(u8 taskId) +{ + s16 spriteId; + s16 matrixNum; + struct Task *task = &gTasks[taskId]; + + matrixNum = AllocOamMatrix(); + if (matrixNum == 0xFF) + { + DestroyAnimVisualTask(taskId); + return; + } + + spriteId = CloneBattlerSpriteWithBlend(gBattleAnimArgs[0]); + if (spriteId < 0) + { + FreeOamMatrix(matrixNum); + DestroyAnimVisualTask(taskId); + return; + } + + gSprites[spriteId].callback = SpriteCallbackDummy; + gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_DOUBLE; + gSprites[spriteId].oam.matrixNum = matrixNum; + gSprites[spriteId].affineAnimPaused = 1; + gSprites[spriteId].subpriority++; + SetSpriteRotScale(spriteId, 256, 256, 0); + CalcCenterToCornerVec(&gSprites[spriteId], gSprites[spriteId].oam.shape, gSprites[spriteId].oam.size, gSprites[spriteId].oam.affineMode); + task->data[13] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]); + task->data[14] = matrixNum; + task->data[15] = spriteId; + task->func = sub_8110134; +} + +static void sub_8110134(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[1] += 4; + task->data[2] = 256 - (gSineTable[task->data[1]] >> 1); + SetSpriteRotScale(task->data[15], task->data[2], task->data[2], 0); + SetBattlerSpriteYOffsetFromOtherYScale(task->data[15], task->data[13]); + if (task->data[1] == 48) + task->data[0]++; + break; + case 1: + task->data[1] -= 4; + task->data[2] = 256 - (gSineTable[task->data[1]] >> 1);; + SetSpriteRotScale(task->data[15], task->data[2], task->data[2], 0); + SetBattlerSpriteYOffsetFromOtherYScale(task->data[15], task->data[13]); + if (task->data[1] == 0) + task->data[0]++; + break; + case 2: + obj_delete_but_dont_free_vram(&gSprites[task->data[15]]); + task->data[0]++; + break; + case 3: + FreeOamMatrix(task->data[14]); + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_8110240(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y); + + if (IsContest()) + sprite->pos1.y += 12; + + sprite->data[1] = 8; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(sprite->data[1], 16 - sprite->data[1])); + sprite->data[0]++; + break; + case 1: + if (sprite->affineAnimEnded) + { + PlaySE12WithPanning(SE_W100, BattleAnimAdjustPanning(-64)); + ChangeSpriteAffineAnim(sprite, 1); + sprite->data[0]++; + } + break; + case 2: + if (sprite->data[2]++ > 1) + { + sprite->data[2] = 0; + sprite->data[1]--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(sprite->data[1], 16 - sprite->data[1])); + if (sprite->data[1] == 0) + { + sprite->data[0]++; + sprite->invisible = 1; + } + } + + sprite->data[3] += 0x380; + sprite->pos2.y -= sprite->data[3] >> 8; + sprite->data[3] &= 0xFF; + break; + case 3: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + DestroyAnimSprite(sprite); + break; + } +} From 370b1093cd40235951f0d1b6762006b085565499 Mon Sep 17 00:00:00 2001 From: Melody Date: Mon, 24 Dec 2018 12:41:38 -0500 Subject: [PATCH 3/3] fix feebas check --- src/wild_encounter.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 00650fc8c..2e6f1642a 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -88,20 +88,12 @@ static bool8 CheckFeebas(void) x -= 7; y -= 7; -#ifdef NONMATCHING + if (y >= gRoute119WaterTileData[3 * 0 + 0] && y <= gRoute119WaterTileData[3 * 0 + 1]) + route119Section = 0; if (y >= gRoute119WaterTileData[3 * 1 + 0] && y <= gRoute119WaterTileData[3 * 1 + 1]) route119Section = 1; if (y >= gRoute119WaterTileData[3 * 2 + 0] && y <= gRoute119WaterTileData[3 * 2 + 1]) route119Section = 2; -#else - { - register const u16 *arr asm("r0"); - if (y >= (arr = gRoute119WaterTileData)[3 * 1 + 0] && y <= arr[3 * 1 + 1]) - route119Section = 1; - if (y >= arr[3 * 2 + 0] && y <= arr[3 * 2 + 1]) - route119Section = 2; - } -#endif if (Random() % 100 > 49) // 50% chance of encountering Feebas return FALSE;