diff --git a/asm/bug.s b/asm/bug.s deleted file mode 100644 index 0b26a3001..000000000 --- a/asm/bug.s +++ /dev/null @@ -1,791 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8110368 -sub_8110368: @ 8110368 - push {r4-r6,lr} - adds r6, r0, 0 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _08110394 - adds r0, r6, 0 - movs r1, 0x2 - bl StartSpriteAffineAnim - ldr r0, =gBattleAnimArgs - ldrh r1, [r0, 0x4] - negs r1, r1 - strh r1, [r0, 0x4] - ldrh r1, [r0] - negs r1, r1 - strh r1, [r0] - b _081103C4 - .pool -_08110394: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _081103C4 - adds r0, r6, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x2] - negs r0, r0 - strh r0, [r1, 0x2] - ldrh r0, [r1, 0x4] - negs r0, r0 - strh r0, [r1, 0x4] - ldrh r0, [r1, 0x6] - negs r0, r0 - strh r0, [r1, 0x6] - ldrh r0, [r1] - negs r0, r0 - strh r0, [r1] -_081103C4: - ldr r5, =gBattleAnimTarget - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord2 - lsls r0, 24 - ldr r4, =gBattleAnimArgs - lsrs r0, 24 - ldrh r1, [r4] - adds r0, r1 - strh r0, [r6, 0x20] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord2 - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x2] - adds r0, r1 - strh r0, [r6, 0x22] - ldrh r0, [r4, 0x8] - strh r0, [r6, 0x2E] - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x4] - adds r0, r1 - strh r0, [r6, 0x32] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r4, [r4, 0x6] - adds r0, r4 - strh r0, [r6, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r6, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r6, 0 - bl StoreSpriteCallbackInData6 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8110368 - - thumb_func_start sub_8110438 -sub_8110438: @ 8110438 - push {r4-r6,lr} - adds r6, r0, 0 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0811045C - ldr r1, =gBattleAnimArgs - ldrh r0, [r1] - negs r0, r0 - strh r0, [r1] - adds r0, r6, 0 - movs r1, 0x2 - bl StartSpriteAffineAnim - b _08110478 - .pool -_0811045C: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _08110478 - ldr r0, =gBattleAnimArgs - ldrh r1, [r0, 0x2] - negs r1, r1 - strh r1, [r0, 0x2] - ldrh r1, [r0] - negs r1, r1 - strh r1, [r0] -_08110478: - ldr r5, =gBattleAnimTarget - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord2 - lsls r0, 24 - ldr r4, =gBattleAnimArgs - lsrs r0, 24 - ldrh r1, [r4] - adds r0, r1 - strh r0, [r6, 0x20] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord2 - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x2] - adds r0, r1 - strh r0, [r6, 0x22] - ldrh r0, [r4, 0x4] - strh r0, [r6, 0x2E] - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x32] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r6, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r6, 0 - bl StoreSpriteCallbackInData6 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8110438 - - thumb_func_start sub_81104E4 -sub_81104E4: @ 81104E4 - push {r4,r5,lr} - adds r5, r0, 0 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _08110500 - ldr r0, =gBattleAnimArgs - movs r2, 0x4 - ldrsh r1, [r0, r2] - lsrs r2, r1, 31 - adds r1, r2 - asrs r1, 1 - strh r1, [r0, 0x4] -_08110500: - adds r0, r5, 0 - movs r1, 0x1 - bl InitAnimSpritePos - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x20] - strh r0, [r5, 0x30] - ldrh r0, [r5, 0x22] - strh r0, [r5, 0x34] - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _08110548 - 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 _0811055A - .pool -_08110548: - 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 -_0811055A: - adds r0, r5, 0 - bl sub_80A6FD4 - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x6] - strh r0, [r5, 0x38] - ldr r0, =sub_811057C - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81104E4 - - thumb_func_start sub_811057C -sub_811057C: @ 811057C - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimLinear - lsls r0, 24 - cmp r0, 0 - beq _08110592 - adds r0, r4, 0 - bl DestroyAnimSprite - b _081105AE -_08110592: - movs r1, 0x3A - ldrsh r0, [r4, r1] - movs r2, 0x38 - ldrsh r1, [r4, r2] - bl Sin - ldrh r1, [r4, 0x24] - adds r0, r1 - strh r0, [r4, 0x24] - ldrh r0, [r4, 0x3A] - adds r0, 0xD - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x3A] -_081105AE: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_811057C - - thumb_func_start sub_81105B4 -sub_81105B4: @ 81105B4 - push {r4,lr} - adds r4, r0, 0 - 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 _081105F0 - ldr r0, =gBattleAnimArgs - ldrh r1, [r4, 0x20] - ldrh r2, [r0] - subs r1, r2 - strh r1, [r4, 0x20] - b _081105FC - .pool -_081105F0: - ldr r1, =gBattleAnimArgs - ldrh r0, [r1] - ldrh r2, [r4, 0x20] - adds r0, r2 - strh r0, [r4, 0x20] - adds r0, r1, 0 -_081105FC: - ldrh r0, [r0, 0x2] - ldrh r1, [r4, 0x22] - adds r0, r1 - strh r0, [r4, 0x22] - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _08110618 - ldrh r0, [r4, 0x22] - adds r0, 0x8 - strh r0, [r4, 0x22] -_08110618: - ldr r0, =sub_8110630 - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81105B4 - - thumb_func_start sub_8110630 -sub_8110630: @ 8110630 - push {lr} - adds r3, r0, 0 - ldrh r0, [r3, 0x2E] - adds r0, 0x1 - strh r0, [r3, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3 - bne _08110664 - movs r0, 0 - strh r0, [r3, 0x2E] - 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] -_08110664: - ldrh r0, [r3, 0x30] - adds r0, 0x1 - strh r0, [r3, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x33 - bne _08110678 - adds r0, r3, 0 - bl DestroyAnimSprite -_08110678: - pop {r0} - bx r0 - thumb_func_end sub_8110630 - - thumb_func_start sub_811067C -sub_811067C: @ 811067C - push {r4,lr} - adds r4, r0, 0 - movs r1, 0xFD - lsls r1, 6 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - movs r0, 0x10 - strh r0, [r4, 0x2E] - ldr r0, =sub_81106A4 - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811067C - - thumb_func_start sub_81106A4 -sub_81106A4: @ 81106A4 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x32] - movs r2, 0x32 - ldrsh r0, [r4, r2] - cmp r0, 0x13 - bgt _081106B8 - adds r0, r1, 0x1 - strh r0, [r4, 0x32] - b _081106F6 -_081106B8: - ldrh r1, [r4, 0x30] - adds r0, r1, 0x1 - strh r0, [r4, 0x30] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081106F6 - ldrh r1, [r4, 0x2E] - subs r1, 0x1 - strh r1, [r4, 0x2E] - 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, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081106F6 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r0, =sub_8110700 - str r0, [r4, 0x1C] -_081106F6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81106A4 - - thumb_func_start sub_8110700 -sub_8110700: @ 8110700 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - adds r0, r4, 0 - bl DestroyAnimSprite - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8110700 - - thumb_func_start sub_8110720 -sub_8110720: @ 8110720 - push {r4-r7,lr} - sub sp, 0x4 - adds r7, r0, 0 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _08110740 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - negs r0, r0 - strh r0, [r1, 0x4] - b _08110762 - .pool -_08110740: - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08110762 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - negs r0, r0 - strh r0, [r1, 0x4] - ldrh r0, [r1, 0x2] - negs r0, r0 - strh r0, [r1, 0x2] - ldrh r0, [r1, 0x6] - negs r0, r0 - strh r0, [r1, 0x6] -_08110762: - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _081107B2 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - adds r4, r0, 0 - ldr r5, =gBattleAnimTarget - ldrb r0, [r5] - bl GetBattlerSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _081107B2 - ldrb r0, [r5] - bl GetBattlerPosition - lsls r0, 24 - cmp r0, 0 - beq _081107A0 - ldrb r0, [r5] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081107B2 -_081107A0: - ldr r0, =gBattleAnimArgs - movs r2, 0x4 - ldrsh r1, [r0, r2] - negs r1, r1 - strh r1, [r0, 0x4] - movs r2, 0 - ldrsh r1, [r0, r2] - negs r1, r1 - strh r1, [r0] -_081107B2: - adds r0, r7, 0 - movs r1, 0x1 - bl InitAnimSpritePos - ldr r5, =gBattleAnimTarget - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - adds r4, r0, 0 - lsls r4, 24 - ldr r6, =gBattleAnimArgs - lsrs r4, 24 - ldrh r0, [r6, 0x4] - adds r4, r0 - lsls r4, 16 - lsrs r4, 16 - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r6, 0x6] - adds r1, r2 - lsls r1, 16 - ldrh r2, [r7, 0x20] - lsls r0, r4, 16 - asrs r0, 16 - subs r0, r2 - lsls r0, 16 - asrs r0, 16 - ldrh r2, [r7, 0x22] - lsrs r5, r1, 16 - asrs r1, 16 - subs r1, r2 - lsls r1, 16 - asrs r1, 16 - bl ArcTan2Neg - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 24 - adds r0, r1 - lsrs r0, 16 - movs r3, 0x80 - lsls r3, 1 - str r0, [sp] - adds r0, r7, 0 - movs r1, 0 - adds r2, r3, 0 - bl sub_80A73E0 - ldrh r0, [r6, 0x8] - strh r0, [r7, 0x2E] - strh r4, [r7, 0x32] - strh r5, [r7, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r7, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r7, 0 - bl StoreSpriteCallbackInData6 - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8110720 - - thumb_func_start sub_8110850 -sub_8110850: @ 8110850 - push {r4-r6,lr} - adds r6, r0, 0 - movs r1, 0x1 - bl InitAnimSpritePos - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08110870 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - negs r0, r0 - strh r0, [r1, 0x4] -_08110870: - ldr r4, =gBattleAnimArgs - ldrh r0, [r4, 0x8] - strh r0, [r6, 0x2E] - ldr r5, =gBattleAnimTarget - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x4] - adds r0, r1 - strh r0, [r6, 0x32] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x6] - adds r0, r1 - strh r0, [r6, 0x36] - ldrh r0, [r4, 0xA] - strh r0, [r6, 0x38] - adds r0, r6, 0 - bl InitAnimArcTranslation - ldr r0, =sub_81108CC - str r0, [r6, 0x1C] - adds r2, r6, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8110850 - - thumb_func_start sub_81108CC -sub_81108CC: @ 81108CC - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x14 - adds r4, r0, 0 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x5 - negs r1, r1 - ands r1, r0 - strb r1, [r2] - adds r0, r4, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _081108F8 - adds r0, r4, 0 - bl DestroyAnimSprite - b _08110988 -_081108F8: - movs r0, 0x2E - adds r0, r4 - mov r8, r0 - ldrh r7, [r4, 0x20] - ldrh r5, [r4, 0x24] - ldrh r1, [r4, 0x22] - mov r12, r1 - ldrh r6, [r4, 0x26] - mov r2, r8 - add r1, sp, 0x4 - movs r3, 0x7 -_0811090E: - ldrh r0, [r2] - strh r0, [r1] - adds r2, 0x2 - adds r1, 0x2 - subs r3, 0x1 - cmp r3, 0 - bge _0811090E - adds r0, r7, r5 - lsls r0, 16 - lsrs r5, r0, 16 - mov r2, r12 - adds r0, r2, r6 - lsls r0, 16 - lsrs r6, r0, 16 - adds r0, r4, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - bne _08110988 - ldrh r0, [r4, 0x24] - ldrh r1, [r4, 0x20] - adds r0, r1 - lsls r1, r5, 16 - asrs r1, 16 - subs r0, r1 - lsls r0, 16 - asrs r0, 16 - ldrh r1, [r4, 0x26] - ldrh r2, [r4, 0x22] - adds r1, r2 - lsls r2, r6, 16 - asrs r2, 16 - subs r1, r2 - lsls r1, 16 - asrs r1, 16 - bl ArcTan2Neg - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 24 - adds r0, r1 - lsrs r0, 16 - movs r3, 0x80 - lsls r3, 1 - str r0, [sp] - adds r0, r4, 0 - movs r1, 0 - adds r2, r3, 0 - bl sub_80A73E0 - add r2, sp, 0x4 - mov r1, r8 - movs r3, 0x7 -_0811097A: - ldrh r0, [r2] - strh r0, [r1] - adds r2, 0x2 - adds r1, 0x2 - subs r3, 0x1 - cmp r3, 0 - bge _0811097A -_08110988: - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81108CC - - thumb_func_start sub_8110994 -sub_8110994: @ 8110994 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _081109B0 - ldr r4, =gBattleAnimAttacker - b _081109B2 - .pool -_081109B0: - ldr r4, =gBattleAnimTarget -_081109B2: - 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 - adds r0, 0x12 - strh r0, [r5, 0x22] - ldr r1, =move_anim_8074EE0 - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =sub_80A67BC - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8110994 - - .align 2, 0 diff --git a/include/battle_anim.h b/include/battle_anim.h index 2a6131117..52f4fdc22 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -84,6 +84,11 @@ void InitAnimArcTranslation(struct Sprite *sprite); bool8 TranslateAnimLinear(struct Sprite *sprite); void TranslateAnimSpriteToTargetMonLocation(struct Sprite *sprite); void sub_80A8EE4(struct Sprite *sprite); +u8 GetBattlerSpriteCoord2(u8 battlerId, u8 attributeId); +void sub_80A6FD4(struct Sprite *sprite); +u16 ArcTan2Neg(s16 a, s16 b); +void sub_80A73E0(struct Sprite *sprite, bool8 a2, s16 xScale, s16 yScale, u16 rotation); +void sub_80A67BC(struct Sprite *sprite); void sub_80A8278(void); void sub_80A6B30(struct UnknownAnimStruct2*); void sub_80A6B90(struct UnknownAnimStruct2*, u32 arg1); diff --git a/ld_script.txt b/ld_script.txt index 90b0bfbe2..6942c40a4 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -166,7 +166,7 @@ SECTIONS { asm/poison.o(.text); asm/flying.o(.text); asm/psychic.o(.text); - asm/bug.o(.text); + src/bug.o(.text); src/rock.o(.text); asm/ghost.o(.text); asm/dragon.o(.text); diff --git a/src/bug.c b/src/bug.c index a14ec2226..59b31b37d 100644 --- a/src/bug.c +++ b/src/bug.c @@ -1,15 +1,22 @@ #include "global.h" #include "battle_anim.h" +#include "gpu_regs.h" +#include "trig.h" #include "constants/rgb.h" -extern void sub_8110368(struct Sprite *); -extern void sub_8110438(struct Sprite *); -extern void sub_81104E4(struct Sprite *); -extern void sub_81105B4(struct Sprite *); -extern void sub_811067C(struct Sprite *); -extern void sub_8110720(struct Sprite *); -extern void sub_8110850(struct Sprite *); -extern void sub_8110994(struct Sprite *); +void sub_8110368(struct Sprite *); +void sub_8110438(struct Sprite *); +void sub_81104E4(struct Sprite *); +void sub_81105B4(struct Sprite *); +void sub_811067C(struct Sprite *); +void AnimTranslateStinger(struct Sprite *); +void AnimMissileArc(struct Sprite *); +void sub_8110994(struct Sprite *); +static void sub_811057C(struct Sprite *); +static void sub_8110630(struct Sprite *); +static void sub_81106A4(struct Sprite *); +static void sub_8110700(struct Sprite *); +static void AnimMissileArcStep(struct Sprite *); const union AffineAnimCmd gUnknown_08596938[] = { @@ -136,7 +143,7 @@ const struct SpriteTemplate gLinearStingerSpriteTemplate = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8110720, + .callback = AnimTranslateStinger, }; const struct SpriteTemplate gPinMissileSpriteTemplate = @@ -147,7 +154,7 @@ const struct SpriteTemplate gPinMissileSpriteTemplate = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8110850, + .callback = AnimMissileArc, }; const struct SpriteTemplate gIcicleSpearSpriteTemplate = @@ -158,7 +165,7 @@ const struct SpriteTemplate gIcicleSpearSpriteTemplate = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8110850, + .callback = AnimMissileArc, }; const union AffineAnimCmd gUnknown_08596A8C[] = @@ -187,3 +194,291 @@ const struct SpriteTemplate gUnknown_08596AC8 = .affineAnims = gUnknown_08596AC4, .callback = sub_8110994, }; + +void sub_8110368(struct Sprite *sprite) +{ + if (IsContest()) + { + StartSpriteAffineAnim(sprite, 2); + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + } + else if (!GetBattlerSide(gBattleAnimTarget)) + { + StartSpriteAffineAnim(sprite, 1); + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + } + + sprite->pos1.x = GetBattlerSpriteCoord2(gBattleAnimTarget, 2) + gBattleAnimArgs[0]; + sprite->pos1.y = GetBattlerSpriteCoord2(gBattleAnimTarget, 3) + gBattleAnimArgs[1]; + sprite->data[0] = gBattleAnimArgs[4]; + + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_8110438(struct Sprite *sprite) +{ + if (IsContest()) + { + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + StartSpriteAffineAnim(sprite, 2); + } + else if (!GetBattlerSide(gBattleAnimTarget)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + } + + sprite->pos1.x = GetBattlerSpriteCoord2(gBattleAnimTarget, 2) + gBattleAnimArgs[0]; + sprite->pos1.y = GetBattlerSpriteCoord2(gBattleAnimTarget, 3) + gBattleAnimArgs[1]; + sprite->data[0] = gBattleAnimArgs[2]; + + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_81104E4(struct Sprite *sprite) +{ + if (IsContest()) + gBattleAnimArgs[2] /= 2; + + InitAnimSpritePos(sprite, 1); + sprite->data[0] = gBattleAnimArgs[2]; + sprite->data[1] = sprite->pos1.x; + sprite->data[3] = sprite->pos1.y; + + if (!gBattleAnimArgs[4]) + { + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + } + else + { + SetAverageBattlerPositions(gBattleAnimTarget, 1, &sprite->data[2], &sprite->data[4]); + } + + sub_80A6FD4(sprite); + sprite->data[5] = gBattleAnimArgs[3]; + sprite->callback = sub_811057C; +} + +static void sub_811057C(struct Sprite *sprite) +{ + if (TranslateAnimLinear(sprite)) + { + DestroyAnimSprite(sprite); + return; + } + + sprite->pos2.x += Sin(sprite->data[6], sprite->data[5]); + sprite->data[6] = (sprite->data[6] + 13) & 0xFF; +} + +void sub_81105B4(struct Sprite *sprite) +{ + SetAverageBattlerPositions(gBattleAnimTarget, 0, &sprite->pos1.x, &sprite->pos1.y); + if (GetBattlerSide(gBattleAnimAttacker)) + sprite->pos1.x -= gBattleAnimArgs[0]; + else + sprite->pos1.x += gBattleAnimArgs[0]; + + sprite->pos1.y += gBattleAnimArgs[1]; + if (!GetBattlerSide(gBattleAnimTarget)) + sprite->pos1.y += 8; + + sprite->callback = sub_8110630; +} + +static void sub_8110630(struct Sprite *sprite) +{ + if (++sprite->data[0] == 3) + { + sprite->data[0] = 0; + sprite->invisible ^= 1; + } + + if (++sprite->data[1] == 51) + { + DestroyAnimSprite(sprite); + } +} + +void sub_811067C(struct Sprite *sprite) +{ + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + + sprite->data[0] = 16; + sprite->callback = sub_81106A4; +} + +static void sub_81106A4(struct Sprite *sprite) +{ + if (sprite->data[2] < 20) + { + sprite->data[2]++; + } + else if (sprite->data[1]++ & 1) + { + sprite->data[0]--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(sprite->data[0], 16 - sprite->data[0])); + + if (sprite->data[0] == 0) + { + sprite->invisible = TRUE; + sprite->callback = sub_8110700; + } + } +} + +static void sub_8110700(struct Sprite *sprite) +{ + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + DestroyAnimSprite(sprite); +} + +// Translates a stinger sprite linearly to a destination location. The sprite is +// initially rotated so that it appears to be traveling in a straight line. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: target x pixel offset +// arg 3: target y pixel offset +// arg 4: duration +void AnimTranslateStinger(struct Sprite *sprite) +{ + s16 lVarX, lVarY; + u16 rot; + + if (IsContest()) + { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + } + else + { + if (GetBattlerSide(gBattleAnimAttacker)) + { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + } + } + + if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) + { + if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT + || GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT) + { + s16 temp1, temp2; + + temp1 = gBattleAnimArgs[2]; + gBattleAnimArgs[2] = -temp1; + + temp2 = gBattleAnimArgs[0]; + gBattleAnimArgs[0] = -temp2; + } + } + + InitAnimSpritePos(sprite, 1); + + lVarX = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[2]; + lVarY = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + rot = ArcTan2Neg(lVarX - sprite->pos1.x, lVarY - sprite->pos1.y); + rot += 0xC000; + sub_80A73E0(sprite, FALSE, 0x100, 0x100, rot); + + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[2] = lVarX; + sprite->data[4] = lVarY; + + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +// Rotates sprite and moves it in an arc, so that it appears like a missle or arrow traveling. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: target x pixel offset +// arg 3: target y pixel offset +// arg 4: duration +// arg 5: wave amplitude +void AnimMissileArc(struct Sprite *sprite) +{ + InitAnimSpritePos(sprite, 1); + + if (GetBattlerSide(gBattleAnimAttacker)) + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + + sprite->data[0] = gBattleAnimArgs[4]; + 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 = AnimMissileArcStep; + sprite->invisible = TRUE; +} + +static void AnimMissileArcStep(struct Sprite *sprite) +{ + sprite->invisible = FALSE; + + if (TranslateAnimArc(sprite)) + { + DestroyAnimSprite(sprite); + } + else + { + s16 tempData[8]; + u16 *data = sprite->data; + u16 x1 = sprite->pos1.x; + s16 x2 = sprite->pos2.x; + u16 y1 = sprite->pos1.y; + s16 y2 = sprite->pos2.y; + int i; + + for (i = 0; i < 8; i++) + tempData[i] = data[i]; + + x2 += x1; + y2 += y1; + + if (!TranslateAnimArc(sprite)) + { + u16 rotation = ArcTan2Neg(sprite->pos1.x + sprite->pos2.x - x2, + sprite->pos1.y + sprite->pos2.y - y2); + rotation += 0xC000; + sub_80A73E0(sprite, FALSE, 0x100, 0x100, rotation); + + for (i = 0; i < 8; i++) + data[i] = tempData[i]; + } + } +} + +void sub_8110994(struct Sprite *sprite) +{ + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3) + 18; + } + else + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + 18; + } + + StoreSpriteCallbackInData6(sprite, move_anim_8074EE0); + sprite->callback = sub_80A67BC; +}