From 64832ff67e1027ed14909039a000904a460515b2 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Thu, 20 Dec 2018 16:20:34 -0500 Subject: [PATCH] start ice --- asm/ice.s | 1590 --------------------------------------- include/battle_anim.h | 4 + include/field_weather.h | 4 + include/graphics.h | 2 + ld_script.txt | 1 + src/ice.c | 801 ++++++++++++++++++++ 6 files changed, 812 insertions(+), 1590 deletions(-) diff --git a/asm/ice.s b/asm/ice.s index c882d22458..bc2be5815a 100644 --- a/asm/ice.s +++ b/asm/ice.s @@ -5,1596 +5,6 @@ .text - thumb_func_start sub_810B614 -sub_810B614: @ 810B614 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - ldr r0, =gUnknown_085956C0 - movs r2, 0x22 - ldrsh r1, [r4, r2] - movs r3, 0x24 - ldrsh r2, [r4, r3] - ldrh r3, [r4, 0x20] - lsls r3, 24 - lsrs r3, 24 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _0810B658 - ldr r3, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r3, 0 - adds r1, 0x1C - adds r1, r0, r1 - ldr r2, =sub_810B684 - str r2, [r1] - adds r0, r3 - strh r5, [r0, 0x3A] - movs r1, 0xA - strh r1, [r0, 0x3C] - ldrh r0, [r4, 0x1C] - adds r0, 0x1 - strh r0, [r4, 0x1C] -_0810B658: - ldrh r2, [r4, 0x24] - movs r0, 0x24 - ldrsh r1, [r4, r0] - movs r3, 0x26 - ldrsh r0, [r4, r3] - cmp r1, r0 - bge _0810B67C - adds r0, r2, 0 - adds r0, 0x20 - strh r0, [r4, 0x24] - movs r0, 0 - b _0810B67E - .pool -_0810B67C: - movs r0, 0x1 -_0810B67E: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_810B614 - - thumb_func_start sub_810B684 -sub_810B684: @ 810B684 - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _0810B6B8 - 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] - adds r0, r4, 0 - bl DestroySprite -_0810B6B8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810B684 - - thumb_func_start sub_810B6C4 -sub_810B6C4: @ 810B6C4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - adds r5, r0, 0 - ldrh r2, [r5, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - adds r1, 0x7 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r5, 0x4] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r3, r0, 24 - ldrb r0, [r4] - movs r1, 0x3 - str r3, [sp] - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x8] - strh r0, [r5, 0x2E] - ldrh r0, [r1] - ldr r3, [sp] - adds r0, r3 - strh r0, [r5, 0x30] - ldrh r0, [r1, 0x4] - mov r4, r9 - adds r0, r4, r0 - strh r0, [r5, 0x32] - ldrh r0, [r1, 0x2] - adds r0, r6 - strh r0, [r5, 0x34] - ldrh r0, [r1, 0x6] - mov r7, r8 - adds r0, r7, r0 - strh r0, [r5, 0x36] - adds r0, r5, 0 - bl sub_80A64EC - adds r4, 0x20 - movs r0, 0x98 - lsls r0, 1 - mov r12, r0 - ldr r3, [sp] - cmp r4, r12 - bhi _0810B79E - adds r0, r7, 0 - adds r0, 0x20 - ldrh r1, [r5, 0x30] - ldrh r2, [r5, 0x32] - cmp r0, 0xE0 - bhi _0810B79E - adds r4, r1, 0 - mov r10, r12 -_0810B76A: - mov r7, r9 - lsls r1, r7, 16 - asrs r1, 16 - adds r1, r4 - lsls r1, 16 - mov r7, r8 - lsls r0, r7, 16 - asrs r0, 16 - adds r0, r2 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsrs r0, r1, 16 - mov r9, r0 - movs r7, 0x80 - lsls r7, 14 - adds r1, r7 - lsrs r1, 16 - cmp r1, r10 - bhi _0810B79E - mov r1, r8 - lsls r0, r1, 16 - adds r0, r7 - lsrs r0, 16 - cmp r0, 0xE0 - bls _0810B76A -_0810B79E: - ldrh r0, [r5, 0x30] - negs r7, r0 - strh r7, [r5, 0x30] - ldrh r0, [r5, 0x32] - negs r4, r0 - strh r4, [r5, 0x32] - lsls r0, r3, 16 - movs r1, 0x80 - lsls r1, 14 - adds r0, r1 - lsrs r0, 16 - movs r2, 0x98 - lsls r2, 1 - mov r12, r2 - ldr r1, =gBattleAnimArgs - mov r10, r1 - cmp r0, r12 - bhi _0810B80A - lsls r1, r6, 16 - movs r2, 0x80 - lsls r2, 14 - adds r0, r1, r2 - b _0810B802 - .pool -_0810B7E0: - lsls r1, r3, 16 - asrs r1, 16 - adds r1, r7 - lsls r1, 16 - asrs r0, r2, 16 - adds r0, r4 - lsls r0, 16 - lsrs r6, r0, 16 - lsrs r3, r1, 16 - movs r0, 0x80 - lsls r0, 14 - adds r1, r0 - lsrs r1, 16 - cmp r1, r12 - bhi _0810B80A - lsls r1, r6, 16 - adds r0, r1, r0 -_0810B802: - lsrs r0, 16 - adds r2, r1, 0 - cmp r0, 0xE0 - bls _0810B7E0 -_0810B80A: - strh r3, [r5, 0x20] - strh r6, [r5, 0x22] - mov r1, r10 - ldrh r0, [r1, 0x8] - strh r0, [r5, 0x2E] - strh r3, [r5, 0x30] - mov r2, r9 - strh r2, [r5, 0x32] - strh r6, [r5, 0x34] - mov r3, r8 - strh r3, [r5, 0x36] - adds r0, r5, 0 - bl sub_80A64EC - mov r7, r10 - ldrh r0, [r7, 0xA] - strh r0, [r5, 0x34] - ldrh r0, [r7, 0xC] - strh r0, [r5, 0x36] - ldr r0, =sub_810B848 - str r0, [r5, 0x1C] - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810B6C4 - - thumb_func_start sub_810B848 -sub_810B848: @ 810B848 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0810B8A0 - ldrh r1, [r4, 0x30] - ldrh r2, [r4, 0x38] - adds r1, r2 - strh r1, [r4, 0x38] - ldrh r0, [r4, 0x32] - ldrh r2, [r4, 0x3A] - adds r0, r2 - strh r0, [r4, 0x3A] - strh r1, [r4, 0x24] - strh r0, [r4, 0x26] - movs r1, 0x3C - ldrsh r0, [r4, r1] - movs r2, 0x34 - ldrsh r1, [r4, r2] - bl Sin - ldrh r1, [r4, 0x24] - adds r0, r1 - strh r0, [r4, 0x24] - movs r2, 0x3C - ldrsh r0, [r4, r2] - movs r2, 0x34 - ldrsh r1, [r4, r2] - bl Sin - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x36] - ldrh r2, [r4, 0x3C] - adds r0, r2 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x3C] - ldrh r0, [r4, 0x2E] - subs r0, 0x1 - strh r0, [r4, 0x2E] - b _0810B8A6 -_0810B8A0: - adds r0, r4, 0 - bl DestroyAnimSprite -_0810B8A6: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810B848 - - thumb_func_start sub_810B8AC -sub_810B8AC: @ 810B8AC - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gBattleAnimArgs - ldrh r0, [r0] - strh r0, [r4, 0x2E] - movs r0, 0x3C - strh r0, [r4, 0x30] - movs r0, 0x9 - strh r0, [r4, 0x32] - movs r0, 0x1E - strh r0, [r4, 0x34] - movs r0, 0xFE - lsls r0, 8 - strh r0, [r4, 0x36] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - ldr r1, =TranslateSpriteInGrowingCircleOverDuration - str r1, [r4, 0x1C] - adds r0, r4, 0 - bl _call_via_r1 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810B8AC - - thumb_func_start sub_810B8EC -sub_810B8EC: @ 810B8EC - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x1 - bl InitSpritePosToAnimAttacker - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x32] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810B92C - ldr r0, =gBattleAnimArgs - ldrh r1, [r4, 0x32] - ldrh r0, [r0, 0x4] - subs r1, r0 - strh r1, [r4, 0x32] - b _0810B936 - .pool -_0810B92C: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x4] - ldrh r1, [r4, 0x32] - adds r0, r1 - strh r0, [r4, 0x32] -_0810B936: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - ldr r1, =gBattleAnimArgs - lsrs r0, 24 - ldrh r2, [r1, 0x6] - adds r0, r2 - strh r0, [r4, 0x36] - ldrh r0, [r1, 0x8] - strh r0, [r4, 0x2E] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =StartAnimLinearTranslation - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810B8EC - - thumb_func_start sub_810B974 -sub_810B974: @ 810B974 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gBattleAnimArgs - movs r1, 0x4 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _0810B990 - adds r0, r4, 0 - movs r1, 0x1 - bl InitSpritePosToAnimTarget - b _0810B9C6 - .pool -_0810B990: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - adds r2, r4, 0 - adds r2, 0x20 - adds r3, r4, 0 - adds r3, 0x22 - movs r1, 0x1 - bl SetAverageBattlerPositions - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810B9B6 - ldrh r0, [r5] - negs r0, r0 - strh r0, [r5] -_0810B9B6: - 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] -_0810B9C6: - ldr r1, =sub_810B9E8 - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =RunStoredCallbackWhenAffineAnimEnds - str r0, [r4, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810B974 - - thumb_func_start sub_810B9E8 -sub_810B9E8: @ 810B9E8 - push {lr} - adds r3, r0, 0 - movs r0, 0x3E - adds r0, r3 - mov r12, r0 - ldrb r2, [r0] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - mov r1, r12 - strb r0, [r1] - ldrh r0, [r3, 0x2E] - adds r0, 0x1 - strh r0, [r3, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x14 - bne _0810BA1E - adds r0, r3, 0 - bl DestroySpriteAndMatrix -_0810BA1E: - pop {r0} - bx r0 - thumb_func_end sub_810B9E8 - - thumb_func_start sub_810BA24 -sub_810BA24: @ 810BA24 - push {r4-r7,lr} - sub sp, 0x10 - adds r5, r0, 0 - movs r1, 0x1 - bl InitSpritePosToAnimAttacker - ldr r6, =gBattleAnimArgs - ldrh r0, [r6, 0x8] - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x20] - strh r0, [r5, 0x30] - ldrh r0, [r5, 0x22] - strh r0, [r5, 0x34] - movs r1, 0xA - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _0810BA74 - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x32] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r6, [r6, 0x6] - adds r0, r6 - strh r0, [r5, 0x36] - b _0810BA86 - .pool -_0810BA74: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - adds r2, r5, 0 - adds r2, 0x32 - adds r3, r5, 0 - adds r3, 0x36 - movs r1, 0x1 - bl SetAverageBattlerPositions -_0810BA86: - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810BAAC - ldr r0, =gBattleAnimArgs - ldrh r1, [r5, 0x32] - ldrh r0, [r0, 0x4] - subs r1, r0 - strh r1, [r5, 0x32] - b _0810BAB6 - .pool -_0810BAAC: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x4] - ldrh r2, [r5, 0x32] - adds r0, r2 - strh r0, [r5, 0x32] -_0810BAB6: - adds r7, r5, 0 - adds r7, 0x2E - adds r2, r7, 0 - mov r1, sp - movs r4, 0x7 -_0810BAC0: - ldrh r0, [r2] - strh r0, [r1] - adds r2, 0x2 - adds r1, 0x2 - subs r4, 0x1 - cmp r4, 0 - bge _0810BAC0 - adds r0, r5, 0 - bl InitAnimFastLinearTranslationWithSpeed - ldrh r0, [r5, 0x30] - movs r1, 0x1 - eors r0, r1 - strh r0, [r5, 0x30] - ldrh r0, [r5, 0x32] - eors r0, r1 - strh r0, [r5, 0x32] -_0810BAE2: - movs r0, 0x1 - strh r0, [r5, 0x2E] - adds r0, r5, 0 - bl AnimFastTranslateLinear - movs r0, 0x20 - ldrsh r1, [r5, r0] - movs r2, 0x24 - ldrsh r0, [r5, r2] - adds r1, r0 - adds r1, 0x10 - movs r0, 0x88 - lsls r0, 1 - cmp r1, r0 - bhi _0810BB16 - movs r0, 0x22 - ldrsh r1, [r5, r0] - movs r2, 0x26 - ldrsh r0, [r5, r2] - adds r1, r0 - cmp r1, 0xA0 - bgt _0810BB16 - movs r0, 0x10 - negs r0, r0 - cmp r1, r0 - bge _0810BAE2 -_0810BB16: - ldrh r0, [r5, 0x24] - ldrh r1, [r5, 0x20] - adds r0, r1 - movs r1, 0 - strh r0, [r5, 0x20] - ldrh r0, [r5, 0x26] - ldrh r2, [r5, 0x22] - adds r0, r2 - strh r0, [r5, 0x22] - strh r1, [r5, 0x26] - strh r1, [r5, 0x24] - ldr r6, =sub_80A718C - ldr r1, =sub_810BB60 - mov r3, sp - adds r2, r7, 0 - movs r4, 0x7 -_0810BB36: - ldrh r0, [r3] - strh r0, [r2] - adds r3, 0x2 - adds r2, 0x2 - subs r4, 0x1 - cmp r4, 0 - bge _0810BB36 - str r6, [r5, 0x1C] - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 - add sp, 0x10 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810BA24 - - thumb_func_start sub_810BB60 -sub_810BB60: @ 810BB60 - push {r4,r5,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x24] - ldrh r1, [r4, 0x20] - adds r0, r1 - movs r5, 0 - strh r0, [r4, 0x20] - ldrh r0, [r4, 0x26] - ldrh r2, [r4, 0x22] - adds r0, r2 - strh r0, [r4, 0x22] - strh r5, [r4, 0x26] - strh r5, [r4, 0x24] - movs r0, 0x80 - strh r0, [r4, 0x2E] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - ldr r1, =0x0000ffec - cmp r0, 0 - beq _0810BB90 - movs r1, 0x14 -_0810BB90: - movs r2, 0x2E - ldrsh r0, [r4, r2] - lsls r1, 16 - asrs r1, 16 - bl Sin - strh r0, [r4, 0x34] - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r1, 0xF - bl Cos - strh r0, [r4, 0x36] - strh r5, [r4, 0x38] - ldr r1, =sub_810BBC8 - str r1, [r4, 0x1C] - adds r0, r4, 0 - bl _call_via_r1 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810BB60 - - thumb_func_start sub_810BBC8 -sub_810BBC8: @ 810BBC8 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - ldr r1, =0x0000ffec - cmp r0, 0 - beq _0810BBDE - movs r1, 0x14 -_0810BBDE: - movs r2, 0x38 - ldrsh r0, [r4, r2] - cmp r0, 0x1F - bgt _0810BC24 - movs r2, 0x2E - ldrsh r0, [r4, r2] - lsls r1, 16 - asrs r1, 16 - bl Sin - ldrh r1, [r4, 0x34] - subs r0, r1 - strh r0, [r4, 0x24] - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r1, 0xF - bl Cos - ldrh r1, [r4, 0x36] - subs r0, r1 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x2E] - adds r0, 0x10 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x2E] - ldrh r0, [r4, 0x38] - adds r0, 0x1 - strh r0, [r4, 0x38] - b _0810BC42 - .pool -_0810BC24: - ldrh r0, [r4, 0x24] - ldrh r2, [r4, 0x20] - adds r0, r2 - movs r1, 0 - strh r0, [r4, 0x20] - ldrh r0, [r4, 0x26] - ldrh r2, [r4, 0x22] - adds r0, r2 - strh r0, [r4, 0x22] - strh r1, [r4, 0x26] - strh r1, [r4, 0x24] - strh r1, [r4, 0x36] - strh r1, [r4, 0x34] - ldr r0, =sub_810BC4C - str r0, [r4, 0x1C] -_0810BC42: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810BBC8 - - thumb_func_start sub_810BC4C -sub_810BC4C: @ 810BC4C - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x1 - strh r0, [r4, 0x2E] - adds r0, r4, 0 - bl AnimFastTranslateLinear - movs r1, 0x20 - ldrsh r0, [r4, r1] - movs r2, 0x24 - ldrsh r1, [r4, r2] - adds r0, r1 - adds r0, 0x10 - movs r1, 0x88 - lsls r1, 1 - cmp r0, r1 - bhi _0810BC88 - movs r1, 0x22 - ldrsh r0, [r4, r1] - movs r2, 0x26 - ldrsh r1, [r4, r2] - adds r1, r0, r1 - movs r0, 0x80 - lsls r0, 1 - cmp r1, r0 - bgt _0810BC88 - movs r0, 0x10 - negs r0, r0 - cmp r1, r0 - bge _0810BC8E -_0810BC88: - adds r0, r4, 0 - bl DestroyAnimSprite -_0810BC8E: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810BC4C - - thumb_func_start sub_810BC94 -sub_810BC94: @ 810BC94 - push {r4-r7,lr} - sub sp, 0x10 - adds r5, r0, 0 - movs r1, 0x1 - bl InitSpritePosToAnimAttacker - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x8] - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x20] - strh r0, [r5, 0x30] - ldrh r0, [r5, 0x22] - strh r0, [r5, 0x34] - movs r2, 0xE - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _0810BCE0 - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x32] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x36] - b _0810BCF2 - .pool -_0810BCE0: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - adds r2, r5, 0 - adds r2, 0x32 - adds r3, r5, 0 - adds r3, 0x36 - movs r1, 0x1 - bl SetAverageBattlerPositions -_0810BCF2: - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810BD1C - ldr r0, =gBattleAnimArgs - ldrh r1, [r5, 0x32] - ldrh r2, [r0, 0x4] - subs r1, r2 - strh r1, [r5, 0x32] - adds r1, r0, 0 - b _0810BD26 - .pool -_0810BD1C: - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - ldrh r2, [r5, 0x32] - adds r0, r2 - strh r0, [r5, 0x32] -_0810BD26: - ldrh r0, [r1, 0x6] - ldrh r1, [r5, 0x36] - adds r0, r1 - strh r0, [r5, 0x36] - adds r0, r5, 0 - bl InitAnimFastLinearTranslationWithSpeed - adds r7, r5, 0 - adds r7, 0x2E - adds r2, r7, 0 - mov r1, sp - movs r4, 0x7 -_0810BD3E: - ldrh r0, [r2] - strh r0, [r1] - adds r2, 0x2 - adds r1, 0x2 - subs r4, 0x1 - cmp r4, 0 - bge _0810BD3E - ldrh r0, [r5, 0x30] - movs r1, 0x1 - eors r0, r1 - strh r0, [r5, 0x30] - ldrh r0, [r5, 0x32] - eors r0, r1 - strh r0, [r5, 0x32] -_0810BD5A: - movs r0, 0x1 - strh r0, [r5, 0x2E] - adds r0, r5, 0 - bl AnimFastTranslateLinear - movs r2, 0x20 - ldrsh r1, [r5, r2] - movs r2, 0x24 - ldrsh r0, [r5, r2] - adds r1, r0 - adds r1, 0x10 - movs r0, 0x88 - lsls r0, 1 - cmp r1, r0 - bhi _0810BD8E - movs r0, 0x22 - ldrsh r1, [r5, r0] - movs r2, 0x26 - ldrsh r0, [r5, r2] - adds r1, r0 - cmp r1, 0xA0 - bgt _0810BD8E - movs r0, 0x10 - negs r0, r0 - cmp r1, r0 - bge _0810BD5A -_0810BD8E: - ldrh r0, [r5, 0x24] - ldrh r1, [r5, 0x20] - adds r0, r1 - movs r1, 0 - strh r0, [r5, 0x20] - ldrh r0, [r5, 0x26] - ldrh r2, [r5, 0x22] - adds r0, r2 - strh r0, [r5, 0x22] - strh r1, [r5, 0x26] - strh r1, [r5, 0x24] - ldr r1, =gBattleAnimArgs - ldr r6, =sub_810BDD8 - mov r3, sp - adds r2, r7, 0 - movs r4, 0x7 -_0810BDAE: - ldrh r0, [r3] - strh r0, [r2] - adds r3, 0x2 - adds r2, 0x2 - subs r4, 0x1 - cmp r4, 0 - bge _0810BDAE - ldrh r0, [r1, 0xA] - strh r0, [r5, 0x38] - ldrh r0, [r1, 0xC] - strh r0, [r5, 0x3A] - str r6, [r5, 0x1C] - add sp, 0x10 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810BC94 - - thumb_func_start sub_810BDD8 -sub_810BDD8: @ 810BDD8 - push {r4,lr} - adds r4, r0, 0 - bl AnimFastTranslateLinear - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0810BDEC - movs r0, 0x1 - strh r0, [r4, 0x2E] -_0810BDEC: - movs r2, 0x3C - ldrsh r0, [r4, r2] - movs r2, 0x38 - ldrsh r1, [r4, r2] - bl Sin - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x3A] - ldrh r2, [r4, 0x3C] - adds r0, r2 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x3C] - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _0810BE42 - movs r2, 0x20 - ldrsh r0, [r4, r2] - movs r2, 0x24 - ldrsh r1, [r4, r2] - adds r0, r1 - adds r0, 0x10 - movs r1, 0x88 - lsls r1, 1 - cmp r0, r1 - bhi _0810BE3C - movs r0, 0x22 - ldrsh r1, [r4, r0] - movs r2, 0x26 - ldrsh r0, [r4, r2] - adds r1, r0 - cmp r1, 0xA0 - bgt _0810BE3C - movs r0, 0x10 - negs r0, r0 - cmp r1, r0 - bge _0810BE42 -_0810BE3C: - adds r0, r4, 0 - bl DestroyAnimSprite -_0810BE42: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810BDD8 - - thumb_func_start sub_810BE48 -sub_810BE48: @ 810BE48 - push {r4,r5,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0810BEB4 - ldr r5, =gBattleAnimArgs - movs r1, 0x4 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _0810BE6C - adds r0, r4, 0 - movs r1, 0 - bl InitSpritePosToAnimTarget - b _0810BEA2 - .pool -_0810BE6C: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - adds r2, r4, 0 - adds r2, 0x20 - adds r3, r4, 0 - adds r3, 0x22 - movs r1, 0 - bl SetAverageBattlerPositions - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810BE92 - ldrh r0, [r5] - negs r0, r0 - strh r0, [r5] -_0810BE92: - 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] -_0810BEA2: - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - b _0810BEC8 - .pool -_0810BEB4: - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _0810BEC8 - adds r0, r4, 0 - bl DestroyAnimSprite -_0810BEC8: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_810BE48 - - thumb_func_start sub_810BED0 -sub_810BED0: @ 810BED0 - push {r4-r6,lr} - adds r5, r0, 0 - ldr r6, =gBattleAnimArgs - movs r1, 0x8 - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _0810BF40 - movs r1, 0xA - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _0810BEF4 - adds r0, r5, 0 - movs r1, 0 - bl InitSpritePosToAnimAttacker - b _0810BF32 - .pool -_0810BEF4: - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - adds r2, r5, 0 - adds r2, 0x20 - adds r3, r5, 0 - adds r3, 0x22 - movs r1, 0 - bl SetAverageBattlerPositions - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810BF20 - ldrh r0, [r5, 0x20] - ldrh r1, [r6] - subs r0, r1 - b _0810BF26 - .pool -_0810BF20: - ldrh r0, [r6] - ldrh r1, [r5, 0x20] - adds r0, r1 -_0810BF26: - strh r0, [r5, 0x20] - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x2] - ldrh r1, [r5, 0x22] - adds r0, r1 - strh r0, [r5, 0x22] -_0810BF32: - ldr r0, =gBattleAnimAttacker - b _0810BF90 - .pool -_0810BF40: - movs r1, 0xA - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _0810BF52 - adds r0, r5, 0 - movs r1, 0 - bl InitSpritePosToAnimTarget - b _0810BF8E -_0810BF52: - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - adds r2, r5, 0 - adds r2, 0x20 - adds r3, r5, 0 - adds r3, 0x22 - movs r1, 0 - bl SetAverageBattlerPositions - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810BF7C - ldrh r0, [r5, 0x20] - ldrh r1, [r6] - subs r0, r1 - b _0810BF82 - .pool -_0810BF7C: - ldrh r0, [r6] - ldrh r1, [r5, 0x20] - adds r0, r1 -_0810BF82: - strh r0, [r5, 0x20] - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x2] - ldrh r1, [r5, 0x22] - adds r0, r1 - strh r0, [r5, 0x22] -_0810BF8E: - ldr r0, =gBattleAnimTarget -_0810BF90: - ldrb r0, [r0] - strh r0, [r5, 0x3C] - ldr r0, =gBattleAnimArgs - movs r1, 0xA - ldrsh r0, [r0, r1] - cmp r0, 0 - beq _0810BFA8 - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - bne _0810BFB4 -_0810BFA8: - movs r0, 0x20 - b _0810BFB6 - .pool -_0810BFB4: - movs r0, 0x40 -_0810BFB6: - strh r0, [r5, 0x3A] - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _0810BFCC - ldrh r0, [r5, 0x22] - adds r0, 0x8 - strh r0, [r5, 0x22] -_0810BFCC: - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x6] - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x20] - strh r0, [r5, 0x30] - strh r0, [r5, 0x32] - ldrh r0, [r5, 0x22] - strh r0, [r5, 0x34] - ldrh r1, [r1, 0x4] - adds r0, r1 - strh r0, [r5, 0x36] - adds r0, r5, 0 - bl InitAnimLinearTranslation - movs r0, 0x40 - strh r0, [r5, 0x38] - ldr r1, =sub_810C008 - str r1, [r5, 0x1C] - adds r0, r5, 0 - bl _call_via_r1 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810BED0 - - thumb_func_start sub_810C008 -sub_810C008: @ 810C008 - push {r4,lr} - adds r4, r0, 0 - bl AnimTranslateLinear - lsls r0, 24 - cmp r0, 0 - bne _0810C092 - movs r1, 0x38 - ldrsh r0, [r4, r1] - movs r2, 0x3A - ldrsh r1, [r4, r2] - bl Sin - ldrh r1, [r4, 0x24] - adds r0, r1 - strh r0, [r4, 0x24] - movs r2, 0x38 - ldrsh r0, [r4, r2] - movs r1, 0x6 - negs r1, r1 - bl Cos - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x38] - subs r0, 0x40 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x7F - bhi _0810C064 - ldrh r0, [r4, 0x3C] - lsls r0, 24 - lsrs r0, 24 - bl GetBattlerSpriteBGPriority - movs r1, 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] - b _0810C086 -_0810C064: - ldrh r0, [r4, 0x3C] - lsls r0, 24 - lsrs r0, 24 - bl GetBattlerSpriteBGPriority - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x1 - movs r1, 0x3 - ands r0, r1 - lsls r0, 2 - ldrb r2, [r4, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - orrs r1, r0 - strb r1, [r4, 0x5] -_0810C086: - ldrh r0, [r4, 0x38] - adds r0, 0x3 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x38] - b _0810C098 -_0810C092: - adds r0, r4, 0 - bl DestroyAnimSprite -_0810C098: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810C008 - - thumb_func_start sub_810C0A0 -sub_810C0A0: @ 810C0A0 - 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 _0810C0E2 - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0x1 - bl SetAnimBgAttribute -_0810C0E2: - 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, =sub_810C164 - str r1, [r0] - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810C0A0 - - thumb_func_start sub_810C164 -sub_810C164: @ 810C164 - push {r4,r5,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gBattle_BG1_X - ldr r2, =0x0000ffff - adds r0, r2, 0 - ldrh r2, [r1] - adds r0, r2 - strh r0, [r1] - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r2, 0x20 - ldrsh r0, [r0, r2] - adds r2, r1, 0 - cmp r0, 0x4 - bls _0810C18E - b _0810C2DA -_0810C18E: - lsls r0, 2 - ldr r1, =_0810C1A8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0810C1A8: - .4byte _0810C1BC - .4byte _0810C214 - .4byte _0810C236 - .4byte _0810C27A - .4byte _0810C29C -_0810C1BC: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r4, r0, r2 - ldrh r0, [r4, 0x1C] - adds r0, 0x1 - movs r5, 0 - strh r0, [r4, 0x1C] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - beq _0810C1D6 - b _0810C2DA -_0810C1D6: - strh r5, [r4, 0x1C] - ldrh r0, [r4, 0x1A] - adds r0, 0x1 - strh r0, [r4, 0x1A] - ldr r1, =gUnknown_08595C5C - movs r2, 0x1A - ldrsh r0, [r4, r2] - adds r0, r1 - ldrb r1, [r0] - 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 r1, 0x1E - ldrsh r0, [r4, r1] - cmp r0, 0x9 - bne _0810C2DA - ldrh r0, [r4, 0x20] - adds r0, 0x1 - strh r0, [r4, 0x20] - strh r5, [r4, 0x1E] - b _0810C2DA - .pool -_0810C214: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r1, r0, r2 - ldrh r0, [r1, 0x1E] - adds r0, 0x1 - strh r0, [r1, 0x1E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x51 - bne _0810C2DA - movs r0, 0x9 - strh r0, [r1, 0x1E] - ldrh r0, [r1, 0x20] - adds r0, 0x1 - strh r0, [r1, 0x20] - b _0810C2DA -_0810C236: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r4, r0, r2 - ldrh r0, [r4, 0x1C] - adds r0, 0x1 - strh r0, [r4, 0x1C] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - bne _0810C2DA - 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 _0810C2DA - ldrh r0, [r4, 0x20] - adds r0, 0x1 - strh r0, [r4, 0x20] - strh r1, [r4, 0x1E] - b _0810C2DA -_0810C27A: - 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] -_0810C29C: - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810C2B0 - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0 - bl SetAnimBgAttribute -_0810C2B0: - 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 -_0810C2DA: - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810C164 - - thumb_func_start sub_810C2F0 -sub_810C2F0: @ 810C2F0 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gBattleAnimAttacker - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x20] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x22] - ldr r0, =TranslateAnimSpriteToTargetMonLocation - str r0, [r4, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810C2F0 - thumb_func_start sub_810C324 sub_810C324: @ 810C324 push {r4,r5,lr} diff --git a/include/battle_anim.h b/include/battle_anim.h index 1c2093da95..a8138b4ff8 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -172,6 +172,10 @@ void oamt_add_pos2_onto_pos1(struct Sprite *sprite); u8 GetBattlerSpriteDefault_Y(u8 battlerId); u8 GetSubstituteSpriteDefault_Y(u8 battlerId); +// battle_anim_80A64EC.c +void sub_80A64EC(struct Sprite *sprite); +void sub_80A718C(struct Sprite *sprite); + // battle_anim_80A9C70.s #define STAT_ANIM_PLUS1 15 #define STAT_ANIM_PLUS2 39 diff --git a/include/field_weather.h b/include/field_weather.h index c032183e15..91dcef1dc4 100644 --- a/include/field_weather.h +++ b/include/field_weather.h @@ -134,6 +134,10 @@ struct Weather // field_weather.c extern struct Weather gWeather; extern struct Weather *const gWeatherPtr; +extern const u16 gUnknown_083970E8[]; + +// field_weather_effect.c +extern const u8 gWeatherFog1Tiles[]; void StartWeather(void); void ChangeWeather(u8 weather); diff --git a/include/graphics.h b/include/graphics.h index d7bdf096e7..cab639f0e7 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4748,6 +4748,8 @@ extern const u32 gBattleAnimBackgroundImage_Surf[]; extern const u32 gBattleAnimBackgroundPalette_Surf[]; extern const u32 gBattleAnimBackgroundImageMuddyWater_Pal[]; +extern const u32 gBattleAnimFogTilemap[]; + // Berry blender extern const u32 gBerryBlenderArrowTiles[]; extern const u32 gBerryBlenderStartTiles[]; diff --git a/ld_script.txt b/ld_script.txt index 73fbc76bc7..c706804f6d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -162,6 +162,7 @@ SECTIONS { src/water.o(.text); src/fire.o(.text); src/electric.o(.text); + src/ice.o(.text); asm/ice.o(.text); src/fight.o(.text); src/poison.o(.text); diff --git a/src/ice.c b/src/ice.c index ebd0d3cf6d..be8255231d 100644 --- a/src/ice.c +++ b/src/ice.c @@ -1,21 +1,39 @@ #include "global.h" #include "battle_anim.h" +#include "bg.h" +#include "field_weather.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "palette.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "constants/battle_anim.h" #include "constants/rgb.h" +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 sub_80A8EE4(struct Sprite *); extern void unc_080B06FC(struct Sprite *); extern void sub_810CD4C(struct Sprite *); +void sub_810C164(u8); const union AnimCmd gUnknown_08595A48[] = { @@ -489,3 +507,786 @@ const struct SpriteTemplate gUnknown_08595DFC = .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_810CD4C, }; + +extern const struct SpriteTemplate gUnknown_085956C0; + +bool8 sub_810B614(struct Task *task, u8 taskId) +{ + u8 spriteId = CreateSprite(&gUnknown_085956C0, task->data[13], task->data[14], task->data[12]); + + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].callback = sub_810B684; + gSprites[spriteId].data[6] = taskId; + gSprites[spriteId].data[7] = 10; + task->data[10]++; + } + if (task->data[14] >= task->data[15]) + return TRUE; + task->data[14] += 32; + return FALSE; +} + +void sub_810B684(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + gTasks[sprite->data[6]].data[sprite->data[7]]--; + DestroySprite(sprite); + } +} + +// unused +#ifdef NONMATCHING +void sub_810B6C4(struct Sprite *sprite) +{ + s16 targetX, targetY, attackerX, attackerY; + s16 i; + + sprite->oam.tileNum += 7; + targetX = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + targetY = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + attackerX = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + attackerY = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[1] = gBattleAnimArgs[0] + attackerX; + sprite->data[2] = gBattleAnimArgs[2] + targetX; + sprite->data[3] = gBattleAnimArgs[1] + attackerY; + sprite->data[4] = gBattleAnimArgs[3] + targetY; + sub_80A64EC(sprite); + while ((targetX >= -32 && targetX <= 272) && (targetY >= -32 && targetY <= 192)) + { + targetX += sprite->data[1]; + targetY += sprite->data[2]; + } + sprite->data[1] = -sprite->data[1]; + sprite->data[2] = -sprite->data[2]; + while ((attackerX >= -32 && attackerX <= 272) && (attackerY >= -32 && attackerY <= 192)) + { + attackerX += sprite->data[1]; + attackerY += sprite->data[2]; + } + sprite->pos1.x = attackerX; + sprite->pos1.y = attackerY; + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[1] = attackerX; + sprite->data[2] = targetX; + sprite->data[3] = attackerY; + sprite->data[4] = targetY; + sub_80A64EC(sprite); + sprite->data[3] = gBattleAnimArgs[5]; + sprite->data[4] = gBattleAnimArgs[6]; + sprite->callback = sub_810B848; +} +#else +NAKED +void sub_810B6C4(struct Sprite *sprite) +{ + 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, 0x4\n\ + adds r5, r0, 0\n\ + ldrh r2, [r5, 0x4]\n\ + lsls r1, r2, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x7\n\ + ldr r3, =0x000003ff\n\ + adds r0, r3, 0\n\ + ands r1, r0\n\ + ldr r0, =0xfffffc00\n\ + ands r0, r2\n\ + orrs r0, r1\n\ + strh r0, [r5, 0x4]\n\ + ldr r4, =gBattleAnimTarget\n\ + ldrb r0, [r4]\n\ + movs r1, 0x2\n\ + bl GetBattlerSpriteCoord\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ + ldrb r0, [r4]\n\ + movs r1, 0x3\n\ + bl GetBattlerSpriteCoord\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + ldr r4, =gBattleAnimAttacker\n\ + ldrb r0, [r4]\n\ + movs r1, 0x2\n\ + bl GetBattlerSpriteCoord\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + ldrb r0, [r4]\n\ + movs r1, 0x3\n\ + str r3, [sp]\n\ + bl GetBattlerSpriteCoord\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + ldr r1, =gBattleAnimArgs\n\ + ldrh r0, [r1, 0x8]\n\ + strh r0, [r5, 0x2E]\n\ + ldrh r0, [r1]\n\ + ldr r3, [sp]\n\ + adds r0, r3\n\ + strh r0, [r5, 0x30]\n\ + ldrh r0, [r1, 0x4]\n\ + mov r4, r9\n\ + adds r0, r4, r0\n\ + strh r0, [r5, 0x32]\n\ + ldrh r0, [r1, 0x2]\n\ + adds r0, r6\n\ + strh r0, [r5, 0x34]\n\ + ldrh r0, [r1, 0x6]\n\ + mov r7, r8\n\ + adds r0, r7, r0\n\ + strh r0, [r5, 0x36]\n\ + adds r0, r5, 0\n\ + bl sub_80A64EC\n\ + adds r4, 0x20\n\ + movs r0, 0x98\n\ + lsls r0, 1\n\ + mov r12, r0\n\ + ldr r3, [sp]\n\ + cmp r4, r12\n\ + bhi _0810B79E\n\ + adds r0, r7, 0\n\ + adds r0, 0x20\n\ + ldrh r1, [r5, 0x30]\n\ + ldrh r2, [r5, 0x32]\n\ + cmp r0, 0xE0\n\ + bhi _0810B79E\n\ + adds r4, r1, 0\n\ + mov r10, r12\n\ +_0810B76A:\n\ + mov r7, r9\n\ + lsls r1, r7, 16\n\ + asrs r1, 16\n\ + adds r1, r4\n\ + lsls r1, 16\n\ + mov r7, r8\n\ + lsls r0, r7, 16\n\ + asrs r0, 16\n\ + adds r0, r2\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r8, r0\n\ + lsrs r0, r1, 16\n\ + mov r9, r0\n\ + movs r7, 0x80\n\ + lsls r7, 14\n\ + adds r1, r7\n\ + lsrs r1, 16\n\ + cmp r1, r10\n\ + bhi _0810B79E\n\ + mov r1, r8\n\ + lsls r0, r1, 16\n\ + adds r0, r7\n\ + lsrs r0, 16\n\ + cmp r0, 0xE0\n\ + bls _0810B76A\n\ +_0810B79E:\n\ + ldrh r0, [r5, 0x30]\n\ + negs r7, r0\n\ + strh r7, [r5, 0x30]\n\ + ldrh r0, [r5, 0x32]\n\ + negs r4, r0\n\ + strh r4, [r5, 0x32]\n\ + lsls r0, r3, 16\n\ + movs r1, 0x80\n\ + lsls r1, 14\n\ + adds r0, r1\n\ + lsrs r0, 16\n\ + movs r2, 0x98\n\ + lsls r2, 1\n\ + mov r12, r2\n\ + ldr r1, =gBattleAnimArgs\n\ + mov r10, r1\n\ + cmp r0, r12\n\ + bhi _0810B80A\n\ + lsls r1, r6, 16\n\ + movs r2, 0x80\n\ + lsls r2, 14\n\ + adds r0, r1, r2\n\ + b _0810B802\n\ + .pool\n\ +_0810B7E0:\n\ + lsls r1, r3, 16\n\ + asrs r1, 16\n\ + adds r1, r7\n\ + lsls r1, 16\n\ + asrs r0, r2, 16\n\ + adds r0, r4\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + lsrs r3, r1, 16\n\ + movs r0, 0x80\n\ + lsls r0, 14\n\ + adds r1, r0\n\ + lsrs r1, 16\n\ + cmp r1, r12\n\ + bhi _0810B80A\n\ + lsls r1, r6, 16\n\ + adds r0, r1, r0\n\ +_0810B802:\n\ + lsrs r0, 16\n\ + adds r2, r1, 0\n\ + cmp r0, 0xE0\n\ + bls _0810B7E0\n\ +_0810B80A:\n\ + strh r3, [r5, 0x20]\n\ + strh r6, [r5, 0x22]\n\ + mov r1, r10\n\ + ldrh r0, [r1, 0x8]\n\ + strh r0, [r5, 0x2E]\n\ + strh r3, [r5, 0x30]\n\ + mov r2, r9\n\ + strh r2, [r5, 0x32]\n\ + strh r6, [r5, 0x34]\n\ + mov r3, r8\n\ + strh r3, [r5, 0x36]\n\ + adds r0, r5, 0\n\ + bl sub_80A64EC\n\ + mov r7, r10\n\ + ldrh r0, [r7, 0xA]\n\ + strh r0, [r5, 0x34]\n\ + ldrh r0, [r7, 0xC]\n\ + strh r0, [r5, 0x36]\n\ + ldr r0, =sub_810B848\n\ + str r0, [r5, 0x1C]\n\ + add sp, 0x4\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n"); +} +#endif + +void sub_810B848(struct Sprite *sprite) +{ + if (sprite->data[0] != 0) + { + sprite->data[5] += sprite->data[1]; + sprite->data[6] += sprite->data[2]; + sprite->pos2.x = sprite->data[5]; + sprite->pos2.y = sprite->data[6]; + sprite->pos2.x += Sin(sprite->data[7], sprite->data[3]); + sprite->pos2.y += Sin(sprite->data[7], sprite->data[3]); + sprite->data[7] = (sprite->data[7] + sprite->data[4]) & 0xFF; + sprite->data[0]--; + } + else + { + DestroyAnimSprite(sprite); + } +} + +// Animates the swirling ice crystals in Ice Punch. +// arg 0: initial position angle around circle (0-256) +void sub_810B8AC(struct Sprite *sprite) +{ + sprite->data[0] = gBattleAnimArgs[0]; + sprite->data[1] = 60; + sprite->data[2] = 9; + sprite->data[3] = 30; + sprite->data[4] = -512; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); + sprite->callback = TranslateSpriteInGrowingCircleOverDuration; + sprite->callback(sprite); +} + +// Animates the ice particles in Ice Beam. +// 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 +void sub_810B8EC(struct Sprite *sprite) +{ + InitSpritePosToAnimAttacker(sprite, TRUE); + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + sprite->data[2] -= gBattleAnimArgs[2]; + else + sprite->data[2] += gBattleAnimArgs[2]; + + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + sprite->data[0] = gBattleAnimArgs[4]; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); + sprite->callback = StartAnimLinearTranslation; +} + +// Animates the ice crystals at the end of Ice Punch, Ice Beam, Tri Attack, +// Weather Ball (Hail), Blizzard, and Powder Snow. +// arg 0: target x offset +// arg 1: target y offset +// arg 2: ??? unknown boolean +void sub_810B974(struct Sprite *sprite) +{ + if (gBattleAnimArgs[2] == 0) + { + InitSpritePosToAnimTarget(sprite, TRUE); + } + else + { + SetAverageBattlerPositions(gBattleAnimTarget, 1, &sprite->pos1.x, &sprite->pos1.y); + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + } + + StoreSpriteCallbackInData6(sprite, sub_810B9E8); + sprite->callback = RunStoredCallbackWhenAffineAnimEnds; +} + +void sub_810B9E8(struct Sprite *sprite) +{ + sprite->invisible ^= 1; + sprite->data[0] += 1; + if (sprite->data[0] == 20) + DestroySpriteAndMatrix(sprite); +} + +// Animates the small snowballs that swirl around the target in Blizzard and Icy Wind. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: target x offset +// arg 3: target y offset +// arg 4: particle speed +// arg 5: multiple targets? (boolean) +void sub_810BA24(struct Sprite *sprite) +{ + int i; + s16 tempDataHolder[8]; + + InitSpritePosToAnimAttacker(sprite, TRUE); + + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[1] = sprite->pos1.x; + sprite->data[3] = sprite->pos1.y; + + if (!gBattleAnimArgs[5]) + { + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + } + else + { + SetAverageBattlerPositions(gBattleAnimTarget, 1, &sprite->data[2], &sprite->data[4]); + } + + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + sprite->data[2] -= gBattleAnimArgs[2]; + else + sprite->data[2] += gBattleAnimArgs[2]; + + for (i = 0; i < 8; i++) + tempDataHolder[i] = sprite->data[i]; + + InitAnimFastLinearTranslationWithSpeed(sprite); + sprite->data[1] ^= 1; + sprite->data[2] ^= 1; + + while (1) + { + sprite->data[0] = 1; + AnimFastTranslateLinear(sprite); + + if ((u32)(sprite->pos1.x + sprite->pos2.x + 16) > 272 + || sprite->pos1.y + sprite->pos2.y > 160 + || sprite->pos1.y + sprite->pos2.y < -16) + break; + } + + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + + for (i = 0; i < 8; i++) + sprite->data[i] = tempDataHolder[i]; + + sprite->callback = sub_80A718C; + StoreSpriteCallbackInData6(sprite, sub_810BB60); +} + +void sub_810BB60(struct Sprite *sprite) +{ + s16 tempVar; + + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + sprite->data[0] = 128; + + tempVar = GetBattlerSide(gBattleAnimAttacker) != 0 ? 20 : -20; + + 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(sprite); +} + +void sub_810BBC8(struct Sprite *sprite) +{ + s16 tempVar; + tempVar = GetBattlerSide(gBattleAnimAttacker) != 0 ? 20 : -20; + + if (sprite->data[5] <= 31) + { + sprite->pos2.x = Sin(sprite->data[0], tempVar) - sprite->data[3]; + sprite->pos2.y = Cos(sprite->data[0], 15) - sprite->data[4]; + sprite->data[0] = (sprite->data[0] + 16) & 0xFF; + sprite->data[5] += 1; + } + else + { + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + sprite->data[4] = 0; + sprite->data[3] = 0; + sprite->callback = sub_810BC4C; + } +} + +void sub_810BC4C(struct Sprite *sprite) +{ + sprite->data[0] = 1; + AnimFastTranslateLinear(sprite); + + if ((u32)(sprite->pos1.x + sprite->pos2.x + 16) > 272 + || sprite->pos1.y + sprite->pos2.y > 256 + || sprite->pos1.y + sprite->pos2.y < -16) + DestroyAnimSprite(sprite); +} + +// Moves particles towards the target mon and off the screen. Used to animate +// the large snowballs in Blizzard and the small snowballs in Powder Snow. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: target x offset +// arg 3: target y offset +// arg 4: speed +// arg 5: wave amplitude +// arg 6: wave frequency +// arg 7: multiple targets? (boolean) +void sub_810BC94(struct Sprite *sprite) +{ + int i; + s16 tempDataHolder[8]; + + InitSpritePosToAnimAttacker(sprite, TRUE); + + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[1] = sprite->pos1.x; + sprite->data[3] = sprite->pos1.y; + + if (!gBattleAnimArgs[7]) + { + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + } + else + { + SetAverageBattlerPositions(gBattleAnimTarget, 1, &sprite->data[2], &sprite->data[4]); + } + + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + sprite->data[2] -= gBattleAnimArgs[2]; + else + sprite->data[2] += gBattleAnimArgs[2]; + + sprite->data[4] += gBattleAnimArgs[3]; + InitAnimFastLinearTranslationWithSpeed(sprite); + for (i = 0; i < 8; i++) + tempDataHolder[i] = sprite->data[i]; + + sprite->data[1] ^= 1; + sprite->data[2] ^= 1; + + while (1) + { + sprite->data[0] = 1; + AnimFastTranslateLinear(sprite); + if ((u32)(sprite->pos1.x + sprite->pos2.x + 16) > 272 + || sprite->pos1.y + sprite->pos2.y > 160 + || sprite->pos1.y + sprite->pos2.y < -16) + break; + } + + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + + for (i = 0; i < 8; i++) + sprite->data[i] = tempDataHolder[i]; + + sprite->data[5] = gBattleAnimArgs[5]; + sprite->data[6] = gBattleAnimArgs[6]; + sprite->callback = sub_810BDD8; +} + +// Moves particles in a sine wave towards the target. +void sub_810BDD8(struct Sprite *sprite) +{ + AnimFastTranslateLinear(sprite); + if (sprite->data[0] == 0) + sprite->data[0] = 1; + + sprite->pos2.y += Sin(sprite->data[7], sprite->data[5]); + sprite->data[7] = (sprite->data[7] + sprite->data[6]) & 0xFF; + if (sprite->data[0] == 1) + { + if ((u32)(sprite->pos1.x + sprite->pos2.x + 16) > 272 + || sprite->pos1.y + sprite->pos2.y > 160 + || sprite->pos1.y + sprite->pos2.y < -16) + DestroyAnimSprite(sprite); + } +} + +// Animates the ice pilar wave used by Icy Wind. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: ??? unknown boolean +void sub_810BE48(struct Sprite *sprite) +{ + if (sprite->data[0] == 0) + { + if (gBattleAnimArgs[2] == 0) + { + InitSpritePosToAnimTarget(sprite, FALSE); + } + else + { + SetAverageBattlerPositions(gBattleAnimTarget, 0, &sprite->pos1.x, &sprite->pos1.y); + + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + } + + sprite->data[0]++; + } + else + { + if (sprite->animEnded) + DestroyAnimSprite(sprite); + } +} + +// Animates the fog that swirls around the mon in Mist and Smog. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: change in y pixels per rotation +// arg 3: duration +// arg 4: animate on opponent? (boolean) +// arg 5: ??? unknown boolean +void sub_810BED0(struct Sprite *sprite) +{ + s16 tempVar; + u8 battler; + + if (gBattleAnimArgs[4] == 0) + { + if (gBattleAnimArgs[5] == 0) + { + InitSpritePosToAnimAttacker(sprite, FALSE); + } + else + { + SetAverageBattlerPositions(gBattleAnimAttacker, 0, &sprite->pos1.x, &sprite->pos1.y); + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + sprite->pos1.x -= gBattleAnimArgs[0]; + else + sprite->pos1.x += gBattleAnimArgs[0]; + + sprite->pos1.y += gBattleAnimArgs[1]; + } + + battler = gBattleAnimAttacker; + } + else + { + if (gBattleAnimArgs[5] == 0) + { + InitSpritePosToAnimTarget(sprite, FALSE); + } + else + { + SetAverageBattlerPositions(gBattleAnimTarget, 0, &sprite->pos1.x, &sprite->pos1.y); + if (GetBattlerSide(gBattleAnimTarget) != B_SIDE_PLAYER) + sprite->pos1.x -= gBattleAnimArgs[0]; + else + sprite->pos1.x += gBattleAnimArgs[0]; + + sprite->pos1.y += gBattleAnimArgs[1]; + } + + battler = gBattleAnimTarget; + } + + sprite->data[7] = battler; + if (gBattleAnimArgs[5] == 0 || !IsDoubleBattle()) + tempVar = 0x20; + else + tempVar = 0x40; + + sprite->data[6] = tempVar; + if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) + sprite->pos1.y += 8; + + sprite->data[0] = gBattleAnimArgs[3]; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = sprite->pos1.x; + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = sprite->pos1.y + gBattleAnimArgs[2]; + + InitAnimLinearTranslation(sprite); + + sprite->data[5] = 64; + sprite->callback = sub_810C008; + sprite->callback(sprite); +} + +// Animates swirling fog initialized by InitSwirlingFogAnim. +void sub_810C008(struct Sprite *sprite) +{ + if (!AnimTranslateLinear(sprite)) + { + sprite->pos2.x += Sin(sprite->data[5], sprite->data[6]); + sprite->pos2.y += Cos(sprite->data[5], -6); + + if ((u16)(sprite->data[5] - 64) <= 0x7F) + sprite->oam.priority = GetBattlerSpriteBGPriority(sprite->data[7]); + else + sprite->oam.priority = GetBattlerSpriteBGPriority(sprite->data[7]) + 1; + + sprite->data[5] = (sprite->data[5] + 3) & 0xFF; + } + else + { + DestroyAnimSprite(sprite); + } +} + +// Fades mons to black and places foggy overlay in Haze. +void sub_810C0A0(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].func = sub_810C164; +} + +void sub_810C164(u8 taskId) +{ + struct UnknownAnimStruct2 subStruct; + + gBattle_BG1_X += -1; + gBattle_BG1_Y += 0; + + switch (gTasks[taskId].data[12]) + { + case 0: + if (++gTasks[taskId].data[10] == 4) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[9]++; + gTasks[taskId].data[11] = gUnknown_08595C5C[gTasks[taskId].data[9]]; + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[11], 16 - gTasks[taskId].data[11])); + if (gTasks[taskId].data[11] == 9) + { + gTasks[taskId].data[12]++; + gTasks[taskId].data[11] = 0; + } + } + break; + case 1: + if (++gTasks[taskId].data[11] == 0x51) + { + gTasks[taskId].data[11] = 9; + gTasks[taskId].data[12]++; + } + break; + case 2: + if (++gTasks[taskId].data[10] == 4) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[11]--; + + 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); + } +} + +// Throws the ball in Mist Ball. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: targey x offset +// arg 3: target y offset +// arg 4: duration +// arg 5: ??? unknown (seems to vibrate target mon somehow) +void sub_810C2F0(struct Sprite *sprite) +{ + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + sprite->callback = TranslateAnimSpriteToTargetMonLocation; +}