From ad73f920612f747a963d9aed8867aa930ebc8173 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 22 Jan 2018 21:32:50 +0100 Subject: [PATCH] start decompiling pokemon animation --- asm/pokemon_animation.s | 538 ------------------- data/pokemon_animation.s | 198 ------- include/pokemon_animation.h | 4 +- include/sprite.h | 1 + ld_script.txt | 2 + src/pokemon_animation.c | 1015 +++++++++++++++++++++++++++++++++++ 6 files changed, 1020 insertions(+), 738 deletions(-) create mode 100644 src/pokemon_animation.c diff --git a/asm/pokemon_animation.s b/asm/pokemon_animation.s index a625f85119..7f0d24cd00 100644 --- a/asm/pokemon_animation.s +++ b/asm/pokemon_animation.s @@ -4,547 +4,9 @@ .syntax unified .text - - thumb_func_start nullsub_69 -nullsub_69: @ 817F3EC - bx lr - thumb_func_end nullsub_69 - thumb_func_start sub_817F3F0 -sub_817F3F0: @ 817F3F0 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x4 - mov r9, r0 - mov r8, r1 - adds r5, r2, 0 - adds r4, r3, 0 - lsls r5, 16 - negs r5, r5 - lsls r4, 16 - negs r4, r4 - lsrs r4, 16 - mov r0, r8 - lsls r0, 16 - asrs r0, 16 - mov r8, r0 - asrs r5, 16 - adds r1, r5, 0 - bl Cos - adds r6, r0, 0 - lsls r4, 16 - asrs r4, 16 - mov r0, r8 - adds r1, r4, 0 - bl Sin - subs r6, r0 - lsls r6, 16 - lsrs r6, 16 - mov r0, r8 - adds r1, r4, 0 - bl Cos - adds r2, r0, 0 - mov r0, r8 - adds r1, r5, 0 - str r2, [sp] - bl Sin - ldr r2, [sp] - adds r2, r0 - negs r5, r5 - negs r4, r4 - lsls r6, 16 - asrs r6, 16 - lsls r5, 16 - asrs r5, 16 - adds r6, r5 - mov r0, r9 - strh r6, [r0, 0x24] - lsls r2, 16 - asrs r2, 16 - lsls r4, 16 - asrs r4, 16 - adds r2, r4 - strh r2, [r0, 0x26] - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_817F3F0 - thumb_func_start GetSpeciesBackAnimId -GetSpeciesBackAnimId: @ 817F474 - push {lr} - lsls r0, 16 - lsrs r0, 16 - ldr r1, =gUnknown_0860A8C8 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _0817F48C - movs r0, 0 - b _0817F492 - .pool -_0817F48C: - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 -_0817F492: - pop {r1} - bx r1 - thumb_func_end GetSpeciesBackAnimId - - thumb_func_start sub_817F498 -sub_817F498: @ 817F498 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r6, r5, 2 - adds r0, r6, r5 - lsls r0, 3 - adds r2, r0, r1 - movs r3, 0xA - ldrsh r0, [r2, r3] - lsls r3, r0, 16 - movs r4, 0xC - ldrsh r0, [r2, r4] - orrs r3, r0 - movs r0, 0x8 - ldrsh r4, [r2, r0] - mov r8, r1 - ldr r0, =SpriteCallbackDummy - mov r12, r0 - cmp r4, 0 - bne _0817F508 - ldrh r0, [r3, 0x2E] - strh r0, [r2, 0x10] - ldrh r0, [r3, 0x32] - strh r0, [r2, 0x12] - movs r0, 0x1 - strh r0, [r3, 0x30] - strh r4, [r3, 0x2E] - movs r0, 0x2 - adds r1, r6, 0 - ldr r6, =gUnknown_0860AA88 - ldr r7, =gUnknown_03001274 - movs r4, 0 - adds r2, r3, 0 - adds r2, 0x32 -_0817F4E2: - strh r4, [r2] - adds r2, 0x2 - adds r0, 0x1 - cmp r0, 0x7 - bls _0817F4E2 - adds r1, r5 - lsls r1, 3 - add r1, r8 - movs r2, 0xE - ldrsh r0, [r1, r2] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - str r0, [r3, 0x1C] - movs r0, 0 - str r0, [r7] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_0817F508: - ldr r0, [r3, 0x1C] - cmp r0, r12 - bne _0817F528 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - add r0, r8 - ldrh r1, [r0, 0x10] - movs r2, 0 - strh r1, [r3, 0x2E] - ldrh r0, [r0, 0x12] - strh r0, [r3, 0x32] - strh r2, [r3, 0x30] - adds r0, r5, 0 - bl DestroyTask -_0817F528: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817F498 - - thumb_func_start LaunchAnimationTaskForFrontSprite -LaunchAnimationTaskForFrontSprite: @ 817F544 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r4, r1, 24 - lsrs r4, 24 - ldr r0, =sub_817F498 - movs r1, 0x80 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - lsrs r0, r5, 16 - strh r0, [r1, 0xA] - strh r5, [r1, 0xC] - strh r4, [r1, 0xE] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end LaunchAnimationTaskForFrontSprite - - thumb_func_start sub_817F578 -sub_817F578: @ 817F578 - lsls r1, 24 - ldr r3, =gUnknown_03001274 - movs r2, 0x1 - str r2, [r3] - ldr r2, =gUnknown_0860AA88 - lsrs r1, 22 - adds r1, r2 - ldr r1, [r1] - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_817F578 - - thumb_func_start LaunchAnimationTaskForBackSprite -LaunchAnimationTaskForBackSprite: @ 817F594 - push {r4-r6,lr} - adds r5, r0, 0 - lsls r6, r1, 24 - lsrs r6, 24 - ldr r0, =sub_817F498 - movs r1, 0x80 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - lsrs r0, r5, 16 - strh r0, [r4, 0xA] - strh r5, [r4, 0xC] - ldrh r0, [r5, 0x2E] - lsls r0, 24 - ldr r1, =gBattlePartyID - lsrs r0, 23 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - bl GetNature - lsls r0, 24 - lsrs r0, 24 - lsls r1, r6, 1 - ldr r2, =gUnknown_0860AD2F - adds r0, r2 - adds r1, r6 - ldrb r0, [r0] - adds r1, r0 - lsls r1, 24 - lsrs r1, 24 - ldr r0, =gUnknown_0860ACE4 - adds r1, r0 - ldrb r0, [r1] - strh r0, [r4, 0xE] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end LaunchAnimationTaskForBackSprite - - thumb_func_start sub_817F60C -sub_817F60C: @ 817F60C - ldr r1, =nullsub_69 - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_817F60C - - thumb_func_start sub_817F618 -sub_817F618: @ 817F618 - push {r4,r5,lr} - sub sp, 0x10 - lsls r1, 16 - lsls r3, 16 - lsrs r3, 16 - ldr r4, =0xffff0000 - lsls r2, 16 - lsrs r1, 16 - orrs r1, r2 - str r1, [sp] - ldr r1, [sp, 0x4] - ands r1, r4 - orrs r1, r3 - str r1, [sp, 0x4] - ldrb r4, [r0, 0x3] - lsls r4, 26 - lsrs r4, 27 - add r5, sp, 0x8 - mov r0, sp - adds r1, r5, 0 - movs r2, 0x1 - movs r3, 0x2 - bl ObjAffineSet - ldr r0, =gOamMatrices - lsls r4, 3 - adds r4, r0 - ldrh r0, [r5] - strh r0, [r4] - ldrh r0, [r5, 0x2] - strh r0, [r4, 0x2] - ldrh r0, [r5, 0x4] - strh r0, [r4, 0x4] - ldrh r0, [r5, 0x6] - strh r0, [r4, 0x6] - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817F618 - - thumb_func_start sub_817F670 -sub_817F670: @ 817F670 - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0x1] - movs r1, 0x3 - orrs r0, r1 - strb r0, [r4, 0x1] - ldr r0, =gSpriteAffineAnimTable_860AD68 - str r0, [r4, 0x10] - ldr r0, =gUnknown_03001274 - ldr r0, [r0] - cmp r0, 0x1 - bne _0817F68E - adds r0, r4, 0 - bl InitSpriteAffineAnim -_0817F68E: - movs r1, 0x30 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0817F6A8 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - b _0817F6B0 - .pool -_0817F6A8: - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAffineAnim -_0817F6B0: - ldrb r3, [r4, 0x1] - lsrs r1, r3, 6 - ldrb r2, [r4, 0x3] - lsrs r2, 6 - lsls r3, 30 - lsrs r3, 30 - adds r0, r4, 0 - bl CalcCenterToCornerVec - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_817F670 - - thumb_func_start sub_817F6D4 -sub_817F6D4: @ 817F6D4 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - lsls r3, 16 - lsrs r3, 16 - movs r5, 0x30 - ldrsh r0, [r4, r5] - cmp r0, 0 - bne _0817F6F8 - lsls r0, r1, 16 - negs r0, r0 - lsrs r1, r0, 16 - negs r0, r3 - lsls r0, 16 - lsrs r3, r0, 16 -_0817F6F8: - lsls r1, 16 - asrs r1, 16 - lsls r2, 16 - asrs r2, 16 - adds r0, r4, 0 - bl sub_817F618 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_817F6D4 - - thumb_func_start sub_817F70C -sub_817F70C: @ 817F70C - push {lr} - adds r1, r0, 0 - movs r2, 0x30 - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _0817F720 - movs r2, 0x24 - ldrsh r0, [r1, r2] - negs r0, r0 - strh r0, [r1, 0x24] -_0817F720: - pop {r0} - bx r0 - thumb_func_end sub_817F70C - - thumb_func_start sub_817F724 -sub_817F724: @ 817F724 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bhi _0817F750 - ldr r1, =gUnknown_03001240 - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - movs r2, 0 - strh r2, [r0, 0x6] - strh r2, [r0] - movs r1, 0x1 - strh r1, [r0, 0x4] - strh r2, [r0, 0x2] - strh r2, [r0, 0x8] - movs r0, 0x1 - b _0817F752 - .pool -_0817F750: - movs r0, 0 -_0817F752: - pop {r1} - bx r1 - thumb_func_end sub_817F724 - - thumb_func_start sub_817F758 -sub_817F758: @ 817F758 - push {r4,lr} - ldr r4, =gUnknown_03001270 - ldrb r1, [r4] - adds r2, r1, 0x1 - adds r0, r2, 0 - asrs r0, 2 - lsls r0, 2 - subs r0, r2, r0 - strb r0, [r4] - ldrb r0, [r4] - bl sub_817F724 - ldrb r0, [r4] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_817F758 - - thumb_func_start sub_817F77C -sub_817F77C: @ 817F77C - push {r4,r5,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0x1] - movs r3, 0x4 - negs r3, r3 - ands r3, r0 - movs r5, 0x1 - orrs r3, r5 - strb r3, [r4, 0x1] - lsrs r1, r3, 6 - ldrb r2, [r4, 0x3] - lsrs r2, 6 - lsls r3, 30 - lsrs r3, 30 - adds r0, r4, 0 - bl CalcCenterToCornerVec - ldr r0, =gUnknown_03001274 - ldr r0, [r0] - cmp r0, 0x1 - bne _0817F800 - movs r1, 0x30 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0817F7C0 - adds r1, r4, 0 - adds r1, 0x3F - ldrb r0, [r1] - orrs r0, r5 - strb r0, [r1] - adds r5, r1, 0 - b _0817F7D0 - .pool -_0817F7C0: - adds r0, r4, 0 - adds r0, 0x3F - ldrb r2, [r0] - movs r1, 0x2 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - adds r5, r0, 0 -_0817F7D0: - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldrb r2, [r4, 0x3] - lsls r1, r2, 26 - lsrs r1, 27 - ldrb r0, [r5] - lsls r0, 31 - lsrs r0, 31 - lsls r0, 3 - orrs r1, r0 - lsls r1, 1 - movs r0, 0x3F - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x3] - ldrb r1, [r4, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - strb r0, [r4, 0x1] -_0817F800: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_817F77C thumb_func_start pokemonanimfunc_01 pokemonanimfunc_01: @ 817F808 diff --git a/data/pokemon_animation.s b/data/pokemon_animation.s index 535c91b2da..ef9a35a491 100644 --- a/data/pokemon_animation.s +++ b/data/pokemon_animation.s @@ -3,204 +3,6 @@ .section .rodata -gUnknown_0860A8C8:: @ 860A8C8 - .byte 0x00, 0x13, 0x02, 0x08, 0x12, 0x15, 0x17, 0x12, 0x12, 0x19, 0x02, 0x13, 0x11, 0x02, 0x13, 0x01, 0x0f, 0x15, 0x0f, 0x0a, 0x0a, 0x0f, 0x15, 0x0f, 0x09, 0x16, 0x16, 0x12, 0x10, 0x12, 0x15, 0x09 - .byte 0x12, 0x15, 0x09, 0x13, 0x13, 0x10, 0x01, 0x13, 0x06, 0x11, 0x09, 0x02, 0x02, 0x14, 0x02, 0x08, 0x0a, 0x11, 0x09, 0x09, 0x10, 0x0f, 0x02, 0x14, 0x10, 0x10, 0x15, 0x15, 0x12, 0x09, 0x0e, 0x14 - .byte 0x14, 0x0d, 0x15, 0x09, 0x09, 0x0b, 0x0b, 0x0b, 0x02, 0x02, 0x0e, 0x08, 0x08, 0x17, 0x15, 0x02, 0x13, 0x0f, 0x0f, 0x02, 0x0f, 0x15, 0x13, 0x02, 0x0b, 0x0c, 0x13, 0x0f, 0x01, 0x01, 0x14, 0x09 - .byte 0x13, 0x14, 0x0a, 0x09, 0x15, 0x15, 0x02, 0x10, 0x15, 0x10, 0x02, 0x0f, 0x02, 0x06, 0x06, 0x0e, 0x0e, 0x12, 0x0b, 0x12, 0x13, 0x11, 0x11, 0x11, 0x13, 0x19, 0x14, 0x0f, 0x13, 0x16, 0x17, 0x0e - .byte 0x0e, 0x10, 0x09, 0x19, 0x05, 0x12, 0x19, 0x16, 0x17, 0x01, 0x13, 0x13, 0x13, 0x15, 0x15, 0x13, 0x19, 0x16, 0x17, 0x02, 0x0f, 0x09, 0x0d, 0x12, 0x12, 0x02, 0x09, 0x12, 0x15, 0x17, 0x15, 0x15 - .byte 0x09, 0x12, 0x10, 0x11, 0x0f, 0x0a, 0x11, 0x0a, 0x02, 0x0f, 0x0b, 0x16, 0x12, 0x13, 0x13, 0x13, 0x11, 0x12, 0x14, 0x12, 0x13, 0x16, 0x11, 0x12, 0x13, 0x02, 0x10, 0x11, 0x11, 0x11, 0x10, 0x13 - .byte 0x02, 0x11, 0x0b, 0x02, 0x14, 0x14, 0x12, 0x13, 0x01, 0x14, 0x0b, 0x14, 0x08, 0x09, 0x0f, 0x05, 0x09, 0x15, 0x09, 0x0d, 0x15, 0x13, 0x15, 0x0f, 0x13, 0x09, 0x17, 0x17, 0x0a, 0x08, 0x02, 0x02 - .byte 0x05, 0x0f, 0x02, 0x15, 0x09, 0x09, 0x19, 0x15, 0x0e, 0x01, 0x13, 0x02, 0x0f, 0x07, 0x02, 0x08, 0x17, 0x02, 0x13, 0x16, 0x17, 0x19, 0x0e, 0x09, 0x0e, 0x19, 0x17, 0x18, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x15, 0x09, 0x12, 0x10, 0x17, 0x02, 0x12, 0x19, 0x12, 0x08 - .byte 0x0f, 0x15, 0x0b, 0x08, 0x11, 0x08, 0x0f, 0x02, 0x10, 0x10, 0x13, 0x09, 0x14, 0x0a, 0x01, 0x14, 0x12, 0x15, 0x13, 0x15, 0x07, 0x11, 0x11, 0x03, 0x11, 0x19, 0x19, 0x13, 0x12, 0x01, 0x13, 0x14 - .byte 0x0e, 0x17, 0x01, 0x0b, 0x09, 0x04, 0x0f, 0x15, 0x03, 0x19, 0x04, 0x15, 0x13, 0x01, 0x0f, 0x0e, 0x0e, 0x15, 0x09, 0x0e, 0x17, 0x13, 0x09, 0x09, 0x0a, 0x08, 0x0f, 0x0f, 0x13, 0x13, 0x10, 0x10 - .byte 0x14, 0x12, 0x12, 0x09, 0x14, 0x14, 0x11, 0x11, 0x12, 0x01, 0x01, 0x18, 0x02, 0x10, 0x08, 0x0b, 0x0b, 0x0e, 0x13, 0x09, 0x0d, 0x13, 0x11, 0x11, 0x14, 0x01, 0x01, 0x0b, 0x15, 0x02, 0x15, 0x09 - .byte 0x0e, 0x11, 0x11, 0x11, 0x0c, 0x0b, 0x0f, 0x09, 0x14, 0x14, 0x14, 0x09, 0x09, 0x08, 0x0f, 0x15, 0x09, 0x09, 0x09, 0x09, 0x19, 0x17, 0x0d, 0x01, 0x01, 0x11, 0x14, 0x11 - -gUnknown_0860AA64:: @ 860AA64 - .byte 0x00, 0x05, 0x01, 0x01, 0x00, 0x0f, 0x01, 0x04, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0xff - -gUnknown_0860AA80:: @ 860AA80 - .byte 0x06, 0x1e, 0xfe, 0x0f, 0x06, 0x1e, 0xff, 0x00 - - .align 2 -gUnknown_0860AA88:: @ 860AA88 - .4byte pokemonanimfunc_00 - .4byte pokemonanimfunc_01 - .4byte pokemonanimfunc_02 - .4byte pokemonanimfunc_03 - .4byte pokemonanimfunc_04 - .4byte pokemonanimfunc_05 - .4byte pokemonanimfunc_06 - .4byte pokemonanimfunc_07 - .4byte pokemonanimfunc_08 - .4byte pokemonanimfunc_09 - .4byte pokemonanimfunc_0A - .4byte pokemonanimfunc_0B - .4byte pokemonanimfunc_0C - .4byte pokemonanimfunc_0D - .4byte pokemonanimfunc_0E - .4byte pokemonanimfunc_0F - .4byte pokemonanimfunc_10 - .4byte pokemonanimfunc_11 - .4byte pokemonanimfunc_12 - .4byte pokemonanimfunc_13 - .4byte pokemonanimfunc_14 - .4byte pokemonanimfunc_15 - .4byte pokemonanimfunc_16 - .4byte pokemonanimfunc_17 - .4byte pokemonanimfunc_18 - .4byte pokemonanimfunc_19 - .4byte pokemonanimfunc_1A - .4byte pokemonanimfunc_1B - .4byte pokemonanimfunc_1C - .4byte pokemonanimfunc_1D - .4byte pokemonanimfunc_1E - .4byte pokemonanimfunc_1F - .4byte pokemonanimfunc_20 - .4byte pokemonanimfunc_21 - .4byte pokemonanimfunc_22 - .4byte pokemonanimfunc_23 - .4byte pokemonanimfunc_24 - .4byte pokemonanimfunc_25 - .4byte pokemonanimfunc_26 - .4byte pokemonanimfunc_27 - .4byte pokemonanimfunc_28 - .4byte pokemonanimfunc_29 - .4byte pokemonanimfunc_2A - .4byte pokemonanimfunc_2B - .4byte pokemonanimfunc_2C - .4byte pokemonanimfunc_2D - .4byte pokemonanimfunc_2E - .4byte pokemonanimfunc_2F - .4byte pokemonanimfunc_30 - .4byte pokemonanimfunc_31 - .4byte pokemonanimfunc_32 - .4byte pokemonanimfunc_33 - .4byte pokemonanimfunc_34 - .4byte pokemonanimfunc_35 - .4byte pokemonanimfunc_36 - .4byte pokemonanimfunc_37 - .4byte pokemonanimfunc_38 - .4byte pokemonanimfunc_39 - .4byte pokemonanimfunc_3A - .4byte pokemonanimfunc_3B - .4byte pokemonanimfunc_3C - .4byte pokemonanimfunc_3D - .4byte pokemonanimfunc_3E - .4byte pokemonanimfunc_3F - .4byte pokemonanimfunc_40 - .4byte pokemonanimfunc_41 - .4byte pokemonanimfunc_42 - .4byte pokemonanimfunc_43 - .4byte pokemonanimfunc_44 - .4byte pokemonanimfunc_45 - .4byte pokemonanimfunc_46 - .4byte pokemonanimfunc_47 - .4byte pokemonanimfunc_48 - .4byte pokemonanimfunc_49 - .4byte pokemonanimfunc_4A - .4byte pokemonanimfunc_4B - .4byte pokemonanimfunc_4C - .4byte pokemonanimfunc_4D - .4byte pokemonanimfunc_4E - .4byte pokemonanimfunc_4F - .4byte pokemonanimfunc_50 - .4byte pokemonanimfunc_51 - .4byte pokemonanimfunc_52 - .4byte pokemonanimfunc_53 - .4byte pokemonanimfunc_54 - .4byte pokemonanimfunc_55 - .4byte pokemonanimfunc_56 - .4byte pokemonanimfunc_57 - .4byte pokemonanimfunc_58 - .4byte pokemonanimfunc_59 - .4byte pokemonanimfunc_5A - .4byte pokemonanimfunc_5B - .4byte pokemonanimfunc_5C - .4byte pokemonanimfunc_5D - .4byte pokemonanimfunc_5E - .4byte pokemonanimfunc_5F - .4byte pokemonanimfunc_60 - .4byte pokemonanimfunc_61 - .4byte pokemonanimfunc_62 - .4byte pokemonanimfunc_63 - .4byte pokemonanimfunc_64 - .4byte pokemonanimfunc_65 - .4byte pokemonanimfunc_66 - .4byte pokemonanimfunc_67 - .4byte pokemonanimfunc_68 - .4byte pokemonanimfunc_69 - .4byte pokemonanimfunc_6A - .4byte pokemonanimfunc_6B - .4byte pokemonanimfunc_6C - .4byte pokemonanimfunc_6D - .4byte pokemonanimfunc_6E - .4byte pokemonanimfunc_6F - .4byte pokemonanimfunc_70 - .4byte pokemonanimfunc_71 - .4byte pokemonanimfunc_72 - .4byte pokemonanimfunc_73 - .4byte pokemonanimfunc_74 - .4byte pokemonanimfunc_75 - .4byte pokemonanimfunc_76 - .4byte pokemonanimfunc_77 - .4byte pokemonanimfunc_78 - .4byte pokemonanimfunc_79 - .4byte pokemonanimfunc_7A - .4byte pokemonanimfunc_7B - .4byte pokemonanimfunc_7C - .4byte pokemonanimfunc_7D - .4byte pokemonanimfunc_7E - .4byte pokemonanimfunc_7F - .4byte pokemonanimfunc_80 - .4byte pokemonanimfunc_81 - .4byte pokemonanimfunc_82 - .4byte pokemonanimfunc_83 - .4byte pokemonanimfunc_84 - .4byte pokemonanimfunc_85 - .4byte pokemonanimfunc_86 - .4byte pokemonanimfunc_87 - .4byte pokemonanimfunc_88 - .4byte pokemonanimfunc_89 - .4byte pokemonanimfunc_8A - .4byte pokemonanimfunc_8B - .4byte pokemonanimfunc_8C - .4byte pokemonanimfunc_8D - .4byte pokemonanimfunc_8E - .4byte pokemonanimfunc_8F - .4byte pokemonanimfunc_90 - .4byte pokemonanimfunc_91 - .4byte pokemonanimfunc_92 - .4byte pokemonanimfunc_93 - .4byte pokemonanimfunc_94 - .4byte pokemonanimfunc_95 - .4byte pokemonanimfunc_96 - -gUnknown_0860ACE4:: @ 860ACE4 - .byte 0x60, 0x5f, 0x02, 0x5e, 0x03, 0x46, 0x6d, 0x3e, 0x6e, 0x6f, 0x70, 0x3f, 0x71, 0x13, 0x72, 0x6c, 0x6b, 0x3a, 0x64, 0x14, 0x4f, 0x5d, 0x0f, 0x4c, 0x61, 0x57, 0x58, 0x67, 0x66, 0x59, 0x74, 0x73 - .byte 0x5a, 0x75, 0x76, 0x5b, 0x77, 0x78, 0x65, 0x63, 0x5c, 0x62, 0x6a, 0x69, 0x68, 0x7b, 0x7a, 0x79, 0x7e, 0x7d, 0x7c, 0x81, 0x80, 0x7f, 0x84, 0x82, 0x83, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b - .byte 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96 - -gUnknown_0860AD2F:: @ 860AD2F - .byte 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01 - - .align 2 -gSpriteAffineAnim_860AD48:: @ 860AD48 - obj_rot_scal_anim_frame 0x100, 0x100, 0, 0 - obj_rot_scal_anim_end - - .align 2 -gSpriteAffineAnim_860AD58:: @ 860AD58 - obj_rot_scal_anim_frame -0x100, 0x100, 0, 0 - obj_rot_scal_anim_end - - .align 2 -gSpriteAffineAnimTable_860AD68:: @ 860AD68 - .4byte gSpriteAffineAnim_860AD48 - .4byte gSpriteAffineAnim_860AD58 - gUnknown_0860AD70:: @ 860AD70 .byte 0xff, 0xff, 0x06, 0x02, 0x00, 0x06, 0xfe, 0x02, 0x06, 0x02, 0x00, 0x06, 0xfe, 0xfe, 0x06, 0x02, 0x00, 0x06, 0xfe, 0x02, 0x06, 0x02, 0x00, 0x06, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00 diff --git a/include/pokemon_animation.h b/include/pokemon_animation.h index 42fc10809e..b6d8c868e9 100644 --- a/include/pokemon_animation.h +++ b/include/pokemon_animation.h @@ -1,7 +1,7 @@ #ifndef GUARD_POKEMON_ANIMATION_H #define GUARD_POKEMON_ANIMATION_H -void LaunchAnimationTaskForFrontSprite(struct Sprite* sprite, u8 frontAnimId); -void LaunchAnimationTaskForBackSprite(struct Sprite* sprite, u8 backAnimId); +void LaunchAnimationTaskForFrontSprite(struct Sprite *sprite, u8 frontAnimId); +void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimId); #endif // GUARD_POKEMON_ANIMATION_H diff --git a/include/sprite.h b/include/sprite.h index d5c6bc402f..b5a1b6ae50 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -233,6 +233,7 @@ extern s16 gSpriteCoordOffsetX; extern s16 gSpriteCoordOffsetY; extern struct Sprite gSprites[]; +extern struct OamMatrix gOamMatrices[]; void ResetSpriteData(void); void AnimateSprites(void); diff --git a/ld_script.txt b/ld_script.txt index 2e52eb3430..f219917349 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -240,6 +240,7 @@ SECTIONS { src/bard_music.o(.text); src/fldeff_teleport.o(.text); asm/battle_link_817C95C.o(.text); + src/pokemon_animation.o(.text); asm/pokemon_animation.o(.text); src/recorded_battle.o(.text); src/battle_controller_recorded_opponent.o(.text); @@ -514,6 +515,7 @@ SECTIONS { src/evolution_graphics.o(.rodata); src/bard_music.o(.rodata); data/battle_link_817C95C.o(.rodata); + src/pokemon_animation.o(.rodata); data/pokemon_animation.o(.rodata); src/battle_controller_recorded_opponent.o(.rodata); src/battle_controller_recorded_player.o(.rodata); diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c new file mode 100644 index 0000000000..960b42dd16 --- /dev/null +++ b/src/pokemon_animation.c @@ -0,0 +1,1015 @@ +#include "global.h" +#include "pokemon.h" +#include "sprite.h" +#include "pokemon_animation.h" +#include "trig.h" +#include "task.h" + +struct UnkAnimStruct +{ + s16 field_0; + s16 field_2; + s16 field_4; + s16 field_6; + s16 field_8; +}; + +extern u16 gBattlePartyID[]; +extern bool32 gUnknown_03001274; +extern struct UnkAnimStruct gUnknown_03001240[]; +extern u8 gUnknown_03001270; + +// this file's functions +void pokemonanimfunc_00(struct Sprite *sprite); +void pokemonanimfunc_01(struct Sprite *sprite); +void pokemonanimfunc_02(struct Sprite *sprite); +void pokemonanimfunc_03(struct Sprite *sprite); +void pokemonanimfunc_04(struct Sprite *sprite); +void pokemonanimfunc_05(struct Sprite *sprite); +void pokemonanimfunc_06(struct Sprite *sprite); +void pokemonanimfunc_07(struct Sprite *sprite); +void pokemonanimfunc_08(struct Sprite *sprite); +void pokemonanimfunc_09(struct Sprite *sprite); +void pokemonanimfunc_0A(struct Sprite *sprite); +void pokemonanimfunc_0B(struct Sprite *sprite); +void pokemonanimfunc_0C(struct Sprite *sprite); +void pokemonanimfunc_0D(struct Sprite *sprite); +void pokemonanimfunc_0E(struct Sprite *sprite); +void pokemonanimfunc_0F(struct Sprite *sprite); +void pokemonanimfunc_10(struct Sprite *sprite); +void pokemonanimfunc_11(struct Sprite *sprite); +void pokemonanimfunc_12(struct Sprite *sprite); +void pokemonanimfunc_13(struct Sprite *sprite); +void pokemonanimfunc_14(struct Sprite *sprite); +void pokemonanimfunc_15(struct Sprite *sprite); +void pokemonanimfunc_16(struct Sprite *sprite); +void pokemonanimfunc_17(struct Sprite *sprite); +void pokemonanimfunc_18(struct Sprite *sprite); +void pokemonanimfunc_19(struct Sprite *sprite); +void pokemonanimfunc_1A(struct Sprite *sprite); +void pokemonanimfunc_1B(struct Sprite *sprite); +void pokemonanimfunc_1C(struct Sprite *sprite); +void pokemonanimfunc_1D(struct Sprite *sprite); +void pokemonanimfunc_1E(struct Sprite *sprite); +void pokemonanimfunc_1F(struct Sprite *sprite); +void pokemonanimfunc_20(struct Sprite *sprite); +void pokemonanimfunc_21(struct Sprite *sprite); +void pokemonanimfunc_22(struct Sprite *sprite); +void pokemonanimfunc_23(struct Sprite *sprite); +void pokemonanimfunc_24(struct Sprite *sprite); +void pokemonanimfunc_25(struct Sprite *sprite); +void pokemonanimfunc_26(struct Sprite *sprite); +void pokemonanimfunc_27(struct Sprite *sprite); +void pokemonanimfunc_28(struct Sprite *sprite); +void pokemonanimfunc_29(struct Sprite *sprite); +void pokemonanimfunc_2A(struct Sprite *sprite); +void pokemonanimfunc_2B(struct Sprite *sprite); +void pokemonanimfunc_2C(struct Sprite *sprite); +void pokemonanimfunc_2D(struct Sprite *sprite); +void pokemonanimfunc_2E(struct Sprite *sprite); +void pokemonanimfunc_2F(struct Sprite *sprite); +void pokemonanimfunc_30(struct Sprite *sprite); +void pokemonanimfunc_31(struct Sprite *sprite); +void pokemonanimfunc_32(struct Sprite *sprite); +void pokemonanimfunc_33(struct Sprite *sprite); +void pokemonanimfunc_34(struct Sprite *sprite); +void pokemonanimfunc_35(struct Sprite *sprite); +void pokemonanimfunc_36(struct Sprite *sprite); +void pokemonanimfunc_37(struct Sprite *sprite); +void pokemonanimfunc_38(struct Sprite *sprite); +void pokemonanimfunc_39(struct Sprite *sprite); +void pokemonanimfunc_3A(struct Sprite *sprite); +void pokemonanimfunc_3B(struct Sprite *sprite); +void pokemonanimfunc_3C(struct Sprite *sprite); +void pokemonanimfunc_3D(struct Sprite *sprite); +void pokemonanimfunc_3E(struct Sprite *sprite); +void pokemonanimfunc_3F(struct Sprite *sprite); +void pokemonanimfunc_40(struct Sprite *sprite); +void pokemonanimfunc_41(struct Sprite *sprite); +void pokemonanimfunc_42(struct Sprite *sprite); +void pokemonanimfunc_43(struct Sprite *sprite); +void pokemonanimfunc_44(struct Sprite *sprite); +void pokemonanimfunc_45(struct Sprite *sprite); +void pokemonanimfunc_46(struct Sprite *sprite); +void pokemonanimfunc_47(struct Sprite *sprite); +void pokemonanimfunc_48(struct Sprite *sprite); +void pokemonanimfunc_49(struct Sprite *sprite); +void pokemonanimfunc_4A(struct Sprite *sprite); +void pokemonanimfunc_4B(struct Sprite *sprite); +void pokemonanimfunc_4C(struct Sprite *sprite); +void pokemonanimfunc_4D(struct Sprite *sprite); +void pokemonanimfunc_4E(struct Sprite *sprite); +void pokemonanimfunc_4F(struct Sprite *sprite); +void pokemonanimfunc_50(struct Sprite *sprite); +void pokemonanimfunc_51(struct Sprite *sprite); +void pokemonanimfunc_52(struct Sprite *sprite); +void pokemonanimfunc_53(struct Sprite *sprite); +void pokemonanimfunc_54(struct Sprite *sprite); +void pokemonanimfunc_55(struct Sprite *sprite); +void pokemonanimfunc_56(struct Sprite *sprite); +void pokemonanimfunc_57(struct Sprite *sprite); +void pokemonanimfunc_58(struct Sprite *sprite); +void pokemonanimfunc_59(struct Sprite *sprite); +void pokemonanimfunc_5A(struct Sprite *sprite); +void pokemonanimfunc_5B(struct Sprite *sprite); +void pokemonanimfunc_5C(struct Sprite *sprite); +void pokemonanimfunc_5D(struct Sprite *sprite); +void pokemonanimfunc_5E(struct Sprite *sprite); +void pokemonanimfunc_5F(struct Sprite *sprite); +void pokemonanimfunc_60(struct Sprite *sprite); +void pokemonanimfunc_61(struct Sprite *sprite); +void pokemonanimfunc_62(struct Sprite *sprite); +void pokemonanimfunc_63(struct Sprite *sprite); +void pokemonanimfunc_64(struct Sprite *sprite); +void pokemonanimfunc_65(struct Sprite *sprite); +void pokemonanimfunc_66(struct Sprite *sprite); +void pokemonanimfunc_67(struct Sprite *sprite); +void pokemonanimfunc_68(struct Sprite *sprite); +void pokemonanimfunc_69(struct Sprite *sprite); +void pokemonanimfunc_6A(struct Sprite *sprite); +void pokemonanimfunc_6B(struct Sprite *sprite); +void pokemonanimfunc_6C(struct Sprite *sprite); +void pokemonanimfunc_6D(struct Sprite *sprite); +void pokemonanimfunc_6E(struct Sprite *sprite); +void pokemonanimfunc_6F(struct Sprite *sprite); +void pokemonanimfunc_70(struct Sprite *sprite); +void pokemonanimfunc_71(struct Sprite *sprite); +void pokemonanimfunc_72(struct Sprite *sprite); +void pokemonanimfunc_73(struct Sprite *sprite); +void pokemonanimfunc_74(struct Sprite *sprite); +void pokemonanimfunc_75(struct Sprite *sprite); +void pokemonanimfunc_76(struct Sprite *sprite); +void pokemonanimfunc_77(struct Sprite *sprite); +void pokemonanimfunc_78(struct Sprite *sprite); +void pokemonanimfunc_79(struct Sprite *sprite); +void pokemonanimfunc_7A(struct Sprite *sprite); +void pokemonanimfunc_7B(struct Sprite *sprite); +void pokemonanimfunc_7C(struct Sprite *sprite); +void pokemonanimfunc_7D(struct Sprite *sprite); +void pokemonanimfunc_7E(struct Sprite *sprite); +void pokemonanimfunc_7F(struct Sprite *sprite); +void pokemonanimfunc_80(struct Sprite *sprite); +void pokemonanimfunc_81(struct Sprite *sprite); +void pokemonanimfunc_82(struct Sprite *sprite); +void pokemonanimfunc_83(struct Sprite *sprite); +void pokemonanimfunc_84(struct Sprite *sprite); +void pokemonanimfunc_85(struct Sprite *sprite); +void pokemonanimfunc_86(struct Sprite *sprite); +void pokemonanimfunc_87(struct Sprite *sprite); +void pokemonanimfunc_88(struct Sprite *sprite); +void pokemonanimfunc_89(struct Sprite *sprite); +void pokemonanimfunc_8A(struct Sprite *sprite); +void pokemonanimfunc_8B(struct Sprite *sprite); +void pokemonanimfunc_8C(struct Sprite *sprite); +void pokemonanimfunc_8D(struct Sprite *sprite); +void pokemonanimfunc_8E(struct Sprite *sprite); +void pokemonanimfunc_8F(struct Sprite *sprite); +void pokemonanimfunc_90(struct Sprite *sprite); +void pokemonanimfunc_91(struct Sprite *sprite); +void pokemonanimfunc_92(struct Sprite *sprite); +void pokemonanimfunc_93(struct Sprite *sprite); +void pokemonanimfunc_94(struct Sprite *sprite); +void pokemonanimfunc_95(struct Sprite *sprite); +void pokemonanimfunc_96(struct Sprite *sprite); + +// const rom data +static const u8 sSpeciesToBackAnimId[] = +{ + 0x00, // SPECIES_NONE + 0x13, // SPECIES_BULBASAUR + 0x02, // SPECIES_IVYSAUR + 0x08, // SPECIES_VENUSAUR + 0x12, // SPECIES_CHARMANDER + 0x15, // SPECIES_CHARMELEON + 0x17, // SPECIES_CHARIZARD + 0x12, // SPECIES_SQUIRTLE + 0x12, // SPECIES_WARTORTLE + 0x19, // SPECIES_BLASTOISE + 0x02, // SPECIES_CATERPIE + 0x13, // SPECIES_METAPOD + 0x11, // SPECIES_BUTTERFREE + 0x02, // SPECIES_WEEDLE + 0x13, // SPECIES_KAKUNA + 0x01, // SPECIES_BEEDRILL + 0x0f, // SPECIES_PIDGEY + 0x15, // SPECIES_PIDGEOTTO + 0x0f, // SPECIES_PIDGEOT + 0x0a, // SPECIES_RATTATA + 0x0a, // SPECIES_RATICATE + 0x0f, // SPECIES_SPEAROW + 0x15, // SPECIES_FEAROW + 0x0f, // SPECIES_EKANS + 0x09, // SPECIES_ARBOK + 0x16, // SPECIES_PIKACHU + 0x16, // SPECIES_RAICHU + 0x12, // SPECIES_SANDSHREW + 0x10, // SPECIES_SANDSLASH + 0x12, // SPECIES_NIDORAN_F + 0x15, // SPECIES_NIDORINA + 0x09, // SPECIES_NIDOQUEEN + 0x12, // SPECIES_NIDORAN_M + 0x15, // SPECIES_NIDORINO + 0x09, // SPECIES_NIDOKING + 0x13, // SPECIES_CLEFAIRY + 0x13, // SPECIES_CLEFABLE + 0x10, // SPECIES_VULPIX + 0x01, // SPECIES_NINETALES + 0x13, // SPECIES_JIGGLYPUFF + 0x06, // SPECIES_WIGGLYTUFF + 0x11, // SPECIES_ZUBAT + 0x09, // SPECIES_GOLBAT + 0x02, // SPECIES_ODDISH + 0x02, // SPECIES_GLOOM + 0x14, // SPECIES_VILEPLUME + 0x02, // SPECIES_PARAS + 0x08, // SPECIES_PARASECT + 0x0a, // SPECIES_VENONAT + 0x11, // SPECIES_VENOMOTH + 0x09, // SPECIES_DIGLETT + 0x09, // SPECIES_DUGTRIO + 0x10, // SPECIES_MEOWTH + 0x0f, // SPECIES_PERSIAN + 0x02, // SPECIES_PSYDUCK + 0x14, // SPECIES_GOLDUCK + 0x10, // SPECIES_MANKEY + 0x10, // SPECIES_PRIMEAPE + 0x15, // SPECIES_GROWLITHE + 0x15, // SPECIES_ARCANINE + 0x12, // SPECIES_POLIWAG + 0x09, // SPECIES_POLIWHIRL + 0x0e, // SPECIES_POLIWRATH + 0x14, // SPECIES_ABRA + 0x14, // SPECIES_KADABRA + 0x0d, // SPECIES_ALAKAZAM + 0x15, // SPECIES_MACHOP + 0x09, // SPECIES_MACHOKE + 0x09, // SPECIES_MACHAMP + 0x0b, // SPECIES_BELLSPROUT + 0x0b, // SPECIES_WEEPINBELL + 0x0b, // SPECIES_VICTREEBEL + 0x02, // SPECIES_TENTACOOL + 0x02, // SPECIES_TENTACRUEL + 0x0e, // SPECIES_GEODUDE + 0x08, // SPECIES_GRAVELER + 0x08, // SPECIES_GOLEM + 0x17, // SPECIES_PONYTA + 0x15, // SPECIES_RAPIDASH + 0x02, // SPECIES_SLOWPOKE + 0x13, // SPECIES_SLOWBRO + 0x0f, // SPECIES_MAGNEMITE + 0x0f, // SPECIES_MAGNETON + 0x02, // SPECIES_FARFETCHD + 0x0f, // SPECIES_DODUO + 0x15, // SPECIES_DODRIO + 0x13, // SPECIES_SEEL + 0x02, // SPECIES_DEWGONG + 0x0b, // SPECIES_GRIMER + 0x0c, // SPECIES_MUK + 0x13, // SPECIES_SHELLDER + 0x0f, // SPECIES_CLOYSTER + 0x01, // SPECIES_GASTLY + 0x01, // SPECIES_HAUNTER + 0x14, // SPECIES_GENGAR + 0x09, // SPECIES_ONIX + 0x13, // SPECIES_DROWZEE + 0x14, // SPECIES_HYPNO + 0x0a, // SPECIES_KRABBY + 0x09, // SPECIES_KINGLER + 0x15, // SPECIES_VOLTORB + 0x15, // SPECIES_ELECTRODE + 0x02, // SPECIES_EXEGGCUTE + 0x10, // SPECIES_EXEGGUTOR + 0x15, // SPECIES_CUBONE + 0x10, // SPECIES_MAROWAK + 0x02, // SPECIES_HITMONLEE + 0x0f, // SPECIES_HITMONCHAN + 0x02, // SPECIES_LICKITUNG + 0x06, // SPECIES_KOFFING + 0x06, // SPECIES_WEEZING + 0x0e, // SPECIES_RHYHORN + 0x0e, // SPECIES_RHYDON + 0x12, // SPECIES_CHANSEY + 0x0b, // SPECIES_TANGELA + 0x12, // SPECIES_KANGASKHAN + 0x13, // SPECIES_HORSEA + 0x11, // SPECIES_SEADRA + 0x11, // SPECIES_GOLDEEN + 0x11, // SPECIES_SEAKING + 0x13, // SPECIES_STARYU + 0x19, // SPECIES_STARMIE + 0x14, // SPECIES_MR_MIME + 0x0f, // SPECIES_SCYTHER + 0x13, // SPECIES_JYNX + 0x16, // SPECIES_ELECTABUZZ + 0x17, // SPECIES_MAGMAR + 0x0e, // SPECIES_PINSIR + 0x0e, // SPECIES_TAUROS + 0x10, // SPECIES_MAGIKARP + 0x09, // SPECIES_GYARADOS + 0x19, // SPECIES_LAPRAS + 0x05, // SPECIES_DITTO + 0x12, // SPECIES_EEVEE + 0x19, // SPECIES_VAPOREON + 0x16, // SPECIES_JOLTEON + 0x17, // SPECIES_FLAREON + 0x01, // SPECIES_PORYGON + 0x13, // SPECIES_OMANYTE + 0x13, // SPECIES_OMASTAR + 0x13, // SPECIES_KABUTO + 0x15, // SPECIES_KABUTOPS + 0x15, // SPECIES_AERODACTYL + 0x13, // SPECIES_SNORLAX + 0x19, // SPECIES_ARTICUNO + 0x16, // SPECIES_ZAPDOS + 0x17, // SPECIES_MOLTRES + 0x02, // SPECIES_DRATINI + 0x0f, // SPECIES_DRAGONAIR + 0x09, // SPECIES_DRAGONITE + 0x0d, // SPECIES_MEWTWO + 0x12, // SPECIES_MEW + 0x12, // SPECIES_CHIKORITA + 0x02, // SPECIES_BAYLEEF + 0x09, // SPECIES_MEGANIUM + 0x12, // SPECIES_CYNDAQUIL + 0x15, // SPECIES_QUILAVA + 0x17, // SPECIES_TYPHLOSION + 0x15, // SPECIES_TOTODILE + 0x15, // SPECIES_CROCONAW + 0x09, // SPECIES_FERALIGATR + 0x12, // SPECIES_SENTRET + 0x10, // SPECIES_FURRET + 0x11, // SPECIES_HOOTHOOT + 0x0f, // SPECIES_NOCTOWL + 0x0a, // SPECIES_LEDYBA + 0x11, // SPECIES_LEDIAN + 0x0a, // SPECIES_SPINARAK + 0x02, // SPECIES_ARIADOS + 0x0f, // SPECIES_CROBAT + 0x0b, // SPECIES_CHINCHOU + 0x16, // SPECIES_LANTURN + 0x12, // SPECIES_PICHU + 0x13, // SPECIES_CLEFFA + 0x13, // SPECIES_IGGLYBUFF + 0x13, // SPECIES_TOGEPI + 0x11, // SPECIES_TOGETIC + 0x12, // SPECIES_NATU + 0x14, // SPECIES_XATU + 0x12, // SPECIES_MAREEP + 0x13, // SPECIES_FLAAFFY + 0x16, // SPECIES_AMPHAROS + 0x11, // SPECIES_BELLOSSOM + 0x12, // SPECIES_MARILL + 0x13, // SPECIES_AZUMARILL + 0x02, // SPECIES_SUDOWOODO + 0x10, // SPECIES_POLITOED + 0x11, // SPECIES_HOPPIP + 0x11, // SPECIES_SKIPLOOM + 0x11, // SPECIES_JUMPLUFF + 0x10, // SPECIES_AIPOM + 0x13, // SPECIES_SUNKERN + 0x02, // SPECIES_SUNFLORA + 0x11, // SPECIES_YANMA + 0x0b, // SPECIES_WOOPER + 0x02, // SPECIES_QUAGSIRE + 0x14, // SPECIES_ESPEON + 0x14, // SPECIES_UMBREON + 0x12, // SPECIES_MURKROW + 0x13, // SPECIES_SLOWKING + 0x01, // SPECIES_MISDREAVUS + 0x14, // SPECIES_UNOWN + 0x0b, // SPECIES_WOBBUFFET + 0x14, // SPECIES_GIRAFARIG + 0x08, // SPECIES_PINECO + 0x09, // SPECIES_FORRETRESS + 0x0f, // SPECIES_DUNSPARCE + 0x05, // SPECIES_GLIGAR + 0x09, // SPECIES_STEELIX + 0x15, // SPECIES_SNUBBULL + 0x09, // SPECIES_GRANBULL + 0x0d, // SPECIES_QWILFISH + 0x15, // SPECIES_SCIZOR + 0x13, // SPECIES_SHUCKLE + 0x15, // SPECIES_HERACROSS + 0x0f, // SPECIES_SNEASEL + 0x13, // SPECIES_TEDDIURSA + 0x09, // SPECIES_URSARING + 0x17, // SPECIES_SLUGMA + 0x17, // SPECIES_MAGCARGO + 0x0a, // SPECIES_SWINUB + 0x08, // SPECIES_PILOSWINE + 0x02, // SPECIES_CORSOLA + 0x02, // SPECIES_REMORAID + 0x05, // SPECIES_OCTILLERY + 0x0f, // SPECIES_DELIBIRD + 0x02, // SPECIES_MANTINE + 0x15, // SPECIES_SKARMORY + 0x09, // SPECIES_HOUNDOUR + 0x09, // SPECIES_HOUNDOOM + 0x19, // SPECIES_KINGDRA + 0x15, // SPECIES_PHANPY + 0x0e, // SPECIES_DONPHAN + 0x01, // SPECIES_PORYGON2 + 0x13, // SPECIES_STANTLER + 0x02, // SPECIES_SMEARGLE + 0x0f, // SPECIES_TYROGUE + 0x07, // SPECIES_HITMONTOP + 0x02, // SPECIES_SMOOCHUM + 0x08, // SPECIES_ELEKID + 0x17, // SPECIES_MAGBY + 0x02, // SPECIES_MILTANK + 0x13, // SPECIES_BLISSEY + 0x16, // SPECIES_RAIKOU + 0x17, // SPECIES_ENTEI + 0x19, // SPECIES_SUICUNE + 0x0e, // SPECIES_LARVITAR + 0x09, // SPECIES_PUPITAR + 0x0e, // SPECIES_TYRANITAR + 0x19, // SPECIES_LUGIA + 0x17, // SPECIES_HO_OH + 0x18, // SPECIES_CELEBI + 0x00, // SPECIES_OLD_UNOWN_B + 0x00, // SPECIES_OLD_UNOWN_C + 0x00, // SPECIES_OLD_UNOWN_D + 0x00, // SPECIES_OLD_UNOWN_E + 0x00, // SPECIES_OLD_UNOWN_F + 0x00, // SPECIES_OLD_UNOWN_G + 0x00, // SPECIES_OLD_UNOWN_H + 0x00, // SPECIES_OLD_UNOWN_I + 0x00, // SPECIES_OLD_UNOWN_J + 0x00, // SPECIES_OLD_UNOWN_K + 0x00, // SPECIES_OLD_UNOWN_L + 0x00, // SPECIES_OLD_UNOWN_M + 0x00, // SPECIES_OLD_UNOWN_N + 0x00, // SPECIES_OLD_UNOWN_O + 0x00, // SPECIES_OLD_UNOWN_P + 0x00, // SPECIES_OLD_UNOWN_Q + 0x00, // SPECIES_OLD_UNOWN_R + 0x00, // SPECIES_OLD_UNOWN_S + 0x00, // SPECIES_OLD_UNOWN_T + 0x00, // SPECIES_OLD_UNOWN_U + 0x00, // SPECIES_OLD_UNOWN_V + 0x00, // SPECIES_OLD_UNOWN_W + 0x00, // SPECIES_OLD_UNOWN_X + 0x00, // SPECIES_OLD_UNOWN_Y + 0x00, // SPECIES_OLD_UNOWN_Z + 0x10, // SPECIES_TREECKO + 0x15, // SPECIES_GROVYLE + 0x09, // SPECIES_SCEPTILE + 0x12, // SPECIES_TORCHIC + 0x10, // SPECIES_COMBUSKEN + 0x17, // SPECIES_BLAZIKEN + 0x02, // SPECIES_MUDKIP + 0x12, // SPECIES_MARSHTOMP + 0x19, // SPECIES_SWAMPERT + 0x12, // SPECIES_POOCHYENA + 0x08, // SPECIES_MIGHTYENA + 0x0f, // SPECIES_ZIGZAGOON + 0x15, // SPECIES_LINOONE + 0x0b, // SPECIES_WURMPLE + 0x08, // SPECIES_SILCOON + 0x11, // SPECIES_BEAUTIFLY + 0x08, // SPECIES_CASCOON + 0x0f, // SPECIES_DUSTOX + 0x02, // SPECIES_LOTAD + 0x10, // SPECIES_LOMBRE + 0x10, // SPECIES_LUDICOLO + 0x13, // SPECIES_SEEDOT + 0x09, // SPECIES_NUZLEAF + 0x14, // SPECIES_SHIFTRY + 0x0a, // SPECIES_NINCADA + 0x01, // SPECIES_NINJASK + 0x14, // SPECIES_SHEDINJA + 0x12, // SPECIES_TAILLOW + 0x15, // SPECIES_SWELLOW + 0x13, // SPECIES_SHROOMISH + 0x15, // SPECIES_BRELOOM + 0x07, // SPECIES_SPINDA + 0x11, // SPECIES_WINGULL + 0x11, // SPECIES_PELIPPER + 0x03, // SPECIES_SURSKIT + 0x11, // SPECIES_MASQUERAIN + 0x19, // SPECIES_WAILMER + 0x19, // SPECIES_WAILORD + 0x13, // SPECIES_SKITTY + 0x12, // SPECIES_DELCATTY + 0x01, // SPECIES_KECLEON + 0x13, // SPECIES_BALTOY + 0x14, // SPECIES_CLAYDOL + 0x0e, // SPECIES_NOSEPASS + 0x17, // SPECIES_TORKOAL + 0x01, // SPECIES_SABLEYE + 0x0b, // SPECIES_BARBOACH + 0x09, // SPECIES_WHISCASH + 0x04, // SPECIES_LUVDISC + 0x0f, // SPECIES_CORPHISH + 0x15, // SPECIES_CRAWDAUNT + 0x03, // SPECIES_FEEBAS + 0x19, // SPECIES_MILOTIC + 0x04, // SPECIES_CARVANHA + 0x15, // SPECIES_SHARPEDO + 0x13, // SPECIES_TRAPINCH + 0x01, // SPECIES_VIBRAVA + 0x0f, // SPECIES_FLYGON + 0x0e, // SPECIES_MAKUHITA + 0x0e, // SPECIES_HARIYAMA + 0x15, // SPECIES_ELECTRIKE + 0x09, // SPECIES_MANECTRIC + 0x0e, // SPECIES_NUMEL + 0x17, // SPECIES_CAMERUPT + 0x13, // SPECIES_SPHEAL + 0x09, // SPECIES_SEALEO + 0x09, // SPECIES_WALREIN + 0x0a, // SPECIES_CACNEA + 0x08, // SPECIES_CACTURNE + 0x0f, // SPECIES_SNORUNT + 0x0f, // SPECIES_GLALIE + 0x13, // SPECIES_LUNATONE + 0x13, // SPECIES_SOLROCK + 0x10, // SPECIES_AZURILL + 0x10, // SPECIES_SPOINK + 0x14, // SPECIES_GRUMPIG + 0x12, // SPECIES_PLUSLE + 0x12, // SPECIES_MINUN + 0x09, // SPECIES_MAWILE + 0x14, // SPECIES_MEDITITE + 0x14, // SPECIES_MEDICHAM + 0x11, // SPECIES_SWABLU + 0x11, // SPECIES_ALTARIA + 0x12, // SPECIES_WYNAUT + 0x01, // SPECIES_DUSKULL + 0x01, // SPECIES_DUSCLOPS + 0x18, // SPECIES_ROSELIA + 0x02, // SPECIES_SLAKOTH + 0x10, // SPECIES_VIGOROTH + 0x08, // SPECIES_SLAKING + 0x0b, // SPECIES_GULPIN + 0x0b, // SPECIES_SWALOT + 0x0e, // SPECIES_TROPIUS + 0x13, // SPECIES_WHISMUR + 0x09, // SPECIES_LOUDRED + 0x0d, // SPECIES_EXPLOUD + 0x13, // SPECIES_CLAMPERL + 0x11, // SPECIES_HUNTAIL + 0x11, // SPECIES_GOREBYSS + 0x14, // SPECIES_ABSOL + 0x01, // SPECIES_SHUPPET + 0x01, // SPECIES_BANETTE + 0x0b, // SPECIES_SEVIPER + 0x15, // SPECIES_ZANGOOSE + 0x02, // SPECIES_RELICANTH + 0x15, // SPECIES_ARON + 0x09, // SPECIES_LAIRON + 0x0e, // SPECIES_AGGRON + 0x11, // SPECIES_CASTFORM + 0x11, // SPECIES_VOLBEAT + 0x11, // SPECIES_ILLUMISE + 0x0c, // SPECIES_LILEEP + 0x0b, // SPECIES_CRADILY + 0x0f, // SPECIES_ANORITH + 0x09, // SPECIES_ARMALDO + 0x14, // SPECIES_RALTS + 0x14, // SPECIES_KIRLIA + 0x14, // SPECIES_GARDEVOIR + 0x09, // SPECIES_BAGON + 0x09, // SPECIES_SHELGON + 0x08, // SPECIES_SALAMENCE + 0x0f, // SPECIES_BELDUM + 0x15, // SPECIES_METANG + 0x09, // SPECIES_METAGROSS + 0x09, // SPECIES_REGIROCK + 0x09, // SPECIES_REGICE + 0x09, // SPECIES_REGISTEEL + 0x19, // SPECIES_KYOGRE + 0x17, // SPECIES_GROUDON + 0x0d, // SPECIES_RAYQUAZA + 0x01, // SPECIES_LATIAS + 0x01, // SPECIES_LATIOS + 0x11, // SPECIES_JIRACHI + 0x14, // SPECIES_DEOXYS + 0x11, // SPECIES_CHIMECHO +}; + +const u8 gUnknown_0860AA64[] = {0x00, 0x05, 0x01, 0x01, 0x00, 0x0f, 0x01, 0x04, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0xff}; + +const u8 gUnknown_0860AA80[] = {0x06, 0x1e, 0xfe, 0x0f, 0x06, 0x1e, 0xff, 0x00}; + +static void (* const sMonAnimFunctions[])(struct Sprite *sprite) = +{ + pokemonanimfunc_00, + pokemonanimfunc_01, + pokemonanimfunc_02, + pokemonanimfunc_03, + pokemonanimfunc_04, + pokemonanimfunc_05, + pokemonanimfunc_06, + pokemonanimfunc_07, + pokemonanimfunc_08, + pokemonanimfunc_09, + pokemonanimfunc_0A, + pokemonanimfunc_0B, + pokemonanimfunc_0C, + pokemonanimfunc_0D, + pokemonanimfunc_0E, + pokemonanimfunc_0F, + pokemonanimfunc_10, + pokemonanimfunc_11, + pokemonanimfunc_12, + pokemonanimfunc_13, + pokemonanimfunc_14, + pokemonanimfunc_15, + pokemonanimfunc_16, + pokemonanimfunc_17, + pokemonanimfunc_18, + pokemonanimfunc_19, + pokemonanimfunc_1A, + pokemonanimfunc_1B, + pokemonanimfunc_1C, + pokemonanimfunc_1D, + pokemonanimfunc_1E, + pokemonanimfunc_1F, + pokemonanimfunc_20, + pokemonanimfunc_21, + pokemonanimfunc_22, + pokemonanimfunc_23, + pokemonanimfunc_24, + pokemonanimfunc_25, + pokemonanimfunc_26, + pokemonanimfunc_27, + pokemonanimfunc_28, + pokemonanimfunc_29, + pokemonanimfunc_2A, + pokemonanimfunc_2B, + pokemonanimfunc_2C, + pokemonanimfunc_2D, + pokemonanimfunc_2E, + pokemonanimfunc_2F, + pokemonanimfunc_30, + pokemonanimfunc_31, + pokemonanimfunc_32, + pokemonanimfunc_33, + pokemonanimfunc_34, + pokemonanimfunc_35, + pokemonanimfunc_36, + pokemonanimfunc_37, + pokemonanimfunc_38, + pokemonanimfunc_39, + pokemonanimfunc_3A, + pokemonanimfunc_3B, + pokemonanimfunc_3C, + pokemonanimfunc_3D, + pokemonanimfunc_3E, + pokemonanimfunc_3F, + pokemonanimfunc_40, + pokemonanimfunc_41, + pokemonanimfunc_42, + pokemonanimfunc_43, + pokemonanimfunc_44, + pokemonanimfunc_45, + pokemonanimfunc_46, + pokemonanimfunc_47, + pokemonanimfunc_48, + pokemonanimfunc_49, + pokemonanimfunc_4A, + pokemonanimfunc_4B, + pokemonanimfunc_4C, + pokemonanimfunc_4D, + pokemonanimfunc_4E, + pokemonanimfunc_4F, + pokemonanimfunc_50, + pokemonanimfunc_51, + pokemonanimfunc_52, + pokemonanimfunc_53, + pokemonanimfunc_54, + pokemonanimfunc_55, + pokemonanimfunc_56, + pokemonanimfunc_57, + pokemonanimfunc_58, + pokemonanimfunc_59, + pokemonanimfunc_5A, + pokemonanimfunc_5B, + pokemonanimfunc_5C, + pokemonanimfunc_5D, + pokemonanimfunc_5E, + pokemonanimfunc_5F, + pokemonanimfunc_60, + pokemonanimfunc_61, + pokemonanimfunc_62, + pokemonanimfunc_63, + pokemonanimfunc_64, + pokemonanimfunc_65, + pokemonanimfunc_66, + pokemonanimfunc_67, + pokemonanimfunc_68, + pokemonanimfunc_69, + pokemonanimfunc_6A, + pokemonanimfunc_6B, + pokemonanimfunc_6C, + pokemonanimfunc_6D, + pokemonanimfunc_6E, + pokemonanimfunc_6F, + pokemonanimfunc_70, + pokemonanimfunc_71, + pokemonanimfunc_72, + pokemonanimfunc_73, + pokemonanimfunc_74, + pokemonanimfunc_75, + pokemonanimfunc_76, + pokemonanimfunc_77, + pokemonanimfunc_78, + pokemonanimfunc_79, + pokemonanimfunc_7A, + pokemonanimfunc_7B, + pokemonanimfunc_7C, + pokemonanimfunc_7D, + pokemonanimfunc_7E, + pokemonanimfunc_7F, + pokemonanimfunc_80, + pokemonanimfunc_81, + pokemonanimfunc_82, + pokemonanimfunc_83, + pokemonanimfunc_84, + pokemonanimfunc_85, + pokemonanimfunc_86, + pokemonanimfunc_87, + pokemonanimfunc_88, + pokemonanimfunc_89, + pokemonanimfunc_8A, + pokemonanimfunc_8B, + pokemonanimfunc_8C, + pokemonanimfunc_8D, + pokemonanimfunc_8E, + pokemonanimfunc_8F, + pokemonanimfunc_90, + pokemonanimfunc_91, + pokemonanimfunc_92, + pokemonanimfunc_93, + pokemonanimfunc_94, + pokemonanimfunc_95, + pokemonanimfunc_96 +}; + +// counting from Id 1, because 0 in sSpeciesToBackAnimId is used for mons with no back animation +static const u8 sBackAnimationIds[] = +{ + 0x60, 0x5f, 0x02, // 1 + 0x5e, 0x03, 0x46, // 2 + 0x6d, 0x3e, 0x6e, // 3 + 0x6f, 0x70, 0x3f, // 4 + 0x71, 0x13, 0x72, // 5 + 0x6c, 0x6b, 0x3a, // 6 + 0x64, 0x14, 0x4f, // 7 + 0x5d, 0x0f, 0x4c, // 8 + 0x61, 0x57, 0x58, // 9 + 0x67, 0x66, 0x59, // 0xA + 0x74, 0x73, 0x5a, // 0xB + 0x75, 0x76, 0x5b, // 0xC + 0x77, 0x78, 0x65, // 0xD + 0x63, 0x5c, 0x62, // 0xE + 0x6a, 0x69, 0x68, // 0xF + 0x7b, 0x7a, 0x79, // 0x10 + 0x7e, 0x7d, 0x7c, // 0x11 + 0x81, 0x80, 0x7f, // 0x12 + 0x84, 0x82, 0x83, // 0x13 + 0x85, 0x86, 0x87, // 0x14 + 0x88, 0x89, 0x8a, // 0x15 + 0x8b, 0x8c, 0x8d, // 0x16 + 0x8e, 0x8f, 0x90, // 0x17 + 0x91, 0x92, 0x93, // 0x18 + 0x94, 0x95, 0x96, // 0x19 +}; + +static const u8 sBackAnimNatureModTable[] = +{ + 0x00, // NATURE_HARDY + 0x02, // NATURE_LONELY + 0x00, // NATURE_BRAVE + 0x00, // NATURE_ADAMANT + 0x00, // NATURE_NAUGHTY + 0x01, // NATURE_BOLD + 0x01, // NATURE_DOCILE + 0x01, // NATURE_RELAXED + 0x00, // NATURE_IMPISH + 0x01, // NATURE_LAX + 0x02, // NATURE_TIMID + 0x00, // NATURE_HASTY + 0x01, // NATURE_SERIOUS + 0x00, // NATURE_JOLLY + 0x00, // NATURE_NAIVE + 0x02, // NATURE_MODEST + 0x02, // NATURE_MILD + 0x02, // NATURE_QUIET + 0x02, // NATURE_BASHFUL + 0x01, // NATURE_RASH + 0x01, // NATURE_CALM + 0x02, // NATURE_GENTLE + 0x01, // NATURE_SASSY + 0x02, // NATURE_CAREFUL + 0x01, // NATURE_QUIRKY +}; + +static const union AffineAnimCmd gSpriteAffineAnim_860AD48[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMDTYPE_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_860AD58[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMDTYPE_END +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_860AD68[] = +{ + gSpriteAffineAnim_860AD48, + gSpriteAffineAnim_860AD58 +}; + +// code +void MonAnimDummySpriteCallback(struct Sprite *sprite) +{ +} + +void sub_817F3F0(struct Sprite *sprite, s16 index, s16 amplitudeX, s16 amplitudeY) +{ + s16 xAdder, yAdder; + + amplitudeX *= -1; + amplitudeY *= -1; + + xAdder = Cos(index, amplitudeX) - Sin(index, amplitudeY); + yAdder = Cos(index, amplitudeY) + Sin(index, amplitudeX); + + amplitudeX *= -1; + amplitudeY *= -1; + + sprite->pos2.x = xAdder + amplitudeX; + sprite->pos2.y = yAdder + amplitudeY; +} + +u8 GetSpeciesBackAnimId(u16 species) +{ + if (sSpeciesToBackAnimId[species] != 0) + return sSpeciesToBackAnimId[species] - 1; + else + return 0; +} + +void sub_817F498(u8 taskId) +{ + u32 i; + struct Sprite *sprite = (struct Sprite*)(u32)((gTasks[taskId].data[1] << 0x10) | (gTasks[taskId].data[2])); + + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[4] = sprite->data[0]; + gTasks[taskId].data[5] = sprite->data[2]; + sprite->data[1] = 1; + sprite->data[0] = 0; + + for (i = 2; i < 8; i++) + sprite->data[i] = 0; + + sprite->callback = sMonAnimFunctions[gTasks[taskId].data[3]]; + gUnknown_03001274 = FALSE; + + gTasks[taskId].data[0]++; + } + if (sprite->callback == SpriteCallbackDummy) + { + sprite->data[0] = gTasks[taskId].data[4]; + sprite->data[2] = gTasks[taskId].data[5]; + sprite->data[1] = 0; + + DestroyTask(taskId); + } +} + +void LaunchAnimationTaskForFrontSprite(struct Sprite *sprite, u8 frontAnimId) +{ + u8 taskId = CreateTask(sub_817F498, 128); + gTasks[taskId].data[1] = (u32)(sprite) >> 0x10; + gTasks[taskId].data[2] = (u32)(sprite); + gTasks[taskId].data[3] = frontAnimId; +} + +void sub_817F578(struct Sprite *sprite, u8 frontAnimId) +{ + gUnknown_03001274 = TRUE; + sprite->callback = sMonAnimFunctions[frontAnimId]; +} + +void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimId) +{ + u8 nature, taskId, animId, bank; + + taskId = CreateTask(sub_817F498, 128); + gTasks[taskId].data[1] = (u32)(sprite) >> 0x10; + gTasks[taskId].data[2] = (u32)(sprite); + + bank = sprite->data[0]; + nature = GetNature(&gPlayerParty[gBattlePartyID[bank]]); + + animId = 3 * backAnimId + sBackAnimNatureModTable[nature]; + gTasks[taskId].data[3] = sBackAnimationIds[animId]; +} + +void sub_817F60C(struct Sprite *sprite) +{ + sprite->callback = MonAnimDummySpriteCallback; +} + +void sub_817F618(struct Sprite *sprite, s16 xScale, s16 yScale, u16 rotation) +{ + u8 matrixNum; + struct ObjAffineSrcData affineSrcData; + struct OamMatrix dest; + + affineSrcData.xScale = xScale; + affineSrcData.yScale = yScale; + affineSrcData.rotation = rotation; + + matrixNum = sprite->oam.matrixNum; + + ObjAffineSet(&affineSrcData, &dest, 1, 2); + gOamMatrices[matrixNum].a = dest.a; + gOamMatrices[matrixNum].b = dest.b; + gOamMatrices[matrixNum].c = dest.c; + gOamMatrices[matrixNum].d = dest.d; +} + +void sub_817F670(struct Sprite *sprite) +{ + sprite->oam.affineMode = 3; + sprite->affineAnims = gSpriteAffineAnimTable_860AD68; + + if (gUnknown_03001274 == TRUE) + InitSpriteAffineAnim(sprite); + + if (!sprite->data[1]) + StartSpriteAffineAnim(sprite, 1); + else + StartSpriteAffineAnim(sprite, 0); + + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); + sprite->affineAnimPaused = 1; +} + +void sub_817F6D4(struct Sprite *sprite, s16 xScale, s16 yScale, u16 rotation) +{ + if (!sprite->data[1]) + { + xScale *= -1; + rotation *= -1; + } + + sub_817F618(sprite, xScale, yScale, rotation); +} + +void sub_817F70C(struct Sprite *sprite) +{ + if (!sprite->data[1]) + sprite->pos2.x *= -1; +} + +bool32 sub_817F724(u8 id) +{ + if (id >= 4) + { + return FALSE; + } + else + { + gUnknown_03001240[id].field_6 = 0; + gUnknown_03001240[id].field_0 = 0; + gUnknown_03001240[id].field_4 = 1; + gUnknown_03001240[id].field_2 = 0; + gUnknown_03001240[id].field_8 = 0; + return TRUE; + } +} + +u8 sub_817F758(void) +{ + gUnknown_03001270 = (gUnknown_03001270 + 1) % 4; + sub_817F724(gUnknown_03001270); + return gUnknown_03001270; +} + +void sub_817F77C(struct Sprite *sprite) +{ + sprite->oam.affineMode = 1; + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); + + if (gUnknown_03001274 == TRUE) + { + if (!sprite->data[1]) + sprite->hFlip = 1; + else + sprite->hFlip = 0; + + FreeOamMatrix(sprite->oam.matrixNum); + sprite->oam.matrixNum |= (sprite->hFlip << 3); + sprite->oam.affineMode = 0; + } +}