From 314b71847170f7853b2d6d863bfdecafa7a0558d Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Fri, 21 Dec 2018 01:37:59 -0500 Subject: [PATCH] finish porting ice --- asm/ice.s | 1354 ------------------------------------ data/battle_anim_scripts.s | 6 +- ld_script.txt | 1 - src/ice.c | 818 ++++++++++++++++++++-- 4 files changed, 750 insertions(+), 1429 deletions(-) delete mode 100644 asm/ice.s diff --git a/asm/ice.s b/asm/ice.s deleted file mode 100644 index bc2be5815..000000000 --- a/asm/ice.s +++ /dev/null @@ -1,1354 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_810C324 -sub_810C324: @ 810C324 - push {r4,r5,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0x1 - bl SetAnimBgAttribute - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl SetAnimBgAttribute - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810C366 - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0x1 - bl SetAnimBgAttribute -_0810C366: - ldr r0, =gBattle_BG1_X - movs r1, 0 - strh r1, [r0] - ldr r4, =gBattle_BG1_Y - strh r1, [r4] - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - ldrh r1, [r4] - movs r0, 0x16 - bl SetGpuReg - mov r0, sp - bl sub_80A6B30 - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gWeatherFog1Tiles - movs r2, 0x80 - lsls r2, 4 - mov r3, sp - ldrh r3, [r3, 0xA] - bl LoadBgTiles - ldr r1, =gBattleAnimFogTilemap - mov r0, sp - movs r2, 0 - bl sub_80A6D60 - ldr r0, =gUnknown_083970E8 - mov r1, sp - ldrb r1, [r1, 0x8] - lsls r1, 4 - movs r2, 0x20 - bl LoadPalette - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =0x0000ffff - strh r1, [r0, 0x26] - ldr r1, =sub_810C3F0 - str r1, [r0] - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810C324 - - thumb_func_start sub_810C3F0 -sub_810C3F0: @ 810C3F0 - push {r4,r5,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r2, =gBattle_BG1_X - ldr r3, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r3 - ldrh r0, [r1, 0x26] - ldrh r5, [r2] - adds r0, r5 - strh r0, [r2] - movs r2, 0x20 - ldrsh r0, [r1, r2] - cmp r0, 0x4 - bls _0810C416 - b _0810C54A -_0810C416: - lsls r0, 2 - ldr r1, =_0810C42C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0810C42C: - .4byte _0810C440 - .4byte _0810C484 - .4byte _0810C4A6 - .4byte _0810C4EA - .4byte _0810C50C -_0810C440: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r4, r0, r3 - ldrh r0, [r4, 0x1A] - adds r0, 0x1 - strh r0, [r4, 0x1A] - ldr r1, =gUnknown_08595C88 - movs r5, 0x1A - ldrsh r0, [r4, r5] - adds r0, r1 - ldrb r1, [r0] - strh r1, [r4, 0x1E] - movs r0, 0x11 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r1, 0x1E - ldrsh r0, [r4, r1] - cmp r0, 0x5 - bne _0810C54A - ldrh r0, [r4, 0x20] - adds r0, 0x1 - strh r0, [r4, 0x20] - movs r0, 0 - strh r0, [r4, 0x1E] - b _0810C54A - .pool -_0810C484: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r1, r0, r3 - ldrh r0, [r1, 0x1E] - adds r0, 0x1 - strh r0, [r1, 0x1E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x51 - bne _0810C54A - movs r0, 0x5 - strh r0, [r1, 0x1E] - ldrh r0, [r1, 0x20] - adds r0, 0x1 - strh r0, [r1, 0x20] - b _0810C54A -_0810C4A6: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r4, r0, r3 - ldrh r0, [r4, 0x1C] - adds r0, 0x1 - strh r0, [r4, 0x1C] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - bne _0810C54A - movs r0, 0 - strh r0, [r4, 0x1C] - ldrh r1, [r4, 0x1E] - subs r1, 0x1 - strh r1, [r4, 0x1E] - movs r0, 0x10 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r2, 0x1E - ldrsh r1, [r4, r2] - cmp r1, 0 - bne _0810C54A - ldrh r0, [r4, 0x20] - adds r0, 0x1 - strh r0, [r4, 0x20] - strh r1, [r4, 0x1E] - b _0810C54A -_0810C4EA: - mov r0, sp - bl sub_80A6B30 - movs r0, 0x1 - bl sub_80A6C68 - movs r0, 0x2 - bl sub_80A6C68 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x20] - adds r0, 0x1 - strh r0, [r1, 0x20] -_0810C50C: - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810C520 - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0 - bl SetAnimBgAttribute -_0810C520: - ldr r0, =gBattle_BG1_X - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_BG1_Y - strh r1, [r0] - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0x1 - bl SetAnimBgAttribute - adds r0, r4, 0 - bl DestroyAnimVisualTask -_0810C54A: - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810C3F0 - - thumb_func_start sub_810C560 -sub_810C560: @ 810C560 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - ldr r6, =gBattleAnimArgs - ldrh r0, [r6] - strh r0, [r5, 0x2E] - ldr r0, =gBattleAnimAttacker - mov r8, r0 - ldrb r0, [r0] - movs r1, 0x2 - bl GetBattlerSpriteCoord - adds r4, r0, 0 - ldr r7, =gBattleAnimTarget - ldrb r0, [r7] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bcs _0810C594 - movs r0, 0x80 - lsls r0, 8 - strh r0, [r5, 0x3C] -_0810C594: - ldr r3, =gBattlerPositions - ldrb r0, [r7] - adds r0, r3 - ldrb r1, [r0] - movs r2, 0x1 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _0810C5F4 - ldrh r0, [r6, 0x2] - negs r0, r0 - strh r0, [r6, 0x2] - ldrh r0, [r6, 0x6] - negs r0, r0 - strh r0, [r6, 0x6] - movs r1, 0x3C - ldrsh r0, [r5, r1] - movs r1, 0x80 - lsls r1, 8 - ands r0, r1 - cmp r0, 0 - beq _0810C5F0 - mov r1, r8 - ldrb r0, [r1] - adds r0, r3 - ldrb r1, [r0] - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _0810C5F0 - movs r0, 0x1 - bl GetAnimBattlerSpriteId - ldr r2, =gSprites - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - adds r1, 0x43 - ldrb r0, [r1] - adds r0, 0x1 - adds r1, r5, 0 - adds r1, 0x43 - strb r0, [r1] -_0810C5F0: - movs r0, 0x1 - strh r0, [r5, 0x3A] -_0810C5F4: - 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] - ldr r6, =gBattleAnimArgs - movs r1, 0xE - ldrsh r0, [r6, r1] - cmp r0, 0 - beq _0810C65C - ldrh r0, [r6, 0x2] - ldrh r1, [r5, 0x20] - adds r0, r1 - strh r0, [r5, 0x30] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r6, 0x6] - adds r0, r1 - strh r0, [r5, 0x32] - ldrh r0, [r6, 0x4] - ldrh r1, [r5, 0x22] - adds r0, r1 - strh r0, [r5, 0x34] - ldrb r0, [r4] - movs r1, 0x3 - b _0810C684 - .pool -_0810C65C: - ldrh r0, [r6, 0x2] - ldrh r1, [r5, 0x20] - adds r0, r1 - strh r0, [r5, 0x30] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r6, 0x6] - adds r0, r1 - strh r0, [r5, 0x32] - ldrh r0, [r6, 0x4] - ldrh r1, [r5, 0x22] - adds r0, r1 - strh r0, [r5, 0x34] - ldrb r0, [r4] - movs r1, 0x1 -_0810C684: - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r6, [r6, 0x8] - adds r0, r6 - strh r0, [r5, 0x36] - ldrb r0, [r4] - bl GetBattlerSpriteBGPriority - lsls r0, 24 - lsrs r0, 16 - ldrh r1, [r5, 0x3C] - orrs r0, r1 - strh r0, [r5, 0x3C] - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0810C6B8 - movs r0, 0x1 - strh r0, [r5, 0x3A] - adds r1, r5, 0 - adds r1, 0x43 - movs r0, 0x80 - strb r0, [r1] -_0810C6B8: - adds r0, r5, 0 - bl InitAnimLinearTranslation - ldr r0, =sub_810C6D4 - str r0, [r5, 0x1C] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810C560 - - thumb_func_start sub_810C6D4 -sub_810C6D4: @ 810C6D4 - push {r4-r6,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x3C] - movs r5, 0xFF - movs r1, 0xFF - ands r1, r0 - cmp r1, 0x1 - beq _0810C7BC - cmp r1, 0x1 - bgt _0810C6EE - cmp r1, 0 - beq _0810C6F6 - b _0810C90C -_0810C6EE: - cmp r1, 0x2 - bne _0810C6F4 - b _0810C8D0 -_0810C6F4: - b _0810C90C -_0810C6F6: - adds r0, r4, 0 - bl AnimTranslateLinear - ldr r1, =gSineTable - movs r2, 0x38 - ldrsh r0, [r4, r2] - lsls r0, 1 - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - asrs r0, 4 - ldrh r2, [r4, 0x24] - adds r0, r2 - strh r0, [r4, 0x24] - movs r1, 0x3A - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0810C724 - ldrh r0, [r4, 0x38] - subs r0, 0x8 - b _0810C728 - .pool -_0810C724: - ldrh r0, [r4, 0x38] - adds r0, 0x8 -_0810C728: - ands r0, r5 - strh r0, [r4, 0x38] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - ble _0810C736 - b _0810C90C -_0810C736: - movs r5, 0x50 - strh r5, [r4, 0x2E] - ldr r6, =gBattleAnimTarget - ldrb r0, [r6] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x20] - strh r0, [r4, 0x30] - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x26] - ldrh r1, [r4, 0x22] - adds r0, r1 - strh r0, [r4, 0x22] - strh r0, [r4, 0x34] - adds r0, 0x1D - strh r0, [r4, 0x36] - ldrh r0, [r4, 0x3C] - adds r0, 0x1 - strh r0, [r4, 0x3C] - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810C78C - ldr r1, =gBattlerPositions - ldrb r0, [r6] - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0810C78C - movs r0, 0xCC - strh r0, [r4, 0x38] - b _0810C78E - .pool -_0810C78C: - strh r5, [r4, 0x38] -_0810C78E: - movs r0, 0 - strh r0, [r4, 0x26] - ldr r1, =gSineTable - movs r2, 0x38 - ldrsh r0, [r4, r2] - lsls r0, 1 - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - asrs r0, 3 - strh r0, [r4, 0x24] - ldrh r0, [r4, 0x38] - adds r0, 0x2 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x38] - adds r0, r4, 0 - bl InitAnimLinearTranslation - b _0810C90C - .pool -_0810C7BC: - adds r0, r4, 0 - bl AnimTranslateLinear - ldr r1, =gSineTable - movs r2, 0x38 - ldrsh r0, [r4, r2] - lsls r0, 1 - adds r0, r1 - movs r2, 0 - ldrsh r0, [r0, r2] - asrs r0, 3 - ldrh r2, [r4, 0x24] - adds r0, r2 - strh r0, [r4, 0x24] - movs r2, 0x38 - ldrsh r0, [r4, r2] - adds r0, 0x40 - lsls r0, 1 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - lsls r0, r1, 1 - adds r0, r1 - negs r0, r0 - asrs r0, 8 - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810C83A - ldrh r1, [r4, 0x38] - adds r0, r1, 0 - subs r0, 0x40 - lsls r0, 16 - lsrs r0, 16 - adds r3, r1, 0 - cmp r0, 0x7F - bhi _0810C81C - ldrh r1, [r4, 0x3C] - lsls r1, 16 - asrs r1, 24 - b _0810C824 - .pool -_0810C81C: - ldrh r1, [r4, 0x3C] - lsls r1, 16 - asrs r1, 24 - adds r1, 0x1 -_0810C824: - movs r0, 0x3 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r4, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x5] - adds r0, r3, 0x4 - b _0810C85A -_0810C83A: - ldrh r0, [r4, 0x38] - subs r0, 0x40 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x7F - bhi _0810C84E - adds r1, r4, 0 - adds r1, 0x43 - movs r0, 0x80 - b _0810C854 -_0810C84E: - adds r1, r4, 0 - adds r1, 0x43 - movs r0, 0x8C -_0810C854: - strb r0, [r1] - ldrh r0, [r4, 0x38] - subs r0, 0x4 -_0810C85A: - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x38] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - bgt _0810C90C - movs r5, 0 - movs r0, 0xC0 - lsls r0, 2 - strh r0, [r4, 0x2E] - ldrh r0, [r4, 0x24] - ldrh r1, [r4, 0x20] - adds r0, r1 - strh r0, [r4, 0x20] - strh r0, [r4, 0x30] - ldrh r0, [r4, 0x26] - ldrh r2, [r4, 0x22] - adds r0, r2 - strh r0, [r4, 0x22] - strh r0, [r4, 0x34] - adds r0, 0x4 - strh r0, [r4, 0x36] - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810C8B4 - ldr r1, =gBattlerPositions - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0810C8B4 - movs r0, 0x80 - lsls r0, 1 - b _0810C8B6 - .pool -_0810C8B4: - ldr r0, =0x0000fff0 -_0810C8B6: - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x3C] - adds r0, 0x1 - movs r1, 0 - strh r0, [r4, 0x3C] - strh r1, [r4, 0x26] - strh r1, [r4, 0x24] - adds r0, r4, 0 - bl sub_80A6FD4 - b _0810C90C - .pool -_0810C8D0: - adds r0, r4, 0 - bl AnimTranslateLinear - lsls r0, 24 - cmp r0, 0 - beq _0810C90C - ldrb r0, [r4, 0x1] - lsls r0, 30 - lsrs r0, 30 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0810C8FE - 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] -_0810C8FE: - adds r0, r4, 0 - bl DestroySprite - ldr r1, =gAnimVisualTaskCount - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] -_0810C90C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810C6D4 - - thumb_func_start sub_810C918 -sub_810C918: @ 810C918 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r1, r0 - ldr r0, =sub_810C934 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_810C918 - - thumb_func_start sub_810C934 -sub_810C934: @ 810C934 - push {r4,r5,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r0, 0x8 - ldrsh r5, [r4, r0] - cmp r5, 0x1 - beq _0810C978 - cmp r5, 0x1 - bgt _0810C95C - cmp r5, 0 - beq _0810C962 - b _0810C9DC - .pool -_0810C95C: - cmp r5, 0x2 - beq _0810C9CE - b _0810C9DC -_0810C962: - ldrh r0, [r4, 0x10] - adds r0, 0x1 - strh r0, [r4, 0x10] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _0810C9DC - strh r5, [r4, 0x10] - strh r5, [r4, 0x12] - strh r5, [r4, 0xC] - b _0810C9B4 -_0810C978: - ldrh r1, [r4, 0x12] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r0, 0 - bne _0810C9C8 - ldrb r0, [r4, 0xE] - ldrb r1, [r4, 0xC] - movs r3, 0x1 - bl sub_810C9E4 - lsls r0, 24 - cmp r0, 0 - beq _0810C998 - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] -_0810C998: - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3 - bne _0810C9C4 - ldrh r0, [r4, 0xE] - adds r0, 0x1 - strh r0, [r4, 0xE] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - bne _0810C9BC -_0810C9B4: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _0810C9DC -_0810C9BC: - ldrh r0, [r4, 0x8] - subs r0, 0x1 - strh r0, [r4, 0x8] - b _0810C9DC -_0810C9C4: - strh r5, [r4, 0x12] - b _0810C9DC -_0810C9C8: - subs r0, r1, 0x1 - strh r0, [r4, 0x12] - b _0810C9DC -_0810C9CE: - movs r1, 0xA - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0810C9DC - adds r0, r2, 0 - bl DestroyAnimVisualTask -_0810C9DC: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_810C934 - - thumb_func_start sub_810C9E4 -sub_810C9E4: @ 810C9E4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - lsls r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - lsls r2, 24 - lsrs r2, 24 - str r2, [sp] - lsls r3, 24 - lsrs r3, 24 - mov r10, r3 - movs r1, 0 - str r1, [sp, 0x4] - ldr r1, =gUnknown_08595CB4 - lsrs r0, 22 - adds r4, r0, r1 - ldrb r0, [r4, 0x3] - lsls r0, 24 - asrs r0, 28 - mov r8, r0 - cmp r0, 0x2 - beq _0810CAD0 - ldrh r0, [r4, 0x2] - lsls r0, 20 - lsrs r0, 24 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r5, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0810CAD0 - movs r0, 0x1 - str r0, [sp, 0x4] - adds r0, r5, 0 - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r7, r0, 24 - adds r0, r5, 0 - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r6, r0, 24 - mov r1, r8 - cmp r1, 0 - beq _0810CA60 - cmp r1, 0x1 - beq _0810CA96 - b _0810CAE2 - .pool -_0810CA60: - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80A861C - lsls r0, 16 - asrs r0, 16 - movs r1, 0x6 - bl __divsi3 - lsls r1, r7, 16 - asrs r1, 16 - subs r1, r0 - lsls r1, 16 - lsrs r7, r1, 16 - adds r0, r5, 0 - movs r1, 0 - bl sub_80A861C - lsls r0, 16 - asrs r0, 16 - movs r1, 0x6 - bl __divsi3 - lsls r1, r6, 16 - asrs r1, 16 - subs r1, r0 - b _0810CACA -_0810CA96: - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80A861C - lsls r0, 16 - asrs r0, 16 - movs r1, 0x6 - bl __divsi3 - lsls r1, r7, 16 - asrs r1, 16 - adds r1, r0 - lsls r1, 16 - lsrs r7, r1, 16 - adds r0, r5, 0 - movs r1, 0 - bl sub_80A861C - lsls r0, 16 - asrs r0, 16 - movs r1, 0x6 - bl __divsi3 - lsls r1, r6, 16 - asrs r1, 16 - adds r1, r0 -_0810CACA: - lsls r1, 16 - lsrs r6, r1, 16 - b _0810CAE2 -_0810CAD0: - ldrh r0, [r4] - lsls r0, 22 - asrs r0, 6 - lsrs r7, r0, 16 - ldr r0, [r4] - lsls r0, 12 - asrs r0, 22 - lsls r0, 16 - lsrs r6, r0, 16 -_0810CAE2: - lsls r0, r6, 16 - asrs r0, 16 - adds r0, 0x8 - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - lsls r1, r7, 16 - asrs r1, 16 - subs r1, r0 - ldr r0, =gUnknown_08595D2C - lsls r1, 16 - asrs r1, 16 - movs r2, 0x8 - negs r2, r2 - movs r3, 0x12 - bl CreateSprite - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x40 - beq _0810CB44 - lsls r4, r5, 4 - adds r4, r5 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - adds r0, r4, 0 - mov r1, r9 - bl StartSpriteAffineAnim - mov r0, sp - ldrh r0, [r0, 0x4] - strh r0, [r4, 0x2E] - strh r7, [r4, 0x34] - strh r6, [r4, 0x36] - mov r1, r9 - strh r1, [r4, 0x38] - mov r0, sp - ldrh r0, [r0] - strh r0, [r4, 0x3A] - mov r1, r10 - strh r1, [r4, 0x3C] - movs r0, 0x1 - b _0810CB46 - .pool -_0810CB44: - movs r0, 0 -_0810CB46: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_810C9E4 - - thumb_func_start sub_810CB58 -sub_810CB58: @ 810CB58 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x20] - adds r0, 0x4 - strh r0, [r4, 0x20] - ldrh r1, [r4, 0x22] - adds r2, r1, 0 - adds r2, 0x8 - strh r2, [r4, 0x22] - lsls r0, 16 - asrs r0, 16 - movs r3, 0x34 - ldrsh r1, [r4, r3] - cmp r0, r1 - bge _0810CB82 - lsls r0, r2, 16 - asrs r0, 16 - movs r2, 0x36 - ldrsh r1, [r4, r2] - cmp r0, r1 - blt _0810CC32 -_0810CB82: - movs r3, 0x2E - ldrsh r0, [r4, r3] - cmp r0, 0x1 - bne _0810CC04 - movs r1, 0x38 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0810CC04 - ldr r0, =gUnknown_08595B68 - movs r2, 0x34 - ldrsh r1, [r4, r2] - movs r3, 0x36 - ldrsh r2, [r4, r3] - adds r3, r4, 0 - adds r3, 0x43 - ldrb r3, [r3] - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x2E] - cmp r0, 0x40 - beq _0810CBE6 - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r2, 0 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_810CC3C - str r1, [r0] - movs r3, 0x2E - ldrsh r1, [r4, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r4, 0x3A] - strh r1, [r0, 0x3A] - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r4, 0x3C] - strh r1, [r0, 0x3C] -_0810CBE6: - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - adds r0, r4, 0 - bl DestroySprite - b _0810CC32 - .pool -_0810CC04: - ldr r3, =gTasks - movs r2, 0x3C - ldrsh r1, [r4, r2] - lsls r1, 1 - movs r0, 0x3A - ldrsh r2, [r4, r0] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0 - adds r3, 0x8 - adds r1, r3 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - adds r0, r4, 0 - bl DestroySprite -_0810CC32: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810CB58 - - thumb_func_start sub_810CC3C -sub_810CC3C: @ 810CC3C - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x14 - bne _0810CC7C - ldr r3, =gTasks - movs r0, 0x3C - ldrsh r1, [r4, r0] - lsls r1, 1 - movs r0, 0x3A - ldrsh r2, [r4, r0] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0 - adds r3, 0x8 - adds r1, r3 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - adds r0, r4, 0 - bl DestroySprite -_0810CC7C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810CC3C - - thumb_func_start unc_080B06FC -unc_080B06FC: @ 810CC88 - push {r4-r6,lr} - adds r5, r0, 0 - ldr r0, =gAnimDisableStructPtr - ldr r0, [r0] - ldrb r1, [r0, 0x11] - lsrs r0, r1, 4 - lsls r1, 28 - lsrs r1, 28 - subs r0, r1 - subs r0, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x4 - bls _0810CCA6 - movs r1, 0x4 -_0810CCA6: - adds r0, r5, 0 - bl StartSpriteAffineAnim - adds r0, r5, 0 - movs r1, 0x1 - bl InitSpritePosToAnimAttacker - ldr r6, =gBattleAnimArgs - ldrh r0, [r6, 0x8] - strh r0, [r5, 0x2E] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810CCCE - ldrh r0, [r6, 0x4] - negs r0, r0 - strh r0, [r6, 0x4] -_0810CCCE: - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r6, 0x4] - adds r0, r1 - strh r0, [r5, 0x32] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r6, 0x6] - adds r0, r1 - strh r0, [r5, 0x36] - ldrh r0, [r6, 0xA] - strh r0, [r5, 0x38] - adds r0, r5, 0 - bl InitAnimArcTranslation - ldr r0, =sub_810CD1C - str r0, [r5, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end unc_080B06FC - - thumb_func_start sub_810CD1C -sub_810CD1C: @ 810CD1C - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _0810CD3E - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim - ldr r0, =RunStoredCallbackWhenAnimEnds - str r0, [r4, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 -_0810CD3E: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810CD1C - - thumb_func_start sub_810CD4C -sub_810CD4C: @ 810CD4C - push {r4-r6,lr} - adds r4, r0, 0 - ldrh r2, [r4, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - adds r1, 0x8 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r4, 0x4] - adds r0, r4, 0 - movs r1, 0x1 - bl InitSpritePosToAnimTarget - bl Random2 - movs r5, 0xFF - ands r5, r0 - movs r0, 0x80 - lsls r0, 1 - adds r6, r0, 0 - orrs r5, r6 - bl Random2 - ldr r1, =0x000001ff - ands r1, r0 - adds r0, r1, 0 - cmp r0, 0xFF - ble _0810CD92 - subs r0, r6, r0 - lsls r0, 16 - lsrs r1, r0, 16 -_0810CD92: - strh r5, [r4, 0x30] - strh r1, [r4, 0x32] - ldr r0, =sub_810CDB0 - str r0, [r4, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810CD4C - - thumb_func_start sub_810CDB0 -sub_810CDB0: @ 810CDB0 - push {r4,lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x30] - ldrh r1, [r2, 0x34] - adds r3, r0, r1 - strh r3, [r2, 0x34] - ldrh r1, [r2, 0x32] - ldrh r4, [r2, 0x36] - adds r1, r4 - strh r1, [r2, 0x36] - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0810CDD4 - lsls r0, r3, 16 - asrs r0, 24 - negs r0, r0 - b _0810CDD8 -_0810CDD4: - lsls r0, r3, 16 - asrs r0, 24 -_0810CDD8: - strh r0, [r2, 0x24] - ldrh r0, [r2, 0x36] - lsls r0, 16 - asrs r0, 24 - strh r0, [r2, 0x26] - ldrh r0, [r2, 0x2E] - adds r0, 0x1 - strh r0, [r2, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x15 - bne _0810CDF6 - adds r0, r2, 0 - bl DestroyAnimSprite -_0810CDF6: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810CDB0 - - thumb_func_start AnimTask_GetRolloutCounter -AnimTask_GetRolloutCounter: @ 810CDFC - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleAnimArgs - ldrb r3, [r1] - lsls r3, 1 - adds r3, r1 - ldr r1, =gAnimDisableStructPtr - ldr r1, [r1] - ldrb r1, [r1, 0x11] - lsrs r2, r1, 4 - lsls r1, 28 - lsrs r1, 28 - subs r2, r1 - subs r2, 0x1 - strh r2, [r3] - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_GetRolloutCounter - - .align 2, 0 diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 6552dd9da..185d18df1 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -3484,7 +3484,7 @@ Move_HAIL: loadspritegfx ANIM_TAG_ICE_CRYSTALS createvisualtask sub_8116620, 10, 1, 3, 0, 6, RGB_BLACK waitforvisualfinish - createvisualtask sub_810C918, 5 + createvisualtask AnimTask_Hail1, 5 loopsewithpan SE_W258, 0, 8, 10 waitforvisualfinish createvisualtask sub_8116620, 10, 1, 3, 6, 0, RGB_BLACK @@ -3956,7 +3956,7 @@ Move_MIST_BALL: createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 1, 1, 1, RGB(23, 16, 31), 16, 0x7FFF, 16 delay 0 playsewithpan SE_W114, 0 - createvisualtask sub_810C324, 5 + createvisualtask AnimTask_LoadMistTiles, 5 createvisualtask sub_8116620, 10, 4, 3, 0, 16, RGB_WHITE delay 8 createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 4, 0, 70, 0 @@ -6937,7 +6937,7 @@ Mist1: Move_HAZE: waitforvisualfinish playsewithpan SE_W114, 0 - createvisualtask sub_810C0A0, 5 + createvisualtask AnimTask_Haze1, 5 delay 30 createvisualtask sub_8116620, 10, 0x780, 2, 0, 16, RGB_BLACK delay 0x5A diff --git a/ld_script.txt b/ld_script.txt index c706804f6..d6f994e0f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -163,7 +163,6 @@ SECTIONS { src/fire.o(.text); src/electric.o(.text); src/ice.o(.text); - asm/ice.o(.text); src/fight.o(.text); src/poison.o(.text); asm/flying.o(.text); diff --git a/src/ice.c b/src/ice.c index be8255231..329cd0b9a 100644 --- a/src/ice.c +++ b/src/ice.c @@ -4,36 +4,52 @@ #include "field_weather.h" #include "gpu_regs.h" #include "graphics.h" +#include "main.h" #include "palette.h" +#include "random.h" #include "sprite.h" #include "task.h" #include "trig.h" #include "constants/battle_anim.h" #include "constants/rgb.h" +struct HailStruct { + s32 unk0:10; + s32 unk1:10; + s32 unk2:8; + s32 unk3:4; +}; + extern void sub_810B684(struct Sprite *); extern void sub_810B6C4(struct Sprite *); extern void sub_810B848(struct Sprite *); -extern void sub_810B8AC(struct Sprite *); -extern void sub_810B8EC(struct Sprite *); -extern void sub_810B974(struct Sprite *); -extern void sub_810B9E8(struct Sprite *); -extern void sub_810BA24(struct Sprite *); -extern void sub_810BB60(struct Sprite *); -extern void sub_810BBC8(struct Sprite *); -extern void sub_810BC4C(struct Sprite *); -extern void sub_810BC94(struct Sprite *); -extern void sub_810BDD8(struct Sprite *); -extern void sub_810BE48(struct Sprite *); -extern void sub_810BED0(struct Sprite *); -extern void sub_810C008(struct Sprite *); -extern void sub_810C2F0(struct Sprite *); -extern void sub_810C560(struct Sprite *); -extern void sub_810CB58(struct Sprite *); +extern void AnimIcePunchSwirlingParticle(struct Sprite *); +extern void AnimIceBeamParticle(struct Sprite *); +extern void AnimIceEffectParticle(struct Sprite *); +extern void AnimFlickerIceEffectParticle(struct Sprite *); +extern void AnimSwirlingSnowball_Step1(struct Sprite *); +extern void AnimSwirlingSnowball_Step2(struct Sprite *); +extern void AnimSwirlingSnowball_Step3(struct Sprite *); +extern void AnimSwirlingSnowball_End(struct Sprite *); +extern void AnimMoveParticleBeyondTarget(struct Sprite *); +extern void AnimWiggleParticleTowardsTarget(struct Sprite *); +extern void AnimWaveFromCenterOfTarget(struct Sprite *); +extern void InitSwirlingFogAnim(struct Sprite *); +extern void AnimSwirlingFogAnim(struct Sprite *); +extern void AnimThrowMistBall(struct Sprite *); +extern void InitPoisonGasCloudAnim(struct Sprite *); +extern void MovePoisonGasCloud(struct Sprite *); +extern void AnimHailBegin(struct Sprite *); +extern void AnimHailContinue(struct Sprite *); extern void sub_80A8EE4(struct Sprite *); -extern void unc_080B06FC(struct Sprite *); -extern void sub_810CD4C(struct Sprite *); -void sub_810C164(u8); +extern void InitIceBallAnim(struct Sprite *); +extern void AnimThrowIceBall(struct Sprite *); +extern void InitIceBallParticle(struct Sprite *); +extern void AnimIceBallParticle(struct Sprite *); +void AnimTask_Haze2(u8); +void AnimTask_OverlayFogTiles(u8); +void AnimTask_Hail2(u8); +bool8 GenerateHailParticle(u8, u8, u8, u8); const union AnimCmd gUnknown_08595A48[] = { @@ -145,7 +161,7 @@ const struct SpriteTemplate gUnknown_08595AD0 = .anims = gUnknown_08595AA8, .images = NULL, .affineAnims = gUnknown_08595ACC, - .callback = sub_810B8AC, + .callback = AnimIcePunchSwirlingParticle, }; const struct SpriteTemplate gUnknown_08595AE8 = @@ -156,7 +172,7 @@ const struct SpriteTemplate gUnknown_08595AE8 = .anims = gUnknown_08595AAC, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810B8AC, + .callback = AnimIcePunchSwirlingParticle, }; const union AffineAnimCmd gUnknown_08595B00[] = @@ -178,7 +194,7 @@ const struct SpriteTemplate gUnknown_08595B14 = .anims = gUnknown_08595AA8, .images = NULL, .affineAnims = gUnknown_08595B10, - .callback = sub_810B8EC, + .callback = AnimIceBeamParticle, }; const struct SpriteTemplate gUnknown_08595B2C = @@ -189,7 +205,7 @@ const struct SpriteTemplate gUnknown_08595B2C = .anims = gUnknown_08595AAC, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810B8EC, + .callback = AnimIceBeamParticle, }; const union AffineAnimCmd gUnknown_08595B44[] = @@ -213,7 +229,7 @@ const struct SpriteTemplate gUnknown_08595B68 = .anims = gUnknown_08595AA8, .images = NULL, .affineAnims = gUnknown_08595B64, - .callback = sub_810B974, + .callback = AnimIceEffectParticle, }; const struct SpriteTemplate gUnknown_08595B80 = @@ -224,7 +240,7 @@ const struct SpriteTemplate gUnknown_08595B80 = .anims = gUnknown_08595AAC, .images = NULL, .affineAnims = gUnknown_08595B64, - .callback = sub_810B974, + .callback = AnimIceEffectParticle, }; const struct SpriteTemplate gUnknown_08595B98 = @@ -235,7 +251,7 @@ const struct SpriteTemplate gUnknown_08595B98 = .anims = gUnknown_08595AB0, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810BA24, + .callback = AnimSwirlingSnowball_Step1, }; const struct SpriteTemplate gUnknown_08595BB0 = @@ -246,7 +262,7 @@ const struct SpriteTemplate gUnknown_08595BB0 = .anims = gUnknown_08595AB4, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810BC94, + .callback = AnimMoveParticleBeyondTarget, }; const struct SpriteTemplate gUnknown_08595BC8 = @@ -257,7 +273,7 @@ const struct SpriteTemplate gUnknown_08595BC8 = .anims = gUnknown_08595AB0, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810BC94, + .callback = AnimMoveParticleBeyondTarget, }; const union AnimCmd gUnknown_08595BE0[] = @@ -285,7 +301,7 @@ const struct SpriteTemplate gUnknown_08595C04 = .anims = gUnknown_08595C00, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810BE48, + .callback = AnimWaveFromCenterOfTarget, }; const union AnimCmd gUnknown_08595C1C[] = @@ -308,7 +324,7 @@ const struct SpriteTemplate gUnknown_08595C2C = .anims = gUnknown_08595C28, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810BED0, + .callback = InitSwirlingFogAnim, }; const struct SpriteTemplate gUnknown_08595C44 = @@ -319,7 +335,7 @@ const struct SpriteTemplate gUnknown_08595C44 = .anims = gUnknown_08595C28, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810BED0, + .callback = InitSwirlingFogAnim, }; const u8 gUnknown_08595C5C[] = @@ -335,7 +351,7 @@ const struct SpriteTemplate gUnknown_08595C70 = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810C2F0, + .callback = AnimThrowMistBall, }; const u8 gUnknown_08595C88[] = @@ -351,21 +367,21 @@ const struct SpriteTemplate gUnknown_08595C9C = .anims = gUnknown_08595C28, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810C560, + .callback = InitPoisonGasCloudAnim, }; -const u8 gUnknown_08595CB4[][4] = +const struct HailStruct gUnknown_08595CB4[] = { - {0x64, 0xE0, 0x01, 0x20}, - {0x55, 0xE0, 0x01, 0x00}, - {0xF2, 0xE0, 0x11, 0x10}, - {0x42, 0xE0, 0x21, 0x10}, - {0xB6, 0xE0, 0x31, 0x00}, - {0x3C, 0xE0, 0x01, 0x20}, - {0xD6, 0xE0, 0x11, 0x00}, - {0x71, 0xE0, 0x01, 0x10}, - {0xD2, 0xE0, 0x31, 0x10}, - {0x26, 0xE0, 0x21, 0x00}, + {100, 120, 0, 2}, + {85, 120, 0, 0}, + {242, 120, 1, 1}, + {66, 120, 2, 1}, + {182, 120, 3, 0}, + {60, 120, 0, 2}, + {214, 120, 1, 0}, + {113, 120, 0, 1}, + {210, 120, 3, 1}, + {38, 120, 2, 0}, }; const union AffineAnimCmd gUnknown_08595CDC[] = @@ -412,7 +428,7 @@ const struct SpriteTemplate gUnknown_08595D2C = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gUnknown_08595D1C, - .callback = sub_810CB58, + .callback = AnimHailBegin, }; const struct SpriteTemplate gUnknown_08595D44 = @@ -494,7 +510,7 @@ const struct SpriteTemplate gUnknown_08595DE4 = .anims = gUnknown_08595D78, .images = NULL, .affineAnims = gUnknown_08595DD0, - .callback = unc_080B06FC, + .callback = InitIceBallAnim, }; const struct SpriteTemplate gUnknown_08595DFC = @@ -505,7 +521,7 @@ const struct SpriteTemplate gUnknown_08595DFC = .anims = gUnknown_08595AAC, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810CD4C, + .callback = InitIceBallParticle, }; extern const struct SpriteTemplate gUnknown_085956C0; @@ -536,7 +552,7 @@ void sub_810B684(struct Sprite *sprite) } } -// unused +// probably unused #ifdef NONMATCHING void sub_810B6C4(struct Sprite *sprite) { @@ -789,7 +805,7 @@ void sub_810B848(struct Sprite *sprite) // Animates the swirling ice crystals in Ice Punch. // arg 0: initial position angle around circle (0-256) -void sub_810B8AC(struct Sprite *sprite) +void AnimIcePunchSwirlingParticle(struct Sprite *sprite) { sprite->data[0] = gBattleAnimArgs[0]; sprite->data[1] = 60; @@ -807,7 +823,7 @@ void sub_810B8AC(struct Sprite *sprite) // arg 2: target x offset // arg 3: target y offset // arg 4: duration -void sub_810B8EC(struct Sprite *sprite) +void AnimIceBeamParticle(struct Sprite *sprite) { InitSpritePosToAnimAttacker(sprite, TRUE); sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); @@ -828,7 +844,7 @@ void sub_810B8EC(struct Sprite *sprite) // arg 0: target x offset // arg 1: target y offset // arg 2: ??? unknown boolean -void sub_810B974(struct Sprite *sprite) +void AnimIceEffectParticle(struct Sprite *sprite) { if (gBattleAnimArgs[2] == 0) { @@ -844,11 +860,11 @@ void sub_810B974(struct Sprite *sprite) sprite->pos1.y += gBattleAnimArgs[1]; } - StoreSpriteCallbackInData6(sprite, sub_810B9E8); + StoreSpriteCallbackInData6(sprite, AnimFlickerIceEffectParticle); sprite->callback = RunStoredCallbackWhenAffineAnimEnds; } -void sub_810B9E8(struct Sprite *sprite) +void AnimFlickerIceEffectParticle(struct Sprite *sprite) { sprite->invisible ^= 1; sprite->data[0] += 1; @@ -863,7 +879,7 @@ void sub_810B9E8(struct Sprite *sprite) // arg 3: target y offset // arg 4: particle speed // arg 5: multiple targets? (boolean) -void sub_810BA24(struct Sprite *sprite) +void AnimSwirlingSnowball_Step1(struct Sprite *sprite) { int i; s16 tempDataHolder[8]; @@ -916,10 +932,10 @@ void sub_810BA24(struct Sprite *sprite) sprite->data[i] = tempDataHolder[i]; sprite->callback = sub_80A718C; - StoreSpriteCallbackInData6(sprite, sub_810BB60); + StoreSpriteCallbackInData6(sprite, AnimSwirlingSnowball_Step2); } -void sub_810BB60(struct Sprite *sprite) +void AnimSwirlingSnowball_Step2(struct Sprite *sprite) { s16 tempVar; @@ -934,11 +950,11 @@ void sub_810BB60(struct Sprite *sprite) sprite->data[3] = Sin(sprite->data[0], tempVar); sprite->data[4] = Cos(sprite->data[0], 0xF); sprite->data[5] = 0; - sprite->callback = sub_810BBC8; + sprite->callback = AnimSwirlingSnowball_Step3; sprite->callback(sprite); } -void sub_810BBC8(struct Sprite *sprite) +void AnimSwirlingSnowball_Step3(struct Sprite *sprite) { s16 tempVar; tempVar = GetBattlerSide(gBattleAnimAttacker) != 0 ? 20 : -20; @@ -958,11 +974,11 @@ void sub_810BBC8(struct Sprite *sprite) sprite->pos2.x = 0; sprite->data[4] = 0; sprite->data[3] = 0; - sprite->callback = sub_810BC4C; + sprite->callback = AnimSwirlingSnowball_End; } } -void sub_810BC4C(struct Sprite *sprite) +void AnimSwirlingSnowball_End(struct Sprite *sprite) { sprite->data[0] = 1; AnimFastTranslateLinear(sprite); @@ -983,7 +999,7 @@ void sub_810BC4C(struct Sprite *sprite) // arg 5: wave amplitude // arg 6: wave frequency // arg 7: multiple targets? (boolean) -void sub_810BC94(struct Sprite *sprite) +void AnimMoveParticleBeyondTarget(struct Sprite *sprite) { int i; s16 tempDataHolder[8]; @@ -1037,11 +1053,11 @@ void sub_810BC94(struct Sprite *sprite) sprite->data[5] = gBattleAnimArgs[5]; sprite->data[6] = gBattleAnimArgs[6]; - sprite->callback = sub_810BDD8; + sprite->callback = AnimWiggleParticleTowardsTarget; } // Moves particles in a sine wave towards the target. -void sub_810BDD8(struct Sprite *sprite) +void AnimWiggleParticleTowardsTarget(struct Sprite *sprite) { AnimFastTranslateLinear(sprite); if (sprite->data[0] == 0) @@ -1062,7 +1078,7 @@ void sub_810BDD8(struct Sprite *sprite) // arg 0: initial x pixel offset // arg 1: initial y pixel offset // arg 2: ??? unknown boolean -void sub_810BE48(struct Sprite *sprite) +void AnimWaveFromCenterOfTarget(struct Sprite *sprite) { if (sprite->data[0] == 0) { @@ -1097,7 +1113,7 @@ void sub_810BE48(struct Sprite *sprite) // arg 3: duration // arg 4: animate on opponent? (boolean) // arg 5: ??? unknown boolean -void sub_810BED0(struct Sprite *sprite) +void InitSwirlingFogAnim(struct Sprite *sprite) { s16 tempVar; u8 battler; @@ -1160,12 +1176,12 @@ void sub_810BED0(struct Sprite *sprite) InitAnimLinearTranslation(sprite); sprite->data[5] = 64; - sprite->callback = sub_810C008; + sprite->callback = AnimSwirlingFogAnim; sprite->callback(sprite); } // Animates swirling fog initialized by InitSwirlingFogAnim. -void sub_810C008(struct Sprite *sprite) +void AnimSwirlingFogAnim(struct Sprite *sprite) { if (!AnimTranslateLinear(sprite)) { @@ -1186,7 +1202,7 @@ void sub_810C008(struct Sprite *sprite) } // Fades mons to black and places foggy overlay in Haze. -void sub_810C0A0(u8 taskId) +void AnimTask_Haze1(u8 taskId) { struct UnknownAnimStruct2 subStruct; @@ -1208,10 +1224,10 @@ void sub_810C0A0(u8 taskId) sub_80A6D60(&subStruct, gBattleAnimFogTilemap, 0); LoadPalette(&gUnknown_083970E8, subStruct.unk8 * 16, 32); - gTasks[taskId].func = sub_810C164; + gTasks[taskId].func = AnimTask_Haze2; } -void sub_810C164(u8 taskId) +void AnimTask_Haze2(u8 taskId) { struct UnknownAnimStruct2 subStruct; @@ -1284,9 +1300,669 @@ void sub_810C164(u8 taskId) // arg 3: target y offset // arg 4: duration // arg 5: ??? unknown (seems to vibrate target mon somehow) -void sub_810C2F0(struct Sprite *sprite) +void AnimThrowMistBall(struct Sprite *sprite) { sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); sprite->callback = TranslateAnimSpriteToTargetMonLocation; } + +// Displays misty background in Mist Ball. +void AnimTask_LoadMistTiles(u8 taskId) +{ + struct UnknownAnimStruct2 subStruct; + + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); + SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 0); + + if (!IsContest()) + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); + + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); + SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); + + sub_80A6B30(&subStruct); + LoadBgTiles(subStruct.bgId, gWeatherFog1Tiles, 0x800, subStruct.tilesOffset); + sub_80A6D60(&subStruct, gBattleAnimFogTilemap, 0); + LoadPalette(&gUnknown_083970E8, subStruct.unk8 * 16, 32); + + gTasks[taskId].data[15] = -1; + gTasks[taskId].func = AnimTask_OverlayFogTiles; +} + +void AnimTask_OverlayFogTiles(u8 taskId) +{ + struct UnknownAnimStruct2 subStruct; + + gBattle_BG1_X += gTasks[taskId].data[15]; + gBattle_BG1_Y += 0; + + switch (gTasks[taskId].data[12]) + { + case 0: + gTasks[taskId].data[9] += 1; + gTasks[taskId].data[11] = gUnknown_08595C88[gTasks[taskId].data[9]]; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[11], 17 - gTasks[taskId].data[11])); + if (gTasks[taskId].data[11] == 5) + { + gTasks[taskId].data[12]++; + gTasks[taskId].data[11] = 0; + } + break; + case 1: + if (++gTasks[taskId].data[11] == 0x51) + { + gTasks[taskId].data[11] = 5; + gTasks[taskId].data[12]++; + } + break; + case 2: + if (++gTasks[taskId].data[10] == 4) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[11] -= 1; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[11], 16 - gTasks[taskId].data[11])); + if (gTasks[taskId].data[11] == 0) + { + gTasks[taskId].data[12]++; + gTasks[taskId].data[11] = 0; + } + } + break; + case 3: + sub_80A6B30(&subStruct); + sub_80A6C68(1); + sub_80A6C68(2); + + gTasks[taskId].data[12]++; + + // fall through + case 4: + if (!IsContest()) + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0); + + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0)); + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); + DestroyAnimVisualTask(taskId); + } +} + +// Initializes gas clouds in the Poison Gas animation. +// arg 0: duration +// arg 1: ? target x offset +// arg 2: ? target y offset +// arg 3: ? swirl start x +// arg 4: ? swirl start y +// arg 5: ??? unknown +// arg 6: ??? unknown +// arg 7: ??? unknown boolean +void InitPoisonGasCloudAnim(struct Sprite *sprite) +{ + sprite->data[0] = gBattleAnimArgs[0]; + + if (GetBattlerSpriteCoord(gBattleAnimAttacker, 2) < GetBattlerSpriteCoord(gBattleAnimTarget, 2)) + sprite->data[7] = 0x8000; + + if (!(gBattlerPositions[gBattleAnimTarget] & 1)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + + if ((sprite->data[7] & 0x8000) && !(gBattlerPositions[gBattleAnimAttacker] & 1)) + sprite->subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1; + + sprite->data[6] = 1; + } + + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + if (gBattleAnimArgs[7]) + { + sprite->data[1] = sprite->pos1.x + gBattleAnimArgs[1]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[3]; + sprite->data[3] = sprite->pos1.y + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[4]; + sprite->data[7] |= GetBattlerSpriteBGPriority(gBattleAnimTarget) << 8; + } + else + { + sprite->data[1] = sprite->pos1.x + gBattleAnimArgs[1]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 0) + gBattleAnimArgs[3]; + sprite->data[3] = sprite->pos1.y + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 1) + gBattleAnimArgs[4]; + sprite->data[7] |= GetBattlerSpriteBGPriority(gBattleAnimTarget) << 8; + } + + if (IsContest()) + { + sprite->data[6] = 1; + sprite->subpriority = 0x80; + } + + InitAnimLinearTranslation(sprite); + sprite->callback = MovePoisonGasCloud; +} + +void MovePoisonGasCloud(struct Sprite *sprite) +{ + int value; + register s16 value2 asm("r5"); + int unused; + + switch (sprite->data[7] & 0xFF) + { + case 0: + AnimTranslateLinear(sprite); + value = gSineTable[sprite->data[5]]; + sprite->pos2.x += value >> 4; + if (sprite->data[6]) + sprite->data[5] = (sprite->data[5] - 8) & 0xFF; + else + sprite->data[5] = (sprite->data[5] + 8) & 0xFF; + + if (sprite->data[0] <= 0) + { + value2 = 80; + sprite->data[0] = value2; + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0); + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = sprite->pos1.x; + sprite->pos1.y += sprite->pos2.y; + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = sprite->pos1.y + 29; + sprite->data[7]++; + if (!IsContest() && gBattlerPositions[gBattleAnimTarget] & 1) + sprite->data[5] = 204; + else + sprite->data[5] = value2; + + sprite->pos2.y = 0; + value = gSineTable[sprite->data[5]]; + sprite->pos2.x = value >> 3; + sprite->data[5] = (sprite->data[5] + 2) & 0xFF; + InitAnimLinearTranslation(sprite); + } + break; + case 1: + AnimTranslateLinear(sprite); + value = gSineTable[sprite->data[5]]; + sprite->pos2.x += value >> 3; + sprite->pos2.y += (gSineTable[sprite->data[5] + 0x40] * -3) >> 8; + if (!IsContest()) + { + u16 var0 = sprite->data[5] - 0x40; + if (var0 <= 0x7F) + sprite->oam.priority = sprite->data[7] >> 8; + else + sprite->oam.priority = (sprite->data[7] >> 8) + 1; + + sprite->data[5] = (sprite->data[5] + 4) & 0xFF; + } + else + { + u16 var0 = sprite->data[5] - 0x40; + if (var0 <= 0x7F) + sprite->subpriority = 128; + else + sprite->subpriority = 140; + + sprite->data[5] = (sprite->data[5] - 4) & 0xFF; + } + + if (sprite->data[0] <= 0) + { + asm("mov r5, #0"); // unused local variable? + unused = 0; + sprite->data[0] = 0x300; + sprite->data[1] = sprite->pos1.x += sprite->pos2.x; + sprite->data[3] = sprite->pos1.y += sprite->pos2.y; + sprite->data[4] = sprite->pos1.y + 4; + if (!IsContest() && gBattlerPositions[gBattleAnimTarget] & 1) + sprite->data[2] = 0x100; + else + sprite->data[2] = -0x10; + + sprite->data[7]++; + sprite->pos2.x = sprite->pos2.y = 0; + sub_80A6FD4(sprite); + } + break; + case 2: + if (AnimTranslateLinear(sprite)) + { + if (sprite->oam.affineMode & 1) + { + FreeOamMatrix(sprite->oam.matrixNum); + sprite->oam.affineMode = ST_OAM_AFFINE_OFF; + } + + DestroySprite(sprite); + gAnimVisualTaskCount--; + } + break; + } +} + +// Creates Hail. +void AnimTask_Hail1(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->func = AnimTask_Hail2; +} + +void AnimTask_Hail2(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + switch (task->data[0]) + { + case 0: + if (++task->data[4] > 2) + { + task->data[4] = 0; + task->data[5] = 0; + task->data[2] = 0; + task->data[0]++; + } + break; + case 1: + if (task->data[5] == 0) + { + if (GenerateHailParticle(task->data[3], task->data[2], taskId, 1)) + task->data[1]++; + + if (++task->data[2] == 3) + { + if (++task->data[3] == 10) + task->data[0]++; + else + task->data[0]--; + } + else + { + task->data[5] = 1; + } + + } + else + { + task->data[5]--; + } + break; + case 2: + if (task->data[1] == 0) + DestroyAnimVisualTask(taskId); + break; + } +} + +#ifdef NONMATCHING +bool8 GenerateHailParticle(u8 a, u8 b, u8 taskId, u8 c) +{ + bool8 possibleBool = FALSE; + // s8 unk = gUnknown_08595CB4[a].unk3; + const struct HailStruct *hailData = &gUnknown_08595CB4[a]; + s8 unk = hailData->unk3; + u8 battler; + s16 battlerX, battlerY; + u8 spriteId; + // struct Sprite *sprite; + s16 spriteX; + + if (unk != 2) + { + battler = GetBattlerAtPosition(hailData->unk2); + if (IsBattlerSpriteVisible(battler)) + { + possibleBool = TRUE; + battlerX = GetBattlerSpriteCoord(battler, 2); + battlerY = GetBattlerSpriteCoord(battler, 3); + switch (unk) + { + case 0: + battlerX -= sub_80A861C(battler, 1) / 6; + battlerY -= sub_80A861C(battler, 0) / 6; + break; + case 1: + battlerX += sub_80A861C(battler, 1) / 6; + battlerY += sub_80A861C(battler, 0) / 6; + break; + } + } + } + else + { + battlerX = (hailData->unk0); + battlerY = (hailData->unk1); + } + spriteX = battlerX - ((battlerY + 8) / 2); + spriteId = CreateSprite(&gUnknown_08595D2C, spriteX, -8, 18); + if (spriteId == MAX_SPRITES) + return FALSE; + // sprite = &gSprites[spriteId]; + StartSpriteAffineAnim(&gSprites[spriteId], b); + gSprites[spriteId].data[0] = possibleBool; + gSprites[spriteId].data[3] = battlerX; + gSprites[spriteId].data[4] = battlerY; + gSprites[spriteId].data[5] = b; + gSprites[spriteId].data[6] = taskId; + gSprites[spriteId].data[7] = c; + return TRUE; +} +#else +NAKED +bool8 GenerateHailParticle(u8 a, u8 b, u8 taskId, u8 c) +{ + asm_unified("push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x8\n\ + lsls r0, 24\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r9, r1\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + str r2, [sp]\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + mov r10, r3\n\ + movs r1, 0\n\ + str r1, [sp, 0x4]\n\ + ldr r1, =gUnknown_08595CB4\n\ + lsrs r0, 22\n\ + adds r4, r0, r1\n\ + ldrb r0, [r4, 0x3]\n\ + lsls r0, 24\n\ + asrs r0, 28\n\ + mov r8, r0\n\ + cmp r0, 0x2\n\ + beq _0810CAD0\n\ + ldrh r0, [r4, 0x2]\n\ + lsls r0, 20\n\ + lsrs r0, 24\n\ + bl GetBattlerAtPosition\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + adds r0, r5, 0\n\ + bl IsBattlerSpriteVisible\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0810CAD0\n\ + movs r0, 0x1\n\ + str r0, [sp, 0x4]\n\ + adds r0, r5, 0\n\ + movs r1, 0x2\n\ + bl GetBattlerSpriteCoord\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + adds r0, r5, 0\n\ + movs r1, 0x3\n\ + bl GetBattlerSpriteCoord\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + mov r1, r8\n\ + cmp r1, 0\n\ + beq _0810CA60\n\ + cmp r1, 0x1\n\ + beq _0810CA96\n\ + b _0810CAE2\n\ + .pool\n\ +_0810CA60:\n\ + adds r0, r5, 0\n\ + movs r1, 0x1\n\ + bl sub_80A861C\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + movs r1, 0x6\n\ + bl __divsi3\n\ + lsls r1, r7, 16\n\ + asrs r1, 16\n\ + subs r1, r0\n\ + lsls r1, 16\n\ + lsrs r7, r1, 16\n\ + adds r0, r5, 0\n\ + movs r1, 0\n\ + bl sub_80A861C\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + movs r1, 0x6\n\ + bl __divsi3\n\ + lsls r1, r6, 16\n\ + asrs r1, 16\n\ + subs r1, r0\n\ + b _0810CACA\n\ +_0810CA96:\n\ + adds r0, r5, 0\n\ + movs r1, 0x1\n\ + bl sub_80A861C\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + movs r1, 0x6\n\ + bl __divsi3\n\ + lsls r1, r7, 16\n\ + asrs r1, 16\n\ + adds r1, r0\n\ + lsls r1, 16\n\ + lsrs r7, r1, 16\n\ + adds r0, r5, 0\n\ + movs r1, 0\n\ + bl sub_80A861C\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + movs r1, 0x6\n\ + bl __divsi3\n\ + lsls r1, r6, 16\n\ + asrs r1, 16\n\ + adds r1, r0\n\ +_0810CACA:\n\ + lsls r1, 16\n\ + lsrs r6, r1, 16\n\ + b _0810CAE2\n\ +_0810CAD0:\n\ + ldrh r0, [r4]\n\ + lsls r0, 22\n\ + asrs r0, 6\n\ + lsrs r7, r0, 16\n\ + ldr r0, [r4]\n\ + lsls r0, 12\n\ + asrs r0, 22\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ +_0810CAE2:\n\ + lsls r0, r6, 16\n\ + asrs r0, 16\n\ + adds r0, 0x8\n\ + lsrs r1, r0, 31\n\ + adds r0, r1\n\ + asrs r0, 1\n\ + lsls r1, r7, 16\n\ + asrs r1, 16\n\ + subs r1, r0\n\ + ldr r0, =gUnknown_08595D2C\n\ + lsls r1, 16\n\ + asrs r1, 16\n\ + movs r2, 0x8\n\ + negs r2, r2\n\ + movs r3, 0x12\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + cmp r5, 0x40\n\ + beq _0810CB44\n\ + lsls r4, r5, 4\n\ + adds r4, r5\n\ + lsls r4, 2\n\ + ldr r0, =gSprites\n\ + adds r4, r0\n\ + adds r0, r4, 0\n\ + mov r1, r9\n\ + bl StartSpriteAffineAnim\n\ + mov r0, sp\n\ + ldrh r0, [r0, 0x4]\n\ + strh r0, [r4, 0x2E]\n\ + strh r7, [r4, 0x34]\n\ + strh r6, [r4, 0x36]\n\ + mov r1, r9\n\ + strh r1, [r4, 0x38]\n\ + mov r0, sp\n\ + ldrh r0, [r0]\n\ + strh r0, [r4, 0x3A]\n\ + mov r1, r10\n\ + strh r1, [r4, 0x3C]\n\ + movs r0, 0x1\n\ + b _0810CB46\n\ + .pool\n\ +_0810CB44:\n\ + movs r0, 0\n\ +_0810CB46:\n\ + add sp, 0x8\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n"); +} +#endif + +void AnimHailBegin(struct Sprite *sprite) +{ + u8 spriteId; + + sprite->pos1.x += 4; + sprite->pos1.y += 8; + + if (sprite->pos1.x < sprite->data[3] && sprite->pos1.y < sprite->data[4]) + return; + + if (sprite->data[0] == 1 && sprite->data[5] == 0) + { + spriteId = CreateSprite(&gUnknown_08595B68, + sprite->data[3], sprite->data[4], sprite->subpriority); + + sprite->data[0] = spriteId; + if (spriteId != 64) + { + gSprites[sprite->data[0]].callback = AnimHailContinue; + gSprites[sprite->data[0]].data[6] = sprite->data[6]; + gSprites[sprite->data[0]].data[7] = sprite->data[7]; + } + + FreeOamMatrix(sprite->oam.matrixNum); + DestroySprite(sprite); + } + else + { + gTasks[sprite->data[6]].data[sprite->data[7]]--; + FreeOamMatrix(sprite->oam.matrixNum); + DestroySprite(sprite); + } +} + +void AnimHailContinue(struct Sprite *sprite) +{ + if (++sprite->data[0] == 20) + { + gTasks[sprite->data[6]].data[sprite->data[7]]--; + FreeOamMatrix(sprite->oam.matrixNum); + DestroySprite(sprite); + } +} + +// Initializes the animation for Ice Ball. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: target x offset +// arg 3: target y offset +// arg 4: duration +// arg 5: arc height (negative) +void InitIceBallAnim(struct Sprite *sprite) +{ + u8 animNum = gAnimDisableStructPtr->rolloutTimerStartValue - gAnimDisableStructPtr->rolloutTimer - 1; + + if (animNum > 4) + animNum = 4; + + StartSpriteAffineAnim(sprite, animNum); + InitSpritePosToAnimAttacker(sprite, 1); + + sprite->data[0] = gBattleAnimArgs[4]; + + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->data[5] = gBattleAnimArgs[5]; + + InitAnimArcTranslation(sprite); + + sprite->callback = AnimThrowIceBall; +} + +// Throws the ball of ice in Ice Ball. +void AnimThrowIceBall(struct Sprite *sprite) +{ + if (!TranslateAnimArc(sprite)) + return; + + StartSpriteAnim(sprite, 1); + sprite->callback = RunStoredCallbackWhenAnimEnds; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +// Initializes the particles that scatter at the end of the Ice Ball animation. +void InitIceBallParticle(struct Sprite *sprite) +{ + s16 randA, randB; + + sprite->oam.tileNum += 8; + InitSpritePosToAnimTarget(sprite, TRUE); + + randA = (Random2() & 0xFF) + 256; + randB = Random2() & 0x1FF; + + if (randB > 0xFF) + randB = 256 - randB; + + sprite->data[1] = randA; + sprite->data[2] = randB; + sprite->callback = AnimIceBallParticle; +} + +// Animates the particles created by InitIceBallParticle. +void AnimIceBallParticle(struct Sprite *sprite) +{ + sprite->data[3] += sprite->data[1]; + sprite->data[4] += sprite->data[2]; + + if (sprite->data[1] & 1) + sprite->pos2.x = -(sprite->data[3] >> 8); + else + sprite->pos2.x = sprite->data[3] >> 8; + + sprite->pos2.y = sprite->data[4] >> 8; + + if (++sprite->data[0] == 21) + DestroyAnimSprite(sprite); +} + +// Counter for Ice Ball. +void AnimTask_GetRolloutCounter(u8 taskId) +{ + u8 arg = gBattleAnimArgs[0]; + + gBattleAnimArgs[arg] = gAnimDisableStructPtr->rolloutTimerStartValue - gAnimDisableStructPtr->rolloutTimer - 1; + DestroyAnimVisualTask(taskId); +}