From fdbe7fa7de9b2e1f8a22efca87201901fcea32b4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Jan 2018 20:45:44 +0100 Subject: [PATCH] up to 30 battle transitions --- asm/battle_transition.s | 2712 +---------------------------------- data/battle_transition.s | 235 --- include/battle_transition.h | 3 +- include/field_camera.h | 1 + ld_script.txt | 1 - src/battle_transition.c | 1664 ++++++++++++++++++--- src/tileset_anims.c | 5 +- 7 files changed, 1485 insertions(+), 3136 deletions(-) delete mode 100644 data/battle_transition.s diff --git a/asm/battle_transition.s b/asm/battle_transition.s index 675f46bfd..eb87f0563 100644 --- a/asm/battle_transition.s +++ b/asm/battle_transition.s @@ -5,2642 +5,8 @@ .text - - - - thumb_func_start Phase2Task_Rayquaza -Phase2Task_Rayquaza: @ 814927C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =sPhase2_Rayquaza_Funcs - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_0814928E: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _0814928E - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_Rayquaza - - thumb_func_start sub_81492B4 -sub_81492B4: @ 81492B4 - push {r4-r6,lr} - sub sp, 0xC - adds r4, r0, 0 - bl sub_8149F08 - bl dp12_8087EA4 - ldr r1, =0x00009a08 - movs r0, 0x8 - bl SetGpuReg - add r0, sp, 0x4 - add r1, sp, 0x8 - bl sub_8149F58 - mov r1, sp - movs r0, 0 - strh r0, [r1] - ldr r1, [sp, 0x4] - ldr r2, =0x01000400 - mov r0, sp - bl CpuSet - ldr r0, =gUnknown_085BF6A0 - ldr r1, [sp, 0x8] - movs r2, 0x80 - lsls r2, 5 - bl CpuSet - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - movs r0, 0 - strh r0, [r1, 0x20] - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - ldr r0, =gUnknown_085BF4A0+0xA0 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - movs r2, 0 - ldr r3, =gUnknown_02038C28 - movs r6, 0 - movs r0, 0xF0 - lsls r0, 3 - adds r5, r3, r0 - movs r4, 0x80 - lsls r4, 1 -_08149316: - lsls r1, r2, 1 - adds r0, r1, r3 - strh r6, [r0] - adds r1, r5 - strh r4, [r1] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0x9F - bls _08149316 - ldr r0, =sub_8149508 - bl SetVBlankCallback - movs r0, 0 - add sp, 0xC - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81492B4 - - thumb_func_start sub_8149358 -sub_8149358: @ 8149358 - push {r4,lr} - sub sp, 0x8 - adds r4, r0, 0 - add r1, sp, 0x4 - mov r0, sp - bl sub_8149F58 - ldr r0, =gUnknown_085C6BE0 - ldr r1, [sp] - movs r2, 0x80 - lsls r2, 4 - bl CpuSet - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0 - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149358 - - thumb_func_start sub_8149388 -sub_8149388: @ 8149388 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0xA] - movs r1, 0x3 - ands r0, r1 - cmp r0, 0 - bne _081493B4 - movs r1, 0xA - ldrsh r0, [r4, r1] - cmp r0, 0 - bge _081493A0 - adds r0, 0x3 -_081493A0: - lsls r0, 14 - lsrs r0, 16 - adds r0, 0x5 - lsls r0, 5 - ldr r1, =gUnknown_085BF4A0 - adds r0, r1 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette -_081493B4: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x28 - ble _081493CC - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0 - strh r0, [r4, 0xA] -_081493CC: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149388 - - thumb_func_start sub_81493D8 -sub_81493D8: @ 81493D8 - push {lr} - sub sp, 0x4 - adds r1, r0, 0 - ldrh r0, [r1, 0xA] - adds r0, 0x1 - movs r2, 0 - strh r0, [r1, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x14 - ble _08149402 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - strh r2, [r1, 0xA] - ldr r0, =0xffff8000 - str r2, [sp] - movs r1, 0x2 - movs r3, 0x10 - bl BeginNormalPaletteFade -_08149402: - movs r0, 0 - add sp, 0x4 - pop {r1} - bx r1 - .pool - thumb_func_end sub_81493D8 - - thumb_func_start sub_8149410 -sub_8149410: @ 8149410 - push {lr} - adds r2, r0, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0814942E - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - movs r0, 0x1 - strh r0, [r1, 0x20] - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] -_0814942E: - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149410 - - thumb_func_start sub_814943C -sub_814943C: @ 814943C - push {r4,lr} - adds r4, r0, 0 - ldr r0, =0x00007fff - movs r1, 0x8 - movs r2, 0 - bl BlendPalettes - ldr r0, =0xffff8000 - movs r1, 0 - movs r2, 0 - bl BlendPalettes - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814943C - - thumb_func_start sub_814946C -sub_814946C: @ 814946C - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0xA - ldrsh r5, [r4, r0] - adds r0, r5, 0 - movs r1, 0x3 - bl __modsi3 - lsls r0, 16 - cmp r0, 0 - bne _0814949A - adds r0, r5, 0 - movs r1, 0x3 - bl __divsi3 - lsls r0, 16 - lsrs r0, 11 - ldr r1, =gUnknown_085BF4A0 - adds r0, r1 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette -_0814949A: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x27 - ble _081494F0 - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - movs r0, 0 - strh r0, [r1, 0x2] - movs r0, 0x3F - strh r0, [r1, 0x4] - movs r0, 0xF0 - strh r0, [r1, 0x6] - movs r0, 0xA0 - strh r0, [r1, 0x8] - movs r1, 0 - ldr r5, =VBlankCB1_Phase2_BigPokeball - ldr r3, =gUnknown_020393A8 - movs r2, 0 -_081494C4: - lsls r0, r1, 1 - adds r0, r3 - strh r2, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x9F - bls _081494C4 - adds r0, r5, 0 - bl SetVBlankCallback - ldrh r0, [r4, 0x8] - adds r0, 0x1 - movs r2, 0 - strh r0, [r4, 0x8] - movs r1, 0x80 - lsls r1, 1 - strh r1, [r4, 0xC] - strh r2, [r4, 0x16] - movs r0, 0 - bl ClearGpuRegBits -_081494F0: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814946C - - thumb_func_start sub_8149508 -sub_8149508: @ 8149508 - push {lr} - ldr r1, =0x040000b0 - ldrh r2, [r1, 0xA] - ldr r0, =0x0000c5ff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r2, [r1, 0xA] - ldr r0, =0x00007fff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r0, [r1, 0xA] - bl VBlankCB_BattleTransition - ldr r0, =sTransitionStructPtr - ldr r0, [r0] - movs r1, 0x20 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _08149548 - ldr r2, =gUnknown_02038C28 - b _08149554 - .pool -_08149548: - ldr r2, =gUnknown_02038C28 - cmp r0, 0x1 - bne _08149554 - movs r0, 0xF0 - lsls r0, 3 - adds r2, r0 -_08149554: - ldr r1, =0x040000b0 - str r2, [r1] - ldr r0, =0x04000012 - str r0, [r1, 0x4] - ldr r0, =0xa2400001 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149508 - - thumb_func_start Phase2Task_WhiteFade -Phase2Task_WhiteFade: @ 8149578 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gUnknown_085C8D8C - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_0814958A: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _0814958A - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_WhiteFade - - thumb_func_start sub_81495B0 -sub_81495B0: @ 81495B0 - push {r4,r5,lr} - adds r5, r0, 0 - bl sub_8149F08 - bl dp12_8087EA4 - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - movs r2, 0 - movs r0, 0xBF - strh r0, [r1, 0xE] - strh r2, [r1, 0x12] - movs r0, 0x1E - strh r0, [r1, 0x2] - movs r0, 0x3F - strh r0, [r1, 0x4] - movs r0, 0xA0 - strh r0, [r1, 0x8] - movs r1, 0 - ldr r2, =gUnknown_020393A8 - movs r4, 0 - movs r3, 0xF0 -_081495DC: - lsls r0, r1, 1 - adds r0, r2 - strh r4, [r0] - adds r0, r1, 0 - adds r0, 0xA0 - lsls r0, 1 - adds r0, r2 - strh r3, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x9F - bls _081495DC - movs r0, 0x2 - bl EnableInterrupts - ldr r0, =sub_8149840 - bl SetHBlankCallback - ldr r0, =sub_8149774 - bl SetVBlankCallback - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81495B0 - - thumb_func_start sub_8149628 -sub_8149628: @ 8149628 - push {r4-r6,lr} - sub sp, 0x10 - adds r6, r0, 0 - ldr r1, =sUnknown_085C8DA0 - mov r0, sp - movs r2, 0x10 - bl memcpy - movs r5, 0 - movs r4, 0 -_0814963C: - ldr r0, =sub_8149864 - bl CreateInvisibleSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r2, r1, r0 - movs r0, 0xF0 - strh r0, [r2, 0x20] - strh r4, [r2, 0x22] - lsls r1, r5, 16 - asrs r1, 16 - lsls r0, r1, 1 - add r0, sp - ldrh r0, [r0] - strh r0, [r2, 0x38] - adds r1, 0x1 - lsls r1, 16 - lsls r0, r4, 16 - movs r3, 0xA0 - lsls r3, 13 - adds r0, r3 - lsrs r4, r0, 16 - lsrs r5, r1, 16 - asrs r1, 16 - cmp r1, 0x7 - ble _0814963C - ldrh r0, [r2, 0x3A] - adds r0, 0x1 - strh r0, [r2, 0x3A] - ldrh r0, [r6, 0x8] - adds r0, 0x1 - strh r0, [r6, 0x8] - movs r0, 0 - add sp, 0x10 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149628 - - thumb_func_start sub_814969C -sub_814969C: @ 814969C - push {r4,lr} - adds r4, r0, 0 - ldr r2, =sTransitionStructPtr - ldr r1, [r2] - ldrb r0, [r1] - movs r0, 0 - strb r0, [r1] - ldr r0, [r2] - movs r1, 0x20 - ldrsh r0, [r0, r1] - cmp r0, 0x7 - ble _081496C6 - movs r0, 0x1 - negs r0, r0 - ldr r2, =0x00007fff - movs r1, 0x10 - bl BlendPalettes - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_081496C6: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814969C - - thumb_func_start sub_81496D8 -sub_81496D8: @ 81496D8 - push {r4-r6,lr} - adds r6, r0, 0 - ldr r4, =sTransitionStructPtr - ldr r0, [r4] - ldrb r1, [r0] - movs r5, 0 - strb r5, [r0] - ldr r1, =0x040000b0 - ldrh r2, [r1, 0xA] - ldr r0, =0x0000c5ff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r2, [r1, 0xA] - ldr r0, =0x00007fff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r0, [r1, 0xA] - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - bl SetHBlankCallback - ldr r1, [r4] - movs r0, 0xF0 - strh r0, [r1, 0x6] - strh r5, [r1, 0x12] - movs r0, 0xFF - strh r0, [r1, 0xE] - movs r0, 0x3F - strh r0, [r1, 0x2] - ldr r0, =sub_8149804 - bl SetVBlankCallback - ldrh r0, [r6, 0x8] - adds r0, 0x1 - strh r0, [r6, 0x8] - movs r0, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81496D8 - - thumb_func_start sub_8149740 -sub_8149740: @ 8149740 - push {lr} - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - ldrh r0, [r1, 0x12] - adds r0, 0x1 - strh r0, [r1, 0x12] - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x10 - bls _08149766 - bl sub_8149F84 - ldr r0, =Phase2Task_WhiteFade - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask -_08149766: - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149740 - - thumb_func_start sub_8149774 -sub_8149774: @ 8149774 - push {r4,lr} - ldr r4, =0x040000b0 - ldrh r1, [r4, 0xA] - ldr r0, =0x0000c5ff - ands r0, r1 - strh r0, [r4, 0xA] - ldrh r1, [r4, 0xA] - ldr r0, =0x00007fff - ands r0, r1 - strh r0, [r4, 0xA] - ldrh r0, [r4, 0xA] - bl VBlankCB_BattleTransition - ldr r2, =0x04000050 - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - ldrh r0, [r1, 0xE] - strh r0, [r2] - subs r2, 0x8 - ldrh r0, [r1, 0x2] - strh r0, [r2] - adds r2, 0x2 - ldrh r0, [r1, 0x4] - strh r0, [r2] - subs r2, 0x6 - ldrh r0, [r1, 0x8] - strh r0, [r2] - ldrb r0, [r1] - cmp r0, 0 - beq _081497C4 - ldr r1, =0x040000d4 - ldr r0, =gUnknown_02038C28 - str r0, [r1] - movs r2, 0xF0 - lsls r2, 3 - adds r0, r2 - str r0, [r1, 0x4] - ldr r0, =0x80000140 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] -_081497C4: - ldr r0, =gUnknown_020394E8 - str r0, [r4] - ldr r0, =0x04000040 - str r0, [r4, 0x4] - ldr r0, =0xa2400001 - str r0, [r4, 0x8] - ldr r0, [r4, 0x8] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149774 - - thumb_func_start sub_8149804 -sub_8149804: @ 8149804 - push {lr} - bl VBlankCB_BattleTransition - ldr r1, =0x04000054 - ldr r0, =sTransitionStructPtr - ldr r2, [r0] - ldrh r0, [r2, 0x12] - strh r0, [r1] - subs r1, 0x4 - ldrh r0, [r2, 0xE] - strh r0, [r1] - subs r1, 0x8 - ldrh r0, [r2, 0x2] - strh r0, [r1] - adds r1, 0x2 - ldrh r0, [r2, 0x4] - strh r0, [r1] - subs r1, 0xA - ldrh r0, [r2, 0x6] - strh r0, [r1] - adds r1, 0x4 - ldrh r0, [r2, 0x8] - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149804 - - thumb_func_start sub_8149840 -sub_8149840: @ 8149840 - ldr r2, =0x04000054 - ldr r1, =gUnknown_02038C28 - ldr r0, =0x04000006 - ldrh r0, [r0] - lsls r0, 1 - movs r3, 0xF0 - lsls r3, 3 - adds r1, r3 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r2] - bx lr - .pool - thumb_func_end sub_8149840 - - thumb_func_start sub_8149864 -sub_8149864: @ 8149864 - push {r4-r6,lr} - adds r3, r0, 0 - ldrh r1, [r3, 0x38] - movs r2, 0x38 - ldrsh r0, [r3, r2] - cmp r0, 0 - beq _08149890 - subs r0, r1, 0x1 - strh r0, [r3, 0x38] - movs r1, 0x3A - ldrsh r0, [r3, r1] - cmp r0, 0 - beq _0814994C - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - ldrb r0, [r1] - movs r0, 0x1 - strb r0, [r1] - b _0814994C - .pool -_08149890: - movs r2, 0x22 - ldrsh r1, [r3, r2] - lsls r1, 1 - ldr r0, =gUnknown_02038C28 - adds r6, r1, r0 - movs r2, 0xA0 - lsls r2, 1 - adds r0, r2 - adds r5, r1, r0 - movs r4, 0 -_081498A4: - lsls r1, r4, 1 - adds r2, r1, r6 - ldrh r0, [r3, 0x2E] - lsls r0, 16 - asrs r0, 24 - strh r0, [r2] - adds r1, r5 - ldrh r0, [r3, 0x20] - lsls r0, 24 - lsrs r0, 24 - strh r0, [r1] - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x13 - bls _081498A4 - movs r1, 0x20 - ldrsh r0, [r3, r1] - ldrh r2, [r3, 0x20] - cmp r0, 0 - bne _081498DE - movs r0, 0x2E - ldrsh r1, [r3, r0] - movs r0, 0x80 - lsls r0, 5 - cmp r1, r0 - bne _081498DE - movs r0, 0x1 - strh r0, [r3, 0x30] -_081498DE: - adds r1, r2, 0 - subs r1, 0x10 - strh r1, [r3, 0x20] - ldrh r0, [r3, 0x2E] - adds r0, 0x80 - strh r0, [r3, 0x2E] - lsls r1, 16 - cmp r1, 0 - bge _081498F4 - movs r0, 0 - strh r0, [r3, 0x20] -_081498F4: - movs r1, 0x2E - ldrsh r0, [r3, r1] - movs r1, 0x80 - lsls r1, 5 - cmp r0, r1 - ble _08149902 - strh r1, [r3, 0x2E] -_08149902: - movs r2, 0x3A - ldrsh r0, [r3, r2] - cmp r0, 0 - beq _08149914 - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - ldrb r0, [r1] - movs r0, 0x1 - strb r0, [r1] -_08149914: - movs r1, 0x30 - ldrsh r0, [r3, r1] - cmp r0, 0 - beq _0814994C - movs r2, 0x3A - ldrsh r0, [r3, r2] - ldr r2, =sTransitionStructPtr - cmp r0, 0 - beq _0814993E - ldr r0, [r2] - movs r1, 0x20 - ldrsh r0, [r0, r1] - cmp r0, 0x6 - ble _0814994C - ldrh r0, [r3, 0x32] - adds r1, r0, 0x1 - strh r1, [r3, 0x32] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x7 - ble _0814994C -_0814993E: - ldr r1, [r2] - ldrh r0, [r1, 0x20] - adds r0, 0x1 - strh r0, [r1, 0x20] - adds r0, r3, 0 - bl DestroySprite -_0814994C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149864 - - thumb_func_start Phase2Task_GridSquares -Phase2Task_GridSquares: @ 814995C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =sUnknown_085C8DB0 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_0814996E: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _0814996E - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_GridSquares - - thumb_func_start sub_8149994 -sub_8149994: @ 8149994 - push {r4,lr} - sub sp, 0xC - adds r4, r0, 0 - add r0, sp, 0x4 - add r1, sp, 0x8 - bl sub_8149F58 - ldr r0, =sShrinkingBoxTileset - ldr r1, [sp, 0x8] - movs r2, 0x10 - bl CpuSet - mov r1, sp - movs r2, 0xF0 - lsls r2, 8 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, [sp, 0x4] - ldr r2, =0x01000400 - mov r0, sp - bl CpuSet - ldr r0, =gFieldEffectObjectPalette10 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0 - add sp, 0xC - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149994 - - thumb_func_start sub_81499E8 -sub_81499E8: @ 81499E8 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - movs r1, 0xA - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08149A2A - mov r0, sp - bl sub_8149F40 - movs r0, 0x3 - strh r0, [r4, 0xA] - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - movs r1, 0xC - ldrsh r0, [r4, r1] - lsls r0, 5 - ldr r1, =sShrinkingBoxTileset - adds r0, r1 - ldr r1, [sp] - movs r2, 0x10 - bl CpuSet - movs r1, 0xC - ldrsh r0, [r4, r1] - cmp r0, 0xD - ble _08149A2A - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0x10 - strh r0, [r4, 0xA] -_08149A2A: - ldrh r0, [r4, 0xA] - subs r0, 0x1 - strh r0, [r4, 0xA] - movs r0, 0 - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81499E8 - - thumb_func_start sub_8149A40 -sub_8149A40: @ 8149A40 - push {lr} - ldrh r1, [r0, 0xA] - subs r1, 0x1 - strh r1, [r0, 0xA] - lsls r1, 16 - cmp r1, 0 - bne _08149A60 - bl sub_8149F84 - ldr r0, =Phase2Task_GridSquares - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask -_08149A60: - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149A40 - - thumb_func_start Phase2Task_Shards -Phase2Task_Shards: @ 8149A6C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =sPhase2_Shards_Funcs - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_08149A7E: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _08149A7E - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_Shards - - thumb_func_start sub_8149AA4 -sub_8149AA4: @ 8149AA4 - push {r4,r5,lr} - adds r5, r0, 0 - bl sub_8149F08 - bl dp12_8087EA4 - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - movs r2, 0 - movs r0, 0x3F - strh r0, [r1, 0x2] - strh r2, [r1, 0x4] - movs r0, 0xA0 - strh r0, [r1, 0x8] - movs r1, 0 - ldr r2, =gUnknown_02038C28 - movs r3, 0xF0 - adds r4, r2, 0 -_08149AC8: - lsls r0, r1, 1 - adds r0, r2 - strh r3, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x9F - bls _08149AC8 - movs r0, 0xF0 - lsls r0, 3 - adds r1, r4, r0 - adds r0, r4, 0 - movs r2, 0xA0 - bl CpuSet - ldr r0, =sub_8149CE8 - bl SetVBlankCallback - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149AA4 - - thumb_func_start sub_8149B08 -sub_8149B08: @ 8149B08 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0xC - mov r8, r0 - ldr r0, =sTransitionStructPtr - ldr r0, [r0] - adds r0, 0x24 - ldr r6, =sUnknown_085C8DD0 - mov r2, r8 - movs r3, 0xA - ldrsh r1, [r2, r3] - lsls r4, r1, 2 - adds r4, r1 - lsls r4, 1 - adds r1, r4, r6 - movs r5, 0 - ldrsh r1, [r1, r5] - adds r2, r6, 0x2 - adds r2, r4, r2 - movs r3, 0 - ldrsh r2, [r2, r3] - adds r3, r6, 0x4 - adds r3, r4, r3 - movs r5, 0 - ldrsh r3, [r3, r5] - adds r5, r6, 0x6 - adds r4, r5 - movs r5, 0 - ldrsh r4, [r4, r5] - str r4, [sp] - movs r4, 0x1 - str r4, [sp, 0x4] - str r4, [sp, 0x8] - bl sub_814A1AC - mov r0, r8 - movs r2, 0xA - ldrsh r1, [r0, r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 1 - adds r6, 0x8 - adds r0, r6 - ldrh r0, [r0] - mov r3, r8 - strh r0, [r3, 0xC] - ldrh r0, [r3, 0x8] - adds r0, 0x1 - strh r0, [r3, 0x8] - movs r0, 0x1 - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149B08 - - thumb_func_start sub_8149B84 -sub_8149B84: @ 8149B84 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r6, r0, 0 - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - ldrb r0, [r1] - movs r0, 0 - strb r0, [r1] - mov r8, r0 - movs r7, 0 - ldr r0, =gUnknown_02038C28 - mov r9, r0 -_08149BA0: - ldr r1, =gUnknown_02038C28 - ldr r0, =sTransitionStructPtr - ldr r2, [r0] - movs r3, 0x2A - ldrsh r0, [r2, r3] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - lsrs r3, r0, 8 - movs r5, 0xFF - ands r5, r0 - movs r4, 0xC - ldrsh r0, [r6, r4] - cmp r0, 0 - bne _08149BDC - movs r1, 0x28 - ldrsh r0, [r2, r1] - cmp r3, r0 - bge _08149BC8 - ldrh r3, [r2, 0x28] -_08149BC8: - lsls r0, r3, 16 - lsls r1, r5, 16 - cmp r0, r1 - ble _08149BF4 - lsrs r3, r1, 16 - b _08149BF4 - .pool -_08149BDC: - lsls r0, r5, 16 - asrs r0, 16 - movs r4, 0x28 - ldrsh r1, [r2, r4] - cmp r0, r1 - ble _08149BEA - ldrh r5, [r2, 0x28] -_08149BEA: - lsls r0, r5, 16 - lsls r1, r3, 16 - cmp r0, r1 - bgt _08149BF4 - lsrs r5, r1, 16 -_08149BF4: - ldr r0, =sTransitionStructPtr - ldr r4, [r0] - movs r0, 0x2A - ldrsh r2, [r4, r0] - lsls r2, 1 - add r2, r9 - lsls r1, r3, 16 - asrs r1, 8 - lsls r0, r5, 16 - asrs r0, 16 - orrs r0, r1 - strh r0, [r2] - cmp r7, 0 - beq _08149C1C - ldrh r0, [r6, 0x8] - adds r0, 0x1 - strh r0, [r6, 0x8] - b _08149C40 - .pool -_08149C1C: - adds r0, r4, 0 - adds r0, 0x24 - movs r1, 0x1 - movs r2, 0x1 - bl sub_814A228 - lsls r0, 24 - lsrs r7, r0, 24 - mov r1, r8 - lsls r0, r1, 16 - movs r3, 0x80 - lsls r3, 9 - adds r0, r3 - lsrs r4, r0, 16 - mov r8, r4 - asrs r0, 16 - cmp r0, 0xF - ble _08149BA0 -_08149C40: - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - ldrb r0, [r1] - adds r0, 0x1 - ldrb r2, [r1] - strb r0, [r1] - movs r0, 0 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149B84 - - thumb_func_start sub_8149C60 -sub_8149C60: @ 8149C60 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0xA] - adds r0, 0x1 - strh r0, [r2, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x6 - ble _08149CAC - ldr r1, =0x040000b0 - ldrh r2, [r1, 0xA] - ldr r0, =0x0000c5ff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r2, [r1, 0xA] - ldr r0, =0x00007fff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r0, [r1, 0xA] - bl sub_8149F84 - ldr r0, =Phase2Task_Shards - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask - movs r0, 0 - b _08149CC4 - .pool -_08149CAC: - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] - ldr r1, =sUnknown_085C8E16 - movs r3, 0xA - ldrsh r0, [r2, r3] - subs r0, 0x1 - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r2, 0xE] - movs r0, 0x1 -_08149CC4: - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149C60 - - thumb_func_start sub_8149CCC -sub_8149CCC: @ 8149CCC - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0xE] - subs r0, 0x1 - strh r0, [r1, 0xE] - lsls r0, 16 - cmp r0, 0 - beq _08149CE0 - movs r0, 0 - b _08149CE4 -_08149CE0: - movs r0, 0x1 - strh r0, [r1, 0x8] -_08149CE4: - pop {r1} - bx r1 - thumb_func_end sub_8149CCC - - thumb_func_start sub_8149CE8 -sub_8149CE8: @ 8149CE8 - push {r4,lr} - ldr r4, =0x040000b0 - ldrh r1, [r4, 0xA] - ldr r0, =0x0000c5ff - ands r0, r1 - strh r0, [r4, 0xA] - ldrh r1, [r4, 0xA] - ldr r0, =0x00007fff - ands r0, r1 - strh r0, [r4, 0xA] - ldrh r0, [r4, 0xA] - bl VBlankCB_BattleTransition - ldr r3, =sTransitionStructPtr - ldr r0, [r3] - ldrb r0, [r0] - cmp r0, 0 - beq _08149D20 - ldr r1, =0x040000d4 - ldr r0, =gUnknown_02038C28 - str r0, [r1] - movs r2, 0xF0 - lsls r2, 3 - adds r0, r2 - str r0, [r1, 0x4] - ldr r0, =0x800000a0 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] -_08149D20: - ldr r2, =0x04000048 - ldr r1, [r3] - ldrh r0, [r1, 0x2] - strh r0, [r2] - adds r2, 0x2 - ldrh r0, [r1, 0x4] - strh r0, [r2] - subs r2, 0x6 - ldrh r0, [r1, 0x8] - strh r0, [r2] - subs r2, 0x4 - ldr r0, =gUnknown_02038C28 - movs r1, 0xF0 - lsls r1, 3 - adds r0, r1 - ldrh r1, [r0] - strh r1, [r2] - str r0, [r4] - str r2, [r4, 0x4] - ldr r0, =0xa2400001 - str r0, [r4, 0x8] - ldr r0, [r4, 0x8] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149CE8 - - thumb_func_start CreatePhase1Task -CreatePhase1Task: @ 8149D78 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x4 - mov r8, r0 - adds r4, r1, 0 - adds r5, r2, 0 - adds r6, r3, 0 - ldr r3, [sp, 0x18] - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - lsls r6, 16 - lsrs r6, 16 - lsls r3, 16 - lsrs r3, 16 - ldr r0, =sub_8149DFC - movs r1, 0x3 - str r3, [sp] - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - mov r0, r8 - strh r0, [r1, 0xA] - strh r4, [r1, 0xC] - strh r5, [r1, 0xE] - strh r6, [r1, 0x10] - ldr r3, [sp] - strh r3, [r1, 0x12] - strh r0, [r1, 0x14] - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end CreatePhase1Task - - thumb_func_start IsPhase1Done -IsPhase1Done: @ 8149DDC - push {lr} - ldr r0, =sub_8149DFC - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _08149DF4 - movs r0, 0 - b _08149DF6 - .pool -_08149DF4: - movs r0, 0x1 -_08149DF6: - pop {r1} - bx r1 - thumb_func_end IsPhase1Done - - thumb_func_start sub_8149DFC -sub_8149DFC: @ 8149DFC - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =sPhase1_TransitionAll_Funcs - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_08149E0E: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _08149E0E - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149DFC - - thumb_func_start sub_8149E34 -sub_8149E34: @ 8149E34 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x14] - movs r2, 0x14 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _08149E4C - subs r0, r1, 0x1 - strh r0, [r4, 0x14] - lsls r0, 16 - cmp r0, 0 - bne _08149E70 -_08149E4C: - ldrh r0, [r4, 0xA] - strh r0, [r4, 0x14] - ldrh r0, [r4, 0x10] - ldrh r1, [r4, 0x16] - adds r0, r1 - strh r0, [r4, 0x16] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x10 - ble _08149E64 - movs r0, 0x10 - strh r0, [r4, 0x16] -_08149E64: - movs r0, 0x1 - negs r0, r0 - ldrb r1, [r4, 0x16] - ldr r2, =0x00002d6b - bl BlendPalettes -_08149E70: - movs r2, 0x16 - ldrsh r0, [r4, r2] - cmp r0, 0xF - ble _08149E82 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - ldrh r0, [r4, 0xC] - strh r0, [r4, 0x14] -_08149E82: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8149E34 - - thumb_func_start sub_8149E90 -sub_8149E90: @ 8149E90 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x14] - movs r2, 0x14 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _08149EA8 - subs r0, r1, 0x1 - strh r0, [r4, 0x14] - lsls r0, 16 - cmp r0, 0 - bne _08149ECA -_08149EA8: - ldrh r0, [r4, 0xC] - strh r0, [r4, 0x14] - ldrh r0, [r4, 0x16] - ldrh r1, [r4, 0x12] - subs r0, r1 - strh r0, [r4, 0x16] - lsls r0, 16 - cmp r0, 0 - bge _08149EBE - movs r0, 0 - strh r0, [r4, 0x16] -_08149EBE: - movs r0, 0x1 - negs r0, r0 - ldrb r1, [r4, 0x16] - ldr r2, =0x00002d6b - bl BlendPalettes -_08149ECA: - movs r0, 0x16 - ldrsh r1, [r4, r0] - cmp r1, 0 - bne _08149EFE - ldrh r0, [r4, 0xE] - subs r0, 0x1 - strh r0, [r4, 0xE] - lsls r0, 16 - cmp r0, 0 - bne _08149EF8 - ldr r0, =sub_8149DFC - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask - b _08149EFE - .pool -_08149EF8: - ldrh r0, [r4, 0xA] - strh r0, [r4, 0x14] - strh r1, [r4, 0x8] -_08149EFE: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8149E90 - - thumb_func_start sub_8149F08 -sub_8149F08: @ 8149F08 - push {r4,lr} - ldr r4, =sTransitionStructPtr - ldr r0, [r4] - movs r1, 0 - movs r2, 0x3C - bl memset - ldr r1, [r4] - adds r0, r1, 0 - adds r0, 0x14 - adds r1, 0x16 - bl sub_8089C08 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149F08 - - thumb_func_start VBlankCB_BattleTransition -VBlankCB_BattleTransition: @ 8149F2C - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end VBlankCB_BattleTransition - - thumb_func_start sub_8149F40 -sub_8149F40: @ 8149F40 - ldr r1, =0x04000008 - ldrh r1, [r1] - lsrs r1, 2 - lsls r1, 30 - lsrs r1, 16 - movs r2, 0xC0 - lsls r2, 19 - adds r1, r2 - str r1, [r0] - bx lr - .pool - thumb_func_end sub_8149F40 - - thumb_func_start sub_8149F58 -sub_8149F58: @ 8149F58 - push {r4,lr} - ldr r3, =0x04000008 - ldrh r2, [r3] - lsrs r2, 8 - ldrh r3, [r3] - lsrs r3, 2 - lsls r2, 27 - lsrs r2, 16 - lsls r3, 30 - lsrs r3, 16 - movs r4, 0xC0 - lsls r4, 19 - adds r2, r4 - str r2, [r0] - adds r3, r4 - str r3, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149F58 - - thumb_func_start sub_8149F84 -sub_8149F84: @ 8149F84 - push {lr} - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - pop {r0} - bx r0 - thumb_func_end sub_8149F84 - - thumb_func_start sub_8149F98 -sub_8149F98: @ 8149F98 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r10, r0 - ldr r0, [sp, 0x20] - ldr r4, [sp, 0x24] - lsls r1, 16 - lsrs r7, r1, 16 - lsls r2, 16 - lsrs r2, 16 - lsls r3, 16 - lsrs r3, 16 - lsls r0, 16 - lsrs r1, r0, 16 - lsls r4, 16 - movs r6, 0 - lsrs r5, r4, 16 - cmp r4, 0 - ble _0814A000 - lsls r0, r7, 16 - asrs r0, 16 - mov r9, r0 - lsls r1, 16 - mov r8, r1 - lsls r0, r3, 16 - asrs r7, r0, 16 -_08149FD0: - lsls r4, r2, 16 - asrs r4, 16 - movs r0, 0xFF - ands r0, r4 - mov r2, r8 - asrs r1, r2, 16 - bl Sin - lsls r1, r6, 1 - add r1, r10 - add r0, r9 - strh r0, [r1] - lsls r1, r5, 16 - ldr r0, =0xffff0000 - adds r1, r0 - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r4, r7 - lsls r4, 16 - lsrs r2, r4, 16 - lsrs r5, r1, 16 - cmp r1, 0 - bgt _08149FD0 -_0814A000: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8149F98 - - thumb_func_start sub_814A014 -sub_814A014: @ 814A014 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - mov r9, r0 - adds r5, r2, 0 - adds r4, r3, 0 - lsls r1, 16 - lsrs r1, 16 - str r1, [sp] - lsls r5, 16 - lsrs r5, 16 - lsls r4, 16 - lsrs r4, 16 - movs r2, 0xA0 - lsls r2, 1 - movs r1, 0xA - bl memset - movs r1, 0 - lsls r4, 16 - asrs r4, 16 - str r4, [sp, 0x4] - lsls r5, 16 - asrs r5, 16 - str r5, [sp, 0x8] -_0814A04C: - lsls r5, r1, 16 - asrs r0, r5, 16 - mov r10, r0 - ldr r1, [sp, 0x4] - bl Sin - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - mov r0, r10 - ldr r1, [sp, 0x4] - bl Cos - ldr r2, [sp] - lsls r1, r2, 16 - asrs r1, 16 - lsls r4, 16 - asrs r4, 16 - subs r2, r1, r4 - lsls r2, 16 - adds r1, r4 - lsls r1, 16 - lsrs r6, r1, 16 - lsls r0, 16 - asrs r0, 16 - ldr r3, [sp, 0x8] - subs r1, r3, r0 - lsls r1, 16 - lsrs r7, r1, 16 - adds r0, r3, r0 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsrs r1, r2, 16 - str r5, [sp, 0x10] - cmp r2, 0 - bge _0814A098 - movs r1, 0 -_0814A098: - lsls r0, r6, 16 - asrs r0, 16 - cmp r0, 0xF0 - ble _0814A0A2 - movs r6, 0xF0 -_0814A0A2: - lsls r0, r7, 16 - cmp r0, 0 - bge _0814A0AA - movs r7, 0 -_0814A0AA: - mov r2, r8 - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, 0x9F - ble _0814A0B8 - movs r3, 0x9F - mov r8, r3 -_0814A0B8: - lsls r0, r1, 24 - lsrs r0, 16 - orrs r6, r0 - lsls r0, r7, 16 - asrs r0, 16 - str r0, [sp, 0xC] - lsls r0, 1 - add r0, r9 - strh r6, [r0] - mov r0, r8 - lsls r4, r0, 16 - asrs r0, r4, 15 - add r0, r9 - strh r6, [r0] - mov r0, r10 - adds r0, 0x1 - lsls r0, 16 - asrs r0, 16 - ldr r1, [sp, 0x4] - bl Cos - lsls r0, 16 - asrs r0, 16 - ldr r2, [sp, 0x8] - subs r1, r2, r0 - lsls r1, 16 - adds r0, r2, r0 - lsls r0, 16 - lsrs r2, r0, 16 - lsrs r3, r1, 16 - cmp r1, 0 - bge _0814A0FA - movs r3, 0 -_0814A0FA: - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, 0x9F - ble _0814A104 - movs r2, 0x9F -_0814A104: - lsls r0, r3, 16 - asrs r1, r0, 16 - adds r3, r0, 0 - lsls r5, r2, 16 - ldr r0, [sp, 0xC] - cmp r0, r1 - ble _0814A128 - adds r2, r1, 0 -_0814A114: - lsls r1, r7, 16 - ldr r0, =0xffff0000 - adds r1, r0 - asrs r0, r1, 15 - add r0, r9 - strh r6, [r0] - lsrs r7, r1, 16 - asrs r1, 16 - cmp r1, r2 - bgt _0814A114 -_0814A128: - lsls r1, r7, 16 - asrs r0, r3, 16 - cmp r1, r3 - bge _0814A146 - adds r2, r0, 0 -_0814A132: - movs r3, 0x80 - lsls r3, 9 - adds r0, r1, r3 - asrs r1, r0, 15 - add r1, r9 - strh r6, [r1] - adds r1, r0, 0 - asrs r0, r1, 16 - cmp r0, r2 - blt _0814A132 -_0814A146: - asrs r0, r5, 16 - cmp r4, r5 - ble _0814A164 - adds r1, r0, 0 -_0814A14E: - ldr r2, =0xffff0000 - adds r0, r4, r2 - lsrs r3, r0, 16 - mov r8, r3 - asrs r0, 15 - add r0, r9 - strh r6, [r0] - lsls r4, r3, 16 - asrs r0, r4, 16 - cmp r0, r1 - bgt _0814A14E -_0814A164: - mov r0, r8 - lsls r4, r0, 16 - asrs r0, r5, 16 - cmp r4, r5 - bge _0814A184 - adds r2, r0, 0 -_0814A170: - movs r1, 0x80 - lsls r1, 9 - adds r0, r4, r1 - asrs r1, r0, 15 - add r1, r9 - strh r6, [r1] - adds r4, r0, 0 - asrs r0, r4, 16 - cmp r0, r2 - blt _0814A170 -_0814A184: - ldr r2, [sp, 0x10] - movs r3, 0x80 - lsls r3, 9 - adds r0, r2, r3 - lsrs r1, r0, 16 - asrs r0, 16 - cmp r0, 0x3F - bgt _0814A196 - b _0814A04C -_0814A196: - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_814A014 - - thumb_func_start sub_814A1AC -sub_814A1AC: @ 814A1AC - push {r4-r7,lr} - adds r6, r0, 0 - ldr r0, [sp, 0x14] - ldr r5, [sp, 0x18] - ldr r4, [sp, 0x1C] - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - lsls r3, 16 - lsrs r3, 16 - lsls r0, 16 - lsrs r0, 16 - adds r7, r0, 0 - lsls r5, 16 - lsrs r5, 16 - lsls r4, 16 - lsrs r4, 16 - strh r1, [r6] - strh r2, [r6, 0x2] - strh r1, [r6, 0x4] - strh r2, [r6, 0x6] - strh r3, [r6, 0x8] - strh r7, [r6, 0xA] - strh r5, [r6, 0xC] - strh r4, [r6, 0xE] - lsls r3, 16 - asrs r3, 16 - lsls r1, 16 - asrs r1, 16 - subs r3, r1 - strh r3, [r6, 0x10] - lsls r0, r3, 16 - cmp r0, 0 - bge _0814A1FE - negs r0, r3 - strh r0, [r6, 0x10] - lsls r0, r5, 16 - asrs r0, 16 - negs r0, r0 - strh r0, [r6, 0xC] -_0814A1FE: - lsls r0, r7, 16 - asrs r0, 16 - lsls r1, r2, 16 - asrs r1, 16 - subs r1, r0, r1 - strh r1, [r6, 0x12] - lsls r0, r1, 16 - cmp r0, 0 - bge _0814A21C - negs r0, r1 - strh r0, [r6, 0x12] - lsls r0, r4, 16 - asrs r0, 16 - negs r0, r0 - strh r0, [r6, 0xE] -_0814A21C: - movs r0, 0 - strh r0, [r6, 0x14] - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_814A1AC - - thumb_func_start sub_814A228 -sub_814A228: @ 814A228 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r3, r0, 0 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - lsls r2, 24 - lsrs r2, 24 - mov r10, r2 - ldrh r0, [r3, 0x10] - mov r8, r0 - movs r1, 0x10 - ldrsh r6, [r3, r1] - ldrh r2, [r3, 0x12] - mov r12, r2 - movs r4, 0x12 - ldrsh r5, [r3, r4] - cmp r6, r5 - ble _0814A278 - ldrh r0, [r3, 0xC] - ldrh r2, [r3, 0x4] - adds r1, r0, r2 - strh r1, [r3, 0x4] - ldrh r2, [r3, 0x14] - add r2, r12 - strh r2, [r3, 0x14] - lsls r1, r2, 16 - asrs r1, 16 - adds r4, r0, 0 - ldrh r7, [r3, 0xE] - cmp r1, r6 - ble _0814A29E - ldrh r1, [r3, 0x6] - adds r0, r7, r1 - strh r0, [r3, 0x6] - mov r1, r8 - b _0814A29A -_0814A278: - ldrh r0, [r3, 0xE] - ldrh r2, [r3, 0x6] - adds r1, r0, r2 - strh r1, [r3, 0x6] - ldrh r2, [r3, 0x14] - add r2, r8 - strh r2, [r3, 0x14] - lsls r1, r2, 16 - asrs r1, 16 - ldrh r4, [r3, 0xC] - adds r7, r0, 0 - cmp r1, r5 - ble _0814A29E - ldrh r1, [r3, 0x4] - adds r0, r4, r1 - strh r0, [r3, 0x4] - mov r1, r12 -_0814A29A: - subs r0, r2, r1 - strh r0, [r3, 0x14] -_0814A29E: - movs r5, 0 - lsls r0, r4, 16 - asrs r2, r0, 16 - cmp r2, 0 - ble _0814A2B6 - movs r4, 0x4 - ldrsh r1, [r3, r4] - movs r4, 0x8 - ldrsh r0, [r3, r4] - ldrh r4, [r3, 0x8] - cmp r1, r0 - bge _0814A2C8 -_0814A2B6: - cmp r2, 0 - bge _0814A2D6 - movs r0, 0x4 - ldrsh r1, [r3, r0] - movs r2, 0x8 - ldrsh r0, [r3, r2] - ldrh r4, [r3, 0x8] - cmp r1, r0 - bgt _0814A2D6 -_0814A2C8: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - mov r0, r9 - cmp r0, 0 - beq _0814A2D6 - strh r4, [r3, 0x4] -_0814A2D6: - lsls r0, r7, 16 - asrs r2, r0, 16 - cmp r2, 0 - ble _0814A2EC - movs r4, 0x6 - ldrsh r1, [r3, r4] - movs r4, 0xA - ldrsh r0, [r3, r4] - ldrh r4, [r3, 0xA] - cmp r1, r0 - bge _0814A2FE -_0814A2EC: - cmp r2, 0 - bge _0814A30C - movs r0, 0x6 - ldrsh r1, [r3, r0] - movs r2, 0xA - ldrsh r0, [r3, r2] - ldrh r4, [r3, 0xA] - cmp r1, r0 - bgt _0814A30C -_0814A2FE: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - mov r0, r10 - cmp r0, 0 - beq _0814A30C - strh r4, [r3, 0x6] -_0814A30C: - cmp r5, 0x2 - beq _0814A314 - movs r0, 0 - b _0814A316 -_0814A314: - movs r0, 0x1 -_0814A316: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_814A228 - - thumb_func_start sub_814A324 -sub_814A324: @ 814A324 - push {r4,lr} - sub sp, 0xC - adds r4, r0, 0 - bl sub_814669C - add r0, sp, 0x4 - add r1, sp, 0x8 - bl sub_8149F58 - mov r1, sp - movs r0, 0 - strh r0, [r1] - ldr r1, [sp, 0x4] - ldr r2, =0x01000400 - mov r0, sp - bl CpuSet - ldr r0, =gUnknown_085C7C00 - ldr r1, [sp, 0x8] - bl LZ77UnCompVram - ldr r0, =gUnknown_085C7BE0 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0 - add sp, 0xC - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814A324 - - thumb_func_start sub_814A374 -sub_814A374: @ 814A374 - push {r4,lr} - sub sp, 0x10 - adds r4, r0, 0 - add r1, sp, 0xC - add r0, sp, 0x8 - bl sub_8149F58 - ldr r0, =gUnknown_085C828C - ldr r1, [sp, 0x8] - bl LZ77UnCompVram - ldr r0, =gUnknown_02038C28 - movs r1, 0x10 - ldrsh r2, [r4, r1] - movs r3, 0x12 - ldrsh r1, [r4, r3] - str r1, [sp] - movs r1, 0xA0 - str r1, [sp, 0x4] - movs r1, 0 - movs r3, 0x84 - bl sub_8149F98 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0x1 - add sp, 0x10 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814A374 - - thumb_func_start Phase2Task_29 -Phase2Task_29: @ 814A3BC - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gUnknown_085C99D0 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_0814A3CE: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _0814A3CE - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_29 - - thumb_func_start Phase2Task_30 -Phase2Task_30: @ 814A3F4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gUnknown_085C99E8 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_0814A406: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _0814A406 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_30 - - thumb_func_start sub_814A42C -sub_814A42C: @ 814A42C - push {r4-r6,lr} - sub sp, 0xC - adds r4, r0, 0 - bl sub_8149F08 - bl dp12_8087EA4 - movs r1, 0xC0 - lsls r1, 7 - movs r0, 0 - bl ClearGpuRegBits - movs r5, 0 - movs r0, 0x80 - lsls r0, 6 - strh r0, [r4, 0xC] - ldr r0, =0x00007fff - strh r0, [r4, 0xA] - strh r5, [r4, 0x12] - movs r0, 0x10 - strh r0, [r4, 0x14] - movs r0, 0xA0 - lsls r0, 4 - strh r0, [r4, 0x16] - ldr r6, =sTransitionStructPtr - ldr r2, [r6] - ldr r3, =0x00003f41 - strh r3, [r2, 0xE] - ldrh r0, [r4, 0x14] - lsls r0, 8 - ldrh r1, [r4, 0x12] - orrs r0, r1 - strh r0, [r2, 0x10] - ldr r0, =0x04000050 - strh r3, [r0] - ldr r1, =0x04000052 - ldrh r0, [r2, 0x10] - strh r0, [r1] - add r0, sp, 0x4 - add r1, sp, 0x8 - bl sub_8149F58 - mov r0, sp - strh r5, [r0] - ldr r1, [sp, 0x4] - ldr r2, =0x01000400 - bl CpuSet - ldr r0, =gUnknown_085C7C00 - ldr r1, [sp, 0x8] - bl LZ77UnCompVram - ldr r0, =gUnknown_085C7BE0 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - ldr r0, [r6] - strh r5, [r0, 0x16] - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0 - add sp, 0xC - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814A42C - - thumb_func_start sub_814A4D4 -sub_814A4D4: @ 814A4D4 - push {r4,lr} - sub sp, 0x8 - adds r4, r0, 0 - add r1, sp, 0x4 - mov r0, sp - bl sub_8149F58 - ldr r0, =gUnknown_085C828C - ldr r1, [sp] - bl LZ77UnCompVram - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r0, 0x1 - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814A4D4 - - thumb_func_start sub_814A500 -sub_814A500: @ 814A500 - push {r4-r6,lr} - adds r5, r0, 0 - movs r2, 0 - ldr r6, =sub_814A684 - ldr r4, =gUnknown_020393A8 - ldr r3, =sTransitionStructPtr -_0814A50C: - lsls r1, r2, 1 - adds r1, r4 - ldr r0, [r3] - ldrh r0, [r0, 0x16] - strh r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x9F - bls _0814A50C - adds r0, r6, 0 - bl SetVBlankCallback - ldr r0, =sub_814A6CC - bl SetHBlankCallback - movs r0, 0x2 - bl EnableInterrupts - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - movs r0, 0x1 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814A500 - - thumb_func_start sub_814A550 -sub_814A550: @ 814A550 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r4, r0, 0 - ldr r1, =sTransitionStructPtr - ldr r0, [r1] - ldrb r2, [r0] - movs r3, 0 - strb r3, [r0] - ldrh r2, [r4, 0xC] - lsls r0, r2, 16 - asrs r0, 24 - lsls r0, 16 - lsrs r7, r0, 16 - ldrh r6, [r4, 0xA] - movs r0, 0xC0 - lsls r0, 1 - mov r8, r0 - ldrh r0, [r4, 0x16] - subs r0, r6, r0 - strh r0, [r4, 0xA] - movs r5, 0xE - ldrsh r0, [r4, r5] - adds r5, r1, 0 - cmp r0, 0x45 - ble _0814A5A2 - movs r1, 0xC - ldrsh r0, [r4, r1] - ldr r1, =0xfffffe80 - adds r0, r1 - cmp r0, 0 - blt _0814A5A0 - adds r0, r2, r1 - strh r0, [r4, 0xC] - b _0814A5A2 - .pool -_0814A5A0: - strh r3, [r4, 0xC] -_0814A5A2: - movs r2, 0xE - ldrsh r0, [r4, r2] - cmp r0, 0 - blt _0814A5E0 - movs r1, 0x3 - bl __modsi3 - lsls r0, 16 - cmp r0, 0 - bne _0814A5E0 - ldrh r1, [r4, 0x12] - movs r2, 0x12 - ldrsh r0, [r4, r2] - cmp r0, 0xF - bgt _0814A5C6 - adds r0, r1, 0x1 - strh r0, [r4, 0x12] - b _0814A5D4 -_0814A5C6: - ldrh r1, [r4, 0x14] - movs r2, 0x14 - ldrsh r0, [r4, r2] - cmp r0, 0 - ble _0814A5D4 - subs r0, r1, 0x1 - strh r0, [r4, 0x14] -_0814A5D4: - ldr r0, [r5] - ldrh r1, [r4, 0x14] - lsls r1, 8 - ldrh r2, [r4, 0x12] - orrs r1, r2 - strh r1, [r0, 0x10] -_0814A5E0: - movs r5, 0 - lsls r7, 16 -_0814A5E4: - lsrs r0, r6, 8 - asrs r1, r7, 16 - bl Sin - ldr r1, =gUnknown_02038C28 - lsls r2, r5, 1 - adds r2, r1 - ldr r1, =sTransitionStructPtr - ldr r1, [r1] - ldrh r1, [r1, 0x16] - adds r0, r1 - strh r0, [r2] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - mov r1, r8 - adds r0, r6, r1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r5, 0x9F - bls _0814A5E4 - ldrh r0, [r4, 0xE] - adds r0, 0x1 - strh r0, [r4, 0xE] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x65 - bne _0814A632 - ldrh r0, [r4, 0x10] - adds r0, 0x1 - strh r0, [r4, 0x10] - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade -_0814A632: - movs r2, 0x10 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _0814A654 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0814A654 - ldr r0, =Phase2Task_30 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask -_0814A654: - ldrh r0, [r4, 0x16] - subs r0, 0x11 - strh r0, [r4, 0x16] - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - ldrb r0, [r1] - adds r0, 0x1 - ldrb r2, [r1] - strb r0, [r1] - movs r0, 0 - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_814A550 - - thumb_func_start sub_814A684 -sub_814A684: @ 814A684 - push {lr} - bl VBlankCB_BattleTransition - ldr r2, =0x04000050 - ldr r0, =sTransitionStructPtr - ldr r1, [r0] - ldrh r0, [r1, 0xE] - strh r0, [r2] - adds r2, 0x2 - ldrh r0, [r1, 0x10] - strh r0, [r2] - ldrb r0, [r1] - cmp r0, 0 - beq _0814A6B4 - ldr r1, =0x040000d4 - ldr r0, =gUnknown_02038C28 - str r0, [r1] - movs r2, 0xF0 - lsls r2, 3 - adds r0, r2 - str r0, [r1, 0x4] - ldr r0, =0x800000a0 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] -_0814A6B4: - pop {r0} - bx r0 - .pool - thumb_func_end sub_814A684 - - thumb_func_start sub_814A6CC -sub_814A6CC: @ 814A6CC - ldr r1, =gUnknown_02038C28 - ldr r0, =0x04000006 - ldrh r0, [r0] - lsls r0, 1 - movs r2, 0xF0 - lsls r2, 3 - adds r1, r2 - adds r0, r1 - ldrh r1, [r0] - ldr r0, =0x04000012 - strh r1, [r0] - bx lr - .pool - thumb_func_end sub_814A6CC - - thumb_func_start Phase2Task_31 -Phase2Task_31: @ 814A6F0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gUnknown_085C99F8 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_0814A702: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _0814A702 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_31 - - thumb_func_start Phase2Task_33 -Phase2Task_33: @ 814A728 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gUnknown_085C9A08 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_0814A73A: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _0814A73A - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_33 - - thumb_func_start Phase2Task_32 -Phase2Task_32: @ 814A760 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gUnknown_085C9A1C - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 -_0814A772: - movs r1, 0x8 - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _0814A772 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Phase2Task_32 - - thumb_func_start sub_814A798 -sub_814A798: @ 814A798 + thumb_func_start Phase2_31_Func1 +Phase2_31_Func1: @ 814A798 push {r4-r6,lr} mov r6, r8 push {r6} @@ -2702,10 +68,10 @@ sub_814A798: @ 814A798 pop {r1} bx r1 .pool - thumb_func_end sub_814A798 + thumb_func_end Phase2_31_Func1 - thumb_func_start sub_814A828 -sub_814A828: @ 814A828 + thumb_func_start Phase2_31_Func2 +Phase2_31_Func2: @ 814A828 push {r4,r5,lr} sub sp, 0x24 adds r4, r0, 0 @@ -2760,10 +126,10 @@ _0814A88A: pop {r1} bx r1 .pool - thumb_func_end sub_814A828 + thumb_func_end Phase2_31_Func2 - thumb_func_start sub_814A898 -sub_814A898: @ 814A898 + thumb_func_start Phase2_31_Func3 +Phase2_31_Func3: @ 814A898 push {r4-r6,lr} sub sp, 0x10 adds r4, r0, 0 @@ -2858,10 +224,10 @@ _0814A956: pop {r4-r6} pop {r1} bx r1 - thumb_func_end sub_814A898 + thumb_func_end Phase2_31_Func3 - thumb_func_start sub_814A960 -sub_814A960: @ 814A960 + thumb_func_start Phase2_33_Func1 +Phase2_33_Func1: @ 814A960 push {r4-r6,lr} mov r6, r8 push {r6} @@ -2931,10 +297,10 @@ sub_814A960: @ 814A960 pop {r1} bx r1 .pool - thumb_func_end sub_814A960 + thumb_func_end Phase2_33_Func1 - thumb_func_start sub_814AA04 -sub_814AA04: @ 814AA04 + thumb_func_start Phase2_33_Func2 +Phase2_33_Func2: @ 814AA04 push {r4-r6,lr} sub sp, 0x24 adds r6, r0, 0 @@ -2992,10 +358,10 @@ _0814AA70: pop {r1} bx r1 .pool - thumb_func_end sub_814AA04 + thumb_func_end Phase2_33_Func2 - thumb_func_start sub_814AA84 -sub_814AA84: @ 814AA84 + thumb_func_start Phase2_33_Func3 +Phase2_33_Func3: @ 814AA84 push {r4,lr} adds r4, r0, 0 movs r0, 0xE0 @@ -3018,10 +384,10 @@ sub_814AA84: @ 814AA84 pop {r1} bx r1 .pool - thumb_func_end sub_814AA84 + thumb_func_end Phase2_33_Func3 - thumb_func_start sub_814AAB8 -sub_814AAB8: @ 814AAB8 + thumb_func_start Phase2_33_Func4 +Phase2_33_Func4: @ 814AAB8 push {r4-r7,lr} mov r7, r8 push {r7} @@ -3130,10 +496,10 @@ _0814AB86: pop {r1} bx r1 .pool - thumb_func_end sub_814AAB8 + thumb_func_end Phase2_33_Func4 - thumb_func_start sub_814ABA0 -sub_814ABA0: @ 814ABA0 + thumb_func_start Phase2_31_33_Func5 +Phase2_31_33_Func5: @ 814ABA0 push {r4,lr} sub sp, 0x8 adds r4, r0, 0 @@ -3162,7 +528,7 @@ sub_814ABA0: @ 814ABA0 pop {r4} pop {r1} bx r1 - thumb_func_end sub_814ABA0 + thumb_func_end Phase2_31_33_Func5 thumb_func_start sub_814ABE4 sub_814ABE4: @ 814ABE4 @@ -3203,8 +569,8 @@ _0814AC24: .pool thumb_func_end sub_814ABE4 - thumb_func_start sub_814AC38 -sub_814AC38: @ 814AC38 + thumb_func_start Phase2_32_Func1 +Phase2_32_Func1: @ 814AC38 push {r4-r6,lr} sub sp, 0x10 adds r6, r0, 0 @@ -3318,10 +684,10 @@ _0814AD2E: pop {r1} bx r1 .pool - thumb_func_end sub_814AC38 + thumb_func_end Phase2_32_Func1 - thumb_func_start sub_814AD48 -sub_814AD48: @ 814AD48 + thumb_func_start Phase2_32_Func2 +Phase2_32_Func2: @ 814AD48 push {r4,lr} sub sp, 0x24 adds r4, r0, 0 @@ -3371,10 +737,10 @@ _0814ADA0: pop {r1} bx r1 .pool - thumb_func_end sub_814AD48 + thumb_func_end Phase2_32_Func2 - thumb_func_start sub_814ADB4 -sub_814ADB4: @ 814ADB4 + thumb_func_start Phase2_32_Func3 +Phase2_32_Func3: @ 814ADB4 push {r4,lr} adds r4, r0, 0 ldr r0, =0xffff7fff @@ -3391,10 +757,10 @@ sub_814ADB4: @ 814ADB4 pop {r1} bx r1 .pool - thumb_func_end sub_814ADB4 + thumb_func_end Phase2_32_Func3 - thumb_func_start sub_814ADD8 -sub_814ADD8: @ 814ADD8 + thumb_func_start Phase2_32_Func4 +Phase2_32_Func4: @ 814ADD8 push {r4,lr} sub sp, 0xC adds r4, r0, 0 @@ -3441,10 +807,10 @@ _0814AE2E: pop {r1} bx r1 .pool - thumb_func_end sub_814ADD8 + thumb_func_end Phase2_32_Func4 - thumb_func_start sub_814AE40 -sub_814AE40: @ 814AE40 + thumb_func_start Phase2_32_Func5 +Phase2_32_Func5: @ 814AE40 push {r4,r5,lr} sub sp, 0x8 adds r5, r0, 0 @@ -3488,6 +854,6 @@ sub_814AE40: @ 814AE40 pop {r1} bx r1 .pool - thumb_func_end sub_814AE40 + thumb_func_end Phase2_32_Func5 .align 2, 0 @ Don't pad with nop. diff --git a/data/battle_transition.s b/data/battle_transition.s deleted file mode 100644 index 68801b22e..000000000 --- a/data/battle_transition.s +++ /dev/null @@ -1,235 +0,0 @@ - - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -sPhase2_Rayquaza_Funcs:: @ 85C8D60 - .4byte Phase2_WeatherTrio_Func1 - .4byte Phase2_WaitPaletteFade - .4byte sub_81492B4 - .4byte sub_8149358 - .4byte sub_8149388 - .4byte sub_81493D8 - .4byte sub_8149410 - .4byte sub_814943C - .4byte sub_814946C - .4byte Phase2_Blackhole1_Func2 - .4byte Phase2_Blackhole1_Func3 - - .align 2 -gUnknown_085C8D8C:: @ 85C8D8C - .4byte sub_81495B0 - .4byte sub_8149628 - .4byte sub_814969C - .4byte sub_81496D8 - .4byte sub_8149740 - - .align 1 -sUnknown_085C8DA0:: @ 85C8DA0 - .2byte 0x0000, 0x0014, 0x000f, 0x0028, 0x000a, 0x0019, 0x0023, 0x0005 - - .align 2 -sUnknown_085C8DB0:: @ 85C8DB0 - .4byte sub_8149994 - .4byte sub_81499E8 - .4byte sub_8149A40 - - .align 2 -sPhase2_Shards_Funcs:: @ 85C8DBC - .4byte sub_8149AA4 - .4byte sub_8149B08 - .4byte sub_8149B84 - .4byte sub_8149C60 - .4byte sub_8149CCC - - .align 1 -sUnknown_085C8DD0:: @ 85C8DD0 - .2byte 0x0038, 0x0000, 0x0000, 0x00a0, 0x0000, 0x0068, 0x00a0, 0x00f0, 0x0058, 0x0001, 0x00f0, 0x0048, 0x0038, 0x0000, 0x0001, 0x0000 - .2byte 0x0020, 0x0090, 0x00a0, 0x0000, 0x0090, 0x00a0, 0x00b8, 0x0000, 0x0001, 0x0038, 0x0000, 0x00a8, 0x00a0, 0x0000, 0x00a8, 0x00a0 - .2byte 0x0030, 0x0000, 0x0001 - - .align 1 -sUnknown_085C8E16:: @ 85C8E16 - .2byte 0x0008, 0x0004, 0x0002, 0x0001, 0x0001, 0x0001, 0x0000 - - .align 2 -sPhase1_TransitionAll_Funcs:: @ 85C8E24 - .4byte sub_8149E34 - .4byte sub_8149E90 - - .align 2 -sSpriteImageTable_85C8E2C:: @ 85C8E2C - obj_frame_tiles sSpriteImage_85B98F0, 0x0200 - - .align 2 -sSpriteAnim_85C8E34:: @ 85C8E34 - obj_image_anim_frame 0, 1 - obj_image_anim_end - - .align 2 -sSpriteAnimTable_85C8E3C:: @ 85C8E3C - .4byte sSpriteAnim_85C8E34 - - .align 2 -sSpriteAffineAnim_85C8E40:: @ 85C8E40 - obj_rot_scal_anim_frame 0, 0, -4, 1 - obj_rot_scal_anim_jump 0 - - .align 2 -sSpriteAffineAnim_85C8E50:: @ 85C8E50 - obj_rot_scal_anim_frame 0, 0, 4, 1 - obj_rot_scal_anim_jump 0 - - .align 2 -sSpriteAffineAnimTable_85C8E60:: @ 85C8E60 - .4byte sSpriteAffineAnim_85C8E40 - .4byte sSpriteAffineAnim_85C8E50 - - .align 2 -gUnknown_085C8E68:: @ 85C8E68 - spr_template 0xffff, 0x1009, gFieldObjectBaseOam_32x32, sSpriteAnimTable_85C8E3C, sSpriteImageTable_85C8E2C, sSpriteAffineAnimTable_85C8E60, sub_814713C - - .align 2 -gOamData_85C8E80:: @ 85C8E80 - .2byte 0x0000, 0xc000, 0x0000, 0x0000 - - .align 2 -sSpriteImageTable_85C8E88:: @ 85C8E88 - obj_frame_tiles sSpriteImage_85B9CD0, 0x0800 - - .align 2 -sSpriteImageTable_85C8E90:: @ 85C8E90 - obj_frame_tiles sSpriteImage_85BA4D0, 0x0800 - - .align 2 -sSpriteAnim_85C8E98:: @ 85C8E98 - obj_image_anim_frame 0, 1 - obj_image_anim_end - - .align 2 -sSpriteAnimTable_85C8EA0:: @ 85C8EA0 - .4byte sSpriteAnim_85C8E98 - - .align 2 -sSpriteTemplate_85C8EA4:: @ 85C8EA4 - spr_template 0xffff, 0x100a, gOamData_85C8E80, sSpriteAnimTable_85C8EA0, sSpriteImageTable_85C8E88, gDummySpriteAffineAnimTable, sub_8148380 - - .align 2 -sSpriteTemplate_85C8EBC:: @ 85C8EBC - spr_template 0xffff, 0x100a, gOamData_85C8E80, sSpriteAnimTable_85C8EA0, sSpriteImageTable_85C8E90, gDummySpriteAffineAnimTable, sub_8148380 - - .align 2 -gFieldEffectObjectPalette10:: @ 85C8ED4 - .incbin "graphics/map_objects/palettes/field_effect_object_palette_10.gbapal" - - .align 2 -gFieldEffectObjectPaletteInfo10:: @ 85C8EF4 - obj_pal gFieldEffectObjectPalette10, 0x1009 - - .align 2 -sMugshotPal_Sidney:: @ 85C8EFC - .incbin "graphics/battle_transitions/sidney_bg.gbapal" - - .align 2 -sMugshotPal_Phoebe:: @ 85C8F1C - .incbin "graphics/battle_transitions/phoebe_bg.gbapal" - - .align 2 -sMugshotPal_Glacia:: @ 85C8F3C - .incbin "graphics/battle_transitions/glacia_bg.gbapal" - - .align 2 -sMugshotPal_Drake:: @ 85C8F5C - .incbin "graphics/battle_transitions/drake_bg.gbapal" - - .align 2 -sMugshotPal_Wallace:: @ 85C8F7C - .incbin "graphics/battle_transitions/wallace_bg.gbapal" - - .align 2 -sMugshotPal_Brendan:: @ 85C8F9C - .incbin "graphics/battle_transitions/brendan_bg.gbapal" - - .align 2 -sMugshotPal_May:: @ 85C8EFC - .incbin "graphics/battle_transitions/may_bg.gbapal" - - .align 2 -sOpponentMugshotsPals:: @ 85C8FDC - .4byte sMugshotPal_Sidney - .4byte sMugshotPal_Phoebe - .4byte sMugshotPal_Glacia - .4byte sMugshotPal_Drake - .4byte sMugshotPal_Wallace - - .align 2 -sPlayerMugshotsPals:: @ 85C8FF0 - .4byte sMugshotPal_Brendan - .4byte sMugshotPal_May - - .align 2 -sUnusedTrainerPalette:: @ 85C8EF8 - .incbin "graphics/battle_transitions/unused_trainer.gbapal" - - .align 2 -sSpritePalette_UnusedTrainer:: @ 85C8EFC - obj_pal sUnusedTrainerPalette, 0x100A - - .align 2 -sBigPokeball_Tilemap:: @ 85C9020 - .incbin "graphics/battle_transitions/big_pokeball_map.bin" - - .align 2 -sMugshotsTilemap:: @ 85C94D0 - .incbin "graphics/battle_transitions/elite_four_bg_map.bin" - - .align 2 -gUnknown_085C99D0:: @ 85C99D0 - .4byte sub_814A324 - .4byte sub_814A374 - .4byte Phase2_BigPokeball_Func3 - .4byte Phase2_BigPokeball_Func4 - .4byte Phase2_BigPokeball_Func5 - .4byte Phase2_BigPokeball_Func6 - - .align 2 -gUnknown_085C99E8:: @ 85C99E8 - .4byte sub_814A42C - .4byte sub_814A4D4 - .4byte sub_814A500 - .4byte sub_814A550 - - .align 2 -gUnknown_085C99F8:: @ 85C99F8 - .4byte sub_814A798 - .4byte sub_814A828 - .4byte sub_814A898 - .4byte sub_814ABA0 - - .align 2 -gUnknown_085C9A08:: @ 85C9A08 - .4byte sub_814A960 - .4byte sub_814AA04 - .4byte sub_814AA84 - .4byte sub_814AAB8 - .4byte sub_814ABA0 - - .align 2 -gUnknown_085C9A1C:: @ 85C9A1C - .4byte sub_814AC38 - .4byte sub_814AD48 - .4byte sub_814ADB4 - .4byte sub_814ADD8 - .4byte sub_814AE40 - -gUnknown_085C9A30:: @ 85C9A30 - .byte 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x1b, 0x14, 0x0d, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x07, 0x0e, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x13, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x0f - .byte 0x10, 0x11, 0x12 - -gUnknown_085C9A53:: @ 85C9A53 - .byte 0x00, 0x10, 0x29, 0x16, 0x2c, 0x02, 0x2b, 0x15, 0x2e, 0x1b, 0x09, 0x30, 0x26, 0x05, 0x39, 0x3b, 0x0c, 0x3f, 0x23, 0x1c, 0x0a, 0x35, 0x07, 0x31, 0x27, 0x17, 0x37, 0x01, 0x3e, 0x11, 0x3d, 0x1e - .byte 0x06, 0x22, 0x0f, 0x33, 0x20, 0x3a, 0x0d, 0x2d, 0x25, 0x34, 0x0b, 0x18, 0x3c, 0x13, 0x38, 0x21, 0x1d, 0x32, 0x28, 0x36, 0x0e, 0x03, 0x2f, 0x14, 0x12, 0x19, 0x04, 0x24, 0x1a, 0x2a, 0x1f, 0x08 - .byte 0x00 - diff --git a/include/battle_transition.h b/include/battle_transition.h index bb8505edb..cd4cdd1b3 100644 --- a/include/battle_transition.h +++ b/include/battle_transition.h @@ -6,6 +6,7 @@ void sub_8149DFC(u8 a1); void BattleTransition_StartOnField(u8 transitionID); void BattleTransition_Start(u8 transitionID); bool8 IsBattleTransitionDone(void); +void Phase1_Task_RunFuncs(u8 taskId); enum // TRANSITION_MUGSHOT { @@ -46,7 +47,7 @@ enum // TRANSITION_MUGSHOT #define B_TRANSITION_KYOGRE 22 #define B_TRANSITION_GROUDON 23 #define B_TRANSITION_RAYQUAZA 24 -#define B_TRANSITION_25 25 +#define B_TRANSITION_SHRED_SPLIT 25 #define B_TRANSITION_BLACKHOLE1 26 #define B_TRANSITION_BLACKHOLE2 27 #define B_TRANSITION_RECTANGULAR_SPIRAL 28 diff --git a/include/field_camera.h b/include/field_camera.h index a8559e1c2..4686742d3 100644 --- a/include/field_camera.h +++ b/include/field_camera.h @@ -24,5 +24,6 @@ extern u16 gUnknown_03005DE8; void DrawWholeMapView(void); void CurrentMapDrawMetatileAt(int x, int y); +void sub_8089C08(s16 *a0, s16 *a1); #endif //GUARD_FIELD_CAMERA_H diff --git a/ld_script.txt b/ld_script.txt index 7aeee8c8d..c74413f19 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -448,7 +448,6 @@ SECTIONS { data/pokedex_cry_screen.o(.rodata); src/landmark.o(.rodata); src/battle_transition.o(.rodata); - data/battle_transition.o(.rodata); src/battle_controller_link_partner.o(.rodata); src/battle_message.o(.rodata); data/cable_car.o(.rodata); diff --git a/src/battle_transition.c b/src/battle_transition.c index 04f48b126..def302889 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -7,6 +7,7 @@ #include "palette.h" #include "trig.h" #include "field_effect.h" +#include "field_camera.h" #include "random.h" #include "sprite.h" #include "sound.h" @@ -56,6 +57,8 @@ typedef bool8 (*TransitionSpriteCallback)(struct Sprite *sprite); extern u16 gUnknown_020393A8[]; extern u16 gUnknown_02038C28[][0x3C0]; +extern const struct OamData gFieldObjectBaseOam_32x32; + extern void c2_exit_to_overworld_2_switch(void); extern void sub_80AC3D0(void); extern void dp12_8087EA4(void); @@ -89,7 +92,7 @@ void Phase2Task_Regirock(u8 taskId); void Phase2Task_Kyogre(u8 taskId); void Phase2Task_Groudon(u8 taskId); void Phase2Task_Rayquaza(u8 taskId); -void Phase2Task_25(u8 taskId); +void Phase2Task_ShredSplit(u8 taskId); void Phase2Task_Blackhole1(u8 taskId); void Phase2Task_Blackhole2(u8 taskId); void Phase2Task_RectangularSpiral(u8 taskId); @@ -108,6 +111,8 @@ void VBlankCB1_Phase2_BigPokeball(void); void VBlankCB_Phase2_Clockwise_BlackFade(void); void VBlankCB_Phase2_Ripple(void); void HBlankCB_Phase2_Ripple(void); +void VBlankCB_Phase2_30(void); +void HBlankCB_Phase2_30(void); void VBlankCB_Phase2_Wave(void); void VBlankCB_Phase2_Slice(void); void HBlankCB_Phase2_Slice(void); @@ -115,6 +120,7 @@ void VBlankCB0_Phase2_WhiteFade(void); void VBlankCB1_Phase2_WhiteFade(void); void HBlankCB_Phase2_WhiteFade(void); void VBlankCB_Phase2_Shards(void); +void VBlankCB_Phase2_Rayquaza(void); bool8 Phase2_Blur_Func1(struct Task *task); bool8 Phase2_Blur_Func2(struct Task *task); bool8 Phase2_Blur_Func3(struct Task *task); @@ -178,10 +184,10 @@ bool8 Phase2_Shards_Func2(struct Task *task); bool8 Phase2_Shards_Func3(struct Task *task); bool8 Phase2_Shards_Func4(struct Task *task); bool8 Phase2_Shards_Func5(struct Task *task); -bool8 Phase2_25_Func1(struct Task *task); -bool8 Phase2_25_Func2(struct Task *task); -bool8 Phase2_25_Func3(struct Task *task); -bool8 Phase2_25_Func4(struct Task *task); +bool8 Phase2_ShredSplit_Func1(struct Task *task); +bool8 Phase2_ShredSplit_Func2(struct Task *task); +bool8 Phase2_ShredSplit_Func3(struct Task *task); +bool8 Phase2_ShredSplit_Func4(struct Task *task); bool8 Phase2_Blackhole_Func1(struct Task *task); bool8 Phase2_Blackhole1_Func2(struct Task *task); bool8 Phase2_Blackhole1_Func3(struct Task *task); @@ -189,6 +195,32 @@ bool8 Phase2_Blackhole2_Func2(struct Task *task); bool8 Phase2_RectangularSpiral_Func1(struct Task *task); bool8 Phase2_RectangularSpiral_Func2(struct Task *task); bool8 Phase2_RectangularSpiral_Func3(struct Task *task); +bool8 Phase2_29_Func1(struct Task *task); +bool8 Phase2_29_Func2(struct Task *task); +bool8 Phase2_30_Func1(struct Task *task); +bool8 Phase2_30_Func2(struct Task *task); +bool8 Phase2_30_Func3(struct Task *task); +bool8 Phase2_30_Func4(struct Task *task); +bool8 Phase2_Rayquaza_Func3(struct Task *task); +bool8 Phase2_Rayquaza_Func4(struct Task *task); +bool8 Phase2_Rayquaza_Func5(struct Task *task); +bool8 Phase2_Rayquaza_Func6(struct Task *task); +bool8 Phase2_Rayquaza_Func7(struct Task *task); +bool8 Phase2_Rayquaza_Func8(struct Task *task); +bool8 Phase2_Rayquaza_Func9(struct Task *task); +bool8 Phase2_31_Func1(struct Task *task); +bool8 Phase2_31_Func2(struct Task *task); +bool8 Phase2_31_Func3(struct Task *task); +bool8 Phase2_31_33_Func5(struct Task *task); +bool8 Phase2_33_Func1(struct Task *task); +bool8 Phase2_33_Func2(struct Task *task); +bool8 Phase2_33_Func3(struct Task *task); +bool8 Phase2_33_Func4(struct Task *task); +bool8 Phase2_32_Func1(struct Task *task); +bool8 Phase2_32_Func2(struct Task *task); +bool8 Phase2_32_Func3(struct Task *task); +bool8 Phase2_32_Func4(struct Task *task); +bool8 Phase2_32_Func5(struct Task *task); bool8 Phase2_Mugshot_Func1(struct Task *task); bool8 Phase2_Mugshot_Func2(struct Task *task); bool8 Phase2_Mugshot_Func3(struct Task *task); @@ -214,15 +246,19 @@ void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4); void sub_814A014(u16 *a0, s16 a1, s16 a2, s16 a3); void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize); void sub_8149F58(u16 **a0, u16 **a1); +void sub_8149F40(u16 **a0); void sub_814A1AC(s16 *a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6); bool8 sub_814A228(s16 *a0, bool8 a1, bool8 a2); void sub_8148484(s16 spriteId, s16 value); void sub_814849C(s16 spriteId); s16 sub_81484B8(s16 spriteId); +bool8 Phase1_TransitionAll_Func1(struct Task *task); +bool8 Phase1_TransitionAll_Func2(struct Task *task); bool8 IsPhase1Done(void); bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpiral *arg1); void sub_814713C(struct Sprite *sprite); void sub_8148380(struct Sprite *sprite); +void sub_8149864(struct Sprite *sprite); bool8 sub_81483A8(struct Sprite *sprite); bool8 sub_81483AC(struct Sprite *sprite); bool8 sub_81483F8(struct Sprite *sprite); @@ -236,15 +272,15 @@ IWRAM_DATA static u8 sTestingTransitionState; IWRAM_DATA static struct StructRectangularSpiral sRectangularSpiralTransition[4]; // ewram vars -EWRAM_DATA struct TransitionData *sTransitionStructPtr = NULL; +EWRAM_DATA static struct TransitionData *sTransitionStructPtr = NULL; // const rom data const u32 sBigPokeball_Tileset[] = INCBIN_U32("graphics/battle_transitions/big_pokeball.4bpp"); const u32 sPokeballTrail_Tileset[] = INCBIN_U32("graphics/battle_transitions/pokeball_trail.4bpp"); -const u32 sSpriteImage_85B98F0[] = INCBIN_U32("graphics/battle_transitions/pokeball.4bpp"); +const u8 sSpriteImage_85B98F0[] = INCBIN_U8("graphics/battle_transitions/pokeball.4bpp"); const u32 sUnknown_085B9AF0[] = INCBIN_U32("graphics/battle_transitions/elite_four_bg.4bpp"); -const u32 sSpriteImage_85B9CD0[] = INCBIN_U32("graphics/battle_transitions/unused_brendan.4bpp"); -const u32 sSpriteImage_85BA4D0[] = INCBIN_U32("graphics/battle_transitions/unused_lass.4bpp"); +const u8 sSpriteImage_85B9CD0[] = INCBIN_U8("graphics/battle_transitions/unused_brendan.4bpp"); +const u8 sSpriteImage_85BA4D0[] = INCBIN_U8("graphics/battle_transitions/unused_lass.4bpp"); const u32 sShrinkingBoxTileset[] = INCBIN_U32("graphics/battle_transitions/shrinking_box.4bpp"); const u32 sEvilTeam_Palette[] = INCBIN_U32("graphics/battle_transitions/evil_team.gbapal"); const u32 sTeamAqua_Tileset[] = INCBIN_U32("graphics/battle_transitions/team_aqua.4bpp.lz"); @@ -312,7 +348,7 @@ const TaskFunc sPhase2_Tasks[B_TRANSITION_COUNT] = Phase2Task_Kyogre, // 22 Phase2Task_Groudon, // 23 Phase2Task_Rayquaza, // 24 - Phase2Task_25, // 25 + Phase2Task_ShredSplit, // 25 Phase2Task_Blackhole1, // 26 Phase2Task_Blackhole2, // 27 Phase2Task_RectangularSpiral, // 28 @@ -527,12 +563,12 @@ const TransitionStateFunc sPhase2_Slice_Funcs[] = Phase2_Slice_Func3 }; -const TransitionStateFunc sPhase2_25_Funcs[] = +const TransitionStateFunc sPhase2_ShredSplit_Funcs[] = { - Phase2_25_Func1, - Phase2_25_Func2, - Phase2_25_Func3, - Phase2_25_Func4 + Phase2_ShredSplit_Func1, + Phase2_ShredSplit_Func2, + Phase2_ShredSplit_Func3, + Phase2_ShredSplit_Func4 }; const u8 gUnknown_085C8C64[] = {39, 119}; @@ -619,12 +655,257 @@ const TransitionStateFunc sPhase2_Groudon_Funcs[] = Phase2_WeatherDuo_Func7 }; -extern const u16 gFieldEffectObjectPalette10[]; -extern const u16 sBigPokeball_Tilemap[]; -extern const u16 sMugshotsTilemap[]; -extern const struct SpriteTemplate gUnknown_085C8E68; -extern const u16 *const sOpponentMugshotsPals[MUGSHOTS_COUNT]; -extern const u16 *const sPlayerMugshotsPals[2]; +const TransitionStateFunc sPhase2_Rayquaza_Funcs[] = +{ + Phase2_WeatherTrio_Func1, + Phase2_WaitPaletteFade, + Phase2_Rayquaza_Func3, + Phase2_Rayquaza_Func4, + Phase2_Rayquaza_Func5, + Phase2_Rayquaza_Func6, + Phase2_Rayquaza_Func7, + Phase2_Rayquaza_Func8, + Phase2_Rayquaza_Func9, + Phase2_Blackhole1_Func2, + Phase2_Blackhole1_Func3 +}; + +const TransitionStateFunc sPhase2_WhiteFade_Funcs[] = +{ + Phase2_WhiteFade_Func1, + Phase2_WhiteFade_Func2, + Phase2_WhiteFade_Func3, + Phase2_WhiteFade_Func4, + Phase2_WhiteFade_Func5 +}; + +const s16 sUnknown_085C8DA0[] = {0, 20, 15, 40, 10, 25, 35, 5}; + +const TransitionStateFunc sPhase2_GridSquares_Funcs[] = +{ + Phase2_GridSquares_Func1, + Phase2_GridSquares_Func2, + Phase2_GridSquares_Func3 +}; + +const TransitionStateFunc sPhase2_Shards_Funcs[] = +{ + Phase2_Shards_Func1, + Phase2_Shards_Func2, + Phase2_Shards_Func3, + Phase2_Shards_Func4, + Phase2_Shards_Func5 +}; + +const s16 sUnknown_085C8DD0[][5] = +{ + {56, 0, 0, 160, 0}, + {104, 160, 240, 88, 1}, + {240, 72, 56, 0, 1}, + {0, 32, 144, 160, 0}, + {144, 160, 184, 0, 1}, + {56, 0, 168, 160, 0}, + {168, 160, 48, 0, 1}, +}; + +const s16 sUnknown_085C8E16[] = {8, 4, 2, 1, 1, 1, 0}; + +const TransitionStateFunc sPhase1_TransitionAll_Funcs[] = +{ + Phase1_TransitionAll_Func1, + Phase1_TransitionAll_Func2 +}; + +const struct SpriteFrameImage sSpriteImageTable_85C8E2C[] = +{ + sSpriteImage_85B98F0, 0x200 +}; + +const union AnimCmd sSpriteAnim_85C8E34[] = +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_END +}; + +const union AnimCmd *const sSpriteAnimTable_85C8E3C[] = +{ + sSpriteAnim_85C8E34 +}; + +const union AffineAnimCmd sSpriteAffineAnim_85C8E40[] = +{ + AFFINEANIMCMD_FRAME(0, 0, -4, 1), + AFFINEANIMCMD_JUMP(0) +}; + +const union AffineAnimCmd sSpriteAffineAnim_85C8E50[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 4, 1), + AFFINEANIMCMD_JUMP(0) +}; + +const union AffineAnimCmd *const sSpriteAffineAnimTable_85C8E60[] = +{ + sSpriteAffineAnim_85C8E40, + sSpriteAffineAnim_85C8E50 +}; + +const struct SpriteTemplate gUnknown_085C8E68 = +{ + .tileTag = 0xFFFF, + .paletteTag = 4105, + .oam = &gFieldObjectBaseOam_32x32, + .anims = sSpriteAnimTable_85C8E3C, + .images = sSpriteImageTable_85C8E2C, + .affineAnims = sSpriteAffineAnimTable_85C8E60, + .callback = sub_814713C +}; + +const struct OamData gOamData_85C8E80 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +const struct SpriteFrameImage sSpriteImageTable_85C8E88[] = +{ + sSpriteImage_85B9CD0, 0x800 +}; + +const struct SpriteFrameImage sSpriteImageTable_85C8E90[] = +{ + sSpriteImage_85BA4D0, 0x800 +}; + +const union AnimCmd sSpriteAnim_85C8E98[] = +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_END +}; + +const union AnimCmd *const sSpriteAnimTable_85C8EA0[] = +{ + sSpriteAnim_85C8E98 +}; + +const struct SpriteTemplate sSpriteTemplate_85C8EA4 = +{ + .tileTag = 0xFFFF, + .paletteTag = 4106, + .oam = &gOamData_85C8E80, + .anims = sSpriteAnimTable_85C8EA0, + .images = sSpriteImageTable_85C8E88, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_8148380 +}; + +const struct SpriteTemplate sSpriteTemplate_85C8EBC = +{ + .tileTag = 0xFFFF, + .paletteTag = 4106, + .oam = &gOamData_85C8E80, + .anims = sSpriteAnimTable_85C8EA0, + .images = sSpriteImageTable_85C8E90, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_8148380 +}; + +const u16 gFieldEffectObjectPalette10[] = INCBIN_U16("graphics/map_objects/palettes/field_effect_object_palette_10.gbapal"); + +const struct SpritePalette gFieldEffectObjectPaletteInfo10 = +{ + gFieldEffectObjectPalette10, 0x1009 +}; + +const u16 sMugshotPal_Sydney[] = INCBIN_U16("graphics/battle_transitions/sidney_bg.gbapal"); +const u16 sMugshotPal_Phoebe[] = INCBIN_U16("graphics/battle_transitions/phoebe_bg.gbapal"); +const u16 sMugshotPal_Glacia[] = INCBIN_U16("graphics/battle_transitions/glacia_bg.gbapal"); +const u16 sMugshotPal_Drake[] = INCBIN_U16("graphics/battle_transitions/drake_bg.gbapal"); +const u16 sMugshotPal_Champion[] = INCBIN_U16("graphics/battle_transitions/wallace_bg.gbapal"); +const u16 sMugshotPal_Brendan[] = INCBIN_U16("graphics/battle_transitions/brendan_bg.gbapal"); +const u16 sMugshotPal_May[] = INCBIN_U16("graphics/battle_transitions/may_bg.gbapal"); + +const u16 *const sOpponentMugshotsPals[MUGSHOTS_COUNT] = +{ + sMugshotPal_Sydney, + sMugshotPal_Phoebe, + sMugshotPal_Glacia, + sMugshotPal_Drake, + sMugshotPal_Champion +}; + +const u16 *const sPlayerMugshotsPals[2] = +{ + sMugshotPal_Brendan, + sMugshotPal_May +}; + +const u16 sUnusedTrainerPalette[] = INCBIN_U16("graphics/battle_transitions/unused_trainer.gbapal"); +const struct SpritePalette sSpritePalette_UnusedTrainer = +{ + sUnusedTrainerPalette, 0x100A +}; + +const u16 sBigPokeball_Tilemap[] = INCBIN_U16("graphics/battle_transitions/big_pokeball_map.bin"); +const u16 sMugshotsTilemap[] = INCBIN_U16("graphics/battle_transitions/elite_four_bg_map.bin"); + +const TransitionStateFunc sPhase2_29_Funcs[] = +{ + Phase2_29_Func1, + Phase2_29_Func2, + Phase2_BigPokeball_Func3, + Phase2_BigPokeball_Func4, + Phase2_BigPokeball_Func5, + Phase2_BigPokeball_Func6 +}; + +const TransitionStateFunc sPhase2_30_Funcs[] = +{ + Phase2_30_Func1, + Phase2_30_Func2, + Phase2_30_Func3, + Phase2_30_Func4 +}; + +const TransitionStateFunc sPhase2_31_Funcs[] = +{ + Phase2_31_Func1, + Phase2_31_Func2, + Phase2_31_Func3, + Phase2_31_33_Func5 +}; + +const TransitionStateFunc sPhase2_33_Funcs[] = +{ + Phase2_33_Func1, + Phase2_33_Func2, + Phase2_33_Func3, + Phase2_33_Func4, + Phase2_31_33_Func5 +}; + +const TransitionStateFunc sPhase2_32_Funcs[] = +{ + Phase2_32_Func1, + Phase2_32_Func2, + Phase2_32_Func3, + Phase2_32_Func4, + Phase2_32_Func5 +}; + +const u8 gUnknown_085C9A30[] = {0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x1b, 0x14, 0x0d, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x07, 0x0e, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x13, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x0f, 0x10, 0x11, 0x12}; +const u8 gUnknown_085C9A53[] = {0x00, 0x10, 0x29, 0x16, 0x2c, 0x02, 0x2b, 0x15, 0x2e, 0x1b, 0x09, 0x30, 0x26, 0x05, 0x39, 0x3b, 0x0c, 0x3f, 0x23, 0x1c, 0x0a, 0x35, 0x07, 0x31, 0x27, 0x17, 0x37, 0x01, 0x3e, 0x11, 0x3d, 0x1e, 0x06, 0x22, 0x0f, 0x33, 0x20, 0x3a, 0x0d, 0x2d, 0x25, 0x34, 0x0b, 0x18, 0x3c, 0x13, 0x38, 0x21, 0x1d, 0x32, 0x28, 0x36, 0x0e, 0x03, 0x2f, 0x14, 0x12, 0x19, 0x04, 0x24, 0x1a, 0x2a, 0x1f, 0x08, 0x00}; // code static void CB2_TestBattleTransition(void) @@ -667,9 +948,11 @@ void BattleTransition_Start(u8 transitionId) LaunchBattleTransitionTask(transitionId); } -// main task that launches sub-tasks for phase1 and phase2 +// in all tasks data[0] is reserved for the state #define tState data[0] -#define tTransitionID data[1] + +// main task that launches sub-tasks for phase1 and phase2 +#define tTransitionId data[1] #define tTransitionDone data[15] bool8 IsBattleTransitionDone(void) @@ -690,7 +973,7 @@ bool8 IsBattleTransitionDone(void) void LaunchBattleTransitionTask(u8 transitionId) { u8 taskId = CreateTask(Task_BattleTransitionMain, 2); - gTasks[taskId].tTransitionID = transitionId; + gTasks[taskId].tTransitionId = transitionId; sTransitionStructPtr = AllocZeroed(sizeof(*sTransitionStructPtr)); } @@ -703,9 +986,9 @@ bool8 Transition_Phase1(struct Task *task) { sub_80AC3D0(); CpuCopy32(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); - if (sPhase1_Tasks[task->tTransitionID] != NULL) + if (sPhase1_Tasks[task->tTransitionId] != NULL) { - CreateTask(sPhase1_Tasks[task->tTransitionID], 4); + CreateTask(sPhase1_Tasks[task->tTransitionId], 4); task->tState++; return FALSE; } @@ -718,7 +1001,7 @@ bool8 Transition_Phase1(struct Task *task) bool8 Transition_WaitForPhase1(struct Task *task) { - if (FindTaskIdByFunc(sPhase1_Tasks[task->tTransitionID]) == 0xFF) + if (FindTaskIdByFunc(sPhase1_Tasks[task->tTransitionId]) == 0xFF) { task->tState++; return TRUE; @@ -731,7 +1014,7 @@ bool8 Transition_WaitForPhase1(struct Task *task) bool8 Transition_Phase2(struct Task *task) { - CreateTask(sPhase2_Tasks[task->tTransitionID], 0); + CreateTask(sPhase2_Tasks[task->tTransitionId], 0); task->tState++; return FALSE; } @@ -739,18 +1022,14 @@ bool8 Transition_Phase2(struct Task *task) bool8 Transition_WaitForPhase2(struct Task *task) { task->tTransitionDone = FALSE; - if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionID]) == 0xFF) + if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionId]) == 0xFF) task->tTransitionDone = TRUE; return FALSE; } -#undef tState -#undef tTransitionID +#undef tTransitionId #undef tTransitionDone -// sub-task for phase1 -#define tState data[0] - void Phase1Task_TransitionAll(u8 taskId) { if (gTasks[taskId].tState == 0) @@ -764,10 +1043,14 @@ void Phase1Task_TransitionAll(u8 taskId) } } -#undef tState - // sub-task for phase2 -#define tState data[0] +#define tData1 data[1] +#define tData2 data[2] +#define tData3 data[3] +#define tData4 data[4] +#define tData5 data[5] +#define tData6 data[6] +#define tFuncState data[7] #define tFrames data[8] #define tOpponentSpriteId data[13] #define tPlayerSpriteId data[14] @@ -790,17 +1073,17 @@ bool8 Phase2_Blur_Func1(struct Task *task) bool8 Phase2_Blur_Func2(struct Task *task) { - if (task->data[1] != 0) + if (task->tData1 != 0) { - task->data[1]--; + task->tData1--; } else { - task->data[1] = 4; - if (++task->data[2] == 10) + task->tData1 = 4; + if (++task->tData2 == 10) BeginNormalPaletteFade(-1, -1, 0, 0x10, 0); - SetGpuReg(REG_OFFSET_MOSAIC, (task->data[2] & 15) * 17); - if (task->data[2] > 14) + SetGpuReg(REG_OFFSET_MOSAIC, (task->tData2 & 15) * 17); + if (task->tData2 > 14) task->tState++; } return FALSE; @@ -840,10 +1123,10 @@ bool8 Phase2_Swirl_Func1(struct Task *task) bool8 Phase2_Swirl_Func2(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; - task->data[1] += 4; - task->data[2] += 8; + task->tData1 += 4; + task->tData2 += 8; - sub_8149F98(gUnknown_02038C28[0], sTransitionStructPtr->field_14, task->data[1], 2, task->data[2], 160); + sub_8149F98(gUnknown_02038C28[0], sTransitionStructPtr->field_14, task->tData1, 2, task->tData2, 160); if (!gPaletteFade.active) { @@ -898,10 +1181,10 @@ bool8 Phase2_Shuffle_Func2(struct Task *task) u16 r3, r4; sTransitionStructPtr->VBlank_DMA = FALSE; - r4 = task->data[1]; - r3 = task->data[2] >> 8; - task->data[1] += 4224; - task->data[2] += 384; + r4 = task->tData1; + r3 = task->tData2 >> 8; + task->tData1 += 4224; + task->tData2 += 384; for (i = 0; i < 160; i++, r4 += 4224) { @@ -973,16 +1256,16 @@ void sub_814669C(struct Task *task) sub_8149F08(); dp12_8087EA4(); - task->data[1] = 16; - task->data[2] = 0; - task->data[4] = 0; - task->data[5] = 0x4000; + task->tData1 = 16; + task->tData2 = 0; + task->tData4 = 0; + task->tData5 = 0x4000; sTransitionStructPtr->WININ = 63; sTransitionStructPtr->WINOUT = 0; sTransitionStructPtr->field_6 = 240; sTransitionStructPtr->WIN0V = 160; sTransitionStructPtr->BLDCNT = 0x3F41; - sTransitionStructPtr->BLDALPHA = (task->data[1] << 8) | (task->data[2]); + sTransitionStructPtr->BLDALPHA = (task->tData1 << 8) | (task->tData2); for (i = 0; i < 160; i++) { @@ -1065,7 +1348,7 @@ bool8 Phase2_BigPokeball_Func2(struct Task *task) dst1[i * 32 + j] = *BigPokeballMap | 0xF000; } } - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5], 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return TRUE; @@ -1077,7 +1360,7 @@ bool8 Phase2_Aqua_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LZ77UnCompVram(sTeamAqua_Tilemap, dst1); - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5], 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1089,7 +1372,7 @@ bool8 Phase2_Magma_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LZ77UnCompVram(sTeamMagma_Tilemap, dst1); - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5], 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1102,7 +1385,7 @@ bool8 Phase2_Regice_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LoadPalette(gUnknown_085BC2B4, 0xF0, 0x20); CpuCopy16(gUnknown_085BC314, dst1, 0x500); - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5], 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1115,7 +1398,7 @@ bool8 Phase2_Registeel_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LoadPalette(gUnknown_085BC2D4, 0xF0, 0x20); CpuCopy16(gUnknown_085BCB14, dst1, 0x500); - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5], 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1128,7 +1411,7 @@ bool8 Phase2_Regirock_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LoadPalette(gUnknown_085BC2F4, 0xF0, 0x20); CpuCopy16(gUnknown_085BD314, dst1, 0x500); - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5], 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1149,16 +1432,16 @@ bool8 Phase2_Kyogre_Func3(struct Task *task) bool8 Phase2_Kyogre_Func4(struct Task *task) { - if (task->data[1] % 3 == 0) + if (task->tData1 % 3 == 0) { - u16 var = task->data[1] % 30; + u16 var = task->tData1 % 30; var /= 3; LoadPalette(gUnknown_085BEDA0 + (var * 16), 0xF0, 0x20); } - if (++task->data[1] > 58) + if (++task->tData1 > 58) { task->tState++; - task->data[1] = 0; + task->tData1 = 0; } return FALSE; @@ -1166,15 +1449,15 @@ bool8 Phase2_Kyogre_Func4(struct Task *task) bool8 Phase2_Kyogre_Func5(struct Task *task) { - if (task->data[1] % 5 == 0) + if (task->tData1 % 5 == 0) { - s16 var = task->data[1] / 5; + s16 var = task->tData1 / 5; LoadPalette(gUnknown_085BEEE0 + (var * 16), 0xF0, 0x20); } - if (++task->data[1] > 68) + if (++task->tData1 > 68) { task->tState++; - task->data[1] = 0; + task->tData1 = 0; task->tFrames = 30; } @@ -1202,18 +1485,18 @@ bool8 Phase2_WeatherDuo_Func7(struct Task *task) bool8 Phase2_BigPokeball_Func3(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->data[3] == 0 || --task->data[3] == 0) + if (task->tData3 == 0 || --task->tData3 == 0) { - task->data[2]++; - task->data[3] = 2; + task->tData2++; + task->tData3 = 2; } - sTransitionStructPtr->BLDALPHA = (task->data[1] << 8) | task->data[2]; - if (task->data[2] > 15) + sTransitionStructPtr->BLDALPHA = (task->tData1 << 8) | task->tData2; + if (task->tData2 > 15) task->tState++; - task->data[4] += 8; - task->data[5] -= 256; + task->tData4 += 8; + task->tData5 -= 256; - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5] >> 8, 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160); sTransitionStructPtr->VBlank_DMA++; return FALSE; @@ -1222,18 +1505,18 @@ bool8 Phase2_BigPokeball_Func3(struct Task *task) bool8 Phase2_BigPokeball_Func4(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->data[3] == 0 || --task->data[3] == 0) + if (task->tData3 == 0 || --task->tData3 == 0) { - task->data[1]--; - task->data[3] = 2; + task->tData1--; + task->tData3 = 2; } - sTransitionStructPtr->BLDALPHA = (task->data[1] << 8) | task->data[2]; - if (task->data[1] == 0) + sTransitionStructPtr->BLDALPHA = (task->tData1 << 8) | task->tData2; + if (task->tData1 == 0) task->tState++; - task->data[4] += 8; - task->data[5] -= 256; + task->tData4 += 8; + task->tData5 -= 256; - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5] >> 8, 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160); sTransitionStructPtr->VBlank_DMA++; return FALSE; @@ -1242,17 +1525,17 @@ bool8 Phase2_BigPokeball_Func4(struct Task *task) bool8 Phase2_BigPokeball_Func5(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; - task->data[4] += 8; - task->data[5] -= 256; + task->tData4 += 8; + task->tData5 -= 256; - sub_8149F98(gUnknown_02038C28[0], 0, task->data[4], 132, task->data[5] >> 8, 160); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160); - if (task->data[5] <= 0) + if (task->tData5 <= 0) { task->tState++; - task->data[1] = 160; - task->data[2] = 256; - task->data[3] = 0; + task->tData1 = 160; + task->tData2 = 256; + task->tData3 = 0; } sTransitionStructPtr->VBlank_DMA++; @@ -1283,16 +1566,16 @@ bool8 Phase2_WaitPaletteFade(struct Task *task) bool8 Phase2_BigPokeball_Func6(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->data[2] < 1024) - task->data[2] += 128; - if (task->data[1] != 0) + if (task->tData2 < 1024) + task->tData2 += 128; + if (task->tData1 != 0) { - task->data[1] -= (task->data[2] >> 8); - if (task->data[1] < 0) - task->data[1] = 0; + task->tData1 -= (task->tData2 >> 8); + if (task->tData1 < 0) + task->tData1 = 0; } - sub_814A014(gUnknown_02038C28[0], 120, 80, task->data[1]); - if (task->data[1] == 0) + sub_814A014(gUnknown_02038C28[0], 120, 80, task->tData1); + if (task->tData1 == 0) { SetVBlankCallback(NULL); DmaStop(0); @@ -1301,9 +1584,9 @@ bool8 Phase2_BigPokeball_Func6(struct Task *task) } else { - if (task->data[3] == 0) + if (task->tData3 == 0) { - task->data[3]++; + task->tData3++; SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); } @@ -1673,12 +1956,12 @@ bool8 Phase2_Ripple_Func2(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; - r3 = task->data[2] >> 8; - r4 = task->data[1]; + r3 = task->tData2 >> 8; + r4 = task->tData1; r8 = 384; - task->data[1] += 0x400; - if (task->data[2] <= 0x1FFF) - task->data[2] += 0x180; + task->tData1 += 0x400; + if (task->tData2 <= 0x1FFF) + task->tData2 += 0x180; for (i = 0; i < 160; i++, r4 += r8) { @@ -1688,13 +1971,13 @@ bool8 Phase2_Ripple_Func2(struct Task *task) gUnknown_02038C28[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3); } - if (++task->data[3] == 81) + if (++task->tData3 == 81) { - task->data[4]++; + task->tData4++; BeginNormalPaletteFade(-1, -2, 0, 0x10, 0); } - if (task->data[4] != 0 && !gPaletteFade.active) + if (task->tData4 != 0 && !gPaletteFade.active) DestroyTask(FindTaskIdByFunc(Phase2Task_Ripple)); sTransitionStructPtr->VBlank_DMA++; @@ -1752,13 +2035,13 @@ bool8 Phase2_Wave_Func2(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; toStore = gUnknown_02038C28[0]; - r5 = task->data[2]; - task->data[2] += 16; - task->data[1] += 8; + r5 = task->tData2; + task->tData2 += 16; + task->tData1 += 8; for (i = 0, nextFunc = TRUE; i < 160; i++, r5 += 4, toStore++) { - s16 value = task->data[1] + Sin(r5, 40); + s16 value = task->tData1 + Sin(r5, 40); if (value < 0) value = 0; if (value > 240) @@ -1837,9 +2120,9 @@ bool8 Phase2_Mugshot_Func1(struct Task *task) dp12_8087EA4(); Mugshots_CreateOpponentPlayerSprites(task); - task->data[1] = 0; - task->data[2] = 1; - task->data[3] = 239; + task->tData1 = 0; + task->tData2 = 1; + task->tData3 = 239; sTransitionStructPtr->WININ = 63; sTransitionStructPtr->WINOUT = 62; sTransitionStructPtr->WIN0V = 160; @@ -1892,12 +2175,12 @@ bool8 Phase2_Mugshot_Func3(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; toStore = gUnknown_02038C28[0]; - r5 = task->data[1]; - task->data[1] += 0x10; + r5 = task->tData1; + task->tData1 += 0x10; for (i = 0; i < 80; i++, toStore++, r5 += 0x10) { - value = task->data[2] + Sin(r5, 0x10); + value = task->tData2 + Sin(r5, 0x10); if (value < 0) value = 1; if (value > 0xF0) @@ -1906,7 +2189,7 @@ bool8 Phase2_Mugshot_Func3(struct Task *task) } for (; i < 160; i++, toStore++, r5 += 0x10) { - value = task->data[3] - Sin(r5, 0x10); + value = task->tData3 - Sin(r5, 0x10); if (value < 0) value = 0; if (value > 0xEF) @@ -1914,13 +2197,13 @@ bool8 Phase2_Mugshot_Func3(struct Task *task) *toStore = (value << 8) | (0xF0); } - task->data[2] += 8; - task->data[3] -= 8; - if (task->data[2] > 0xF0) - task->data[2] = 0xF0; - if (task->data[3] < 0) - task->data[3] = 0; - mergedValue = *(s32*)(&task->data[2]); + task->tData2 += 8; + task->tData3 -= 8; + if (task->tData2 > 0xF0) + task->tData2 = 0xF0; + if (task->tData3 < 0) + task->tData3 = 0; + mergedValue = *(s32*)(&task->tData2); if (mergedValue == 0xF0) task->tState++; @@ -1943,9 +2226,9 @@ bool8 Phase2_Mugshot_Func4(struct Task *task) } task->tState++; - task->data[1] = 0; - task->data[2] = 0; - task->data[3] = 0; + task->tData1 = 0; + task->tData2 = 0; + task->tData3 = 0; sTransitionStructPtr->field_18 -= 8; sTransitionStructPtr->field_1A += 8; @@ -1985,8 +2268,8 @@ bool8 Phase2_Mugshot_Func6(struct Task *task) SetGpuReg(REG_OFFSET_WIN0H, 0xF0); SetGpuReg(REG_OFFSET_BLDY, 0); task->tState++; - task->data[3] = 0; - task->data[4] = 0; + task->tData3 = 0; + task->tData4 = 0; sTransitionStructPtr->BLDCNT = 0xBF; SetVBlankCallback(VBlankCB1_Phase2_Mugshots); } @@ -2002,15 +2285,15 @@ bool8 Phase2_Mugshot_Func7(struct Task *task) sTransitionStructPtr->field_18 -= 8; sTransitionStructPtr->field_1A += 8; - if (task->data[4] < 0x50) - task->data[4] += 2; - if (task->data[4] > 0x50) - task->data[4] = 0x50; + if (task->tData4 < 0x50) + task->tData4 += 2; + if (task->tData4 > 0x50) + task->tData4 = 0x50; - if (++task->data[3] & 1) + if (++task->tData3 & 1) { s16 i; - for (i = 0, r6 = FALSE; i <= task->data[4]; i++) + for (i = 0, r6 = FALSE; i <= task->tData4; i++) { s16 index1 = 0x50 - i; s16 index2 = 0x50 + i; @@ -2027,7 +2310,7 @@ bool8 Phase2_Mugshot_Func7(struct Task *task) } } - if (task->data[4] == 0x50 && !r6) + if (task->tData4 == 0x50 && !r6) task->tState++; sTransitionStructPtr->VBlank_DMA++; @@ -2039,7 +2322,7 @@ bool8 Phase2_Mugshot_Func8(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; BlendPalettes(-1, 0x10, 0x7FFF); sTransitionStructPtr->BLDCNT = 0xFF; - task->data[3] = 0; + task->tData3 = 0; task->tState++; return TRUE; @@ -2049,9 +2332,9 @@ bool8 Phase2_Mugshot_Func9(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; - task->data[3]++; - memset(gUnknown_02038C28[0], task->data[3], 0x140); - if (task->data[3] > 15) + task->tData3++; + memset(gUnknown_02038C28[0], task->tData3, 0x140); + if (task->tData3 > 15) task->tState++; sTransitionStructPtr->VBlank_DMA++; @@ -2216,8 +2499,8 @@ bool8 Phase2_Slice_Func1(struct Task *task) sub_8149F08(); dp12_8087EA4(); - task->data[2] = 256; - task->data[3] = 1; + task->tData2 = 256; + task->tData3 = 1; sTransitionStructPtr->WININ = 63; sTransitionStructPtr->WINOUT = 0; sTransitionStructPtr->WIN0V = 160; @@ -2245,13 +2528,13 @@ bool8 Phase2_Slice_Func2(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; - task->data[1] += (task->data[2] >> 8); - if (task->data[1] > 0xF0) - task->data[1] = 0xF0; - if (task->data[2] <= 0xFFF) - task->data[2] += task->data[3]; - if (task->data[3] < 128) - task->data[3] <<= 1; // multiplying by two + task->tData1 += (task->tData2 >> 8); + if (task->tData1 > 0xF0) + task->tData1 = 0xF0; + if (task->tData2 <= 0xFFF) + task->tData2 += task->tData3; + if (task->tData3 < 128) + task->tData3 <<= 1; // multiplying by two for (i = 0; i < 160; i++) { @@ -2259,17 +2542,17 @@ bool8 Phase2_Slice_Func2(struct Task *task) u16* storeLoc2 = &gUnknown_02038C28[0][i + 160]; if (1 & i) { - *storeLoc1 = sTransitionStructPtr->field_14 + task->data[1]; - *storeLoc2 = 0xF0 - task->data[1]; + *storeLoc1 = sTransitionStructPtr->field_14 + task->tData1; + *storeLoc2 = 0xF0 - task->tData1; } else { - *storeLoc1 = sTransitionStructPtr->field_14 - task->data[1]; - *storeLoc2 = (task->data[1] << 8) | (0xF1); + *storeLoc1 = sTransitionStructPtr->field_14 - task->tData1; + *storeLoc2 = (task->tData1 << 8) | (0xF1); } } - if (task->data[1] > 0xEF) + if (task->tData1 > 0xEF) task->tState++; sTransitionStructPtr->VBlank_DMA++; @@ -2307,12 +2590,12 @@ void HBlankCB_Phase2_Slice(void) } } -void Phase2Task_25(u8 taskId) +void Phase2Task_ShredSplit(u8 taskId) { - while (sPhase2_25_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sPhase2_ShredSplit_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -bool8 Phase2_25_Func1(struct Task *task) +bool8 Phase2_ShredSplit_Func1(struct Task *task) { u16 i; @@ -2334,9 +2617,9 @@ bool8 Phase2_25_Func1(struct Task *task) gUnknown_02038C28[0][0x280 + i] = 1; } - task->data[4] = 0; - task->data[5] = 0; - task->data[6] = 7; + task->tData4 = 0; + task->tData5 = 0; + task->tData6 = 7; EnableInterrupts(INTR_FLAG_HBLANK); @@ -2347,7 +2630,7 @@ bool8 Phase2_25_Func1(struct Task *task) return TRUE; } -bool8 Phase2_25_Func2(struct Task *task) +bool8 Phase2_ShredSplit_Func2(struct Task *task) { u16 i, j, k; u8 arr1[ARRAY_COUNT(gUnknown_085C8C64)]; @@ -2362,7 +2645,7 @@ bool8 Phase2_25_Func2(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; var = 0; - for (i = 0; i <= task->data[5]; i++) + for (i = 0; i <= task->tData5; i++) { for (j = 0; j < 2; j++) { @@ -2433,10 +2716,10 @@ bool8 Phase2_25_Func2(struct Task *task) } } - if (--task->data[4] < 0) - task->data[4] = 0; - if (task->data[4] <= 0 && task->data[5] + 1 <= 20) - task->data[4] = task->data[6], task->data[5]++; + if (--task->tData4 < 0) + task->tData4 = 0; + if (task->tData4 <= 0 && task->tData5 + 1 <= 20) + task->tData4 = task->tData6, task->tData5++; if (var > 0x9F) task->tState++; @@ -2444,7 +2727,7 @@ bool8 Phase2_25_Func2(struct Task *task) return FALSE; } -bool8 Phase2_25_Func3(struct Task *task) +bool8 Phase2_ShredSplit_Func3(struct Task *task) { u16 i; bool32 done = TRUE; @@ -2462,11 +2745,11 @@ bool8 Phase2_25_Func3(struct Task *task) return FALSE; } -bool8 Phase2_25_Func4(struct Task *task) +bool8 Phase2_ShredSplit_Func4(struct Task *task) { DmaStop(0); sub_8149F84(); - DestroyTask(FindTaskIdByFunc(Phase2Task_25)); + DestroyTask(FindTaskIdByFunc(Phase2Task_ShredSplit)); return FALSE; } @@ -2500,16 +2783,16 @@ bool8 Phase2_Blackhole_Func1(struct Task *task) SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); task->tState++; - task->data[1] = 1; - task->data[2] = 0x100; - task->data[7] = 0; + task->tData1 = 1; + task->tData2 = 0x100; + task->tFuncState = 0; return FALSE; } bool8 Phase2_Blackhole1_Func3(struct Task *task) { - if (task->data[7] == 1) + if (task->tFuncState == 1) { DmaStop(0); SetVBlankCallback(NULL); @@ -2518,16 +2801,16 @@ bool8 Phase2_Blackhole1_Func3(struct Task *task) else { sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->data[2] < 0x400) - task->data[2] += 0x80; - if (task->data[1] < 0xA0) - task->data[1] += (task->data[2] >> 8); - if (task->data[1] > 0xA0) - task->data[1] = 0xA0; - sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->data[1]); - if (task->data[1] == 0xA0) + if (task->tData2 < 0x400) + task->tData2 += 0x80; + if (task->tData1 < 0xA0) + task->tData1 += (task->tData2 >> 8); + if (task->tData1 > 0xA0) + task->tData1 = 0xA0; + sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1); + if (task->tData1 == 0xA0) { - task->data[7] = 1; + task->tFuncState = 1; sub_8149F84(); } else @@ -2542,19 +2825,19 @@ bool8 Phase2_Blackhole1_Func3(struct Task *task) bool8 Phase2_Blackhole1_Func2(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->data[7] == 0) + if (task->tFuncState == 0) { - task->data[7]++; - task->data[1] = 0x30; - task->data[6] = 0; + task->tFuncState++; + task->tData1 = 0x30; + task->tData6 = 0; } - task->data[1] += gUnknown_085C8C80[task->data[6]]; - task->data[6] = (task->data[6] + 1) % 2; - sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->data[1]); - if (task->data[1] < 9) + task->tData1 += gUnknown_085C8C80[task->tData6]; + task->tData6 = (task->tData6 + 1) % 2; + sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1); + if (task->tData1 < 9) { task->tState++; - task->data[7] = 0; + task->tFuncState = 0; } sTransitionStructPtr->VBlank_DMA++; @@ -2567,40 +2850,40 @@ bool8 Phase2_Blackhole2_Func2(struct Task *task) s16 amplitude; sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->data[7] == 0) + if (task->tFuncState == 0) { - task->data[7]++; - task->data[5] = 2; - task->data[6] = 2; + task->tFuncState++; + task->tData5 = 2; + task->tData6 = 2; } - if (task->data[1] > 0xA0) - task->data[1] = 0xA0; + if (task->tData1 > 0xA0) + task->tData1 = 0xA0; - sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->data[1]); - if (task->data[1] == 0xA0) + sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1); + if (task->tData1 == 0xA0) { DmaStop(0); sub_8149F84(); DestroyTask(FindTaskIdByFunc(task->func)); } - index = task->data[5]; - if ((task->data[5] & 0xFF) <= 128) + index = task->tData5; + if ((task->tData5 & 0xFF) <= 128) { - amplitude = task->data[6]; - task->data[5] += 8; + amplitude = task->tData6; + task->tData5 += 8; } else { - amplitude = task->data[6] - 1; - task->data[5] += 16; + amplitude = task->tData6 - 1; + task->tData5 += 16; } - task->data[1] += Sin(index & 0xFF, amplitude); + task->tData1 += Sin(index & 0xFF, amplitude); - if (task->data[1] <= 0) - task->data[1] = 1; - if (task->data[5] > 0xFE) - task->data[5] >>= 8, task->data[6]++; + if (task->tData1 <= 0) + task->tData1 = 1; + if (task->tData5 > 0xFE) + task->tData5 >>= 8, task->tData6++; sTransitionStructPtr->VBlank_DMA++; return FALSE; @@ -2621,7 +2904,7 @@ bool8 Phase2_RectangularSpiral_Func1(struct Task *task) CpuFill16(0xF000, dst1, 0x800); LoadPalette(gFieldEffectObjectPalette10, 0xF0, 0x20); - task->data[3] = 1; + task->tData3 = 1; task->tState++; sRectangularSpiralTransition[0].field_0 = 0; @@ -2775,21 +3058,21 @@ bool8 Phase2_Groudon_Func3(struct Task *task) LZ77UnCompVram(gUnknown_085BEA88, dst1); task->tState++; - task->data[1] = 0; + task->tData1 = 0; return FALSE; } bool8 Phase2_Groudon_Func4(struct Task *task) { - if (task->data[1] % 3 == 0) + if (task->tData1 % 3 == 0) { - u16 var = (task->data[1] % 30) / 3; + u16 var = (task->tData1 % 30) / 3; LoadPalette(gUnknown_085BF0A0 + (var * 16), 0xF0, 0x20); } - if (++task->data[1] > 58) + if (++task->tData1 > 58) { task->tState++; - task->data[1] = 0; + task->tData1 = 0; } return FALSE; @@ -2797,18 +3080,951 @@ bool8 Phase2_Groudon_Func4(struct Task *task) bool8 Phase2_Groudon_Func5(struct Task *task) { - if (task->data[1] % 5 == 0) + if (task->tData1 % 5 == 0) { - s16 var = task->data[1] / 5; + s16 var = task->tData1 / 5; LoadPalette(gUnknown_085BF2A0 + (var * 16), 0xF0, 0x20); } - if (++task->data[1] > 68) + if (++task->tData1 > 68) { task->tState++; - task->data[1] = 0; + task->tData1 = 0; task->tFrames = 30; } return FALSE; } +void Phase2Task_Rayquaza(u8 taskId) +{ + while (sPhase2_Rayquaza_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +bool8 Phase2_Rayquaza_Func3(struct Task *task) +{ + u16 *dst1, *dst2; + u16 i; + + sub_8149F08(); + dp12_8087EA4(); + + SetGpuReg(REG_OFFSET_BG0CNT, 0x9A08); + sub_8149F58(&dst1, &dst2); + CpuFill16(0, dst1, 0x800); + CpuCopy16(gUnknown_085BF6A0, dst2, 0x2000); + + sTransitionStructPtr->field_20 = 0; + task->tState++; + LoadPalette(gUnknown_085BF4A0 + 0x50, 0xF0, 0x20); + + for (i = 0; i < 160; i++) + { + gUnknown_02038C28[0][i] = 0; + gUnknown_02038C28[1][i] = 0x100; + } + + SetVBlankCallback(VBlankCB_Phase2_Rayquaza); + return FALSE; +} + +bool8 Phase2_Rayquaza_Func4(struct Task *task) +{ + u16 *dst1, *dst2; + + sub_8149F58(&dst1, &dst2); + CpuCopy16(gUnknown_085C6BE0, dst1, 0x1000); + task->tState++; + return FALSE; +} + +bool8 Phase2_Rayquaza_Func5(struct Task *task) +{ + if ((task->tData1 % 4) == 0) + { + u16 value = task->tData1 / 4; + const u16 *palPtr = &gUnknown_085BF4A0[(value + 5) * 16]; + LoadPalette(palPtr, 0xF0, 0x20); + } + if (++task->tData1 > 40) + { + task->tState++; + task->tData1 = 0; + } + + return FALSE; +} + +bool8 Phase2_Rayquaza_Func6(struct Task *task) +{ + if (++task->tData1 > 20) + { + task->tState++; + task->tData1 = 0; + BeginNormalPaletteFade(0xFFFF8000, 2, 0, 0x10, 0); + } + + return FALSE; +} + +bool8 Phase2_Rayquaza_Func7(struct Task *task) +{ + if (!gPaletteFade.active) + { + sTransitionStructPtr->field_20 = 1; + task->tState++; + } + + return FALSE; +} + +bool8 Phase2_Rayquaza_Func8(struct Task *task) +{ + BlendPalettes(0x00007FFF, 8, 0); + BlendPalettes(0xFFFF8000, 0, 0); + + task->tState++; + return FALSE; +} + +bool8 Phase2_Rayquaza_Func9(struct Task *task) +{ + if ((task->tData1 % 3) == 0) + { + u16 value = task->tData1 / 3; + const u16 *palPtr = &gUnknown_085BF4A0[(value + 0) * 16]; + LoadPalette(palPtr, 0xF0, 0x20); + } + if (++task->tData1 >= 40) + { + u16 i; + + sTransitionStructPtr->WININ = 0; + sTransitionStructPtr->WINOUT = 63; + sTransitionStructPtr->field_6 = 240; + sTransitionStructPtr->WIN0V = 160; + + for (i = 0; i < 160; i++) + { + gUnknown_02038C28[1][i] = 0; + } + + SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); + task->tState++; + task->tData2 = 0x100; + task->tFuncState = 0; + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON); + } + + return FALSE; +} + +void VBlankCB_Phase2_Rayquaza(void) +{ + void *dmaSrc; + + DmaStop(0); + VBlankCB_BattleTransition(); + + if (sTransitionStructPtr->field_20 == 0) + dmaSrc = gUnknown_02038C28[0]; + else if (sTransitionStructPtr->field_20 == 1) + dmaSrc = gUnknown_02038C28[1]; + else + dmaSrc = gUnknown_02038C28[0]; + + DmaSet(0, dmaSrc, ®_BG0VOFS, 0xA2400001); +} + +void Phase2Task_WhiteFade(u8 taskId) +{ + while (sPhase2_WhiteFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +bool8 Phase2_WhiteFade_Func1(struct Task *task) +{ + u16 i; + + sub_8149F08(); + dp12_8087EA4(); + + sTransitionStructPtr->BLDCNT = 0xBF; + sTransitionStructPtr->BLDY = 0; + sTransitionStructPtr->WININ = 0x1E; + sTransitionStructPtr->WINOUT = 0x3F; + sTransitionStructPtr->WIN0V = 0xA0; + + for (i = 0; i < 160; i++) + { + gUnknown_02038C28[1][i] = 0; + gUnknown_02038C28[1][i + 160] = 0xF0; + } + + EnableInterrupts(INTR_FLAG_HBLANK); + SetHBlankCallback(HBlankCB_Phase2_WhiteFade); + SetVBlankCallback(VBlankCB0_Phase2_WhiteFade); + + task->tState++; + return FALSE; +} + +bool8 Phase2_WhiteFade_Func2(struct Task *task) +{ + s16 i, posY; + s16 arr1[ARRAY_COUNT(sUnknown_085C8DA0)]; + struct Sprite *sprite; + + memcpy(arr1, sUnknown_085C8DA0, sizeof(sUnknown_085C8DA0)); + for (i = 0, posY = 0; i < 8; i++, posY += 0x14) + { + sprite = &gSprites[CreateInvisibleSprite(sub_8149864)]; + sprite->pos1.x = 0xF0; + sprite->pos1.y = posY; + sprite->data[5] = arr1[i]; + } + sprite->data[6]++; + + task->tState++; + return FALSE; +} + +bool8 Phase2_WhiteFade_Func3(struct Task *task) +{ + sTransitionStructPtr->VBlank_DMA = 0; + if (sTransitionStructPtr->field_20 > 7) + { + BlendPalettes(-1, 0x10, 0x7FFF); + task->tState++; + } + return FALSE; +} + +bool8 Phase2_WhiteFade_Func4(struct Task *task) +{ + sTransitionStructPtr->VBlank_DMA = 0; + + DmaStop(0); + SetVBlankCallback(0); + SetHBlankCallback(0); + + sTransitionStructPtr->field_6 = 0xF0; + sTransitionStructPtr->BLDY = 0; + sTransitionStructPtr->BLDCNT = 0xFF; + sTransitionStructPtr->WININ = 0x3F; + + SetVBlankCallback(VBlankCB1_Phase2_WhiteFade); + + task->tState++; + return FALSE; +} + +bool8 Phase2_WhiteFade_Func5(struct Task *task) +{ + if (++sTransitionStructPtr->BLDY > 16) + { + sub_8149F84(); + DestroyTask(FindTaskIdByFunc(Phase2Task_WhiteFade)); + } + return FALSE; +} + +void VBlankCB0_Phase2_WhiteFade(void) +{ + DmaStop(0); + VBlankCB_BattleTransition(); + REG_BLDCNT = sTransitionStructPtr->BLDCNT; + REG_WININ = sTransitionStructPtr->WININ; + REG_WINOUT = sTransitionStructPtr->WINOUT; + REG_WIN0V = sTransitionStructPtr->WIN0V; + if (sTransitionStructPtr->VBlank_DMA) + DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 640); + DmaSet(0, &gUnknown_02038C28[1][160], ®_WIN0H, 0xA2400001); +} + +void VBlankCB1_Phase2_WhiteFade(void) +{ + VBlankCB_BattleTransition(); + REG_BLDY = sTransitionStructPtr->BLDY; + REG_BLDCNT = sTransitionStructPtr->BLDCNT; + REG_WININ = sTransitionStructPtr->WININ; + REG_WINOUT = sTransitionStructPtr->WINOUT; + REG_WIN0H = sTransitionStructPtr->field_6; + REG_WIN0V = sTransitionStructPtr->WIN0V; +} + +void HBlankCB_Phase2_WhiteFade(void) +{ + REG_BLDY = gUnknown_02038C28[1][REG_VCOUNT]; +} + +void sub_8149864(struct Sprite *sprite) +{ + if (sprite->data[5]) + { + sprite->data[5]--; + if (sprite->data[6]) + sTransitionStructPtr->VBlank_DMA = 1; + } + else + { + u16 i; + u16* ptr1 = &gUnknown_02038C28[0][sprite->pos1.y]; + u16* ptr2 = &gUnknown_02038C28[0][sprite->pos1.y + 160]; + for (i = 0; i < 20; i++) + { + ptr1[i] = sprite->data[0] >> 8; + ptr2[i] = (u8)(sprite->pos1.x); + } + if (sprite->pos1.x == 0 && sprite->data[0] == 0x1000) + sprite->data[1] = 1; + + sprite->pos1.x -= 16; + sprite->data[0] += 0x80; + + if (sprite->pos1.x < 0) + sprite->pos1.x = 0; + if (sprite->data[0] > 0x1000) + sprite->data[0] = 0x1000; + + if (sprite->data[6]) + sTransitionStructPtr->VBlank_DMA = 1; + + if (sprite->data[1]) + { + if (sprite->data[6] == 0 || (sTransitionStructPtr->field_20 > 6 && sprite->data[2]++ > 7)) + { + sTransitionStructPtr->field_20++; + DestroySprite(sprite); + } + } + } +} + +void Phase2Task_GridSquares(u8 taskId) +{ + while (sPhase2_GridSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +bool8 Phase2_GridSquares_Func1(struct Task *task) +{ + u16 *dst1, *dst2; + + sub_8149F58(&dst1, &dst2); + CpuSet(sShrinkingBoxTileset, dst2, 0x10); + CpuFill16(0xF000, dst1, 0x800); + LoadPalette(gFieldEffectObjectPalette10, 0xF0, 0x20); + + task->tState++; + return FALSE; +} + +bool8 Phase2_GridSquares_Func2(struct Task *task) +{ + u16* dst1; + + if (task->tData1 == 0) + { + sub_8149F40(&dst1); + task->tData1 = 3; + task->tData2++; + CpuSet(sShrinkingBoxTileset + (task->tData2 * 8), dst1, 0x10); + if (task->tData2 > 0xD) + { + task->tState++; + task->tData1 = 16; + } + } + + task->tData1--; + return FALSE; +} + +bool8 Phase2_GridSquares_Func3(struct Task *task) +{ + if (--task->tData1 == 0) + { + sub_8149F84(); + DestroyTask(FindTaskIdByFunc(Phase2Task_GridSquares)); + } + return FALSE; +} + +void Phase2Task_Shards(u8 taskId) +{ + while (sPhase2_Shards_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +bool8 Phase2_Shards_Func1(struct Task *task) +{ + u16 i; + + sub_8149F08(); + dp12_8087EA4(); + + sTransitionStructPtr->WININ = 0x3F; + sTransitionStructPtr->WINOUT = 0; + sTransitionStructPtr->WIN0V = 0xA0; + + for (i = 0; i < 160; i++) + { + gUnknown_02038C28[0][i] = 0xF0; + } + + CpuSet(gUnknown_02038C28[0], gUnknown_02038C28[1], 0xA0); + SetVBlankCallback(VBlankCB_Phase2_Shards); + + task->tState++; + return TRUE; +} + +bool8 Phase2_Shards_Func2(struct Task *task) +{ + sub_814A1AC(sTransitionStructPtr->data, + sUnknown_085C8DD0[task->tData1][0], + sUnknown_085C8DD0[task->tData1][1], + sUnknown_085C8DD0[task->tData1][2], + sUnknown_085C8DD0[task->tData1][3], + 1, 1); + task->tData2 = sUnknown_085C8DD0[task->tData1][4]; + task->tState++; + return TRUE; +} + +bool8 Phase2_Shards_Func3(struct Task *task) +{ + s16 i; + bool8 nextFunc; + + sTransitionStructPtr->VBlank_DMA = 0; + + for (i = 0, nextFunc = FALSE; i < 16; i++) + { + s16 r3 = gUnknown_02038C28[0][sTransitionStructPtr->data[3]] >> 8; + s16 r4 = gUnknown_02038C28[0][sTransitionStructPtr->data[3]] & 0xFF; + if (task->tData2 == 0) + { + if (r3 < sTransitionStructPtr->data[2]) + r3 = sTransitionStructPtr->data[2]; + if (r3 > r4) + r3 = r4; + } + else + { + if (r4 > sTransitionStructPtr->data[2]) + r4 = sTransitionStructPtr->data[2]; + if (r4 <= r3) + r4 = r3; + } + gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (r4) | (r3 << 8); + if (nextFunc) + { + task->tState++; + break; + } + else + nextFunc = sub_814A228(sTransitionStructPtr->data, 1, 1); + } + + sTransitionStructPtr->VBlank_DMA++; + return FALSE; +} + +bool8 Phase2_Shards_Func4(struct Task *task) +{ + if (++task->tData1 < 7) + { + task->tState++; + task->tData3 = sUnknown_085C8E16[task->tData1 - 1]; + return TRUE; + } + else + { + DmaStop(0); + sub_8149F84(); + DestroyTask(FindTaskIdByFunc(Phase2Task_Shards)); + return FALSE; + } +} + +bool8 Phase2_Shards_Func5(struct Task *task) +{ + if (--task->tData3 == 0) + { + task->tState = 1; + return TRUE; + } + else + return FALSE; +} + +void VBlankCB_Phase2_Shards(void) +{ + DmaStop(0); + VBlankCB_BattleTransition(); + if (sTransitionStructPtr->VBlank_DMA) + DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + REG_WININ = sTransitionStructPtr->WININ; + REG_WINOUT = sTransitionStructPtr->WINOUT; + REG_WIN0V = sTransitionStructPtr->WIN0V; + REG_WIN0H = gUnknown_02038C28[1][0]; + DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001); +} + +// sub-task for phase2 +#undef tData1 +#undef tData2 +#undef tData3 +#undef tData4 +#undef tData5 +#undef tData6 +#undef tFuncState +#undef tFrames +#undef tOpponentSpriteId +#undef tPlayerSpriteId +#undef tMugshotId + +// sub-task for sub-task phase +#define tData1 data[1] +#define tData2 data[2] +#define tData3 data[3] +#define tData4 data[4] +#define tData5 data[5] +#define tData6 data[6] +#define tData7 data[7] + +void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4) +{ + u8 taskId = CreateTask(Phase1_Task_RunFuncs, 3); + gTasks[taskId].tData1 = a0; + gTasks[taskId].tData2 = a1; + gTasks[taskId].tData3 = a2; + gTasks[taskId].tData4 = a3; + gTasks[taskId].tData5 = a4; + gTasks[taskId].tData6 = a0; +} + +bool8 IsPhase1Done(void) +{ + if (FindTaskIdByFunc(Phase1_Task_RunFuncs) == 0xFF) + return TRUE; + else + return FALSE; +} + +void Phase1_Task_RunFuncs(u8 taskId) +{ + while (sPhase1_TransitionAll_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +bool8 Phase1_TransitionAll_Func1(struct Task *task) +{ + if (task->tData6 == 0 || --task->tData6 == 0) + { + task->tData6 = task->tData1; + task->tData7 += task->tData4; + if (task->tData7 > 16) + task->tData7 = 16; + BlendPalettes(-1, task->tData7, 0x2D6B); + } + if (task->tData7 > 15) + { + task->tState++; + task->tData6 = task->tData2; + } + return FALSE; +} + +bool8 Phase1_TransitionAll_Func2(struct Task *task) +{ + if (task->tData6 == 0 || --task->tData6 == 0) + { + task->tData6 = task->tData2; + task->tData7 -= task->tData5; + if (task->tData7 < 0) + task->tData7 = 0; + BlendPalettes(-1, task->tData7, 0x2D6B); + } + if (task->tData7 == 0) + { + if (--task->tData3 == 0) + DestroyTask(FindTaskIdByFunc(Phase1_Task_RunFuncs)); + else + { + task->tData6 = task->tData1; + task->tState = 0; + } + } + return FALSE; +} + +#undef tData1 +#undef tData2 +#undef tData3 +#undef tData4 +#undef tData5 +#undef tData6 +#undef tData7 + +void sub_8149F08(void) +{ + memset(sTransitionStructPtr, 0, sizeof(*sTransitionStructPtr)); + sub_8089C08(&sTransitionStructPtr->field_14, &sTransitionStructPtr->field_16); +} + +void VBlankCB_BattleTransition(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void sub_8149F40(u16 **a0) +{ + u16 reg, *vram; + + reg = REG_BG0CNT >> 2; + reg <<= 0xE; + vram = (u16*)(VRAM + reg); + + *a0 = vram; +} + +void sub_8149F58(u16 **a0, u16 **a1) +{ + u16 reg0, reg1, *vram0, *vram1; + + reg0 = REG_BG0CNT >> 8; + reg1 = REG_BG0CNT >> 2; + + reg0 <<= 0xB; + reg1 <<= 0xE; + + vram0 = (u16*)(VRAM + reg0); + *a0 = vram0; + + vram1 = (u16*)(VRAM + reg1); + *a1 = vram1; +} + +void sub_8149F84(void) +{ + BlendPalettes(-1, 0x10, 0); +} + +void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize) +{ + u8 i; + for (i = 0; arrSize > 0; arrSize--, i++, index += indexIncrementer) + { + array[i] = sinAdd + Sin(0xFF & index, amplitude); + } +} + +void sub_814A014(u16 *array, s16 a1, s16 a2, s16 a3) +{ + s16 i; + + memset(array, 0xA, 160 * sizeof(s16)); + for (i = 0; i < 64; i++) + { + s16 sinResult, cosResult; + s16 toStoreOrr, r2, r3, toStore, r7, r8; + + sinResult = Sin(i, a3); + cosResult = Cos(i, a3); + + toStoreOrr = a1 - sinResult; + toStore = a1 + sinResult; + r7 = a2 - cosResult; + r8 = a2 + cosResult; + + if (toStoreOrr < 0) + toStoreOrr = 0; + if (toStore > 0xF0) + toStore = 0xF0; + if (r7 < 0) + r7 = 0; + if (r8 > 0x9F) + r8 = 0x9F; + + toStore |= (toStoreOrr << 8); + array[r7] = toStore; + array[r8] = toStore; + + cosResult = Cos(i + 1, a3); + r3 = a2 - cosResult; + r2 = a2 + cosResult; + + if (r3 < 0) + r3 = 0; + if (r2 > 0x9F) + r2 = 0x9F; + + while (r7 > r3) + array[--r7] = toStore; + while (r7 < r3) + array[++r7] = toStore; + + while (r8 > r2) + array[--r8] = toStore; + while (r8 < r2) + array[++r8] = toStore; + } +} + +void sub_814A1AC(s16 *data, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6) +{ + data[0] = a1; + data[1] = a2; + data[2] = a1; + data[3] = a2; + data[4] = a3; + data[5] = a4; + data[6] = a5; + data[7] = a6; + data[8] = a3 - a1; + if (data[8] < 0) + { + data[8] = -data[8]; + data[6] = -a5; + } + data[9] = a4 - a2; + if (data[9] < 0) + { + data[9] = -data[9]; + data[7] = -a6; + } + data[10] = 0; +} + +bool8 sub_814A228(s16 *data, bool8 a1, bool8 a2) +{ + u8 var; + if (data[8] > data[9]) + { + data[2] += data[6]; + data[10] += data[9]; + if (data[10] > data[8]) + { + data[3] += data[7]; + data[10] -= data[8]; + } + } + else + { + data[3] += data[7]; + data[10] += data[8]; + if (data[10] > data[9]) + { + data[2] += data[6]; + data[10] -= data[9]; + } + } + var = 0; + if ((data[6] > 0 && data[2] >= data[4]) || (data[6] < 0 && data[2] <= data[4])) + { + var++; + if (a1) + data[2] = data[4]; + } + if ((data[7] > 0 && data[3] >= data[5]) || (data[7] < 0 && data[3] <= data[5])) + { + var++; + if (a2) + data[3] = data[5]; + } + + if (var == 2) + return TRUE; + else + return FALSE; +} + +// sub-task for phase2 of a couple of new transitions +#define tData1 data[1] +#define tData2 data[2] +#define tData3 data[3] +#define tData4 data[4] +#define tData5 data[5] +#define tData6 data[6] +#define tData7 data[7] + +bool8 Phase2_29_Func1(struct Task *task) +{ + u16 *dst1, *dst2; + + sub_814669C(task); + sub_8149F58(&dst1, &dst2); + CpuFill16(0, dst1, 0x800); + LZ77UnCompVram(gUnknown_085C7C00, dst2); + LoadPalette(gUnknown_085C7BE0, 0xF0, 0x20); + + task->tState++; + return FALSE; +} + +bool8 Phase2_29_Func2(struct Task *task) +{ + u16 *dst1, *dst2; + + sub_8149F58(&dst1, &dst2); + LZ77UnCompVram(gUnknown_085C828C, dst1); + sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 0x84, task->tData5, 160); + + task->tState++; + return TRUE; +} + +void Phase2Task_29(u8 taskId) +{ + while (sPhase2_29_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +void Phase2Task_30(u8 taskId) +{ + while (sPhase2_30_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +bool8 Phase2_30_Func1(struct Task *task) +{ + u16 *dst1, *dst2; + + sub_8149F08(); + dp12_8087EA4(); + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON); + task->data[2] = 0x2000; + task->data[1] = 0x7FFF; + task->data[5] = 0; + task->data[6] = 16; + task->data[7] = 2560; + sTransitionStructPtr->BLDCNT = 0x3F41; + sTransitionStructPtr->BLDALPHA = (task->tData6 << 8) | (task->tData5); + REG_BLDCNT = sTransitionStructPtr->BLDCNT; + REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; + sub_8149F58(&dst1, &dst2); + CpuFill16(0, dst1, 0x800); + LZ77UnCompVram(gUnknown_085C7C00, dst2); + LoadPalette(gUnknown_085C7BE0, 0xF0, 0x20); + sTransitionStructPtr->field_16 = 0; + + task->tState++; + return FALSE; +} + +bool8 Phase2_30_Func2(struct Task *task) +{ + u16 *dst1, *dst2; + + sub_8149F58(&dst1, &dst2); + LZ77UnCompVram(gUnknown_085C828C, dst1); + + task->tState++; + return TRUE; +} + +bool8 Phase2_30_Func3(struct Task *task) +{ + u8 i; + + for (i = 0; i < 160; i++) + { + gUnknown_02038C28[1][i] = sTransitionStructPtr->field_16; + } + + SetVBlankCallback(VBlankCB_Phase2_30); + SetHBlankCallback(HBlankCB_Phase2_30); + EnableInterrupts(INTR_FLAG_HBLANK); + + task->tState++; + return TRUE; +} + +bool8 Phase2_30_Func4(struct Task *task) +{ + u8 i; + u16 var6, amplitude, var8; + + sTransitionStructPtr->VBlank_DMA = FALSE; + + amplitude = task->tData2 >> 8; + var6 = task->tData1; + var8 = 384; + + task->tData1 = var6 - task->tData7; + + if (task->tData3 >= 70) + { + if (task->tData2 - 384 >= 0) + task->tData2 -= 384; + else + task->tData2 = 0; + } + + if (task->tData3 >= 0 && task->tData3 % 3 == 0) + { + if (task->tData5 < 16) + task->tData5++; + else if (task->tData6 > 0) + task->tData6--; + + sTransitionStructPtr->BLDALPHA = (task->tData6 << 8) | (task->tData5); + } + + for (i = 0; i < 160; i++, var6 += var8) + { + s16 index = var6 / 256; + asm(""); + gUnknown_02038C28[0][i] = sTransitionStructPtr->field_16 + Sin(index, amplitude); + } + + if (++task->tData3 == 101) + { + task->tData4++; + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + } + + if (task->tData4 != 0 && !gPaletteFade.active) + DestroyTask(FindTaskIdByFunc(Phase2Task_30)); + + task->tData7 -= 17; + sTransitionStructPtr->VBlank_DMA++; + return FALSE; +} + +void VBlankCB_Phase2_30(void) +{ + VBlankCB_BattleTransition(); + REG_BLDCNT = sTransitionStructPtr->BLDCNT; + REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; + + if (sTransitionStructPtr->VBlank_DMA) + DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); +} + +void HBlankCB_Phase2_30(void) +{ + u16 var = gUnknown_02038C28[1][REG_VCOUNT]; + REG_BG0VOFS = var; +} + +void Phase2Task_31(u8 taskId) +{ + while (sPhase2_31_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +void Phase2Task_33(u8 taskId) +{ + while (sPhase2_33_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +void Phase2Task_32(u8 taskId) +{ + while (sPhase2_32_Funcs[gTasks[taskId].tState](&gTasks[taskId])); +} + +#undef tData1 +#undef tData2 +#undef tData3 +#undef tData4 +#undef tData5 +#undef tData6 +#undef tData7 diff --git a/src/tileset_anims.c b/src/tileset_anims.c index 4ad787e1c..062647202 100644 --- a/src/tileset_anims.c +++ b/src/tileset_anims.c @@ -5,6 +5,7 @@ #include "blend_palette.h" #include "battle_transition.h" #include "task.h" +#include "battle_transition.h" // Static type declarations @@ -1392,7 +1393,7 @@ static void sub_80A1818(u16 a1) { CpuCopy16(gTilesetAnims_BattleDomePals0[a1 & 0x3], gPlttBufferUnfaded + 0x80, 32); BlendPalette(0x80, 0x10, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); - if ((u8)FindTaskIdByFunc(sub_8149DFC) != 0xFF ) + if ((u8)FindTaskIdByFunc(Phase1_Task_RunFuncs) != 0xFF ) { sSecondaryTilesetCB = sub_80A1670; sSecondaryTilesetCBBufferSize = 0x20; @@ -1402,7 +1403,7 @@ static void sub_80A1818(u16 a1) static void sub_80A1884(u16 a1) { CpuCopy16(gTilesetAnims_BattleDomePals0[a1 & 0x3], gPlttBufferUnfaded + 0x80, 32); - if ((u8)FindTaskIdByFunc(sub_8149DFC) == 0xFF ) + if ((u8)FindTaskIdByFunc(Phase1_Task_RunFuncs) == 0xFF ) { BlendPalette(0x80, 0x10, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); if (!--sSecondaryTilesetCBBufferSize)