From db6185275eeacef224ed76dfc733f912cb5350b7 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 31 Jan 2018 13:05:36 +0100 Subject: [PATCH 1/7] start decompiling rayquaza scene --- asm/rayquaza_scene.s | 1295 +------------------------------------ include/graphics.h | 5 + include/rayquaza_scene.h | 15 + include/scanline_effect.h | 4 +- src/rayquaza_scene.c | 406 +++++++++++- sym_ewram.txt | 2 +- 6 files changed, 430 insertions(+), 1297 deletions(-) create mode 100644 include/rayquaza_scene.h diff --git a/asm/rayquaza_scene.s b/asm/rayquaza_scene.s index 8832d3942d..611c34f5f9 100644 --- a/asm/rayquaza_scene.s +++ b/asm/rayquaza_scene.s @@ -5,1266 +5,7 @@ .text - thumb_func_start sub_81D6720 -sub_81D6720: @ 81D6720 - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r4, r0, 0 - adds r5, r1, 0 - mov r8, r2 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - ldr r6, =gUnknown_0203CF60 - ldr r0, =0x00002018 - bl AllocZeroed - str r0, [r6] - ldr r1, =0x00002006 - adds r0, r1 - strb r4, [r0] - ldr r0, [r6] - mov r1, r8 - str r1, [r0] - ldr r1, =0x00002007 - adds r0, r1 - strb r5, [r0] - ldr r0, =sub_81D6774 - bl SetMainCallback2 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D6720 - - thumb_func_start sub_81D6774 -sub_81D6774: @ 81D6774 - push {lr} - bl SetVBlankHBlankCallbacksToNull - bl clear_scheduled_bg_copies_to_vram - bl ScanlineEffect_Stop - bl FreeAllSpritePalettes - bl ResetPaletteFade - bl ResetSpriteData - bl ResetTasks - movs r0, 0 - movs r1, 0xF0 - movs r2, 0x20 - bl FillPalette - ldr r1, =gUnknown_0862A6A0 - ldr r0, =gUnknown_0203CF60 - ldr r0, [r0] - ldr r2, =0x00002006 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0 - bl CreateTask - ldr r0, =sub_81D67D0 - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D6774 - - thumb_func_start sub_81D67D0 -sub_81D67D0: @ 81D67D0 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl do_scheduled_bg_tilemap_copies_to_vram - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_81D67D0 - - thumb_func_start sub_81D67EC -sub_81D67EC: @ 81D67EC - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_81D67EC - - thumb_func_start sub_81D6800 -sub_81D6800: @ 81D6800 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081D6830 - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r4, =gUnknown_0203CF60 - ldr r0, [r4] - ldr r0, [r0] - bl SetMainCallback2 - ldr r0, [r4] - bl Free - adds r0, r5, 0 - bl DestroyTask -_081D6830: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D6800 - - thumb_func_start sub_81D6840 -sub_81D6840: @ 81D6840 - push {r4-r6,lr} - lsls r0, 24 - lsrs r3, r0, 24 - adds r6, r3, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _081D68B2 - ldr r2, =gUnknown_0203CF60 - ldr r1, [r2] - ldr r4, =0x00002007 - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, 0x1 - bne _081D6888 - ldr r0, =gTasks - lsls r1, r3, 2 - adds r1, r3 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_81D6800 - b _081D68B0 - .pool -_081D6888: - ldr r4, =0x00002006 - adds r1, r4 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r2, [r2] - ldr r1, =0x00002004 - adds r0, r2, r1 - strh r5, [r0] - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldr r3, =gUnknown_0862A6A0 - adds r2, r4 - ldrb r0, [r2] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] -_081D68B0: - str r0, [r1] -_081D68B2: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D6840 - - thumb_func_start sub_81D68C8 -sub_81D68C8: @ 81D68C8 - push {lr} - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - movs r0, 0x4A - movs r1, 0 - bl SetGpuReg - movs r0, 0x40 - movs r1, 0xF0 - bl SetGpuReg - ldr r1, =0x00001888 - movs r0, 0x44 - bl SetGpuReg - ldr r0, =gPlttBufferUnfaded - movs r1, 0 - strh r1, [r0] - ldr r0, =gPlttBufferFaded - strh r1, [r0] - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D68C8 - - thumb_func_start sub_81D6904 -sub_81D6904: @ 81D6904 - push {lr} - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x3F - bl SetGpuReg - pop {r0} - bx r0 - thumb_func_end sub_81D6904 - - thumb_func_start sub_81D691C -sub_81D691C: @ 81D691C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - bl sub_81D750C - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081D697E - movs r0, 0 - ldrsh r1, [r5, r0] - cmp r1, 0x40 - bne _081D6954 - bl sub_81D7438 - b _081D6978 - .pool -_081D6954: - cmp r1, 0x90 - bne _081D695E - bl sub_81D7480 - b _081D6978 -_081D695E: - cmp r1, 0x94 - beq _081D6974 - movs r0, 0xA4 - lsls r0, 1 - cmp r1, r0 - bne _081D6978 - adds r0, r4, 0 - movs r1, 0 - bl sub_81D75B4 - b _081D697E -_081D6974: - bl sub_81D74C8 -_081D6978: - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] -_081D697E: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81D691C - - thumb_func_start sub_81D6984 -sub_81D6984: @ 81D6984 - push {r4-r6,lr} - mov r6, r8 - push {r6} - ldr r0, =gUnknown_0862A72C - mov r8, r0 - movs r1, 0x58 - movs r2, 0x48 - movs r3, 0x3 - bl CreateSprite - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r6, =gSprites - lsls r4, r5, 4 - adds r4, r5 - lsls r4, 2 - adds r0, r6, 0 - adds r0, 0x1C - adds r0, r4, r0 - ldr r1, =sub_81D6A20 - str r1, [r0] - adds r0, r6, 0 - adds r0, 0x2E - adds r4, r0 - mov r0, r8 - movs r1, 0x38 - movs r2, 0x68 - movs r3, 0x3 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - ldr r0, =gUnknown_0862A750 - movs r1, 0x4B - movs r2, 0x65 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x2] - ldr r0, =gUnknown_0862A774 - movs r1, 0x6D - movs r2, 0x72 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x4] - movs r0, 0 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x1 - bl StartSpriteAnim - adds r0, r5, 0 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D6984 - - thumb_func_start sub_81D6A20 -sub_81D6A20: @ 81D6A20 - push {r4,lr} - adds r3, r0, 0 - movs r0, 0x2E - adds r0, r3 - mov r12, r0 - ldrh r0, [r0, 0xA] - adds r0, 0x1 - movs r1, 0x1F - ands r0, r1 - mov r1, r12 - strh r0, [r1, 0xA] - cmp r0, 0 - bne _081D6A84 - ldrh r1, [r3, 0x20] - movs r2, 0x20 - ldrsh r0, [r3, r2] - cmp r0, 0x48 - beq _081D6A84 - subs r0, r1, 0x1 - strh r0, [r3, 0x20] - ldr r2, =gSprites - movs r4, 0x2E - ldrsh r1, [r3, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x1 - strh r1, [r0, 0x20] - mov r0, r12 - movs r4, 0x2 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x1 - strh r1, [r0, 0x20] - mov r0, r12 - movs r4, 0x4 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x1 - strh r1, [r0, 0x20] -_081D6A84: - adds r0, r3, 0 - adds r0, 0x2B - ldrb r3, [r0] - cmp r3, 0x1 - beq _081D6AE4 - cmp r3, 0x1 - bgt _081D6A9C - cmp r3, 0 - beq _081D6AA6 - b _081D6B68 - .pool -_081D6A9C: - cmp r3, 0x2 - beq _081D6B24 - cmp r3, 0x3 - beq _081D6AE4 - b _081D6B68 -_081D6AA6: - ldr r2, =gSprites - mov r0, r12 - movs r4, 0x2 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x24] - mov r0, r12 - movs r4, 0x2 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x26] - mov r0, r12 - movs r4, 0x4 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x24] - mov r0, r12 - movs r4, 0x4 - ldrsh r1, [r0, r4] - b _081D6B5E - .pool -_081D6AE4: - ldr r2, =gSprites - mov r0, r12 - movs r3, 0x2 - ldrsh r1, [r0, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x0000ffff - strh r1, [r0, 0x24] - mov r4, r12 - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r3, 0 - strh r3, [r0, 0x26] - movs r0, 0x4 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x1 - negs r1, r1 - b _081D6B58 - .pool -_081D6B24: - ldr r2, =gSprites - mov r3, r12 - movs r4, 0x2 - ldrsh r1, [r3, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x0000ffff - strh r1, [r0, 0x24] - movs r0, 0x2 - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r3, 0x1 - strh r3, [r0, 0x26] - mov r4, r12 - movs r0, 0x4 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x0000fffe -_081D6B58: - strh r1, [r0, 0x24] - movs r0, 0x4 - ldrsh r1, [r4, r0] -_081D6B5E: - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x26] -_081D6B68: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D6A20 - - thumb_func_start sub_81D6B7C -sub_81D6B7C: @ 81D6B7C - push {r4-r6,lr} - mov r6, r8 - push {r6} - ldr r5, =gUnknown_0862A81C - adds r0, r5, 0 - movs r1, 0x88 - movs r2, 0x60 - movs r3, 0x1 - bl CreateSprite - mov r8, r0 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r6, =gSprites - lsls r4, r0, 4 - add r4, r8 - lsls r4, 2 - adds r0, r6, 0 - adds r0, 0x1C - adds r0, r4, r0 - ldr r1, =sub_81D6D20 - str r1, [r0] - adds r0, r6, 0 - adds r0, 0x2E - adds r4, r0 - adds r0, r5, 0 - movs r1, 0xA8 - movs r2, 0x60 - movs r3, 0x1 - bl CreateSprite - lsls r0, 8 - strh r0, [r4] - adds r0, r5, 0 - movs r1, 0x88 - movs r2, 0x70 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4] - orrs r0, r1 - strh r0, [r4] - adds r0, r5, 0 - movs r1, 0xA8 - movs r2, 0x70 - movs r3, 0x1 - bl CreateSprite - lsls r0, 8 - strh r0, [r4, 0x2] - adds r0, r5, 0 - movs r1, 0x88 - movs r2, 0x80 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x2] - orrs r0, r1 - strh r0, [r4, 0x2] - adds r0, r5, 0 - movs r1, 0xA8 - movs r2, 0x80 - movs r3, 0x1 - bl CreateSprite - lsls r0, 8 - strh r0, [r4, 0x4] - adds r0, r5, 0 - movs r1, 0x68 - movs r2, 0x80 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x4] - orrs r0, r1 - strh r0, [r4, 0x4] - adds r0, r5, 0 - movs r1, 0x88 - movs r2, 0x80 - movs r3, 0x2 - bl CreateSprite - lsls r0, 8 - strh r0, [r4, 0x6] - adds r0, r5, 0 - movs r1, 0xB8 - movs r2, 0x80 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x6] - orrs r0, r1 - strh r0, [r4, 0x6] - ldr r0, =gUnknown_0862A84C - movs r1, 0xD0 - movs r2, 0x84 - movs r3, 0 - bl CreateSprite - lsls r0, 8 - strh r0, [r4, 0x8] - ldr r0, =gUnknown_0862A864 - movs r1, 0xC8 - movs r2, 0x78 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x8] - orrs r0, r1 - strh r0, [r4, 0x8] - ldrh r1, [r4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x1 - bl StartSpriteAnim - ldrb r1, [r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x2 - bl StartSpriteAnim - ldrh r1, [r4, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x3 - bl StartSpriteAnim - ldrb r1, [r4, 0x2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x4 - bl StartSpriteAnim - ldrh r1, [r4, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x5 - bl StartSpriteAnim - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x6 - bl StartSpriteAnim - ldrh r1, [r4, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x7 - bl StartSpriteAnim - ldrb r1, [r4, 0x6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x8 - bl StartSpriteAnim - mov r0, r8 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D6B7C - - thumb_func_start sub_81D6D20 -sub_81D6D20: @ 81D6D20 - push {r4-r7,lr} - adds r4, r0, 0 - adds r3, r4, 0 - adds r3, 0x2E - ldrh r0, [r3, 0xA] - adds r0, 0x1 - movs r1, 0x1F - ands r0, r1 - strh r0, [r3, 0xA] - ldr r7, =gSprites - cmp r0, 0 - bne _081D6E0E - ldrh r1, [r4, 0x20] - movs r2, 0x20 - ldrsh r0, [r4, r2] - cmp r0, 0x98 - beq _081D6E0E - adds r0, r1, 0x1 - strh r0, [r4, 0x20] - ldrh r1, [r4, 0x2E] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r4, 0x2E] - movs r2, 0xFF - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r3, 0x2] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r1, [r3, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r3, 0x4] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r1, [r3, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r3, 0x6] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r1, [r3, 0x8] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r3, 0x8] - ands r2, r0 - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] -_081D6E0E: - adds r6, r7, 0 - movs r5, 0xFF - ldrb r1, [r3, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x2B - ldrb r2, [r0] - cmp r2, 0x1 - beq _081D6EE0 - cmp r2, 0x1 - bgt _081D6E34 - cmp r2, 0 - beq _081D6E40 - b _081D6FC8 - .pool -_081D6E34: - cmp r2, 0x2 - bne _081D6E3A - b _081D6F68 -_081D6E3A: - cmp r2, 0x3 - beq _081D6EE0 - b _081D6FC8 -_081D6E40: - strh r2, [r4, 0x26] - ldrh r1, [r3] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r0, [r3] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x2] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x4] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x6] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x8] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x8] - ands r1, r5 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - b _081D6FC6 -_081D6EE0: - movs r2, 0x1 - strh r2, [r4, 0x26] - ldrh r1, [r3] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3, 0x2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3, 0x6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x8] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3, 0x8] - b _081D6FBE -_081D6F68: - strh r2, [r4, 0x26] - ldrh r1, [r3] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r0, [r3] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x2] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x8] - ands r1, r5 -_081D6FBE: - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 -_081D6FC6: - strh r2, [r0, 0x26] -_081D6FC8: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D6D20 - - thumb_func_start sub_81D6FD0 -sub_81D6FD0: @ 81D6FD0 - push {lr} - bl sub_81D67EC - bl ScanlineEffect_InitHBlankDmaTransfer - pop {r0} - bx r0 - thumb_func_end sub_81D6FD0 - - thumb_func_start sub_81D6FE0 -sub_81D6FE0: @ 81D6FE0 - push {r4,lr} - bl ResetVramOamAndBgCntRegs - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0862A888 - movs r0, 0 - movs r2, 0x3 - bl InitBgsFromTemplates - ldr r4, =gUnknown_0203CF60 - ldr r1, [r4] - adds r1, 0x4 - movs r0, 0 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00000804 - adds r1, r0 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00001004 - adds r1, r0 - movs r0, 0x2 - bl SetBgTilemapBuffer - bl ResetAllBgsCoordinates - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D6FE0 - - thumb_func_start sub_81D706C -sub_81D706C: @ 81D706C - push {r4,lr} - sub sp, 0x4 - bl reset_temp_tile_data_buffers - ldr r1, =gRaySceneClouds_Gfx - movs r0, 0 - str r0, [sp] - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram -_081D7082: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081D7082 - ldr r0, =gRaySceneClouds2_Tilemap - ldr r4, =gUnknown_0203CF60 - ldr r1, [r4] - adds r1, 0x4 - bl LZDecompressWram - ldr r0, =gRaySceneClouds1_Tilemap - ldr r1, [r4] - ldr r2, =0x00000804 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneClouds3_Tilemap - ldr r1, [r4] - ldr r2, =0x00001004 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneClouds_Pal - movs r1, 0 - movs r2, 0x40 - bl LoadCompressedPalette - ldr r0, =gUnknown_0862A8C4 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862A8F8 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862A924 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862A9D4 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AA14 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AA34 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862A8CC - bl LoadCompressedObjectPalette - ldr r0, =gUnknown_0862A9DC - bl LoadCompressedObjectPalette - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D706C - - thumb_func_start sub_81D7134 -sub_81D7134: @ 81D7134 - push {r4-r7,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r6, r1, 3 - ldr r7, =gTasks + 0x8 - adds r5, r6, r7 - bl ScanlineEffect_Clear - bl sub_81D6FE0 - bl sub_81D706C - movs r4, 0 - str r4, [sp, 0x4] - ldr r1, =gScanlineEffectRegBuffers - ldr r2, =0x010003c0 - add r0, sp, 0x4 - bl CpuFastSet - ldr r2, =gUnknown_0862A87C - ldr r0, [r2] - ldr r1, [r2, 0x4] - ldr r2, [r2, 0x8] - bl ScanlineEffect_SetParams - strh r4, [r5] - ldr r0, =sub_81D7228 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x2] - ldr r0, =gUnknown_0203CF60 - ldr r0, [r0] - ldr r1, =0x00002006 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _081D71CC - bl sub_81D6984 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x4] - bl sub_81D6B7C - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x6] - adds r0, r7, 0 - subs r0, 0x8 - adds r0, r6, r0 - ldr r1, =sub_81D691C - str r1, [r0] - b _081D71EE - .pool -_081D71CC: - bl sub_81D7664 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x4] - bl sub_81D78BC - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x6] - adds r0, r7, 0 - subs r0, 0x8 - adds r0, r6, r0 - ldr r1, =sub_81D736C - str r1, [r0] - bl StopMapMusic -_081D71EE: - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =sub_81D6FD0 - bl SetVBlankCallback - movs r0, 0x53 - bl PlaySE - add sp, 0x8 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7134 + thumb_func_start sub_81D7228 sub_81D7228: @ 81D7228 @@ -1277,7 +18,7 @@ sub_81D7228: @ 81D7228 ldr r0, =gTasks + 0x8 adds r3, r1, r0 movs r1, 0x18 - ldr r7, =gUnknown_0203CF60 + ldr r7, =sRayScene ldr r4, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 @@ -1781,7 +522,7 @@ sub_81D7600: @ 81D7600 adds r0, r7, 0 subs r0, 0x8 adds r0, r6, r0 - ldr r1, =sub_81D6840 + ldr r1, =Task_SetNextAnim str r1, [r0] _081D7652: pop {r4-r7} @@ -2765,7 +1506,7 @@ sub_81D7E10: @ 81D7E10 movs r0, 0x1 movs r2, 0x3 bl InitBgsFromTemplates - ldr r4, =gUnknown_0203CF60 + ldr r4, =sRayScene ldr r1, [r4] adds r1, 0x4 movs r0, 0 @@ -2836,7 +1577,7 @@ _081D7ED0: cmp r0, 0 bne _081D7ED0 ldr r0, =gRaySceneClouds2_Tilemap - ldr r4, =gUnknown_0203CF60 + ldr r4, =sRayScene ldr r1, [r4] adds r1, 0x4 bl LZDecompressWram @@ -3146,7 +1887,7 @@ sub_81D8164: @ 81D8164 adds r1, r4 lsls r1, 3 adds r1, r0 - ldr r0, =sub_81D6840 + ldr r0, =Task_SetNextAnim str r0, [r1] _081D8192: pop {r4} @@ -3299,7 +2040,7 @@ sub_81D82B0: @ 81D82B0 movs r0, 0 movs r2, 0x4 bl InitBgsFromTemplates - ldr r4, =gUnknown_0203CF60 + ldr r4, =sRayScene ldr r1, [r4] adds r1, 0x4 movs r0, 0 @@ -3375,7 +2116,7 @@ _081D8380: cmp r6, 0 bne _081D8380 ldr r0, =gRaySceneRayquazaLight_Tilemap - ldr r5, =gUnknown_0203CF60 + ldr r5, =sRayScene ldr r1, [r5] adds r1, 0x4 bl LZDecompressWram @@ -3441,7 +2182,7 @@ sub_81D844C: @ 81D844C lsrs r0, 16 cmp r0, 0x6F bhi _081D848C - ldr r0, =gUnknown_0203CF60 + ldr r0, =sRayScene ldr r0, [r0] ldr r3, =0x00002008 adds r0, r3 @@ -3462,7 +2203,7 @@ _081D8492: strh r0, [r1] cmp r2, 0 bne _081D84E0 - ldr r0, =gUnknown_0203CF60 + ldr r0, =sRayScene ldr r1, [r0] ldr r2, =0x00002008 adds r3, r1, r2 @@ -3531,7 +2272,7 @@ sub_81D84EC: @ 81D84EC bl BlendPalettes ldr r0, =sub_81D67EC bl SetVBlankCallback - ldr r0, =gUnknown_0203CF60 + ldr r0, =sRayScene ldr r0, [r0] ldr r1, =0x00002008 adds r2, r0, r1 @@ -3708,7 +2449,7 @@ sub_81D8684: @ 81D8684 adds r1, r4 lsls r1, 3 adds r1, r0 - ldr r0, =sub_81D6840 + ldr r0, =Task_SetNextAnim str r0, [r1] _081D86B8: pop {r4} @@ -3906,7 +2647,7 @@ sub_81D8828: @ 81D8828 movs r0, 0 movs r2, 0x4 bl InitBgsFromTemplates - ldr r4, =gUnknown_0203CF60 + ldr r4, =sRayScene ldr r1, [r4] adds r1, 0x4 movs r0, 0 @@ -3986,7 +2727,7 @@ _081D8904: cmp r0, 0 bne _081D8904 ldr r0, =gRayChaseRayquazaChase2_Tilemap - ldr r4, =gUnknown_0203CF60 + ldr r4, =sRayScene ldr r1, [r4] adds r1, 0x4 bl LZDecompressWram @@ -4342,7 +3083,7 @@ sub_81D8BEC: @ 81D8BEC adds r0, r6, 0 subs r0, 0x8 adds r0, r5, r0 - ldr r1, =sub_81D6840 + ldr r1, =Task_SetNextAnim str r1, [r0] _081D8C26: pop {r4-r6} @@ -4361,7 +3102,7 @@ sub_81D8C38: @ 81D8C38 movs r0, 0x1 movs r2, 0x3 bl InitBgsFromTemplates - ldr r4, =gUnknown_0203CF60 + ldr r4, =sRayScene ldr r1, [r4] adds r1, 0x4 movs r0, 0 @@ -4426,7 +3167,7 @@ _081D8CEA: cmp r0, 0 bne _081D8CEA ldr r0, =gRaySceneHushRing_Tilemap - ldr r4, =gUnknown_0203CF60 + ldr r4, =sRayScene ldr r1, [r4] ldr r2, =0x00000804 adds r1, r2 @@ -4815,7 +3556,7 @@ _081D9078: adds r0, r7, 0 subs r0, 0x8 adds r0, r6, r0 - ldr r1, =sub_81D6840 + ldr r1, =Task_SetNextAnim str r1, [r0] b _081D90A0 .pool diff --git a/include/graphics.h b/include/graphics.h index 5917e9d2ae..c089ec2545 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2678,5 +2678,10 @@ extern const u8 gRaySceneGroudonLeft_Pal[]; extern const u8 gRaySceneKyogreRight_Pal[]; extern const u8 gRaySceneRayquazaHover_Pal[]; extern const u8 gRaySceneSplash_Pal[]; +extern const u8 gRaySceneClouds_Gfx[]; +extern const u8 gRaySceneClouds_Pal[]; +extern const u8 gRaySceneClouds2_Tilemap[]; +extern const u8 gRaySceneClouds1_Tilemap[]; +extern const u8 gRaySceneClouds3_Tilemap[]; #endif //GUARD_GRAPHICS_H diff --git a/include/rayquaza_scene.h b/include/rayquaza_scene.h new file mode 100644 index 0000000000..e997c9db72 --- /dev/null +++ b/include/rayquaza_scene.h @@ -0,0 +1,15 @@ +#ifndef GUARD_RAYQUAZA_SCENE_H +#define GUARD_RAYQUAZA_SCENE_H + +enum +{ + RAY_ANIM_DUO_FIGHT_PRE, + RAY_ANIM_DUO_FIGHT, + RAY_ANIM_TAKES_FLIGHT, + RAY_ANIM_DESCENDS, + RAY_ANIM_CHARGES, + RAY_ANIM_CHACES_AWAY, + RAY_ANIM_END +}; + +#endif // GUARD_RAYQUAZA_SCENE_H diff --git a/include/scanline_effect.h b/include/scanline_effect.h index 54dfe17bdd..eb837e7e23 100644 --- a/include/scanline_effect.h +++ b/include/scanline_effect.h @@ -1,7 +1,7 @@ #ifndef GUARD_SCANLINE_EFFECT_H #define GUARD_SCANLINE_EFFECT_H -// DMA control value to ransfer a single 16-bit value at HBlank +// DMA control value to transfer a single 16-bit value at HBlank #define SCANLINE_EFFECT_DMACNT_16BIT (((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_SRC_INC | DMA_DEST_INC | DMA_16BIT | DMA_DEST_RELOAD) << 16) | 1) #define SCANLINE_EFFECT_REG_BG0HOFS (REG_ADDR_BG0HOFS - REG_ADDR_BG0HOFS) @@ -36,7 +36,7 @@ struct ScanlineEffect extern struct ScanlineEffect gScanlineEffect; -extern u16 gScanlineEffectRegBuffers[][0x3C0]; +extern u16 gScanlineEffectRegBuffers[2][0x3C0]; void ScanlineEffect_Stop(void); void ScanlineEffect_Clear(void); diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index ce87473952..72aeab94ed 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -1,15 +1,19 @@ #include "global.h" +#include "rayquaza_scene.h" #include "sprite.h" #include "task.h" #include "graphics.h" #include "bg.h" - -struct UnkRayquazaStruct -{ - u32 field_0; - u32 field_4; - u32 field_8; -}; +#include "main.h" +#include "malloc.h" +#include "palette.h" +#include "scanline_effect.h" +#include "menu.h" +#include "menu_helpers.h" +#include "gpu_regs.h" +#include "decompress.h" +#include "sound.h" +#include "constants/songs.h" // this file's functions void sub_81D7134(u8 taskId); @@ -17,21 +21,21 @@ void sub_81D7F4C(u8 taskId); void sub_81D84EC(u8 taskId); void sub_81D8980(u8 taskId); void sub_81D8DB4(u8 taskId); -void sub_81D6800(u8 taskId); +void Task_EndAfterFadeScreen(u8 taskId); void sub_81D8260(struct Sprite *sprite); void sub_81D961C(struct Sprite *sprite); // const rom data -const TaskFunc gUnknown_0862A6A0[] = +const TaskFunc sTasksForAnimations[] = { - sub_81D7134, - sub_81D7134, - sub_81D7F4C, - sub_81D84EC, - sub_81D8980, - sub_81D8DB4, - sub_81D6800 + sub_81D7134, // RAY_ANIM_DUO_FIGHT_PRE + sub_81D7134, // RAY_ANIM_DUO_FIGHT + sub_81D7F4C, // RAY_ANIM_TAKES_FLIGHT + sub_81D84EC, // RAY_ANIM_DESCENDS + sub_81D8980, // RAY_ANIM_CHARGES + sub_81D8DB4, // RAY_ANIM_CHACES_AWAY + Task_EndAfterFadeScreen // RAY_ANIM_END }; static const struct OamData sOamData_862A6BC = @@ -372,7 +376,12 @@ const struct SpriteTemplate gUnknown_0862A864 = .callback = SpriteCallbackDummy, }; -const struct UnkRayquazaStruct gUnknown_0862A87C = {0x4000014, 0xA2600001, 1}; +const struct ScanlineEffectParams gUnknown_0862A87C = +{ + .dmaDest = (vu16 *)REG_ADDR_BG1HOFS, + .dmaControl = 0xA2600001, + .initState = 1 +}; const struct BgTemplate gUnknown_0862A888[] = { @@ -1162,3 +1171,366 @@ const struct BgTemplate gUnknown_0862AD08[] = } }; +struct RaySceneStruct +{ + MainCallback callback; + u8 tilemapBuffers[3][0x800]; + u8 field_1804[0x800]; + u16 field_2004; + u8 animId; + bool8 onlyOneAnim; +}; + +extern struct RaySceneStruct *sRayScene; + +// this file's functions +void sub_81D6774(void); +void sub_81D67D0(void); +void sub_81D750C(void); +void sub_81D7438(void); +void sub_81D7480(void); +void sub_81D74C8(void); +void sub_81D75B4(u8 taskId, s8 palDelay); +void sub_81D6A20(struct Sprite *sprite); +void sub_81D6D20(struct Sprite *sprite); +void sub_81D7228(u8 taskId); +void sub_81D736C(u8 taskId); +u8 sub_81D7664(void); +u8 sub_81D78BC(void); + +// code +void sub_81D6720(u8 animId, bool8 onlyOneAnim, MainCallback callback) +{ + sRayScene = AllocZeroed(0x2018); + sRayScene->animId = animId; + sRayScene->callback = callback; + sRayScene->onlyOneAnim = onlyOneAnim; + SetMainCallback2(sub_81D6774); +} + +void sub_81D6774(void) +{ + SetVBlankHBlankCallbacksToNull(); + clear_scheduled_bg_copies_to_vram(); + ScanlineEffect_Stop(); + FreeAllSpritePalettes(); + ResetPaletteFade(); + ResetSpriteData(); + ResetTasks(); + FillPalette(0, 0xF0, 0x20); + CreateTask(sTasksForAnimations[sRayScene->animId], 0); + SetMainCallback2(sub_81D67D0); +} + +void sub_81D67D0(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + do_scheduled_bg_tilemap_copies_to_vram(); + UpdatePaletteFade(); +} + +void sub_81D67EC(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void Task_EndAfterFadeScreen(u8 taskId) +{ + if (!gPaletteFade.active) + { + ResetSpriteData(); + FreeAllSpritePalettes(); + SetMainCallback2(sRayScene->callback); + Free(sRayScene); + DestroyTask(taskId); + } +} + +void Task_SetNextAnim(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (sRayScene->onlyOneAnim == TRUE) + { + gTasks[taskId].func = Task_EndAfterFadeScreen; + } + else + { + sRayScene->animId++; + sRayScene->field_2004 = 0; + gTasks[taskId].func = sTasksForAnimations[sRayScene->animId]; + } + } +} + +void sub_81D68C8(void) +{ + SetGpuReg(REG_OFFSET_WININ, 0x3F); + SetGpuReg(REG_OFFSET_WINOUT, 0); + SetGpuReg(REG_OFFSET_WIN0H, 0xF0); + SetGpuReg(REG_OFFSET_WIN0V, 0x1888); + gPlttBufferUnfaded[0] = 0; + gPlttBufferFaded[0] = 0; +} + +void sub_81D6904(void) +{ + SetGpuReg(REG_OFFSET_WININ, 0x3F); + SetGpuReg(REG_OFFSET_WINOUT, 0x3F); +} + +void sub_81D691C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + sub_81D750C(); + if (!gPaletteFade.active) + { + s16 counter = data[0]; + if (counter == 64) + { + sub_81D7438(); + } + else if (counter == 144) + { + sub_81D7480(); + } + else + { + switch (counter) + { + case 328: + sub_81D75B4(taskId, 0); + return; + case 148: + sub_81D74C8(); + break; + } + } + + data[0]++; + } +} + +u8 sub_81D6984(void) +{ + u8 spriteId; + s16 *data; + + spriteId = CreateSprite(&gUnknown_0862A72C, 88, 72, 3); + gSprites[spriteId].callback = sub_81D6A20; + data = gSprites[spriteId].data; + data[0] = CreateSprite(&gUnknown_0862A72C, 56, 104, 3); + data[1] = CreateSprite(&gUnknown_0862A750, 75, 101, 0); + data[2] = CreateSprite(&gUnknown_0862A774, 109, 114, 1); + StartSpriteAnim(&gSprites[data[0]], 1); + return spriteId; +} + +void sub_81D6A20(struct Sprite *sprite) +{ + s16 *data = sprite->data; + data[5]++; + data[5] &= 0x1F; + if (data[5] == 0 && sprite->pos1.x != 72) + { + sprite->pos1.x--; + gSprites[sprite->data[0]].pos1.x--; + gSprites[data[1]].pos1.x--; + gSprites[data[2]].pos1.x--; + } + + switch (sprite->animCmdIndex) + { + case 0: + gSprites[data[1]].pos2.x = 0; + gSprites[data[1]].pos2.y = 0; + gSprites[data[2]].pos2.x = 0; + gSprites[data[2]].pos2.y = 0; + break; + case 1: + case 3: + gSprites[data[1]].pos2.x = -1; + gSprites[data[1]].pos2.y = 0; + gSprites[data[2]].pos2.x = -1; + gSprites[data[2]].pos2.y = 0; + break; + case 2: + gSprites[data[1]].pos2.x = -1; + gSprites[data[1]].pos2.y = 1; + gSprites[data[2]].pos2.x = -2; + gSprites[data[2]].pos2.y = 1; + break; + } +} + +u8 sub_81D6B7C(void) +{ + u8 spriteId; + s16 *data; + + spriteId = CreateSprite(&gUnknown_0862A81C, 136, 96, 1); + gSprites[spriteId].callback = sub_81D6D20; + data = gSprites[spriteId].data; + + data[0] = CreateSprite(&gUnknown_0862A81C, 168, 96, 1) << 8; + data[0] |= CreateSprite(&gUnknown_0862A81C, 136, 112, 1); + data[1] = CreateSprite(&gUnknown_0862A81C, 168, 112, 1) << 8; + data[1] |= CreateSprite(&gUnknown_0862A81C, 136, 128, 1); + data[2] = CreateSprite(&gUnknown_0862A81C, 168, 128, 1) << 8; + data[2] |= CreateSprite(&gUnknown_0862A81C, 104, 128, 2); + data[3] = CreateSprite(&gUnknown_0862A81C, 136, 128, 2) << 8; + data[3] |= CreateSprite(&gUnknown_0862A81C, 184, 128, 0); + data[4] = CreateSprite(&gUnknown_0862A84C, 208, 132, 0) << 8; + data[4] |= CreateSprite(&gUnknown_0862A864, 200, 120, 1); + + StartSpriteAnim(&gSprites[data[0] >> 8], 1); + StartSpriteAnim(&gSprites[data[0] & 0xFF], 2); + StartSpriteAnim(&gSprites[data[1] >> 8], 3); + StartSpriteAnim(&gSprites[data[1] & 0xFF], 4); + StartSpriteAnim(&gSprites[data[2] >> 8], 5); + StartSpriteAnim(&gSprites[data[2] & 0xFF], 6); + StartSpriteAnim(&gSprites[data[3] >> 8], 7); + StartSpriteAnim(&gSprites[data[3] & 0xFF], 8); + + return spriteId; +} + +void sub_81D6D20(struct Sprite *sprite) +{ + s16 *data = sprite->data; + data[5]++; + data[5] &= 0x1F; + if (data[5] == 0 && sprite->pos1.x != 152) + { + sprite->pos1.x++; + gSprites[sprite->data[0] >> 8].pos1.x++; + gSprites[sprite->data[0] & 0xFF].pos1.x++; + gSprites[data[1] >> 8].pos1.x++; + gSprites[data[1] & 0xFF].pos1.x++; + gSprites[data[2] >> 8].pos1.x++; + gSprites[data[2] & 0xFF].pos1.x++; + gSprites[data[3] >> 8].pos1.x++; + gSprites[data[3] & 0xFF].pos1.x++; + gSprites[data[4] >> 8].pos1.x++; + gSprites[data[4] & 0xFF].pos1.x++; + } + + switch (gSprites[data[2] & 0xFF].animCmdIndex) + { + case 0: + sprite->pos2.y = 0; + gSprites[data[0] >> 8].pos2.y = 0; + gSprites[data[0] & 0xFF].pos2.y = 0; + gSprites[data[1] >> 8].pos2.y = 0; + gSprites[data[1] & 0xFF].pos2.y = 0; + gSprites[data[2] >> 8].pos2.y = 0; + gSprites[data[2] & 0xFF].pos2.y = 0; + gSprites[data[3] >> 8].pos2.y = 0; + gSprites[data[3] & 0xFF].pos2.y = 0; + gSprites[data[4] >> 8].pos2.y = 0; + gSprites[data[4] & 0xFF].pos2.y = 0; + break; + case 1: + case 3: + sprite->pos2.y = 1; + gSprites[data[0] >> 8].pos2.y = 1; + gSprites[data[0] & 0xFF].pos2.y = 1; + gSprites[data[1] >> 8].pos2.y = 1; + gSprites[data[1] & 0xFF].pos2.y = 1; + gSprites[data[2] >> 8].pos2.y = 1; + gSprites[data[2] & 0xFF].pos2.y = 1; + gSprites[data[3] >> 8].pos2.y = 1; + gSprites[data[3] & 0xFF].pos2.y = 1; + gSprites[data[4] >> 8].pos2.y = 1; + gSprites[data[4] & 0xFF].pos2.y = 1; + break; + case 2: + sprite->pos2.y = 2; + gSprites[data[0] >> 8].pos2.y = 2; + gSprites[data[0] & 0xFF].pos2.y = 2; + gSprites[data[1] >> 8].pos2.y = 2; + gSprites[data[1] & 0xFF].pos2.y = 2; + gSprites[data[2] >> 8].pos2.y = 2; + gSprites[data[4] & 0xFF].pos2.y = 2; + break; + } +} + +void sub_81D6FD0(void) +{ + sub_81D67EC(); + ScanlineEffect_InitHBlankDmaTransfer(); +} + +void sub_81D6FE0(void) +{ + ResetVramOamAndBgCntRegs(); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_0862A888, 3); + SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); + SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); + SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); + ResetAllBgsCoordinates(); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); + schedule_bg_copy_tilemap_to_vram(2); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ShowBg(0); + ShowBg(1); + ShowBg(2); + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +void sub_81D706C(void) +{ + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(0, gRaySceneClouds_Gfx, 0, 0, 0); + while (free_temp_tile_data_buffers_if_possible()); + + LZDecompressWram(gRaySceneClouds2_Tilemap, sRayScene->tilemapBuffers[0]); + LZDecompressWram(gRaySceneClouds1_Tilemap, sRayScene->tilemapBuffers[1]); + LZDecompressWram(gRaySceneClouds3_Tilemap, sRayScene->tilemapBuffers[2]); + LoadCompressedPalette(gRaySceneClouds_Pal, 0, 0x40); + LoadCompressedObjectPic(&gUnknown_0862A8C4); + LoadCompressedObjectPic(&gUnknown_0862A8F8); + LoadCompressedObjectPic(&gUnknown_0862A924); + LoadCompressedObjectPic(&gUnknown_0862A9D4); + LoadCompressedObjectPic(&gUnknown_0862AA14); + LoadCompressedObjectPic(&gUnknown_0862AA34); + LoadCompressedObjectPalette(&gUnknown_0862A8CC); + LoadCompressedObjectPalette(&gUnknown_0862A9DC); +} + +void sub_81D7134(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + ScanlineEffect_Clear(); + sub_81D6FE0(); + sub_81D706C(); + CpuFastFill16(0, gScanlineEffectRegBuffers, sizeof(gScanlineEffectRegBuffers)); + ScanlineEffect_SetParams(gUnknown_0862A87C); + data[0] = 0; + data[1] = CreateTask(sub_81D7228, 0); + if (sRayScene->animId == RAY_ANIM_DUO_FIGHT_PRE) + { + data[2] = sub_81D6984(); + data[3] = sub_81D6B7C(); + gTasks[taskId].func = sub_81D691C; + } + else + { + data[2] = sub_81D7664(); + data[3] = sub_81D78BC(); + gTasks[taskId].func = sub_81D736C; + StopMapMusic(); + } + + BlendPalettes(-1, 0x10, 0); + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + SetVBlankCallback(sub_81D6FD0); + PlaySE(SE_T_OOAME); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 67911a3cca..eb26556c42 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1527,4 +1527,4 @@ gUnknown_0203CF58: @ 203CF58 gUnknown_0203CF5C: @ 203CF5C .space 0x4 -gUnknown_0203CF60: @ 203CF60 +sRayScene: @ 203CF60 From 68146af07cfc5103120a41837765c9d668114f74 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 1 Feb 2018 11:17:07 +0100 Subject: [PATCH 2/7] more ray scene work --- asm/rayquaza_scene.s | 3084 ------------------------------------------ include/graphics.h | 17 + include/palette.h | 1 + src/rayquaza_scene.c | 918 ++++++++++++- 4 files changed, 933 insertions(+), 3087 deletions(-) diff --git a/asm/rayquaza_scene.s b/asm/rayquaza_scene.s index 611c34f5f9..a7614239a1 100644 --- a/asm/rayquaza_scene.s +++ b/asm/rayquaza_scene.s @@ -5,3092 +5,8 @@ .text - - thumb_func_start sub_81D7228 -sub_81D7228: @ 81D7228 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r3, r1, r0 - movs r1, 0x18 - ldr r7, =sRayScene - ldr r4, =gScanlineEffectRegBuffers - movs r0, 0xF0 - lsls r0, 3 - adds r5, r4, r0 -_081D7244: - lsls r0, r1, 16 - asrs r1, r0, 16 - adds r6, r0, 0 - cmp r1, 0x2F - bgt _081D726C - lsls r1, 1 - adds r2, r1, r4 - ldrh r0, [r3] - lsrs r0, 8 - strh r0, [r2] - adds r1, r5 - ldrh r0, [r3] - b _081D72CA - .pool -_081D726C: - cmp r1, 0x3F - bgt _081D7280 - lsls r1, 1 - adds r2, r1, r4 - ldrh r0, [r3, 0x2] - lsrs r0, 8 - strh r0, [r2] - adds r1, r5 - ldrh r0, [r3, 0x2] - b _081D72CA -_081D7280: - cmp r1, 0x4B - bgt _081D7294 - lsls r1, 1 - adds r2, r1, r4 - ldrh r0, [r3, 0x4] - lsrs r0, 8 - strh r0, [r2] - adds r1, r5 - ldrh r0, [r3, 0x4] - b _081D72CA -_081D7294: - cmp r1, 0x53 - bgt _081D72A8 - lsls r1, 1 - adds r2, r1, r4 - ldrh r0, [r3, 0x6] - lsrs r0, 8 - strh r0, [r2] - adds r1, r5 - ldrh r0, [r3, 0x6] - b _081D72CA -_081D72A8: - cmp r1, 0x57 - bgt _081D72BC - lsls r1, 1 - adds r2, r1, r4 - ldrh r0, [r3, 0x8] - lsrs r0, 8 - strh r0, [r2] - adds r1, r5 - ldrh r0, [r3, 0x8] - b _081D72CA -_081D72BC: - lsls r1, 1 - adds r2, r1, r4 - ldrh r0, [r3, 0xA] - lsrs r0, 8 - strh r0, [r2] - adds r1, r5 - ldrh r0, [r3, 0xA] -_081D72CA: - lsrs r0, 8 - strh r0, [r1] - movs r1, 0x80 - lsls r1, 9 - adds r0, r6, r1 - lsrs r1, r0, 16 - asrs r0, 16 - cmp r0, 0x5B - ble _081D7244 - ldr r0, [r7] - ldr r1, =0x00002006 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _081D7324 - movs r1, 0xE0 - lsls r1, 1 - adds r0, r1, 0 - ldrh r1, [r3] - adds r0, r1 - strh r0, [r3] - movs r1, 0xC0 - lsls r1, 1 - adds r0, r1, 0 - ldrh r1, [r3, 0x2] - adds r0, r1 - strh r0, [r3, 0x2] - movs r1, 0xA0 - lsls r1, 1 - adds r0, r1, 0 - ldrh r1, [r3, 0x4] - adds r0, r1 - strh r0, [r3, 0x4] - movs r1, 0x80 - lsls r1, 1 - adds r0, r1, 0 - ldrh r1, [r3, 0x6] - adds r0, r1 - strh r0, [r3, 0x6] - ldrh r0, [r3, 0x8] - adds r0, 0xC0 - b _081D735E - .pool -_081D7324: - movs r1, 0xC0 - lsls r1, 2 - adds r0, r1, 0 - ldrh r1, [r3] - adds r0, r1 - strh r0, [r3] - movs r1, 0xA0 - lsls r1, 2 - adds r0, r1, 0 - ldrh r1, [r3, 0x2] - adds r0, r1 - strh r0, [r3, 0x2] - movs r1, 0x80 - lsls r1, 2 - adds r0, r1, 0 - ldrh r1, [r3, 0x4] - adds r0, r1 - strh r0, [r3, 0x4] - movs r1, 0xC0 - lsls r1, 1 - adds r0, r1, 0 - ldrh r1, [r3, 0x6] - adds r0, r1 - strh r0, [r3, 0x6] - movs r1, 0x80 - lsls r1, 1 - adds r0, r1, 0 - ldrh r1, [r3, 0x8] - adds r0, r1 -_081D735E: - strh r0, [r3, 0x8] - ldrh r0, [r3, 0xA] - adds r0, 0x80 - strh r0, [r3, 0xA] - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D7228 - thumb_func_start sub_81D736C -sub_81D736C: @ 81D736C - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r7, =gTasks + 0x8 - adds r4, r0, r7 - bl sub_81D750C - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - bne _081D742E - movs r0, 0 - ldrsh r1, [r4, r0] - cmp r1, 0x20 - beq _081D739C - cmp r1, 0x70 - bne _081D73AC -_081D739C: - bl sub_81D7438 - b _081D7428 - .pool -_081D73AC: - cmp r1, 0xD8 - bne _081D73B6 - bl sub_81D7480 - b _081D7428 -_081D73B6: - cmp r1, 0xDC - bne _081D73C0 - bl sub_81D74C8 - b _081D7428 -_081D73C0: - movs r0, 0xBE - lsls r0, 1 - cmp r1, r0 - beq _081D73D8 - adds r0, 0x20 - cmp r1, r0 - bne _081D7428 - adds r0, r5, 0 - movs r1, 0x2 - bl sub_81D75B4 - b _081D742E -_081D73D8: - movs r1, 0x91 - lsls r1, 2 - movs r0, 0x50 - bl SetGpuReg - adds r2, r7, 0 - subs r2, 0x8 - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldr r1, =sub_81D752C - str r1, [r0] - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - strh r6, [r0, 0x8] - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrh r1, [r4, 0x4] - strh r1, [r0, 0xC] - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrh r1, [r4, 0x6] - strh r1, [r0, 0xE] - bl ScanlineEffect_Stop -_081D7428: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] -_081D742E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D736C - - thumb_func_start sub_81D7438 -sub_81D7438: @ 81D7438 - push {r4,lr} - sub sp, 0xC - movs r0, 0x57 - bl PlaySE - ldr r0, =0x00007fff - ldr r1, =0x0000ffff - str r1, [sp] - movs r4, 0 - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl sub_80A2C44 - ldr r0, =0xffff0000 - str r4, [sp] - str r4, [sp, 0x4] - movs r1, 0x1 - str r1, [sp, 0x8] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl sub_80A2C44 - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7438 - - thumb_func_start sub_81D7480 -sub_81D7480: @ 81D7480 - push {r4,lr} - sub sp, 0xC - movs r0, 0x57 - bl PlaySE - ldr r0, =0x00007fff - ldr r1, =0x0000ffff - str r1, [sp] - movs r4, 0 - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0 - movs r2, 0x10 - movs r3, 0x10 - bl sub_80A2C44 - ldr r0, =0xffff0000 - str r4, [sp] - str r4, [sp, 0x4] - movs r1, 0x1 - str r1, [sp, 0x8] - movs r1, 0 - movs r2, 0x10 - movs r3, 0x10 - bl sub_80A2C44 - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7480 - - thumb_func_start sub_81D74C8 -sub_81D74C8: @ 81D74C8 - push {r4,lr} - sub sp, 0xC - ldr r0, =0x00007fff - ldr r1, =0x0000ffff - str r1, [sp] - movs r4, 0 - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x4 - movs r2, 0x10 - movs r3, 0 - bl sub_80A2C44 - ldr r0, =0xffff0000 - str r4, [sp] - str r4, [sp, 0x4] - movs r1, 0x1 - str r1, [sp, 0x8] - movs r1, 0x4 - movs r2, 0x10 - movs r3, 0 - bl sub_80A2C44 - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D74C8 - - thumb_func_start sub_81D750C -sub_81D750C: @ 81D750C - push {lr} - movs r1, 0x80 - lsls r1, 3 - movs r0, 0x2 - movs r2, 0x1 - bl ChangeBgX - movs r1, 0x80 - lsls r1, 4 - movs r0, 0x2 - movs r2, 0x2 - bl ChangeBgY - pop {r0} - bx r0 - thumb_func_end sub_81D750C - - thumb_func_start sub_81D752C -sub_81D752C: @ 81D752C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r5, r1, r0 - movs r0, 0x4 - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - bl sub_81D7860 - movs r0, 0x6 - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl sub_81D7D14 - movs r0, 0x1 - bl GetBgY - lsls r0, 16 - lsrs r4, r0, 16 - movs r0, 0x1 - bl GetBgY - cmp r0, 0 - beq _081D757A - movs r0, 0x80 - lsls r0, 8 - cmp r4, r0 - bls _081D7586 -_081D757A: - movs r1, 0x80 - lsls r1, 3 - movs r0, 0x1 - movs r2, 0x2 - bl ChangeBgY -_081D7586: - ldrh r2, [r5] - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0x10 - beq _081D75A6 - adds r2, 0x1 - strh r2, [r5] - lsls r1, r2, 8 - movs r0, 0x10 - subs r0, r2 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg -_081D75A6: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D752C - - thumb_func_start sub_81D75B4 -sub_81D75B4: @ 81D75B4 - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r4, r1, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x54 - bl PlaySE - movs r0, 0x1 - negs r0, r0 - lsls r4, 24 - asrs r4, 24 - movs r1, 0 - str r1, [sp] - adds r1, r4, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81D7600 - str r1, [r0] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D75B4 - - thumb_func_start sub_81D7600 -sub_81D7600: @ 81D7600 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r6, r1, 3 - ldr r7, =gTasks + 0x8 - adds r5, r6, r7 - bl sub_81D750C - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _081D7652 - ldrb r0, [r5, 0x2] - bl DestroyTask - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0 - bl SetVBlankCallback - bl ScanlineEffect_Stop - bl ResetSpriteData - bl FreeAllSpritePalettes - strh r4, [r5] - adds r0, r7, 0 - subs r0, 0x8 - adds r0, r6, r0 - ldr r1, =Task_SetNextAnim - str r1, [r0] -_081D7652: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7600 - - thumb_func_start sub_81D7664 -sub_81D7664: @ 81D7664 - push {r4-r6,lr} - mov r6, r8 - push {r6} - ldr r0, =gUnknown_0862A8D4 - mov r8, r0 - movs r1, 0x62 - movs r2, 0x48 - movs r3, 0x3 - bl CreateSprite - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r6, =gSprites - lsls r4, r5, 4 - adds r4, r5 - lsls r4, 2 - adds r0, r6, 0 - adds r0, 0x1C - adds r0, r4, r0 - ldr r1, =sub_81D7700 - str r1, [r0] - adds r0, r6, 0 - adds r0, 0x2E - adds r4, r0 - mov r0, r8 - movs r1, 0x42 - movs r2, 0x68 - movs r3, 0x3 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - ldr r0, =gUnknown_0862A900 - movs r1, 0x55 - movs r2, 0x65 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x2] - ldr r0, =gUnknown_0862A92C - movs r1, 0x77 - movs r2, 0x72 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x4] - movs r0, 0 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x1 - bl StartSpriteAnim - adds r0, r5, 0 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D7664 - - thumb_func_start sub_81D7700 -sub_81D7700: @ 81D7700 - push {r4,lr} - adds r3, r0, 0 - movs r0, 0x2E - adds r0, r3 - mov r12, r0 - ldrh r0, [r0, 0xA] - adds r0, 0x1 - movs r1, 0xF - ands r0, r1 - mov r1, r12 - strh r0, [r1, 0xA] - movs r1, 0x7 - ands r1, r0 - cmp r1, 0 - bne _081D7768 - ldrh r1, [r3, 0x20] - movs r2, 0x20 - ldrsh r0, [r3, r2] - cmp r0, 0x48 - beq _081D7768 - subs r0, r1, 0x1 - strh r0, [r3, 0x20] - ldr r2, =gSprites - movs r4, 0x2E - ldrsh r1, [r3, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x1 - strh r1, [r0, 0x20] - mov r0, r12 - movs r4, 0x2 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x1 - strh r1, [r0, 0x20] - mov r0, r12 - movs r4, 0x4 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x1 - strh r1, [r0, 0x20] -_081D7768: - adds r0, r3, 0 - adds r0, 0x2B - ldrb r3, [r0] - cmp r3, 0x1 - beq _081D77C8 - cmp r3, 0x1 - bgt _081D7780 - cmp r3, 0 - beq _081D778A - b _081D784C - .pool -_081D7780: - cmp r3, 0x2 - beq _081D7808 - cmp r3, 0x3 - beq _081D77C8 - b _081D784C -_081D778A: - ldr r2, =gSprites - mov r0, r12 - movs r4, 0x2 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x24] - mov r0, r12 - movs r4, 0x2 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x26] - mov r0, r12 - movs r4, 0x4 - ldrsh r1, [r0, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x24] - mov r0, r12 - movs r4, 0x4 - ldrsh r1, [r0, r4] - b _081D7842 - .pool -_081D77C8: - ldr r2, =gSprites - mov r0, r12 - movs r3, 0x2 - ldrsh r1, [r0, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x0000ffff - strh r1, [r0, 0x24] - mov r4, r12 - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r3, 0 - strh r3, [r0, 0x26] - movs r0, 0x4 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x1 - negs r1, r1 - b _081D783C - .pool -_081D7808: - ldr r2, =gSprites - mov r3, r12 - movs r4, 0x2 - ldrsh r1, [r3, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x0000ffff - strh r1, [r0, 0x24] - movs r0, 0x2 - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r3, 0x1 - strh r3, [r0, 0x26] - mov r4, r12 - movs r0, 0x4 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x0000fffe -_081D783C: - strh r1, [r0, 0x24] - movs r0, 0x4 - ldrsh r1, [r4, r0] -_081D7842: - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x26] -_081D784C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7700 - - thumb_func_start sub_81D7860 -sub_81D7860: @ 81D7860 - push {r4,lr} - adds r1, r0, 0 - adds r3, r1, 0 - adds r3, 0x2E - ldrh r2, [r1, 0x22] - movs r4, 0x22 - ldrsh r0, [r1, r4] - cmp r0, 0xA0 - bgt _081D78B0 - adds r0, r2, 0 - adds r0, 0x8 - strh r0, [r1, 0x22] - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r1, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - movs r4, 0x2 - ldrsh r1, [r3, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - movs r0, 0x4 - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] -_081D78B0: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7860 - - thumb_func_start sub_81D78BC -sub_81D78BC: @ 81D78BC - push {r4-r6,lr} - mov r6, r8 - push {r6} - ldr r5, =gUnknown_0862A9E4 - adds r0, r5, 0 - movs r1, 0x7E - movs r2, 0x60 - movs r3, 0x1 - bl CreateSprite - mov r8, r0 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r6, =gSprites - lsls r4, r0, 4 - add r4, r8 - lsls r4, 2 - adds r0, r6, 0 - adds r0, 0x1C - adds r0, r4, r0 - ldr r1, =sub_81D7A60 - str r1, [r0] - adds r0, r6, 0 - adds r0, 0x2E - adds r4, r0 - adds r0, r5, 0 - movs r1, 0x9E - movs r2, 0x60 - movs r3, 0x1 - bl CreateSprite - lsls r0, 8 - strh r0, [r4] - adds r0, r5, 0 - movs r1, 0x7E - movs r2, 0x70 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4] - orrs r0, r1 - strh r0, [r4] - adds r0, r5, 0 - movs r1, 0x9E - movs r2, 0x70 - movs r3, 0x1 - bl CreateSprite - lsls r0, 8 - strh r0, [r4, 0x2] - adds r0, r5, 0 - movs r1, 0x7E - movs r2, 0x80 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x2] - orrs r0, r1 - strh r0, [r4, 0x2] - adds r0, r5, 0 - movs r1, 0x9E - movs r2, 0x80 - movs r3, 0x1 - bl CreateSprite - lsls r0, 8 - strh r0, [r4, 0x4] - adds r0, r5, 0 - movs r1, 0x5E - movs r2, 0x80 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x4] - orrs r0, r1 - strh r0, [r4, 0x4] - adds r0, r5, 0 - movs r1, 0x7E - movs r2, 0x80 - movs r3, 0x2 - bl CreateSprite - lsls r0, 8 - strh r0, [r4, 0x6] - adds r0, r5, 0 - movs r1, 0xAE - movs r2, 0x80 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x6] - orrs r0, r1 - strh r0, [r4, 0x6] - ldr r0, =gUnknown_0862AA1C - movs r1, 0xC6 - movs r2, 0x84 - movs r3, 0 - bl CreateSprite - lsls r0, 8 - strh r0, [r4, 0x8] - ldr r0, =gUnknown_0862AA3C - movs r1, 0xBE - movs r2, 0x78 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x8] - orrs r0, r1 - strh r0, [r4, 0x8] - ldrh r1, [r4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x1 - bl StartSpriteAnim - ldrb r1, [r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x2 - bl StartSpriteAnim - ldrh r1, [r4, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x3 - bl StartSpriteAnim - ldrb r1, [r4, 0x2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x4 - bl StartSpriteAnim - ldrh r1, [r4, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x5 - bl StartSpriteAnim - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x6 - bl StartSpriteAnim - ldrh r1, [r4, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x7 - bl StartSpriteAnim - ldrb r1, [r4, 0x6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x8 - bl StartSpriteAnim - mov r0, r8 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D78BC - - thumb_func_start sub_81D7A60 -sub_81D7A60: @ 81D7A60 - push {r4-r7,lr} - adds r4, r0, 0 - adds r3, r4, 0 - adds r3, 0x2E - ldrh r0, [r3, 0xA] - adds r0, 0x1 - movs r1, 0xF - ands r0, r1 - strh r0, [r3, 0xA] - movs r1, 0x7 - ands r1, r0 - ldr r7, =gSprites - cmp r1, 0 - bne _081D7B52 - ldrh r1, [r4, 0x20] - movs r2, 0x20 - ldrsh r0, [r4, r2] - cmp r0, 0x98 - beq _081D7B52 - adds r0, r1, 0x1 - strh r0, [r4, 0x20] - ldrh r1, [r4, 0x2E] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r4, 0x2E] - movs r2, 0xFF - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r3, 0x2] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r1, [r3, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r3, 0x4] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r1, [r3, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r3, 0x6] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r1, [r3, 0x8] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] - ldrh r0, [r3, 0x8] - ands r2, r0 - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, 0x1 - strh r1, [r0, 0x20] -_081D7B52: - adds r6, r7, 0 - movs r5, 0xFF - ldrb r1, [r3, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x2B - ldrb r2, [r0] - cmp r2, 0x1 - beq _081D7C24 - cmp r2, 0x1 - bgt _081D7B78 - cmp r2, 0 - beq _081D7B84 - b _081D7D0C - .pool -_081D7B78: - cmp r2, 0x2 - bne _081D7B7E - b _081D7CAC -_081D7B7E: - cmp r2, 0x3 - beq _081D7C24 - b _081D7D0C -_081D7B84: - strh r2, [r4, 0x26] - ldrh r1, [r3] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r0, [r3] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x2] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x4] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x6] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x8] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x8] - ands r1, r5 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - b _081D7D0A -_081D7C24: - movs r2, 0x1 - strh r2, [r4, 0x26] - ldrh r1, [r3] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3, 0x2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3, 0x6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x8] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrb r1, [r3, 0x8] - b _081D7D02 -_081D7CAC: - strh r2, [r4, 0x26] - ldrh r1, [r3] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r0, [r3] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x2] - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x26] - ldrh r1, [r3, 0x8] - ands r1, r5 -_081D7D02: - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 -_081D7D0A: - strh r2, [r0, 0x26] -_081D7D0C: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D7A60 - - thumb_func_start sub_81D7D14 -sub_81D7D14: @ 81D7D14 - push {lr} - adds r2, r0, 0 - movs r0, 0x2E - adds r0, r2 - mov r12, r0 - ldrh r1, [r2, 0x22] - movs r3, 0x22 - ldrsh r0, [r2, r3] - cmp r0, 0xA0 - bgt _081D7E08 - adds r0, r1, 0 - adds r0, 0x8 - strh r0, [r2, 0x22] - ldr r3, =gSprites - ldrh r1, [r2, 0x2E] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - ldrh r0, [r2, 0x2E] - movs r2, 0xFF - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - mov r0, r12 - ldrh r1, [r0, 0x2] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - mov r1, r12 - ldrh r0, [r1, 0x2] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - mov r0, r12 - ldrh r1, [r0, 0x4] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - mov r1, r12 - ldrh r0, [r1, 0x4] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - mov r0, r12 - ldrh r1, [r0, 0x6] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - mov r1, r12 - ldrh r0, [r1, 0x6] - adds r1, r2, 0 - ands r1, r0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - mov r0, r12 - ldrh r1, [r0, 0x8] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] - mov r1, r12 - ldrh r0, [r1, 0x8] - ands r2, r0 - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x22] - adds r1, 0x8 - strh r1, [r0, 0x22] -_081D7E08: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7D14 - - thumb_func_start sub_81D7E10 -sub_81D7E10: @ 81D7E10 - push {r4,lr} - bl ResetVramOamAndBgCntRegs - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0862AA54 - movs r0, 0x1 - movs r2, 0x3 - bl InitBgsFromTemplates - ldr r4, =sRayScene - ldr r1, [r4] - adds r1, 0x4 - movs r0, 0 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00000804 - adds r1, r0 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00001004 - adds r1, r0 - movs r0, 0x2 - bl SetBgTilemapBuffer - bl ResetAllBgsCoordinates - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7E10 - - thumb_func_start sub_81D7E9C -sub_81D7E9C: @ 81D7E9C - push {r4,lr} - sub sp, 0x4 - bl reset_temp_tile_data_buffers - ldr r1, =gRaySceneClouds_Gfx - movs r4, 0 - str r4, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gRaySceneOvercast_Gfx - str r4, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gRaySceneRayquaza_Gfx - str r4, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram -_081D7ED0: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081D7ED0 - ldr r0, =gRaySceneClouds2_Tilemap - ldr r4, =sRayScene - ldr r1, [r4] - adds r1, 0x4 - bl LZDecompressWram - ldr r0, =gRaySceneOvercast_Tilemap - ldr r1, [r4] - ldr r2, =0x00000804 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneRayquaza_Tilemap - ldr r1, [r4] - ldr r2, =0x00001004 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneRayquaza_Pal - movs r1, 0 - movs r2, 0x40 - bl LoadCompressedPalette - ldr r0, =gUnknown_0862AA90 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AA98 - bl LoadCompressedObjectPalette - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7E9C - - thumb_func_start sub_81D7F4C -sub_81D7F4C: @ 81D7F4C - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r5, =gTasks + 0x8 - adds r6, r4, r5 - movs r0, 0xE8 - lsls r0, 1 - bl PlayNewMapMusic - bl sub_81D7E10 - bl sub_81D7E9C - movs r1, 0x94 - lsls r1, 2 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x00000808 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - ldr r0, =sub_81D67EC - bl SetVBlankCallback - ldr r0, =sub_81D81A4 - movs r1, 0 - bl CreateTask - movs r0, 0 - strh r0, [r6] - strh r0, [r6, 0x2] - subs r5, 0x8 - adds r4, r5 - ldr r0, =sub_81D7FC0 - str r0, [r4] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D7F4C - - thumb_func_start sub_81D7FC0 -sub_81D7FC0: @ 81D7FC0 - push {r4-r6,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - movs r0, 0 - ldrsh r5, [r4, r0] - cmp r5, 0x1 - beq _081D802A - cmp r5, 0x1 - bgt _081D7FE8 - cmp r5, 0 - beq _081D7FF4 - b _081D815A - .pool -_081D7FE8: - cmp r5, 0x2 - beq _081D80A4 - cmp r5, 0x3 - bne _081D7FF2 - b _081D8124 -_081D7FF2: - b _081D815A -_081D7FF4: - ldrh r1, [r4, 0x2] - movs r2, 0x2 - ldrsh r0, [r4, r2] - cmp r0, 0x8 - bne _081D8024 - movs r0, 0x1 - negs r0, r0 - str r5, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - strh r5, [r4, 0x4] - movs r0, 0x1E - strh r0, [r4, 0x6] - strh r5, [r4, 0x8] - movs r0, 0x7 - strh r0, [r4, 0xA] - strh r5, [r4, 0x2] - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _081D815A -_081D8024: - adds r0, r1, 0x1 - strh r0, [r4, 0x2] - b _081D815A -_081D802A: - ldrh r1, [r4, 0x6] - ldrh r3, [r4, 0x4] - adds r0, r1, r3 - strh r0, [r4, 0x4] - ldrh r2, [r4, 0xA] - ldrh r3, [r4, 0x8] - adds r0, r2, r3 - strh r0, [r4, 0x8] - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0x3 - ble _081D8046 - subs r0, r1, 0x3 - strh r0, [r4, 0x6] -_081D8046: - lsls r0, r2, 16 - cmp r0, 0 - beq _081D8050 - subs r0, r2, 0x1 - strh r0, [r4, 0xA] -_081D8050: - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, 0xFF - ble _081D8078 - movs r2, 0x80 - lsls r2, 1 - adds r0, r2, 0 - strh r0, [r4, 0x4] - movs r1, 0 - strh r1, [r4, 0x6] - movs r0, 0xC - strh r0, [r4, 0xC] - movs r3, 0x1 - negs r3, r3 - adds r0, r3, 0 - strh r0, [r4, 0xE] - strh r1, [r4, 0x2] - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] -_081D8078: - movs r1, 0xF0 - lsls r1, 7 - movs r2, 0xC0 - lsls r2, 5 - ldrh r0, [r4, 0x8] - adds r0, 0x20 - lsls r0, 16 - asrs r0, 16 - str r0, [sp] - movs r3, 0x4 - ldrsh r0, [r4, r3] - str r0, [sp, 0x4] - movs r3, 0x4 - ldrsh r0, [r4, r3] - str r0, [sp, 0x8] - movs r0, 0 - str r0, [sp, 0xC] - movs r0, 0x2 - movs r3, 0x78 - bl SetBgAffine - b _081D815A -_081D80A4: - ldrh r0, [r4, 0x2] - adds r0, 0x1 - strh r0, [r4, 0x2] - movs r1, 0xF0 - lsls r1, 7 - movs r2, 0xC0 - lsls r2, 5 - ldrh r0, [r4, 0xC] - lsls r0, 16 - asrs r0, 18 - adds r0, 0x20 - ldrh r3, [r4, 0x8] - adds r0, r3 - lsls r0, 16 - asrs r0, 16 - str r0, [sp] - movs r3, 0x4 - ldrsh r0, [r4, r3] - str r0, [sp, 0x4] - movs r3, 0x4 - ldrsh r0, [r4, r3] - str r0, [sp, 0x8] - movs r5, 0 - str r5, [sp, 0xC] - movs r0, 0x2 - movs r3, 0x78 - bl SetBgAffine - ldrh r0, [r4, 0xE] - ldrh r1, [r4, 0xC] - adds r0, r1 - strh r0, [r4, 0xC] - lsls r0, 16 - asrs r1, r0, 16 - cmp r1, 0xC - beq _081D80F4 - movs r0, 0xC - negs r0, r0 - cmp r1, r0 - bne _081D815A -_081D80F4: - movs r2, 0xE - ldrsh r0, [r4, r2] - negs r0, r0 - strh r0, [r4, 0xE] - movs r3, 0x2 - ldrsh r1, [r4, r3] - ldr r0, =0x00000127 - cmp r1, r0 - ble _081D815A - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - movs r0, 0x1 - negs r0, r0 - str r5, [sp] - movs r1, 0x6 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _081D815A - .pool -_081D8124: - ldrh r0, [r4, 0x4] - adds r0, 0x10 - strh r0, [r4, 0x4] - movs r1, 0xF0 - lsls r1, 7 - movs r2, 0xC0 - lsls r2, 5 - ldrh r0, [r4, 0x8] - adds r0, 0x20 - lsls r0, 16 - asrs r0, 16 - str r0, [sp] - movs r3, 0x4 - ldrsh r0, [r4, r3] - str r0, [sp, 0x4] - movs r3, 0x4 - ldrsh r0, [r4, r3] - str r0, [sp, 0x8] - movs r0, 0 - str r0, [sp, 0xC] - movs r0, 0x2 - movs r3, 0x78 - bl SetBgAffine - adds r0, r6, 0 - bl sub_81D8164 -_081D815A: - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81D7FC0 - - thumb_func_start sub_81D8164 -sub_81D8164: @ 81D8164 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081D8192 - movs r0, 0 - bl SetVBlankCallback - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =Task_SetNextAnim - str r0, [r1] -_081D8192: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8164 - - thumb_func_start sub_81D81A4 -sub_81D81A4: @ 81D81A4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldrh r1, [r4, 0x2] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _081D8254 - ldr r0, =gUnknown_0862AAA0 - ldr r3, =gUnknown_0862AAB8 - movs r1, 0 - ldrsh r2, [r4, r1] - lsls r2, 1 - adds r1, r2, r3 - ldrb r1, [r1] - lsls r1, 24 - asrs r1, 24 - lsls r1, 18 - movs r6, 0xF0 - lsls r6, 15 - adds r1, r6 - asrs r1, 16 - adds r3, 0x1 - adds r2, r3 - ldrb r2, [r2] - lsls r2, 24 - asrs r2, 24 - lsls r2, 18 - movs r3, 0xA0 - lsls r3, 15 - adds r2, r3 - asrs r2, 16 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gSprites - lsls r3, r0, 4 - adds r3, r0 - lsls r3, 2 - adds r3, r1 - movs r0, 0 - ldrsb r0, [r4, r0] - strh r0, [r3, 0x2E] - ldrb r2, [r3, 0x1] - movs r1, 0xD - negs r1, r1 - adds r0, r1, 0 - ands r0, r2 - movs r2, 0x4 - orrs r0, r2 - movs r2, 0x3 - orrs r0, r2 - strb r0, [r3, 0x1] - ldrb r0, [r3, 0x5] - ands r1, r0 - movs r0, 0x8 - orrs r1, r0 - strb r1, [r3, 0x5] - adds r0, r3, 0 - bl InitSpriteAffineAnim - ldrh r1, [r4] - movs r6, 0 - ldrsh r0, [r4, r6] - cmp r0, 0x9 - bne _081D8250 - adds r0, r5, 0 - bl DestroyTask - b _081D825A - .pool -_081D8250: - adds r0, r1, 0x1 - strh r0, [r4] -_081D8254: - ldrh r0, [r4, 0x2] - adds r0, 0x1 - strh r0, [r4, 0x2] -_081D825A: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81D81A4 - - thumb_func_start sub_81D8260 -sub_81D8260: @ 81D8260 - push {lr} - adds r2, r0, 0 - movs r1, 0x30 - ldrsh r0, [r2, r1] - cmp r0, 0 - bne _081D8270 - strh r0, [r2, 0x24] - b _081D829A -_081D8270: - ldr r1, =gUnknown_0862AAB8 - movs r3, 0x2E - ldrsh r0, [r2, r3] - lsls r0, 1 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - ldrh r3, [r2, 0x24] - adds r0, r3 - strh r0, [r2, 0x24] - movs r3, 0x2E - ldrsh r0, [r2, r3] - lsls r0, 1 - adds r1, 0x1 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - ldrh r1, [r2, 0x26] - adds r0, r1 -_081D829A: - strh r0, [r2, 0x26] - ldrh r0, [r2, 0x30] - adds r0, 0x1 - movs r1, 0xF - ands r0, r1 - strh r0, [r2, 0x30] - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8260 - - thumb_func_start sub_81D82B0 -sub_81D82B0: @ 81D82B0 - push {r4,lr} - bl ResetVramOamAndBgCntRegs - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0862AACC - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - ldr r4, =sRayScene - ldr r1, [r4] - adds r1, 0x4 - movs r0, 0 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00000804 - adds r1, r0 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00001004 - adds r1, r0 - movs r0, 0x2 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00001804 - adds r1, r0 - movs r0, 0x3 - bl SetBgTilemapBuffer - bl ResetAllBgsCoordinates - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x3 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D82B0 - - thumb_func_start sub_81D8358 -sub_81D8358: @ 81D8358 - push {r4-r7,lr} - sub sp, 0xC - bl reset_temp_tile_data_buffers - ldr r1, =gRaySceneRayquazaLight_Gfx - movs r4, 0 - str r4, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gRaySceneOvercast2_Gfx - str r4, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - add r7, sp, 0x8 -_081D8380: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - bne _081D8380 - ldr r0, =gRaySceneRayquazaLight_Tilemap - ldr r5, =sRayScene - ldr r1, [r5] - adds r1, 0x4 - bl LZDecompressWram - ldr r0, =gRaySceneOvercast2_Tilemap - ldr r1, [r5] - ldr r4, =0x00001804 - adds r1, r4 - bl LZDecompressWram - str r6, [sp, 0x4] - ldr r1, [r5] - ldr r0, =0x00001004 - adds r1, r0 - ldr r2, =0x01000200 - add r0, sp, 0x4 - bl CpuFastSet - ldr r1, [r5] - adds r4, r1, r4 - ldr r0, =0x00000804 - adds r1, r0 - movs r2, 0x80 - lsls r2, 2 - adds r0, r4, 0 - bl CpuFastSet - str r6, [sp, 0x8] - ldr r1, [r5] - ldr r0, =0x00000904 - adds r1, r0 - ldr r2, =0x010000d0 - adds r0, r7, 0 - bl CpuFastSet - ldr r0, =gRaySceneOvercast2_Pal - movs r1, 0 - movs r2, 0x40 - bl LoadCompressedPalette - ldr r0, =gPlttBufferUnfaded - ldr r1, =0x00007fff - strh r1, [r0] - ldr r0, =gPlttBufferFaded - strh r1, [r0] - ldr r0, =gUnknown_0862AAFC - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AB04 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AB0C - bl LoadCompressedObjectPalette - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8358 - - thumb_func_start sub_81D844C -sub_81D844C: @ 81D844C - push {r4,r5,lr} - movs r0, 0x6 - bl GetGpuReg - lsls r0, 16 - lsrs r2, r0, 16 - adds r1, r2, 0 - subs r1, 0x18 - lsls r0, r1, 16 - lsrs r0, 16 - cmp r0, 0x6F - bhi _081D848C - ldr r0, =sRayScene - ldr r0, [r0] - ldr r3, =0x00002008 - adds r0, r3 - movs r3, 0 - ldrsh r0, [r0, r3] - cmp r1, r0 - bgt _081D848C - ldr r1, =0x04000052 - ldr r3, =0x00000d08 - b _081D8492 - .pool -_081D848C: - ldr r1, =0x04000052 - movs r3, 0x80 - lsls r3, 5 -_081D8492: - adds r0, r3, 0 - strh r0, [r1] - cmp r2, 0 - bne _081D84E0 - ldr r0, =sRayScene - ldr r1, [r0] - ldr r2, =0x00002008 - adds r3, r1, r2 - ldrh r4, [r3] - movs r1, 0 - ldrsh r2, [r3, r1] - ldr r1, =0x00001fff - adds r5, r0, 0 - cmp r2, r1 - bgt _081D84D4 - cmp r2, 0x27 - bgt _081D84C8 - adds r0, r4, 0x4 - b _081D84D2 - .pool -_081D84C8: - cmp r2, 0x4F - bgt _081D84D0 - adds r0, r4, 0x2 - b _081D84D2 -_081D84D0: - adds r0, r4, 0x1 -_081D84D2: - strh r0, [r3] -_081D84D4: - ldr r1, [r5] - ldr r2, =0x0000200a - adds r1, r2 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] -_081D84E0: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D844C - - thumb_func_start sub_81D84EC -sub_81D84EC: @ 81D84EC - push {r4-r6,lr} - mov r6, r8 - push {r6} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r6, =gTasks + 0x8 - adds r5, r4, r6 - bl sub_81D82B0 - bl sub_81D8358 - ldr r1, =0x00001e41 - movs r0, 0x50 - bl SetGpuRegBits - movs r0, 0x80 - lsls r0, 5 - mov r8, r0 - movs r0, 0x52 - mov r1, r8 - bl SetGpuReg - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - ldr r0, =sub_81D67EC - bl SetVBlankCallback - ldr r0, =sRayScene - ldr r0, [r0] - ldr r1, =0x00002008 - adds r2, r0, r1 - movs r1, 0 - strh r1, [r2] - ldr r2, =0x0000200a - adds r0, r2 - strh r1, [r0] - strh r1, [r5] - strh r1, [r5, 0x2] - strh r1, [r5, 0x4] - strh r1, [r5, 0x6] - mov r0, r8 - strh r0, [r5, 0x8] - subs r6, 0x8 - adds r4, r6 - ldr r0, =sub_81D857C - str r0, [r4] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D84EC - - thumb_func_start sub_81D857C -sub_81D857C: @ 81D857C - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0x4 - bhi _081D8674 - lsls r0, 2 - ldr r1, =_081D85A8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081D85A8: - .4byte _081D85BC - .4byte _081D85DC - .4byte _081D861A - .4byte _081D863A - .4byte _081D8656 -_081D85BC: - ldrh r1, [r5, 0x2] - movs r2, 0x2 - ldrsh r0, [r5, r2] - cmp r0, 0x8 - bne _081D8634 - movs r0, 0x1 - negs r0, r0 - movs r4, 0 - str r4, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - strh r4, [r5, 0x2] - b _081D864E -_081D85DC: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _081D8674 - ldrh r2, [r5, 0x2] - movs r3, 0x2 - ldrsh r0, [r5, r3] - cmp r0, 0xA - bne _081D8614 - strh r1, [r5, 0x2] - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] - ldr r0, =sub_81D844C - bl SetHBlankCallback - movs r0, 0x3 - bl EnableInterrupts - b _081D8674 - .pool -_081D8614: - adds r0, r2, 0x1 - strh r0, [r5, 0x2] - b _081D8674 -_081D861A: - ldrh r1, [r5, 0x2] - movs r2, 0x2 - ldrsh r0, [r5, r2] - cmp r0, 0x50 - bne _081D8634 - movs r0, 0 - strh r0, [r5, 0x2] - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] - bl sub_81D86CC - b _081D8674 -_081D8634: - adds r0, r1, 0x1 - strh r0, [r5, 0x2] - b _081D8674 -_081D863A: - ldrh r0, [r5, 0x2] - adds r0, 0x1 - strh r0, [r5, 0x2] - lsls r0, 16 - movs r1, 0xB8 - lsls r1, 17 - cmp r0, r1 - bne _081D8674 - movs r0, 0 - strh r0, [r5, 0x2] -_081D864E: - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] - b _081D8674 -_081D8656: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81D8684 - str r1, [r0] -_081D8674: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D857C - - thumb_func_start sub_81D8684 -sub_81D8684: @ 81D8684 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081D86B8 - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - bl SetHBlankCallback - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =Task_SetNextAnim - str r0, [r1] -_081D86B8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8684 - - thumb_func_start sub_81D86CC -sub_81D86CC: @ 81D86CC - push {r4-r6,lr} - mov r6, r8 - push {r6} - ldr r0, =gUnknown_0862AB14 - movs r1, 0xA0 - movs r2, 0 - movs r3, 0 - bl CreateSprite - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r5, r6, 4 - adds r5, r6 - lsls r5, 2 - ldr r4, =gSprites + 0x2E - adds r0, r5, r4 - mov r8, r0 - ldr r0, =gUnknown_0862AB2C - movs r2, 0x30 - negs r2, r2 - movs r1, 0xB8 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - strh r0, [r1] - adds r3, r4, 0 - subs r3, 0x2E - subs r4, 0x12 - adds r4, r5, r4 - ldr r0, =sub_81D874C - str r0, [r4] - adds r5, r3 - ldrb r0, [r5, 0x5] - movs r2, 0xC - orrs r0, r2 - strb r0, [r5, 0x5] - movs r4, 0 - ldrsh r1, [r1, r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrb r1, [r0, 0x5] - orrs r1, r2 - strb r1, [r0, 0x5] - adds r0, r6, 0 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D86CC - - thumb_func_start sub_81D874C -sub_81D874C: @ 81D874C - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r5, 0 - adds r4, 0x2E - movs r0, 0x4 - ldrsh r1, [r4, r0] - cmp r1, 0 - bne _081D8764 - movs r0, 0xC - strh r0, [r4, 0x6] - movs r0, 0x8 - b _081D87C2 -_081D8764: - movs r0, 0x80 - lsls r0, 1 - cmp r1, r0 - bne _081D8774 - movs r0, 0x9 - strh r0, [r4, 0x6] - movs r0, 0x7 - b _081D87C2 -_081D8774: - movs r0, 0x86 - lsls r0, 1 - cmp r1, r0 - bne _081D8784 - movs r0, 0x8 - strh r0, [r4, 0x6] - movs r0, 0x6 - b _081D87C2 -_081D8784: - movs r0, 0x8C - lsls r0, 1 - cmp r1, r0 - bne _081D8794 - movs r0, 0x7 - strh r0, [r4, 0x6] - movs r0, 0x5 - b _081D87C2 -_081D8794: - movs r0, 0x92 - lsls r0, 1 - cmp r1, r0 - bne _081D87A4 - movs r0, 0x6 - strh r0, [r4, 0x6] - movs r0, 0x4 - b _081D87C2 -_081D87A4: - movs r0, 0x98 - lsls r0, 1 - cmp r1, r0 - bne _081D87B4 - movs r0, 0x5 - strh r0, [r4, 0x6] - movs r0, 0x3 - b _081D87C2 -_081D87B4: - movs r0, 0xA0 - lsls r0, 1 - cmp r1, r0 - bne _081D87C4 - movs r0, 0x4 - strh r0, [r4, 0x6] - movs r0, 0x2 -_081D87C2: - strh r0, [r4, 0x8] -_081D87C4: - movs r1, 0x4 - ldrsh r0, [r4, r1] - movs r2, 0x6 - ldrsh r1, [r4, r2] - bl __modsi3 - cmp r0, 0 - bne _081D87EE - ldrh r0, [r5, 0x24] - subs r0, 0x1 - strh r0, [r5, 0x24] - ldr r2, =gSprites - movs r0, 0 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x24] - subs r1, 0x1 - strh r1, [r0, 0x24] -_081D87EE: - movs r1, 0x4 - ldrsh r0, [r4, r1] - movs r2, 0x8 - ldrsh r1, [r4, r2] - bl __modsi3 - cmp r0, 0 - bne _081D8818 - ldrh r0, [r5, 0x26] - adds r0, 0x1 - strh r0, [r5, 0x26] - ldr r2, =gSprites - movs r0, 0 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x26] - adds r1, 0x1 - strh r1, [r0, 0x26] -_081D8818: - ldrh r0, [r4, 0x4] - adds r0, 0x1 - strh r0, [r4, 0x4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D874C - - thumb_func_start sub_81D8828 -sub_81D8828: @ 81D8828 - push {r4,lr} - bl ResetVramOamAndBgCntRegs - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0862AB44 - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - ldr r4, =sRayScene - ldr r1, [r4] - adds r1, 0x4 - movs r0, 0 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00000804 - adds r1, r0 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00001004 - adds r1, r0 - movs r0, 0x2 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00001804 - adds r1, r0 - movs r0, 0x3 - bl SetBgTilemapBuffer - bl ResetAllBgsCoordinates - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x3 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0xC1 - lsls r1, 6 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8828 - - thumb_func_start sub_81D88D0 -sub_81D88D0: @ 81D88D0 - push {r4,lr} - sub sp, 0x4 - bl reset_temp_tile_data_buffers - ldr r1, =gRaySceneRayquazaChase_Gfx - movs r4, 0 - str r4, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gRaySceneChaseStreaks_Gfx - str r4, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gRaySceneChaseBg_Gfx - str r4, [sp] - movs r0, 0x3 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram -_081D8904: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081D8904 - ldr r0, =gRayChaseRayquazaChase2_Tilemap - ldr r4, =sRayScene - ldr r1, [r4] - adds r1, 0x4 - bl LZDecompressWram - ldr r0, =gRayChaseRayquazaChase_Tilemap - ldr r1, [r4] - ldr r2, =0x00000804 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneChaseStreaks_Tilemap - ldr r1, [r4] - ldr r2, =0x00001004 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneChaseBg_Tilemap - ldr r1, [r4] - ldr r2, =0x00001804 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneChase_Pal - movs r1, 0 - movs r2, 0x80 - bl LoadCompressedPalette - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D88D0 - - thumb_func_start sub_81D8980 -sub_81D8980: @ 81D8980 - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r5, =gTasks + 0x8 - adds r6, r4, r5 - bl sub_81D8828 - bl sub_81D88D0 - bl sub_81D68C8 - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - ldr r0, =sub_81D67EC - bl SetVBlankCallback - movs r0, 0 - strh r0, [r6] - strh r0, [r6, 0x2] - ldr r0, =sub_81D8AD8 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x4] - subs r5, 0x8 - adds r4, r5 - ldr r0, =sub_81D89E0 - str r0, [r4] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8980 - - thumb_func_start sub_81D89E0 -sub_81D89E0: @ 81D89E0 - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - bl sub_81D8BB4 - ldrh r1, [r4, 0x6] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _081D8A16 - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bgt _081D8A16 - movs r2, 0x2 - ldrsh r0, [r4, r2] - cmp r0, 0x59 - bgt _081D8A16 - movs r0, 0x67 - bl PlaySE -_081D8A16: - ldrh r0, [r4, 0x6] - adds r0, 0x1 - strh r0, [r4, 0x6] - movs r0, 0 - ldrsh r5, [r4, r0] - cmp r5, 0x1 - beq _081D8A5C - cmp r5, 0x1 - bgt _081D8A34 - cmp r5, 0 - beq _081D8A3E - b _081D8AC6 - .pool -_081D8A34: - cmp r5, 0x2 - beq _081D8A8C - cmp r5, 0x3 - beq _081D8AA8 - b _081D8AC6 -_081D8A3E: - ldrh r1, [r4, 0x2] - movs r2, 0x2 - ldrsh r0, [r4, r2] - cmp r0, 0x8 - bne _081D8AA2 - movs r0, 0x1 - negs r0, r0 - str r5, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - strh r5, [r4, 0x2] - b _081D8A9A -_081D8A5C: - ldrh r1, [r4, 0x2] - movs r2, 0x2 - ldrsh r0, [r4, r2] - cmp r0, 0x7F - bne _081D8AA2 - movs r0, 0 - strh r0, [r4, 0x2] - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - ldr r2, =gTasks - movs r0, 0x4 - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldr r1, =sub_81D8B2C - b _081D8AC4 - .pool -_081D8A8C: - ldrh r1, [r4, 0x2] - movs r2, 0x2 - ldrsh r0, [r4, r2] - cmp r0, 0xC - bne _081D8AA2 - movs r0, 0 - strh r0, [r4, 0x2] -_081D8A9A: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _081D8AC6 -_081D8AA2: - adds r0, r1, 0x1 - strh r0, [r4, 0x2] - b _081D8AC6 -_081D8AA8: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81D8BEC -_081D8AC4: - str r1, [r0] -_081D8AC6: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D89E0 - - thumb_func_start sub_81D8AD8 -sub_81D8AD8: @ 81D8AD8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r5, r1, r0 - ldrh r1, [r5, 0x1E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _081D8B1C - bl Random - movs r4, 0x7 - adds r1, r4, 0 - ands r1, r0 - subs r1, 0x4 - lsls r1, 8 - movs r0, 0x1 - movs r2, 0 - bl ChangeBgX - bl Random - ands r4, r0 - subs r4, 0x4 - lsls r4, 8 - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0 - bl ChangeBgY -_081D8B1C: - ldrh r0, [r5, 0x1E] - adds r0, 0x1 - strh r0, [r5, 0x1E] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8AD8 - - thumb_func_start sub_81D8B2C -sub_81D8B2C: @ 81D8B2C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r4, r1, r0 - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081D8B70 - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - movs r0, 0xA - strh r0, [r4, 0x2] - movs r1, 0x1 - negs r1, r1 - adds r0, r1, 0 - b _081D8BAA - .pool -_081D8B70: - cmp r0, 0x1 - bne _081D8BAC - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r1, 8 - movs r0, 0x1 - movs r2, 0x2 - bl ChangeBgX - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r1, 8 - movs r0, 0x1 - movs r2, 0x1 - bl ChangeBgY - ldrh r0, [r4, 0x4] - ldrh r1, [r4, 0x2] - adds r0, r1 - strh r0, [r4, 0x2] - lsls r0, 16 - asrs r0, 16 - movs r1, 0xA - negs r1, r1 - cmp r0, r1 - bne _081D8BAC - movs r1, 0x4 - ldrsh r0, [r4, r1] - negs r0, r0 -_081D8BAA: - strh r0, [r4, 0x4] -_081D8BAC: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81D8B2C - - thumb_func_start sub_81D8BB4 -sub_81D8BB4: @ 81D8BB4 - push {r4,lr} - movs r4, 0x80 - lsls r4, 3 - movs r0, 0x2 - adds r1, r4, 0 - movs r2, 0x2 - bl ChangeBgX - movs r0, 0x2 - adds r1, r4, 0 - movs r2, 0x1 - bl ChangeBgY - movs r4, 0x80 - lsls r4, 4 - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x2 - bl ChangeBgX - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl ChangeBgY - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81D8BB4 - - thumb_func_start sub_81D8BEC -sub_81D8BEC: @ 81D8BEC - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r5, r1, 3 - ldr r6, =gTasks + 0x8 - adds r4, r5, r6 - bl sub_81D8BB4 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081D8C26 - movs r0, 0 - bl SetVBlankCallback - bl sub_81D6904 - ldrb r0, [r4, 0x4] - bl DestroyTask - adds r0, r6, 0 - subs r0, 0x8 - adds r0, r5, r0 - ldr r1, =Task_SetNextAnim - str r1, [r0] -_081D8C26: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8BEC thumb_func_start sub_81D8C38 sub_81D8C38: @ 81D8C38 diff --git a/include/graphics.h b/include/graphics.h index c089ec2545..37890fb966 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2673,6 +2673,10 @@ extern const u8 gRaySceneGroudonTail_Gfx[]; extern const u8 gRaySceneKyogreRight_Gfx[]; extern const u8 gRaySceneRayquazaHover_Gfx[]; extern const u8 gRaySceneRayquazaFlyIn_Gfx[]; +extern const u8 gRaySceneOvercast_Gfx[]; +extern const u8 gRaySceneOvercast_Tilemap[]; +extern const u8 gRaySceneRayquaza_Gfx[]; +extern const u8 gRaySceneRayquaza_Tilemap[]; extern const u8 gRaySceneSplash_Gfx[]; extern const u8 gRaySceneGroudonLeft_Pal[]; extern const u8 gRaySceneKyogreRight_Pal[]; @@ -2683,5 +2687,18 @@ extern const u8 gRaySceneClouds_Pal[]; extern const u8 gRaySceneClouds2_Tilemap[]; extern const u8 gRaySceneClouds1_Tilemap[]; extern const u8 gRaySceneClouds3_Tilemap[]; +extern const u8 gRaySceneRayquazaLight_Gfx[]; +extern const u8 gRaySceneRayquazaLight_Tilemap[]; +extern const u8 gRaySceneOvercast2_Gfx[]; +extern const u8 gRaySceneOvercast2_Tilemap[]; +extern const u8 gRaySceneOvercast2_Pal[]; +extern const u8 gRaySceneRayquazaChase_Gfx[]; +extern const u8 gRaySceneChaseStreaks_Gfx[]; +extern const u8 gRaySceneChaseBg_Gfx[]; +extern const u8 gRayChaseRayquazaChase2_Tilemap[]; +extern const u8 gRayChaseRayquazaChase_Tilemap[]; +extern const u8 gRaySceneChaseStreaks_Tilemap[]; +extern const u8 gRaySceneChaseBg_Tilemap[]; +extern const u8 gRaySceneChase_Pal[]; #endif //GUARD_GRAPHICS_H diff --git a/include/palette.h b/include/palette.h index cb03699a62..41cef40484 100644 --- a/include/palette.h +++ b/include/palette.h @@ -67,5 +67,6 @@ void BeginFastPaletteFade(u8); void BeginHardwarePaletteFade(u8, u8, u8, u8, u8); void BlendPalettes(u32, u8, u16); void BlendPalettesUnfaded(u32, u8, u16); +void sub_80A2C44(u32 a1, s8 a2, u8 a3, u8 a4, u16 a5, u8 a6, u8 a7); #endif // GUARD_PALETTE_H diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index 72aeab94ed..44c4d86f44 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -14,6 +14,8 @@ #include "decompress.h" #include "sound.h" #include "constants/songs.h" +#include "constants/rgb.h" +#include "random.h" // this file's functions void sub_81D7134(u8 taskId); @@ -21,6 +23,12 @@ void sub_81D7F4C(u8 taskId); void sub_81D84EC(u8 taskId); void sub_81D8980(u8 taskId); void sub_81D8DB4(u8 taskId); +void sub_81D857C(u8 taskId); +void sub_81D8684(u8 taskId); +void sub_81D89E0(u8 taskId); +void sub_81D8AD8(u8 taskId); +void sub_81D8B2C(u8 taskId); +void sub_81D8BEC(u8 taskId); void Task_EndAfterFadeScreen(u8 taskId); void sub_81D8260(struct Sprite *sprite); @@ -1174,11 +1182,12 @@ const struct BgTemplate gUnknown_0862AD08[] = struct RaySceneStruct { MainCallback callback; - u8 tilemapBuffers[3][0x800]; - u8 field_1804[0x800]; + u8 tilemapBuffers[4][0x800]; u16 field_2004; u8 animId; bool8 onlyOneAnim; + s16 field_2008; + s16 field_200A; }; extern struct RaySceneStruct *sRayScene; @@ -1190,13 +1199,25 @@ void sub_81D750C(void); void sub_81D7438(void); void sub_81D7480(void); void sub_81D74C8(void); +void sub_81D8BB4(void); void sub_81D75B4(u8 taskId, s8 palDelay); void sub_81D6A20(struct Sprite *sprite); void sub_81D6D20(struct Sprite *sprite); +void sub_81D7860(struct Sprite *sprite); +void sub_81D7D14(struct Sprite *sprite); +void sub_81D7700(struct Sprite *sprite); +void sub_81D7A60(struct Sprite *sprite); +void sub_81D874C(struct Sprite *sprite); void sub_81D7228(u8 taskId); void sub_81D736C(u8 taskId); +void sub_81D752C(u8 taskId); +void sub_81D7600(u8 taskId); +void sub_81D7FC0(u8 taskId); +void sub_81D81A4(u8 taskId); +void sub_81D8164(u8 taskId); u8 sub_81D7664(void); u8 sub_81D78BC(void); +u8 sub_81D86CC(void); // code void sub_81D6720(u8 animId, bool8 onlyOneAnim, MainCallback callback) @@ -1470,7 +1491,7 @@ void sub_81D6FE0(void) { ResetVramOamAndBgCntRegs(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0862A888, 3); + InitBgsFromTemplates(0, gUnknown_0862A888, ARRAY_COUNT(gUnknown_0862A888)); SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); @@ -1534,3 +1555,894 @@ void sub_81D7134(u8 taskId) SetVBlankCallback(sub_81D6FD0); PlaySE(SE_T_OOAME); } + +void sub_81D7228(u8 taskId) +{ + s16 i; + u16 *data = gTasks[taskId].data; + + for (i = 24; i < 92; i++) + { + if (i <= 47) + { + gScanlineEffectRegBuffers[0][i] = data[0] >> 8; + gScanlineEffectRegBuffers[1][i] = data[0] >> 8; + } + else if (i <= 63) + { + gScanlineEffectRegBuffers[0][i] = data[1] >> 8; + gScanlineEffectRegBuffers[1][i] = data[1] >> 8; + } + else if (i <= 75) + { + gScanlineEffectRegBuffers[0][i] = data[2] >> 8; + gScanlineEffectRegBuffers[1][i] = data[2] >> 8; + } + else if (i <= 83) + { + gScanlineEffectRegBuffers[0][i] = data[3] >> 8; + gScanlineEffectRegBuffers[1][i] = data[3] >> 8; + } + else if (i <= 87) + { + gScanlineEffectRegBuffers[0][i] = data[4] >> 8; + gScanlineEffectRegBuffers[1][i] = data[4] >> 8; + } + else + { + gScanlineEffectRegBuffers[0][i] = data[5] >> 8; + gScanlineEffectRegBuffers[1][i] = data[5] >> 8; + } + } + + if (sRayScene->animId == RAY_ANIM_DUO_FIGHT_PRE) + { + data[0] += 448; + data[1] += 384; + data[2] += 320; + data[3] += 256; + data[4] += 192; + data[5] += 128; + } + else + { + data[0] += 768; + data[1] += 640; + data[2] += 512; + data[3] += 384; + data[4] += 256; + data[5] += 128; + } +} + +void sub_81D736C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + sub_81D750C(); + if (!gPaletteFade.active) + { + s16 counter = data[0]; + if (counter == 32 || counter == 112) + { + sub_81D7438(); + } + else if (counter == 216) + { + sub_81D7480(); + } + else if (counter == 220) + { + sub_81D74C8(); + } + else + { + switch (counter) + { + case 412: + sub_81D75B4(taskId, 2); + return; + case 380: + SetGpuReg(REG_OFFSET_BLDCNT, 0x244); + gTasks[data[1]].func = sub_81D752C; + gTasks[data[1]].data[0] = 0; + gTasks[data[1]].data[2] = data[2]; + gTasks[data[1]].data[3] = data[3]; + ScanlineEffect_Stop(); + break; + } + } + + data[0]++; + } +} + +void sub_81D7438(void) +{ + PlaySE(SE_T_KAMI); + sub_80A2C44(0x7FFF, 0, 0x10, 0, -1, 0, 0); + sub_80A2C44(0xFFFF0000, 0, 0x10, 0, 0, 0, 1); +} + +void sub_81D7480(void) +{ + PlaySE(SE_T_KAMI); + sub_80A2C44(0x7FFF, 0, 0x10, 0x10, -1, 0, 0); + sub_80A2C44(0xFFFF0000, 0, 0x10, 0x10, 0, 0, 1); +} + +void sub_81D74C8(void) +{ + sub_80A2C44(0x7FFF, 4, 0x10, 0, -1, 0, 0); + sub_80A2C44(0xFFFF0000, 4, 0x10, 0, 0, 0, 1); +} + +void sub_81D750C(void) +{ + ChangeBgX(2, 0x400, 1); + ChangeBgY(2, 0x800, 2); +} + +void sub_81D752C(u8 taskId) +{ + u16 bgY; + s16 *data = gTasks[taskId].data; + sub_81D7860(&gSprites[data[2]]); + sub_81D7D14(&gSprites[data[3]]); + + bgY = GetBgY(1); + if (GetBgY(1) == 0 || bgY > 0x8000) + ChangeBgY(1, 0x400, 2); + + if (data[0] != 16) + { + data[0]++; + SetGpuReg(REG_OFFSET_BLDALPHA, (data[0] << 8) | (16 - data[0])); + } +} + +void sub_81D75B4(u8 taskId, s8 palDelay) +{ + PlaySE(SE_T_OOAME_E); + BeginNormalPaletteFade(-1, palDelay, 0, 0x10, 0); + gTasks[taskId].func = sub_81D7600; +} + +void sub_81D7600(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + sub_81D750C(); + if (!gPaletteFade.active) + { + DestroyTask(data[1]); + ChangeBgY(1, 0, 0); + SetVBlankCallback(NULL); + ScanlineEffect_Stop(); + ResetSpriteData(); + FreeAllSpritePalettes(); + data[0] = 0; + gTasks[taskId].func = Task_SetNextAnim; + } +} + +u8 sub_81D7664(void) +{ + u8 spriteId; + s16 *data; + + spriteId = CreateSprite(&gUnknown_0862A8D4, 98, 72, 3); + gSprites[spriteId].callback = sub_81D7700; + data = gSprites[spriteId].data; + data[0] = CreateSprite(&gUnknown_0862A8D4, 66, 104, 3); + data[1] = CreateSprite(&gUnknown_0862A900, 85, 101, 0); + data[2] = CreateSprite(&gUnknown_0862A92C, 119, 114, 1); + StartSpriteAnim(&gSprites[data[0]], 1); + return spriteId; +} + +void sub_81D7700(struct Sprite *sprite) +{ + s16 *data = sprite->data; + data[5]++; + data[5] &= 0xF; + if (!(data[5] & 7) && sprite->pos1.x != 72) + { + sprite->pos1.x--; + gSprites[sprite->data[0]].pos1.x--; + gSprites[data[1]].pos1.x--; + gSprites[data[2]].pos1.x--; + } + + switch (sprite->animCmdIndex) + { + case 0: + gSprites[data[1]].pos2.x = 0; + gSprites[data[1]].pos2.y = 0; + gSprites[data[2]].pos2.x = 0; + gSprites[data[2]].pos2.y = 0; + break; + case 1: + case 3: + gSprites[data[1]].pos2.x = -1; + gSprites[data[1]].pos2.y = 0; + gSprites[data[2]].pos2.x = -1; + gSprites[data[2]].pos2.y = 0; + break; + case 2: + gSprites[data[1]].pos2.x = -1; + gSprites[data[1]].pos2.y = 1; + gSprites[data[2]].pos2.x = -2; + gSprites[data[2]].pos2.y = 1; + break; + } +} + +void sub_81D7860(struct Sprite *sprite) +{ + s16 *data = sprite->data; + if (sprite->pos1.y <= 160) + { + sprite->pos1.y += 8; + gSprites[sprite->data[0]].pos1.y += 8; + gSprites[data[1]].pos1.y += 8; + gSprites[data[2]].pos1.y += 8; + } +} + +u8 sub_81D78BC(void) +{ + u8 spriteId; + s16 *data; + + spriteId = CreateSprite(&gUnknown_0862A9E4, 126, 96, 1); + gSprites[spriteId].callback = sub_81D7A60; + data = gSprites[spriteId].data; + + data[0] = CreateSprite(&gUnknown_0862A9E4, 158, 96, 1) << 8; + data[0] |= CreateSprite(&gUnknown_0862A9E4, 126, 112, 1); + data[1] = CreateSprite(&gUnknown_0862A9E4, 158, 112, 1) << 8; + data[1] |= CreateSprite(&gUnknown_0862A9E4, 126, 128, 1); + data[2] = CreateSprite(&gUnknown_0862A9E4, 158, 128, 1) << 8; + data[2] |= CreateSprite(&gUnknown_0862A9E4, 94, 128, 2); + data[3] = CreateSprite(&gUnknown_0862A9E4, 126, 128, 2) << 8; + data[3] |= CreateSprite(&gUnknown_0862A9E4, 174, 128, 0); + data[4] = CreateSprite(&gUnknown_0862AA1C, 198, 132, 0) << 8; + data[4] |= CreateSprite(&gUnknown_0862AA3C, 190, 120, 1); + + StartSpriteAnim(&gSprites[data[0] >> 8], 1); + StartSpriteAnim(&gSprites[data[0] & 0xFF], 2); + StartSpriteAnim(&gSprites[data[1] >> 8], 3); + StartSpriteAnim(&gSprites[data[1] & 0xFF], 4); + StartSpriteAnim(&gSprites[data[2] >> 8], 5); + StartSpriteAnim(&gSprites[data[2] & 0xFF], 6); + StartSpriteAnim(&gSprites[data[3] >> 8], 7); + StartSpriteAnim(&gSprites[data[3] & 0xFF], 8); + + return spriteId; +} + +void sub_81D7A60(struct Sprite *sprite) +{ + s16 *data = sprite->data; + data[5]++; + data[5] &= 0xF; + if (!(data[5] & 7) && sprite->pos1.x != 152) + { + sprite->pos1.x++; + gSprites[sprite->data[0] >> 8].pos1.x++; + gSprites[sprite->data[0] & 0xFF].pos1.x++; + gSprites[data[1] >> 8].pos1.x++; + gSprites[data[1] & 0xFF].pos1.x++; + gSprites[data[2] >> 8].pos1.x++; + gSprites[data[2] & 0xFF].pos1.x++; + gSprites[data[3] >> 8].pos1.x++; + gSprites[data[3] & 0xFF].pos1.x++; + gSprites[data[4] >> 8].pos1.x++; + gSprites[data[4] & 0xFF].pos1.x++; + } + + switch (gSprites[data[2] & 0xFF].animCmdIndex) + { + case 0: + sprite->pos2.y = 0; + gSprites[data[0] >> 8].pos2.y = 0; + gSprites[data[0] & 0xFF].pos2.y = 0; + gSprites[data[1] >> 8].pos2.y = 0; + gSprites[data[1] & 0xFF].pos2.y = 0; + gSprites[data[2] >> 8].pos2.y = 0; + gSprites[data[2] & 0xFF].pos2.y = 0; + gSprites[data[3] >> 8].pos2.y = 0; + gSprites[data[3] & 0xFF].pos2.y = 0; + gSprites[data[4] >> 8].pos2.y = 0; + gSprites[data[4] & 0xFF].pos2.y = 0; + break; + case 1: + case 3: + sprite->pos2.y = 1; + gSprites[data[0] >> 8].pos2.y = 1; + gSprites[data[0] & 0xFF].pos2.y = 1; + gSprites[data[1] >> 8].pos2.y = 1; + gSprites[data[1] & 0xFF].pos2.y = 1; + gSprites[data[2] >> 8].pos2.y = 1; + gSprites[data[2] & 0xFF].pos2.y = 1; + gSprites[data[3] >> 8].pos2.y = 1; + gSprites[data[3] & 0xFF].pos2.y = 1; + gSprites[data[4] >> 8].pos2.y = 1; + gSprites[data[4] & 0xFF].pos2.y = 1; + break; + case 2: + sprite->pos2.y = 2; + gSprites[data[0] >> 8].pos2.y = 2; + gSprites[data[0] & 0xFF].pos2.y = 2; + gSprites[data[1] >> 8].pos2.y = 2; + gSprites[data[1] & 0xFF].pos2.y = 2; + gSprites[data[2] >> 8].pos2.y = 2; + gSprites[data[4] & 0xFF].pos2.y = 2; + break; + } +} + +void sub_81D7D14(struct Sprite *sprite) +{ + s16 *data = sprite->data; + if (sprite->pos1.y <= 160) + { + sprite->pos1.y += 8; + gSprites[sprite->data[0] >> 8].pos1.y += 8; + gSprites[sprite->data[0] & 0xFF].pos1.y += 8; + gSprites[data[1] >> 8].pos1.y += 8; + gSprites[data[1] & 0xFF].pos1.y += 8; + gSprites[data[2] >> 8].pos1.y += 8; + gSprites[data[2] & 0xFF].pos1.y += 8; + gSprites[data[3] >> 8].pos1.y += 8; + gSprites[data[3] & 0xFF].pos1.y += 8; + gSprites[data[4] >> 8].pos1.y += 8; + gSprites[data[4] & 0xFF].pos1.y += 8; + } +} + +void sub_81D7E10(void) +{ + ResetVramOamAndBgCntRegs(); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(1, gUnknown_0862AA54, ARRAY_COUNT(gUnknown_0862AA54)); + SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); + SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); + SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); + ResetAllBgsCoordinates(); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); + schedule_bg_copy_tilemap_to_vram(2); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ShowBg(0); + ShowBg(1); + ShowBg(2); + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +void sub_81D7E9C(void) +{ + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(0, gRaySceneClouds_Gfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(1, gRaySceneOvercast_Gfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(2, gRaySceneRayquaza_Gfx, 0, 0, 0); + while (free_temp_tile_data_buffers_if_possible()); + + LZDecompressWram(gRaySceneClouds2_Tilemap, sRayScene->tilemapBuffers[0]); + LZDecompressWram(gRaySceneOvercast_Tilemap, sRayScene->tilemapBuffers[1]); + LZDecompressWram(gRaySceneRayquaza_Tilemap, sRayScene->tilemapBuffers[2]); + LoadCompressedPalette(gRaySceneRayquaza_Pal, 0, 0x40); + LoadCompressedObjectPic(&gUnknown_0862AA90); + LoadCompressedObjectPalette(&gUnknown_0862AA98); +} + +void sub_81D7F4C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + PlayNewMapMusic(MUS_REKKUU_KOURIN); + sub_81D7E10(); + sub_81D7E9C(); + SetGpuReg(REG_OFFSET_BLDCNT, 0x250); + SetGpuReg(REG_OFFSET_BLDALPHA, 0x808); + BlendPalettes(-1, 0x10, 0); + SetVBlankCallback(sub_81D67EC); + CreateTask(sub_81D81A4, 0); + data[0] = 0; + data[1] = 0; + gTasks[taskId].func = sub_81D7FC0; +} + +void sub_81D7FC0(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + switch (data[0]) + { + case 0: + if (data[1] == 8) + { + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + data[2] = 0; + data[3] = 30; + data[4] = 0; + data[5] = 7; + data[1] = 0; + data[0]++; + } + else + { + data[1]++; + } + break; + case 1: + data[2] += data[3]; + data[4] += data[5]; + if (data[3] > 3) + data[3] -= 3; + if (data[5] != 0) + data[5]--; + if (data[2] > 255) + { + data[2] = 256; + data[3] = 0; + data[6] = 12; + data[7] = -1; + data[1] = 0; + data[0]++; + } + SetBgAffine(2, 0x7800, 0x1800, 0x78, data[4] + 32, data[2], data[2], 0); + break; + case 2: + data[1]++; + SetBgAffine(2, 0x7800, 0x1800, 0x78, data[4] + 32 + (data[6] >> 2), data[2], data[2], 0); + data[6] += data[7]; + if (data[6] == 12 || data[6] == -12) + { + data[7] *= -1; + if (data[1] > 295) + { + data[0]++; + BeginNormalPaletteFade(-1, 6, 0, 0x10, 0); + } + } + break; + case 3: + data[2] += 16; + SetBgAffine(2, 0x7800, 0x1800, 0x78, data[4] + 32, data[2], data[2], 0); + sub_81D8164(taskId); + break; + } +} + +void sub_81D8164(u8 taskId) +{ + if (!gPaletteFade.active) + { + SetVBlankCallback(NULL); + ResetSpriteData(); + FreeAllSpritePalettes(); + gTasks[taskId].func = Task_SetNextAnim; + } +} + +void sub_81D81A4(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if ((data[1] & 3) == 0) + { + u8 spriteId = CreateSprite(&gUnknown_0862AAA0, + (gUnknown_0862AAB8[data[0]][0] * 4) + 120, + (gUnknown_0862AAB8[data[0]][1] * 4) + 80, + 0); + gSprites[spriteId].data[0] = (s8)(data[0]); + gSprites[spriteId].oam.objMode = 1; + gSprites[spriteId].oam.affineMode = 3; + gSprites[spriteId].oam.priority = 2; + InitSpriteAffineAnim(&gSprites[spriteId]); + if (data[0] == 9) + { + DestroyTask(taskId); + return; + } + else + { + data[0]++; + } + } + + data[1]++; +} + +void sub_81D8260(struct Sprite *sprite) +{ + if (sprite->data[1] == 0) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + else + { + sprite->pos2.x += gUnknown_0862AAB8[sprite->data[0]][0]; + sprite->pos2.y += gUnknown_0862AAB8[sprite->data[0]][1]; + } + + sprite->data[1]++; + sprite->data[1] &= 0xF; +} + +void sub_81D82B0(void) +{ + ResetVramOamAndBgCntRegs(); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_0862AACC, ARRAY_COUNT(gUnknown_0862AACC)); + SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); + SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); + SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); + SetBgTilemapBuffer(3, sRayScene->tilemapBuffers[3]); + ResetAllBgsCoordinates(); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); + schedule_bg_copy_tilemap_to_vram(2); + schedule_bg_copy_tilemap_to_vram(3); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +void sub_81D8358(void) +{ + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(0, gRaySceneRayquazaLight_Gfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(1, gRaySceneOvercast2_Gfx, 0, 0, 0); + while (free_temp_tile_data_buffers_if_possible()); + + LZDecompressWram(gRaySceneRayquazaLight_Tilemap, sRayScene->tilemapBuffers[0]); + LZDecompressWram(gRaySceneOvercast2_Tilemap, sRayScene->tilemapBuffers[3]); + CpuFastFill16(0, sRayScene->tilemapBuffers[2], 0x800); + CpuFastCopy(sRayScene->tilemapBuffers[3], sRayScene->tilemapBuffers[1], 0x800); + CpuFastFill16(0, &sRayScene->tilemapBuffers[1][0x100], 0x340); + + LoadCompressedPalette(gRaySceneOvercast2_Pal, 0, 0x40); + gPlttBufferUnfaded[0] = RGB_WHITE; + gPlttBufferFaded[0] = RGB_WHITE; + LoadCompressedObjectPic(&gUnknown_0862AAFC); + LoadCompressedObjectPic(&gUnknown_0862AB04); + LoadCompressedObjectPalette(&gUnknown_0862AB0C); +} + +void sub_81D844C(void) +{ + u16 VCOUNT = GetGpuReg(REG_OFFSET_VCOUNT); + if (VCOUNT >= 24 && VCOUNT <= 135 && VCOUNT - 24 <= sRayScene->field_2008) + REG_BLDALPHA = 0xD08; + else + REG_BLDALPHA = 0x1000; + + if (VCOUNT == 0) + { + if (sRayScene->field_2008 <= 0x1FFF) + { + if (sRayScene->field_2008 <= 39) + sRayScene->field_2008 += 4; + else if (sRayScene->field_2008 <= 79) + sRayScene->field_2008 += 2; + else + sRayScene->field_2008 += 1; + } + + sRayScene->field_200A++; + } +} + +void sub_81D84EC(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + sub_81D82B0(); + sub_81D8358(); + SetGpuRegBits(REG_OFFSET_BLDCNT, 0x1E41); + SetGpuReg(REG_OFFSET_BLDALPHA, 0x1000); + BlendPalettes(-1, 0x10, 0); + SetVBlankCallback(sub_81D67EC); + sRayScene->field_2008 = 0; + sRayScene->field_200A = 0; + data[0] = 0; + data[1] = 0; + data[2] = 0; + data[3] = 0; + data[4] = 0x1000; + gTasks[taskId].func = sub_81D857C; +} + +void sub_81D857C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + switch (data[0]) + { + case 0: + if (data[1] == 8) + { + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + data[1] = 0; + data[0]++; + } + else + { + data[1]++; + } + break; + case 1: + if (!gPaletteFade.active) + { + if (data[1] == 10) + { + data[1] = 0; + data[0]++; + SetHBlankCallback(sub_81D844C); + EnableInterrupts(INTR_FLAG_HBLANK | INTR_FLAG_VBLANK); + } + else + { + data[1]++; + } + } + break; + case 2: + if (data[1] == 80) + { + data[1] = 0; + data[0]++; + sub_81D86CC(); + } + else + { + data[1]++; + } + break; + case 3: + if (++data[1] == 368) + { + data[1] = 0; + data[0]++; + } + break; + case 4: + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskId].func = sub_81D8684; + break; + } +} + +void sub_81D8684(u8 taskId) +{ + if (!gPaletteFade.active) + { + SetVBlankCallback(NULL); + SetHBlankCallback(NULL); + ResetSpriteData(); + FreeAllSpritePalettes(); + gTasks[taskId].func = Task_SetNextAnim; + } +} + +u8 sub_81D86CC(void) +{ + u8 spriteId = CreateSprite(&gUnknown_0862AB14, 160, 0, 0); + s16 *data = gSprites[spriteId].data; + data[0] = CreateSprite(&gUnknown_0862AB2C, 184, -48, 0); + gSprites[spriteId].callback = sub_81D874C; + gSprites[spriteId].oam.priority = 3; + gSprites[data[0]].oam.priority = 3; + return spriteId; +} + +void sub_81D874C(struct Sprite *sprite) +{ + s16 *data = sprite->data; + s16 counter = data[2]; + if (counter == 0) + { + data[3] = 12; + data[4] = 8; + } + else if (counter == 256) + { + data[3] = 9; + data[4] = 7; + } + else if (counter == 268) + { + data[3] = 8; + data[4] = 6; + } + else if (counter == 280) + { + data[3] = 7; + data[4] = 5; + } + else if (counter == 292) + { + data[3] = 6; + data[4] = 4; + } + else if (counter == 304) + { + data[3] = 5; + data[4] = 3; + } + else if (counter == 320) + { + data[3] = 4; + data[4] = 2; + } + + if (data[2] % data[3] == 0) + { + sprite->pos2.x--; + gSprites[data[0]].pos2.x--; + } + if (data[2] % data[4] == 0) + { + sprite->pos2.y++; + gSprites[data[0]].pos2.y++; + } + + data[2]++; +} + +void sub_81D8828(void) +{ + ResetVramOamAndBgCntRegs(); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_0862AB44, ARRAY_COUNT(gUnknown_0862AB44)); + SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); + SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); + SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); + SetBgTilemapBuffer(3, sRayScene->tilemapBuffers[3]); + ResetAllBgsCoordinates(); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); + schedule_bg_copy_tilemap_to_vram(2); + schedule_bg_copy_tilemap_to_vram(3); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_WIN0_ON); + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +void sub_81D88D0(void) +{ + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(1, gRaySceneRayquazaChase_Gfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(2, gRaySceneChaseStreaks_Gfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(3, gRaySceneChaseBg_Gfx, 0, 0, 0); + while (free_temp_tile_data_buffers_if_possible()); + + LZDecompressWram(gRayChaseRayquazaChase2_Tilemap, sRayScene->tilemapBuffers[0]); + LZDecompressWram(gRayChaseRayquazaChase_Tilemap, sRayScene->tilemapBuffers[1]); + LZDecompressWram(gRaySceneChaseStreaks_Tilemap, sRayScene->tilemapBuffers[2]); + LZDecompressWram(gRaySceneChaseBg_Tilemap, sRayScene->tilemapBuffers[3]); + LoadCompressedPalette(gRaySceneChase_Pal, 0, 0x80); +} + +void sub_81D8980(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + sub_81D8828(); + sub_81D88D0(); + sub_81D68C8(); + BlendPalettes(-1, 0x10, 0); + SetVBlankCallback(sub_81D67EC); + data[0] = 0; + data[1] = 0; + data[2] = CreateTask(sub_81D8AD8, 0); + gTasks[taskId].func = sub_81D89E0; +} + +void sub_81D89E0(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + sub_81D8BB4(); + if ((data[3] & 7) == 0 && data[0] <= 1 && data[1] <= 89) + PlaySE(SE_OP_BASYU); + + data[3]++; + switch (data[0]) + { + case 0: + if (data[1] == 8) + { + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + data[1] = 0; + data[0]++; + } + else + { + data[1]++; + } + break; + case 1: + if (data[1] == 127) + { + data[1] = 0; + data[0]++; + gTasks[data[2]].func = sub_81D8B2C; + } + else + { + data[1]++; + } + break; + case 2: + if (data[1] == 12) + { + data[1] = 0; + data[0]++; + } + else + { + data[1]++; + } + break; + case 3: + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskId].func = sub_81D8BEC; + break; + } +} + +void sub_81D8AD8(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if ((data[15] & 3) == 0) + { + ChangeBgX(1, (Random() % 8 - 4) << 8, 0); + ChangeBgY(1, (Random() % 8 - 4) << 8, 0); + } + + data[15]++; +} + +void sub_81D8B2C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if (data[0] == 0) + { + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + data[0]++; + data[1] = 10; + data[2] = -1; + } + else if (data[0] == 1) + { + ChangeBgX(1, data[1] << 8, 2); + ChangeBgY(1, data[1] << 8, 1); + data[1] += data[2]; + if (data[1] == -10) + data[2] *= -1; + } +} + +void sub_81D8BB4(void) +{ + ChangeBgX(2, 0x400, 2); + ChangeBgY(2, 0x400, 1); + ChangeBgX(0, 0x800, 2); + ChangeBgY(0, 0x800, 1); +} + +void sub_81D8BEC(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + sub_81D8BB4(); + if (!gPaletteFade.active) + { + SetVBlankCallback(NULL); + sub_81D6904(); + DestroyTask(data[2]); + gTasks[taskId].func = Task_SetNextAnim; + } +} From b6974978359be5b0605523f761990bb89919e193 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 1 Feb 2018 14:47:41 +0100 Subject: [PATCH 3/7] ray scene is decompiled --- asm/field_specials.s | 4 +- asm/rayquaza_scene.s | 1629 -------------------------------------- include/graphics.h | 6 + include/rayquaza_scene.h | 2 + ld_script.txt | 1 - src/rayquaza_scene.c | 920 ++++++++++++++++----- sym_ewram.txt | 2 +- 7 files changed, 713 insertions(+), 1851 deletions(-) delete mode 100644 asm/rayquaza_scene.s diff --git a/asm/field_specials.s b/asm/field_specials.s index 200ab1fdb7..5dd779a471 100644 --- a/asm/field_specials.s +++ b/asm/field_specials.s @@ -7156,14 +7156,14 @@ sub_813B7D8: @ 813B7D8 ldr r2, =c2_exit_to_overworld_1_continue_scripts_restart_music movs r0, 0 movs r1, 0x1 - bl sub_81D6720 + bl DoRayquazaScene b _0813B802 .pool _0813B7F8: ldr r2, =c2_exit_to_overworld_1_continue_scripts_restart_music movs r0, 0x1 movs r1, 0 - bl sub_81D6720 + bl DoRayquazaScene _0813B802: pop {r0} bx r0 diff --git a/asm/rayquaza_scene.s b/asm/rayquaza_scene.s deleted file mode 100644 index a7614239a1..0000000000 --- a/asm/rayquaza_scene.s +++ /dev/null @@ -1,1629 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - - thumb_func_start sub_81D8C38 -sub_81D8C38: @ 81D8C38 - push {r4,lr} - bl ResetVramOamAndBgCntRegs - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0862AD08 - movs r0, 0x1 - movs r2, 0x3 - bl InitBgsFromTemplates - ldr r4, =sRayScene - ldr r1, [r4] - adds r1, 0x4 - movs r0, 0 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00000804 - adds r1, r0 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00001004 - adds r1, r0 - movs r0, 0x2 - bl SetBgTilemapBuffer - bl ResetAllBgsCoordinates - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0xC1 - lsls r1, 6 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8C38 - - thumb_func_start sub_81D8CC4 -sub_81D8CC4: @ 81D8CC4 - push {r4,lr} - sub sp, 0x4 - bl reset_temp_tile_data_buffers - ldr r1, =gRaySceneHushRing_Gfx - movs r4, 0 - str r4, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gRaySceneHushBg_Gfx - str r4, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram -_081D8CEA: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081D8CEA - ldr r0, =gRaySceneHushRing_Tilemap - ldr r4, =sRayScene - ldr r1, [r4] - ldr r2, =0x00000804 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneHushBg_Tilemap - ldr r1, [r4] - adds r1, 0x4 - bl LZDecompressWram - ldr r0, =gRaySceneHushRing_Map - ldr r1, [r4] - ldr r2, =0x00001004 - adds r1, r2 - bl LZDecompressWram - ldr r0, =gRaySceneHushBg_Pal - movs r1, 0 - movs r2, 0x60 - bl LoadCompressedPalette - ldr r0, =gUnknown_0862AC28 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AC30 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AC38 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AC40 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AC48 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AC50 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0862AC58 - bl LoadCompressedObjectPalette - ldr r0, =gUnknown_0862AC60 - bl LoadCompressedObjectPalette - ldr r0, =gUnknown_0862AC68 - bl LoadCompressedObjectPalette - ldr r0, =gUnknown_0862AC70 - bl LoadCompressedObjectPalette - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8CC4 - - thumb_func_start sub_81D8DB4 -sub_81D8DB4: @ 81D8DB4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r5, =gTasks + 0x8 - adds r6, r4, r5 - bl sub_81D8C38 - bl sub_81D8CC4 - bl sub_81D68C8 - movs r1, 0x80 - lsls r1, 3 - movs r0, 0 - bl ClearGpuRegBits - ldr r1, =0x00000241 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x00000e09 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - ldr r0, =sub_81D67EC - bl SetVBlankCallback - movs r0, 0 - strh r0, [r6] - strh r0, [r6, 0x2] - subs r5, 0x8 - adds r4, r5 - ldr r0, =sub_81D8E80 - str r0, [r4] - ldr r0, =sub_81D8FB0 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x4] - movs r0, 0x4 - ldrsh r1, [r6, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r2, 0 - strh r2, [r0, 0x8] - movs r0, 0x4 - ldrsh r1, [r6, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r2, [r0, 0xA] - movs r0, 0x4 - ldrsh r1, [r6, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r2, [r0, 0xC] - movs r0, 0x4 - ldrsh r1, [r6, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r2, 0x1 - strh r2, [r0, 0xE] - movs r0, 0x4 - ldrsh r1, [r6, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r2, [r0, 0x10] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8DB4 - - thumb_func_start sub_81D8E80 -sub_81D8E80: @ 81D8E80 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0xC - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r7, r0, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 - adds r4, r7, r0 - movs r1, 0 - ldrsh r5, [r4, r1] - cmp r5, 0x1 - beq _081D8EDE - cmp r5, 0x1 - bgt _081D8EB0 - cmp r5, 0 - beq _081D8EBA - b _081D8FA0 - .pool -_081D8EB0: - cmp r5, 0x2 - beq _081D8F1E - cmp r5, 0x3 - beq _081D8F84 - b _081D8FA0 -_081D8EBA: - ldrh r1, [r4, 0x2] - movs r2, 0x2 - ldrsh r0, [r4, r2] - cmp r0, 0x8 - bne _081D8F18 - adds r0, r6, 0 - bl sub_81D90A8 - movs r0, 0x1 - negs r0, r0 - str r5, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - strh r5, [r4, 0x2] - b _081D8F30 -_081D8EDE: - ldr r2, =gSprites - movs r0, 0xA - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, 0x1C - adds r0, r2 - ldr r1, [r0] - ldr r0, =sub_81D97E0 - cmp r1, r0 - bne _081D8FA0 - ldrh r1, [r4, 0x2] - movs r2, 0x2 - ldrsh r0, [r4, r2] - cmp r0, 0x40 - bne _081D8F18 - adds r0, r6, 0 - bl sub_81D94D4 - adds r0, r6, 0 - bl sub_81D93D8 - b _081D8F2C - .pool -_081D8F18: - adds r0, r1, 0x1 - strh r0, [r4, 0x2] - b _081D8FA0 -_081D8F1E: - ldrh r2, [r4, 0x2] - movs r0, 0x2 - ldrsh r1, [r4, r0] - movs r0, 0xE0 - lsls r0, 1 - cmp r1, r0 - bne _081D8F38 -_081D8F2C: - movs r0, 0 - strh r0, [r4, 0x2] -_081D8F30: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _081D8FA0 -_081D8F38: - adds r0, r2, 0x1 - strh r0, [r4, 0x2] - movs r1, 0x2 - ldrsh r0, [r4, r1] - movs r1, 0x90 - bl __modsi3 - lsls r0, 16 - asrs r4, r0, 16 - cmp r4, 0 - bne _081D8FA0 - ldr r0, =0x0000fffe - ldr r1, =0x0000ffff - str r1, [sp] - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl sub_80A2C44 - ldr r0, =0xffff0000 - str r4, [sp] - str r4, [sp, 0x4] - movs r1, 0x1 - str r1, [sp, 0x8] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl sub_80A2C44 - b _081D8FA0 - .pool -_081D8F84: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r1, 0x4 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - mov r0, r8 - subs r0, 0x8 - adds r0, r7, r0 - ldr r1, =sub_81D9034 - str r1, [r0] -_081D8FA0: - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8E80 - - thumb_func_start sub_81D8FB0 -sub_81D8FB0: @ 81D8FB0 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r4, r1, r0 - ldrh r1, [r4] - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - bne _081D9024 - ldrh r1, [r4, 0x2] - adds r1, 0xE - lsls r1, 8 - movs r2, 0xF8 - lsls r2, 5 - adds r0, r2, 0 - ands r1, r0 - ldrh r0, [r4, 0x4] - adds r0, 0x9 - movs r2, 0xF - ands r0, r2 - orrs r1, r0 - movs r0, 0x52 - bl SetGpuReg - ldrh r1, [r4, 0x2] - ldrh r0, [r4, 0x6] - subs r1, r0 - strh r1, [r4, 0x2] - ldrh r0, [r4, 0x8] - ldrh r2, [r4, 0x4] - adds r0, r2 - strh r0, [r4, 0x4] - lsls r1, 16 - asrs r1, 16 - movs r0, 0x3 - negs r0, r0 - cmp r1, r0 - beq _081D9008 - cmp r1, 0 - bne _081D9010 -_081D9008: - movs r1, 0x6 - ldrsh r0, [r4, r1] - negs r0, r0 - strh r0, [r4, 0x6] -_081D9010: - movs r2, 0x4 - ldrsh r0, [r4, r2] - cmp r0, 0x3 - beq _081D901C - cmp r0, 0 - bne _081D9024 -_081D901C: - movs r1, 0x8 - ldrsh r0, [r4, r1] - negs r0, r0 - strh r0, [r4, 0x8] -_081D9024: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D8FB0 - - thumb_func_start sub_81D9034 -sub_81D9034: @ 81D9034 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r6, r1, 3 - ldr r7, =gTasks + 0x8 - adds r4, r6, r7 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _081D90A0 - bl StopMapMusic - movs r1, 0x2 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081D9078 - movs r0, 0 - bl SetVBlankCallback - bl sub_81D6904 - bl ResetSpriteData - bl FreeAllSpritePalettes - ldrb r0, [r4, 0x4] - bl DestroyTask -_081D9078: - ldrh r1, [r4, 0x2] - movs r2, 0x2 - ldrsh r0, [r4, r2] - cmp r0, 0x20 - bne _081D909C - strh r5, [r4, 0x2] - adds r0, r7, 0 - subs r0, 0x8 - adds r0, r6, r0 - ldr r1, =Task_SetNextAnim - str r1, [r0] - b _081D90A0 - .pool -_081D909C: - adds r0, r1, 0x1 - strh r0, [r4, 0x2] -_081D90A0: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D9034 - - thumb_func_start sub_81D90A8 -sub_81D90A8: @ 81D90A8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldr r0, =gUnknown_0862AC78 - movs r1, 0x40 - movs r2, 0x78 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x6] - movs r0, 0x6 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites + 0x2E - mov r10, r1 - adds r7, r0, r1 - ldr r0, =gUnknown_0862AC90 - movs r1, 0x10 - movs r2, 0x82 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7] - movs r2, 0x2E - negs r2, r2 - add r2, r10 - mov r8, r2 - movs r1, 0x6 - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - ldrb r2, [r1, 0x5] - movs r6, 0xD - negs r6, r6 - adds r0, r6, 0 - ands r0, r2 - movs r2, 0x4 - mov r9, r2 - mov r2, r9 - orrs r0, r2 - strb r0, [r1, 0x5] - movs r1, 0 - ldrsh r0, [r7, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - ldrb r2, [r1, 0x5] - adds r0, r6, 0 - ands r0, r2 - mov r2, r9 - orrs r0, r2 - strb r0, [r1, 0x5] - ldr r5, =gUnknown_0862ACA8 - adds r0, r5, 0 - movs r1, 0xA0 - movs r2, 0x80 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x8] - movs r0, 0x8 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - mov r1, r10 - adds r7, r0, r1 - adds r0, r5, 0 - movs r1, 0xC0 - movs r2, 0x80 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7] - adds r0, r5, 0 - movs r1, 0xE0 - movs r2, 0x80 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7, 0x2] - movs r2, 0x8 - ldrsh r0, [r4, r2] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - ldrb r2, [r1, 0x5] - adds r0, r6, 0 - ands r0, r2 - mov r2, r9 - orrs r0, r2 - strb r0, [r1, 0x5] - movs r1, 0 - ldrsh r0, [r7, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - ldrb r2, [r1, 0x5] - adds r0, r6, 0 - ands r0, r2 - mov r2, r9 - orrs r0, r2 - strb r0, [r1, 0x5] - movs r1, 0x2 - ldrsh r0, [r7, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - ldrb r2, [r1, 0x5] - adds r0, r6, 0 - ands r0, r2 - mov r2, r9 - orrs r0, r2 - strb r0, [r1, 0x5] - movs r0, 0 - ldrsh r1, [r7, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - movs r1, 0x1 - bl StartSpriteAnim - movs r2, 0x2 - ldrsh r1, [r7, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - movs r1, 0x2 - bl StartSpriteAnim - ldr r0, =gUnknown_0862ACC0 - movs r2, 0x41 - negs r2, r2 - movs r1, 0x78 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0xA] - movs r0, 0xA - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - mov r1, r10 - adds r7, r0, r1 - ldr r0, =gUnknown_0862ACD8 - movs r2, 0x71 - negs r2, r2 - movs r1, 0x78 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7] - movs r2, 0xA - ldrsh r0, [r4, r2] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - ldrb r2, [r1, 0x5] - adds r0, r6, 0 - ands r0, r2 - mov r2, r9 - orrs r0, r2 - strb r0, [r1, 0x5] - movs r0, 0 - ldrsh r1, [r7, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - ldrb r1, [r0, 0x5] - ands r6, r1 - orrs r6, r2 - strb r6, [r0, 0x5] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D90A8 - - thumb_func_start sub_81D9274 -sub_81D9274: @ 81D9274 - push {r4-r6,lr} - mov r6, r8 - push {r6} - lsls r0, 24 - lsrs r0, 24 - lsls r2, r0, 2 - adds r2, r0 - lsls r2, 3 - ldr r0, =gTasks + 0x8 - adds r2, r0 - ldr r3, =gSprites - movs r0, 0x6 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - movs r1, 0x1C - adds r1, r3 - mov r8, r1 - add r0, r8 - ldr r6, =pokemon_alive_on_battle_side - str r6, [r0] - movs r0, 0x6 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - movs r4, 0 - strh r4, [r0, 0x36] - movs r0, 0x6 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r4, [r0, 0x38] - movs r0, 0x6 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - movs r5, 0x4 - strh r5, [r0, 0x3A] - movs r0, 0x6 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r4, [r0, 0x3C] - movs r0, 0x8 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - str r6, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r4, [r0, 0x36] - movs r0, 0x8 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r4, [r0, 0x38] - movs r0, 0x8 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r5, [r0, 0x3A] - movs r0, 0x8 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - movs r1, 0x1 - strh r1, [r0, 0x3C] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D9274 - - thumb_func_start pokemon_alive_on_battle_side -pokemon_alive_on_battle_side: @ 81D9338 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x36] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _081D93CC - movs r1, 0x3C - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081D9370 - ldrh r0, [r4, 0x20] - ldrh r3, [r4, 0x3A] - subs r0, r3 - strh r0, [r4, 0x20] - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, r3 - b _081D939E - .pool -_081D9370: - ldrh r2, [r4, 0x3A] - ldrh r1, [r4, 0x20] - adds r0, r2, r1 - strh r0, [r4, 0x20] - ldr r3, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x20] - adds r2, r1 - strh r2, [r0, 0x20] - movs r2, 0x30 - ldrsh r1, [r4, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r4, 0x3A] - ldrh r2, [r0, 0x20] - adds r1, r2 -_081D939E: - strh r1, [r0, 0x20] - ldrh r1, [r4, 0x38] - adds r1, 0x1 - movs r2, 0 - strh r1, [r4, 0x38] - ldrh r0, [r4, 0x3A] - subs r0, r1 - strh r0, [r4, 0x3A] - lsls r1, 16 - asrs r1, 16 - cmp r1, 0x3 - bne _081D93CC - strh r2, [r4, 0x36] - strh r2, [r4, 0x38] - strh r2, [r4, 0x3A] - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] - b _081D93D2 - .pool -_081D93CC: - ldrh r0, [r4, 0x36] - adds r0, 0x1 - strh r0, [r4, 0x36] -_081D93D2: - pop {r4} - pop {r0} - bx r0 - thumb_func_end pokemon_alive_on_battle_side - - thumb_func_start sub_81D93D8 -sub_81D93D8: @ 81D93D8 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r2, r0, 2 - adds r2, r0 - lsls r2, 3 - ldr r0, =gTasks + 0x8 - adds r2, r0 - ldr r3, =gSprites - movs r0, 0x6 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r3, 0 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_81D9420 - str r1, [r0] - movs r0, 0x6 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - movs r1, 0x1 - bl StartSpriteAnim - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D93D8 - - thumb_func_start sub_81D9420 -sub_81D9420: @ 81D9420 - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x2B - ldrb r0, [r0] - cmp r0, 0x1 - beq _081D9488 - cmp r0, 0x1 - bgt _081D9436 - cmp r0, 0 - beq _081D9440 - b _081D94C4 -_081D9436: - cmp r0, 0x2 - beq _081D9440 - cmp r0, 0x3 - beq _081D9488 - b _081D94C4 -_081D9440: - adds r0, r4, 0 - adds r0, 0x2C - ldrb r0, [r0] - lsls r0, 26 - lsrs r0, 26 - movs r1, 0xC - bl __umodsi3 - lsls r0, 24 - ldr r2, =gSprites - cmp r0, 0 - bne _081D9470 - ldrh r0, [r4, 0x20] - subs r0, 0x2 - strh r0, [r4, 0x20] - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x20] - subs r1, 0x2 - strh r1, [r0, 0x20] -_081D9470: - movs r1, 0x2E - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - movs r0, 0 - strh r0, [r1, 0x26] - b _081D94C4 - .pool -_081D9488: - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x0000fffe - strh r1, [r0, 0x26] - adds r0, r4, 0 - adds r0, 0x2C - ldrb r1, [r0] - lsls r1, 26 - lsrs r1, 26 - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - bne _081D94C4 - ldrh r0, [r4, 0x22] - adds r0, 0x1 - strh r0, [r4, 0x22] - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x22] - adds r1, 0x1 - strh r1, [r0, 0x22] -_081D94C4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D9420 - - thumb_func_start sub_81D94D4 -sub_81D94D4: @ 81D94D4 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r1, r0 - movs r0, 0x8 - ldrsh r1, [r1, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r2, =gSprites + 0x2E - adds r4, r0, r2 - subs r2, 0x12 - adds r0, r2 - ldr r3, =sub_81D9528 - str r3, [r0] - movs r0, 0 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - str r3, [r0] - movs r0, 0x2 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - str r3, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D94D4 - - thumb_func_start sub_81D9528 -sub_81D9528: @ 81D9528 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r0, 0 - ldrh r1, [r7, 0x36] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _081D9550 - ldrh r1, [r7, 0x24] - movs r2, 0x24 - ldrsh r0, [r7, r2] - cmp r0, 0x1 - bne _081D954C - ldr r0, =0x0000ffff - b _081D954E - .pool -_081D954C: - movs r0, 0x1 -_081D954E: - strh r0, [r7, 0x24] -_081D9550: - movs r1, 0x38 - ldrsh r0, [r7, r1] - cmp r0, 0x80 - bne _081D95CE - ldr r2, =gUnknown_0862ACF0 - mov r8, r2 - mov r0, r8 - movs r1, 0x98 - movs r2, 0x84 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7, 0x3C] - ldr r5, =gSprites - movs r1, 0x3C - ldrsh r0, [r7, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r5 - ldrb r2, [r1, 0x5] - movs r4, 0xD - negs r4, r4 - adds r0, r4, 0 - ands r0, r2 - movs r6, 0x4 - orrs r0, r6 - strb r0, [r1, 0x5] - mov r0, r8 - movs r1, 0xE0 - movs r2, 0x84 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7, 0x3C] - movs r2, 0x3C - ldrsh r1, [r7, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrb r1, [r0, 0x5] - ands r4, r1 - orrs r4, r6 - strb r4, [r0, 0x5] - movs r0, 0x3C - ldrsh r1, [r7, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3F - ldrb r1, [r0] - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0] - ldrh r0, [r7, 0x38] - adds r0, 0x1 - strh r0, [r7, 0x38] -_081D95CE: - ldrh r1, [r7, 0x38] - movs r2, 0x38 - ldrsh r0, [r7, r2] - cmp r0, 0x7F - ble _081D95F8 - movs r1, 0x26 - ldrsh r0, [r7, r1] - cmp r0, 0x20 - beq _081D95FC - ldrh r0, [r7, 0x3A] - adds r0, 0x1 - strh r0, [r7, 0x3A] - lsls r0, 16 - asrs r0, 20 - strh r0, [r7, 0x26] - b _081D95FC - .pool -_081D95F8: - adds r0, r1, 0x1 - strh r0, [r7, 0x38] -_081D95FC: - ldrh r0, [r7, 0x36] - movs r1, 0x3F - ands r0, r1 - cmp r0, 0 - bne _081D960C - movs r0, 0xA5 - bl PlaySE -_081D960C: - ldrh r0, [r7, 0x36] - adds r0, 0x1 - strh r0, [r7, 0x36] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D9528 - - thumb_func_start sub_81D961C -sub_81D961C: @ 81D961C - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x3C - ldrsh r1, [r4, r0] - cmp r1, 0x40 - bgt _081D968C - ldrh r0, [r4, 0x26] - adds r0, 0x2 - strh r0, [r4, 0x26] - ldr r5, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrh r1, [r0, 0x26] - adds r1, 0x2 - strh r1, [r0, 0x26] - movs r1, 0x3C - ldrsh r0, [r4, r1] - cmp r0, 0x40 - beq _081D964C - b _081D979E -_081D964C: - movs r3, 0x30 - negs r3, r3 - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0 - bl sub_81D9868 - movs r2, 0x5 - strh r2, [r4, 0x36] - ldr r0, =0x0000ffff - strh r0, [r4, 0x38] - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r1, 0x3 - strh r1, [r0, 0x36] - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - strh r2, [r0, 0x38] - b _081D979E - .pool -_081D968C: - cmp r1, 0x6F - bgt _081D96BE - adds r0, r4, 0 - bl sub_81D97E0 - movs r1, 0x36 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081D96A4 - movs r0, 0x68 - bl PlaySE -_081D96A4: - movs r0, 0x36 - ldrsh r1, [r4, r0] - movs r0, 0x3 - negs r0, r0 - cmp r1, r0 - bne _081D979E - adds r0, r4, 0 - movs r1, 0x2 - movs r2, 0x30 - movs r3, 0x10 - bl sub_81D9868 - b _081D979E -_081D96BE: - cmp r1, 0x70 - bne _081D96EC - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x7 - strh r1, [r0, 0x36] - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x3 - strh r1, [r0, 0x38] - b _081D96F2 - .pool -_081D96EC: - ldr r0, =0x00000147 - cmp r1, r0 - bgt _081D9700 -_081D96F2: - adds r0, r4, 0 - bl sub_81D97E0 - b _081D979E - .pool -_081D9700: - movs r0, 0xA4 - lsls r0, 1 - cmp r1, r0 - bne _081D974C - adds r0, r4, 0 - bl sub_81D97E0 - adds r0, r4, 0 - movs r1, 0x3 - movs r2, 0x30 - movs r3, 0x10 - bl sub_81D9868 - movs r3, 0x1 - strh r3, [r4, 0x24] - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x24] - movs r0, 0xCB - lsls r0, 1 - movs r1, 0 - bl PlayCry1 - ldr r0, =sub_81D98B4 - movs r1, 0 - bl CreateTask - b _081D979E - .pool -_081D974C: - movs r0, 0xB0 - lsls r0, 1 - cmp r1, r0 - beq _081D9790 - adds r0, 0x18 - cmp r1, r0 - bne _081D979E - movs r3, 0 - strh r3, [r4, 0x24] - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r3, [r0, 0x24] - adds r0, r4, 0 - bl sub_81D97E0 - adds r0, r4, 0 - movs r1, 0x2 - movs r2, 0x30 - movs r3, 0x10 - bl sub_81D9868 - ldr r0, =sub_81D97E0 - str r0, [r4, 0x1C] - b _081D97D2 - .pool -_081D9790: - ldr r0, =sub_81D8E80 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl sub_81D9274 -_081D979E: - ldrh r2, [r4, 0x3C] - movs r0, 0x3C - ldrsh r1, [r4, r0] - movs r0, 0xA4 - lsls r0, 1 - cmp r1, r0 - ble _081D97CC - movs r0, 0x1 - ands r0, r2 - cmp r0, 0 - bne _081D97CC - movs r1, 0x24 - ldrsh r2, [r4, r1] - negs r2, r2 - strh r2, [r4, 0x24] - ldr r3, =gSprites - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r2, [r0, 0x24] -_081D97CC: - ldrh r0, [r4, 0x3C] - adds r0, 0x1 - strh r0, [r4, 0x3C] -_081D97D2: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D961C - - thumb_func_start sub_81D97E0 -sub_81D97E0: @ 81D97E0 - push {r4-r7,lr} - adds r3, r0, 0 - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r5, =gSprites - adds r4, r0, r5 - ldrh r1, [r3, 0x3A] - ldrh r0, [r4, 0x36] - ands r0, r1 - cmp r0, 0 - bne _081D985C - ldrh r2, [r3, 0x36] - ldrh r1, [r3, 0x26] - adds r0, r2, r1 - strh r0, [r3, 0x26] - movs r7, 0x2E - ldrsh r1, [r3, r7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrh r1, [r0, 0x26] - adds r2, r1 - strh r2, [r0, 0x26] - ldrh r0, [r3, 0x38] - ldrh r2, [r3, 0x36] - adds r0, r2 - strh r0, [r3, 0x36] - lsls r0, 16 - asrs r5, r0, 16 - ldrh r6, [r4, 0x38] - movs r7, 0x38 - ldrsh r2, [r4, r7] - cmp r5, r2 - bge _081D9836 - movs r0, 0x36 - ldrsh r1, [r3, r0] - adds r0, r2, 0 - cmn r1, r0 - bgt _081D985C -_081D9836: - cmp r5, r2 - ble _081D9844 - strh r6, [r3, 0x36] - b _081D9854 - .pool -_081D9844: - movs r0, 0x36 - ldrsh r1, [r3, r0] - movs r2, 0x38 - ldrsh r0, [r4, r2] - cmn r1, r0 - bge _081D9854 - negs r0, r6 - strh r0, [r3, 0x36] -_081D9854: - movs r7, 0x38 - ldrsh r0, [r3, r7] - negs r0, r0 - strh r0, [r3, 0x38] -_081D985C: - ldrh r0, [r3, 0x3A] - adds r0, 0x1 - strh r0, [r3, 0x3A] - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D97E0 - - thumb_func_start sub_81D9868 -sub_81D9868: @ 81D9868 - push {r4,r5,lr} - adds r5, r1, 0 - lsls r5, 24 - lsrs r5, 24 - movs r4, 0x2E - ldrsh r1, [r0, r4] - lsls r4, r1, 4 - adds r4, r1 - lsls r4, 2 - ldr r1, =gSprites - adds r4, r1 - lsls r2, 16 - asrs r2, 16 - ldrh r1, [r0, 0x20] - adds r2, r1 - strh r2, [r4, 0x20] - lsls r3, 16 - asrs r3, 16 - ldrh r1, [r0, 0x22] - adds r3, r1 - strh r3, [r4, 0x22] - ldrh r1, [r0, 0x24] - strh r1, [r4, 0x24] - ldrh r1, [r0, 0x26] - strh r1, [r4, 0x26] - adds r1, r5, 0 - bl StartSpriteAnim - adds r0, r4, 0 - adds r1, r5, 0 - bl StartSpriteAnim - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D9868 - - thumb_func_start sub_81D98B4 -sub_81D98B4: @ 81D98B4 - push {r4,r5,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - movs r0, 0 - ldrsh r1, [r4, r0] - cmp r1, 0x1 - beq _081D990C - cmp r1, 0x1 - bgt _081D98DC - cmp r1, 0 - beq _081D98E2 - b _081D99B4 - .pool -_081D98DC: - cmp r1, 0x2 - beq _081D99A4 - b _081D99B4 -_081D98E2: - movs r2, 0x80 - lsls r2, 7 - movs r0, 0x40 - str r0, [sp] - adds r0, 0xC0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r1, [sp, 0xC] - movs r0, 0x2 - adds r1, r2, 0 - movs r3, 0x78 - bl SetBgAffine - movs r1, 0x80 - lsls r1, 3 - movs r0, 0 - bl SetGpuRegBits - movs r0, 0x10 - strh r0, [r4, 0x8] - b _081D9922 -_081D990C: - movs r1, 0xA - ldrsh r0, [r4, r1] - cmp r0, 0x8 - bne _081D991A - movs r0, 0x12 - bl PlaySE -_081D991A: - movs r3, 0x4 - ldrsh r0, [r4, r3] - cmp r0, 0x2 - bne _081D992A -_081D9922: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _081D99B4 -_081D992A: - ldrh r5, [r4, 0x8] - ldrh r1, [r4, 0x2] - adds r0, r5, r1 - strh r0, [r4, 0x2] - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - movs r3, 0x6 - ldrsh r0, [r4, r3] - movs r1, 0x3 - bl __modsi3 - lsls r0, 16 - cmp r0, 0 - bne _081D9954 - lsls r0, r5, 16 - asrs r0, 16 - cmp r0, 0x4 - beq _081D9954 - subs r0, r5, 0x2 - strh r0, [r4, 0x8] -_081D9954: - ldrh r0, [r4, 0x6] - adds r0, 0x1 - strh r0, [r4, 0x6] - movs r2, 0x80 - lsls r2, 7 - movs r0, 0x40 - str r0, [sp] - ldrh r0, [r4, 0x2] - movs r3, 0x80 - lsls r3, 1 - adds r1, r3, 0 - subs r0, r1, r0 - lsls r0, 16 - asrs r0, 16 - str r0, [sp, 0x4] - ldrh r0, [r4, 0x2] - subs r1, r0 - lsls r1, 16 - asrs r1, 16 - str r1, [sp, 0x8] - movs r5, 0 - str r5, [sp, 0xC] - movs r0, 0x2 - adds r1, r2, 0 - movs r3, 0x78 - bl SetBgAffine - movs r1, 0x2 - ldrsh r0, [r4, r1] - cmp r0, 0xFF - ble _081D99B4 - strh r5, [r4, 0x2] - strh r5, [r4, 0x6] - strh r5, [r4, 0xA] - movs r0, 0x10 - strh r0, [r4, 0x8] - ldrh r0, [r4, 0x4] - adds r0, 0x1 - strh r0, [r4, 0x4] - b _081D99B4 -_081D99A4: - movs r1, 0x80 - lsls r1, 3 - movs r0, 0 - bl ClearGpuRegBits - adds r0, r5, 0 - bl DestroyTask -_081D99B4: - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81D98B4 - - - .align 2, 0 @ Don't pad with nop. diff --git a/include/graphics.h b/include/graphics.h index 37890fb966..02711009ab 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2700,5 +2700,11 @@ extern const u8 gRayChaseRayquazaChase_Tilemap[]; extern const u8 gRaySceneChaseStreaks_Tilemap[]; extern const u8 gRaySceneChaseBg_Tilemap[]; extern const u8 gRaySceneChase_Pal[]; +extern const u8 gRaySceneHushRing_Tilemap[]; +extern const u8 gRaySceneHushBg_Tilemap[]; +extern const u8 gRaySceneHushRing_Map[]; +extern const u8 gRaySceneHushBg_Pal[]; +extern const u8 gRaySceneHushBg_Gfx[]; +extern const u8 gRaySceneHushRing_Gfx[]; #endif //GUARD_GRAPHICS_H diff --git a/include/rayquaza_scene.h b/include/rayquaza_scene.h index e997c9db72..fe66b3df06 100644 --- a/include/rayquaza_scene.h +++ b/include/rayquaza_scene.h @@ -1,6 +1,8 @@ #ifndef GUARD_RAYQUAZA_SCENE_H #define GUARD_RAYQUAZA_SCENE_H +void DoRayquazaScene(u8 animId, bool8 onlyOneAnim, void (*callback)(void)); + enum { RAY_ANIM_DUO_FIGHT_PRE, diff --git a/ld_script.txt b/ld_script.txt index 8717296910..6013175d5a 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -269,7 +269,6 @@ SECTIONS { asm/pokemon_summary_screen.o(.text); asm/pokenav.o(.text); src/rayquaza_scene.o(.text); - asm/rayquaza_scene.o(.text); src/walda_phrase.o(.text); asm/contest_link_81D9DE4.o(.text); asm/trainer_rematch.o(.text); diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index 44c4d86f44..e326555788 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -14,28 +14,80 @@ #include "decompress.h" #include "sound.h" #include "constants/songs.h" +#include "constants/species.h" #include "constants/rgb.h" #include "random.h" -// this file's functions -void sub_81D7134(u8 taskId); -void sub_81D7F4C(u8 taskId); -void sub_81D84EC(u8 taskId); -void sub_81D8980(u8 taskId); -void sub_81D8DB4(u8 taskId); -void sub_81D857C(u8 taskId); -void sub_81D8684(u8 taskId); -void sub_81D89E0(u8 taskId); -void sub_81D8AD8(u8 taskId); -void sub_81D8B2C(u8 taskId); -void sub_81D8BEC(u8 taskId); -void Task_EndAfterFadeScreen(u8 taskId); +struct RaySceneStruct +{ + MainCallback callback; + u8 tilemapBuffers[4][0x800]; + u16 field_2004; // set but unused + u8 animId; + bool8 onlyOneAnim; + s16 field_2008; + s16 field_200A; + u8 unusedFields[12]; // completely unused +}; -void sub_81D8260(struct Sprite *sprite); -void sub_81D961C(struct Sprite *sprite); +// EWRAM vars +static EWRAM_DATA struct RaySceneStruct *sRayScene = NULL; + +// this file's functions +static void sub_81D7134(u8 taskId); +static void sub_81D7F4C(u8 taskId); +static void sub_81D84EC(u8 taskId); +static void sub_81D8980(u8 taskId); +static void sub_81D8DB4(u8 taskId); +static void sub_81D857C(u8 taskId); +static void sub_81D8684(u8 taskId); +static void sub_81D89E0(u8 taskId); +static void sub_81D8AD8(u8 taskId); +static void sub_81D8B2C(u8 taskId); +static void sub_81D8BEC(u8 taskId); +static void sub_81D8E80(u8 taskId); +static void sub_81D8FB0(u8 taskId); +static void sub_81D7228(u8 taskId); +static void sub_81D736C(u8 taskId); +static void sub_81D752C(u8 taskId); +static void sub_81D7600(u8 taskId); +static void sub_81D7FC0(u8 taskId); +static void sub_81D81A4(u8 taskId); +static void sub_81D8164(u8 taskId); +static void sub_81D94D4(u8 taskId); +static void sub_81D93D8(u8 taskId); +static void sub_81D9034(u8 taskId); +static void sub_81D90A8(u8 taskId); +static void sub_81D98B4(u8 taskId); +static void Task_EndAfterFadeScreen(u8 taskId); +static void sub_81D6774(void); +static void sub_81D67D0(void); +static void sub_81D750C(void); +static void sub_81D7438(void); +static void sub_81D7480(void); +static void sub_81D74C8(void); +static void sub_81D8BB4(void); +static void sub_81D6A20(struct Sprite *sprite); +static void sub_81D6D20(struct Sprite *sprite); +static void sub_81D7860(struct Sprite *sprite); +static void sub_81D7D14(struct Sprite *sprite); +static void sub_81D7700(struct Sprite *sprite); +static void sub_81D7A60(struct Sprite *sprite); +static void sub_81D874C(struct Sprite *sprite); +static void sub_81D9338(struct Sprite *sprite); +static void sub_81D9420(struct Sprite *sprite); +static void sub_81D8260(struct Sprite *sprite); +static void sub_81D961C(struct Sprite *sprite); +static void sub_81D97E0(struct Sprite *sprite); +static void sub_81D9528(struct Sprite *sprite); +static u8 sub_81D7664(void); +static u8 sub_81D78BC(void); +static u8 sub_81D86CC(void); +static void sub_81D75B4(u8 taskId, s8 palDelay); +static void sub_81D9868(struct Sprite *sprite, u8 animNum, s16 x, s16 y); // const rom data -const TaskFunc sTasksForAnimations[] = +static const TaskFunc sTasksForAnimations[] = { sub_81D7134, // RAY_ANIM_DUO_FIGHT_PRE sub_81D7134, // RAY_ANIM_DUO_FIGHT @@ -206,7 +258,7 @@ static const union AnimCmd *const sSpriteAnimTable_862A724[] = sSpriteAnim_862A710 }; -const struct SpriteTemplate gUnknown_0862A72C = +static const struct SpriteTemplate sUnknown_0862A72C = { .tileTag = 30505, .paletteTag = 30505, @@ -228,7 +280,7 @@ static const union AnimCmd *const sSpriteAnimTable_862A74C[] = sSpriteAnim_862A744 }; -const struct SpriteTemplate gUnknown_0862A750 = +static const struct SpriteTemplate sUnknown_0862A750 = { .tileTag = 30506, .paletteTag = 30505, @@ -250,7 +302,7 @@ static const union AnimCmd *const sSpriteAnimTable_862A770[] = sSpriteAnim_862A768 }; -const struct SpriteTemplate gUnknown_0862A774 = +static const struct SpriteTemplate sUnknown_0862A774 = { .tileTag = 30507, .paletteTag = 30505, @@ -337,7 +389,7 @@ static const union AnimCmd *const sSpriteAnimTable_862A7F8[] = sSpriteAnim_862A7E4 }; -const struct SpriteTemplate gUnknown_0862A81C = +static const struct SpriteTemplate sUnknown_0862A81C = { .tileTag = 30508, .paletteTag = 30508, @@ -362,7 +414,7 @@ static const union AnimCmd *const sSpriteAnimTable_862A848[] = sSpriteAnim_862A834 }; -const struct SpriteTemplate gUnknown_0862A84C = +static const struct SpriteTemplate sUnknown_0862A84C = { .tileTag = 30509, .paletteTag = 30508, @@ -373,7 +425,7 @@ const struct SpriteTemplate gUnknown_0862A84C = .callback = SpriteCallbackDummy, }; -const struct SpriteTemplate gUnknown_0862A864 = +static const struct SpriteTemplate sUnknown_0862A864 = { .tileTag = 30510, .paletteTag = 30508, @@ -384,14 +436,14 @@ const struct SpriteTemplate gUnknown_0862A864 = .callback = SpriteCallbackDummy, }; -const struct ScanlineEffectParams gUnknown_0862A87C = +static const struct ScanlineEffectParams sUnknown_0862A87C = { .dmaDest = (vu16 *)REG_ADDR_BG1HOFS, .dmaControl = 0xA2600001, .initState = 1 }; -const struct BgTemplate gUnknown_0862A888[] = +static const struct BgTemplate sUnknown_0862A888[] = { { .bg = 0, @@ -446,17 +498,17 @@ static const union AnimCmd *const sSpriteAnimTable_862A8BC[] = sSpriteAnim_862A8A8 }; -const struct CompressedSpriteSheet gUnknown_0862A8C4 = +static const struct CompressedSpriteSheet sUnknown_0862A8C4 = { gRaySceneGroudon_Gfx, 0x3000, 30505 }; -const struct CompressedSpritePalette gUnknown_0862A8CC = +static const struct CompressedSpritePalette sUnknown_0862A8CC = { gRaySceneGroudon_Pal, 30505 }; -const struct SpriteTemplate gUnknown_0862A8D4 = +static const struct SpriteTemplate sUnknown_0862A8D4 = { .tileTag = 30505, .paletteTag = 30505, @@ -478,12 +530,12 @@ static const union AnimCmd *const sSpriteAnimTable_862A8F4[] = sSpriteAnim_862A8EC }; -const struct CompressedSpriteSheet gUnknown_0862A8F8 = +static const struct CompressedSpriteSheet sUnknown_0862A8F8 = { gRaySceneGroudon2_Gfx, 0x200, 30506 }; -const struct SpriteTemplate gUnknown_0862A900 = +static const struct SpriteTemplate sUnknown_0862A900 = { .tileTag = 30506, .paletteTag = 30505, @@ -505,12 +557,12 @@ static const union AnimCmd *const sSpriteAnimTable_862A920[] = sSpriteAnim_862A918 }; -const struct CompressedSpriteSheet gUnknown_0862A924 = +static const struct CompressedSpriteSheet sUnknown_0862A924 = { gRaySceneGroudon3_Gfx, 0x400, 30507 }; -const struct SpriteTemplate gUnknown_0862A92C = +static const struct SpriteTemplate sUnknown_0862A92C = { .tileTag = 30507, .paletteTag = 30505, @@ -597,17 +649,17 @@ static const union AnimCmd *const sSpriteAnimTable_862A9B0[] = sSpriteAnim_862A99C }; -const struct CompressedSpriteSheet gUnknown_0862A9D4 = +static const struct CompressedSpriteSheet sUnknown_0862A9D4 = { gRaySceneKyogre_Gfx, 0xF00, 30508 }; -const struct CompressedSpritePalette gUnknown_0862A9DC = +static const struct CompressedSpritePalette sUnknown_0862A9DC = { gRaySceneKyogre_Pal, 30508 }; -const struct SpriteTemplate gUnknown_0862A9E4 = +static const struct SpriteTemplate sUnknown_0862A9E4 = { .tileTag = 30508, .paletteTag = 30508, @@ -632,12 +684,12 @@ static const union AnimCmd *const sSpriteAnimTable_862AA10[] = sSpriteAnim_862A9FC }; -const struct CompressedSpriteSheet gUnknown_0862AA14 = +static const struct CompressedSpriteSheet sUnknown_0862AA14 = { gRaySceneKyogre2_Gfx, 0xC0, 30509 }; -const struct SpriteTemplate gUnknown_0862AA1C = +static const struct SpriteTemplate sUnknown_0862AA1C = { .tileTag = 30509, .paletteTag = 30508, @@ -648,12 +700,12 @@ const struct SpriteTemplate gUnknown_0862AA1C = .callback = SpriteCallbackDummy, }; -const struct CompressedSpriteSheet gUnknown_0862AA34 = +static const struct CompressedSpriteSheet sUnknown_0862AA34 = { gRaySceneKyogre3_Gfx, 0x200, 30510 }; -const struct SpriteTemplate gUnknown_0862AA3C = +static const struct SpriteTemplate sUnknown_0862AA3C = { .tileTag = 30510, .paletteTag = 30508, @@ -664,7 +716,7 @@ const struct SpriteTemplate gUnknown_0862AA3C = .callback = SpriteCallbackDummy, }; -const struct BgTemplate gUnknown_0862AA54[] = +static const struct BgTemplate sUnknown_0862AA54[] = { { .bg = 0, @@ -719,17 +771,17 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_862AA8C[] = sSpriteAffineAnim_862AA6C }; -const struct CompressedSpriteSheet gUnknown_0862AA90 = +static const struct CompressedSpriteSheet sUnknown_0862AA90 = { gRaySceneSmoke_Gfx, 0x100, 30555 }; -const struct CompressedSpritePalette gUnknown_0862AA98 = +static const struct CompressedSpritePalette sUnknown_0862AA98 = { gRaySceneSmoke_Pal, 30555 }; -const struct SpriteTemplate gUnknown_0862AAA0 = +static const struct SpriteTemplate sUnknown_0862AAA0 = { .tileTag = 30555, .paletteTag = 30555, @@ -740,7 +792,7 @@ const struct SpriteTemplate gUnknown_0862AAA0 = .callback = sub_81D8260, }; -const s8 gUnknown_0862AAB8[][2] = +static const s8 sUnknown_0862AAB8[][2] = { {-1, 5}, {-3, -4}, @@ -754,7 +806,7 @@ const s8 gUnknown_0862AAB8[][2] = {9, 1} }; -const struct BgTemplate gUnknown_0862AACC[] = +static const struct BgTemplate sUnknown_0862AACC[] = { { .bg = 0, @@ -818,22 +870,22 @@ static const union AnimCmd *const sSpriteAnimTable_862AAF8[] = sSpriteAnim_862AAEC }; -const struct CompressedSpriteSheet gUnknown_0862AAFC = +static const struct CompressedSpriteSheet sUnknown_0862AAFC = { gRaySceneRayquazaFly1_Gfx, 0x1000, 30556 }; -const struct CompressedSpriteSheet gUnknown_0862AB04 = +static const struct CompressedSpriteSheet sUnknown_0862AB04 = { gRaySceneRayquazaTail_Gfx, 0x200, 30557 }; -const struct CompressedSpritePalette gUnknown_0862AB0C = +static const struct CompressedSpritePalette sUnknown_0862AB0C = { gRaySceneRayquaza_Pal, 30556 }; -const struct SpriteTemplate gUnknown_0862AB14 = +static const struct SpriteTemplate sUnknown_0862AB14 = { .tileTag = 30556, .paletteTag = 30556, @@ -844,7 +896,7 @@ const struct SpriteTemplate gUnknown_0862AB14 = .callback = SpriteCallbackDummy, }; -const struct SpriteTemplate gUnknown_0862AB2C = +static const struct SpriteTemplate sUnknown_0862AB2C = { .tileTag = 30557, .paletteTag = 30556, @@ -855,7 +907,7 @@ const struct SpriteTemplate gUnknown_0862AB2C = .callback = SpriteCallbackDummy, }; -const struct BgTemplate gUnknown_0862AB44[] = +static const struct BgTemplate sUnknown_0862AB44[] = { { .bg = 0, @@ -1032,57 +1084,57 @@ static const union AnimCmd *const sSpriteAnimTable_862AC24[] = sSpriteAnim_862AC08 }; -const struct CompressedSpriteSheet gUnknown_0862AC28 = +static const struct CompressedSpriteSheet sUnknown_0862AC28 = { gRaySceneGroudonLeft_Gfx, 0x1800, 30565 }; -const struct CompressedSpriteSheet gUnknown_0862AC30 = +static const struct CompressedSpriteSheet sUnknown_0862AC30 = { gRaySceneGroudonTail_Gfx, 0x80, 30566 }; -const struct CompressedSpriteSheet gUnknown_0862AC38 = +static const struct CompressedSpriteSheet sUnknown_0862AC38 = { gRaySceneKyogreRight_Gfx, 0x600, 30568 }; -const struct CompressedSpriteSheet gUnknown_0862AC40 = +static const struct CompressedSpriteSheet sUnknown_0862AC40 = { gRaySceneRayquazaHover_Gfx, 0x2000, 30569 }; -const struct CompressedSpriteSheet gUnknown_0862AC48 = +static const struct CompressedSpriteSheet sUnknown_0862AC48 = { gRaySceneRayquazaFlyIn_Gfx, 0x800, 30570 }; -const struct CompressedSpriteSheet gUnknown_0862AC50 = +static const struct CompressedSpriteSheet sUnknown_0862AC50 = { gRaySceneSplash_Gfx, 0x300, 30571 }; -const struct CompressedSpritePalette gUnknown_0862AC58 = +static const struct CompressedSpritePalette sUnknown_0862AC58 = { gRaySceneGroudonLeft_Pal, 30565 }; -const struct CompressedSpritePalette gUnknown_0862AC60 = +static const struct CompressedSpritePalette sUnknown_0862AC60 = { gRaySceneKyogreRight_Pal, 30568 }; -const struct CompressedSpritePalette gUnknown_0862AC68 = +static const struct CompressedSpritePalette sUnknown_0862AC68 = { gRaySceneRayquazaHover_Pal, 30569 }; -const struct CompressedSpritePalette gUnknown_0862AC70 = +static const struct CompressedSpritePalette sUnknown_0862AC70 = { gRaySceneSplash_Pal, 30571 }; -const struct SpriteTemplate gUnknown_0862AC78 = +static const struct SpriteTemplate sUnknown_0862AC78 = { .tileTag = 30565, .paletteTag = 30565, @@ -1093,7 +1145,7 @@ const struct SpriteTemplate gUnknown_0862AC78 = .callback = SpriteCallbackDummy, }; -const struct SpriteTemplate gUnknown_0862AC90 = +static const struct SpriteTemplate sUnknown_0862AC90 = { .tileTag = 30566, .paletteTag = 30565, @@ -1104,7 +1156,7 @@ const struct SpriteTemplate gUnknown_0862AC90 = .callback = SpriteCallbackDummy, }; -const struct SpriteTemplate gUnknown_0862ACA8 = +static const struct SpriteTemplate sUnknown_0862ACA8 = { .tileTag = 30568, .paletteTag = 30568, @@ -1115,7 +1167,7 @@ const struct SpriteTemplate gUnknown_0862ACA8 = .callback = SpriteCallbackDummy, }; -const struct SpriteTemplate gUnknown_0862ACC0 = +static const struct SpriteTemplate sUnknown_0862ACC0 = { .tileTag = 30569, .paletteTag = 30569, @@ -1126,7 +1178,7 @@ const struct SpriteTemplate gUnknown_0862ACC0 = .callback = sub_81D961C, }; -const struct SpriteTemplate gUnknown_0862ACD8 = +static const struct SpriteTemplate sUnknown_0862ACD8 = { .tileTag = 30570, .paletteTag = 30569, @@ -1137,7 +1189,7 @@ const struct SpriteTemplate gUnknown_0862ACD8 = .callback = SpriteCallbackDummy, }; -const struct SpriteTemplate gUnknown_0862ACF0 = +static const struct SpriteTemplate sUnknown_0862ACF0 = { .tileTag = 30571, .paletteTag = 30571, @@ -1148,7 +1200,7 @@ const struct SpriteTemplate gUnknown_0862ACF0 = .callback = SpriteCallbackDummy, }; -const struct BgTemplate gUnknown_0862AD08[] = +static const struct BgTemplate sUnknown_0862AD08[] = { { .bg = 0, @@ -1179,57 +1231,17 @@ const struct BgTemplate gUnknown_0862AD08[] = } }; -struct RaySceneStruct -{ - MainCallback callback; - u8 tilemapBuffers[4][0x800]; - u16 field_2004; - u8 animId; - bool8 onlyOneAnim; - s16 field_2008; - s16 field_200A; -}; - -extern struct RaySceneStruct *sRayScene; - -// this file's functions -void sub_81D6774(void); -void sub_81D67D0(void); -void sub_81D750C(void); -void sub_81D7438(void); -void sub_81D7480(void); -void sub_81D74C8(void); -void sub_81D8BB4(void); -void sub_81D75B4(u8 taskId, s8 palDelay); -void sub_81D6A20(struct Sprite *sprite); -void sub_81D6D20(struct Sprite *sprite); -void sub_81D7860(struct Sprite *sprite); -void sub_81D7D14(struct Sprite *sprite); -void sub_81D7700(struct Sprite *sprite); -void sub_81D7A60(struct Sprite *sprite); -void sub_81D874C(struct Sprite *sprite); -void sub_81D7228(u8 taskId); -void sub_81D736C(u8 taskId); -void sub_81D752C(u8 taskId); -void sub_81D7600(u8 taskId); -void sub_81D7FC0(u8 taskId); -void sub_81D81A4(u8 taskId); -void sub_81D8164(u8 taskId); -u8 sub_81D7664(void); -u8 sub_81D78BC(void); -u8 sub_81D86CC(void); - // code -void sub_81D6720(u8 animId, bool8 onlyOneAnim, MainCallback callback) +void DoRayquazaScene(u8 animId, bool8 onlyOneAnim, void (*callback)(void)) { - sRayScene = AllocZeroed(0x2018); + sRayScene = AllocZeroed(sizeof(*sRayScene)); sRayScene->animId = animId; sRayScene->callback = callback; sRayScene->onlyOneAnim = onlyOneAnim; SetMainCallback2(sub_81D6774); } -void sub_81D6774(void) +static void sub_81D6774(void) { SetVBlankHBlankCallbacksToNull(); clear_scheduled_bg_copies_to_vram(); @@ -1243,7 +1255,7 @@ void sub_81D6774(void) SetMainCallback2(sub_81D67D0); } -void sub_81D67D0(void) +static void sub_81D67D0(void) { RunTasks(); AnimateSprites(); @@ -1252,14 +1264,14 @@ void sub_81D67D0(void) UpdatePaletteFade(); } -void sub_81D67EC(void) +static void sub_81D67EC(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -void Task_EndAfterFadeScreen(u8 taskId) +static void Task_EndAfterFadeScreen(u8 taskId) { if (!gPaletteFade.active) { @@ -1271,7 +1283,7 @@ void Task_EndAfterFadeScreen(u8 taskId) } } -void Task_SetNextAnim(u8 taskId) +static void Task_SetNextAnim(u8 taskId) { if (!gPaletteFade.active) { @@ -1288,7 +1300,7 @@ void Task_SetNextAnim(u8 taskId) } } -void sub_81D68C8(void) +static void sub_81D68C8(void) { SetGpuReg(REG_OFFSET_WININ, 0x3F); SetGpuReg(REG_OFFSET_WINOUT, 0); @@ -1298,13 +1310,13 @@ void sub_81D68C8(void) gPlttBufferFaded[0] = 0; } -void sub_81D6904(void) +static void sub_81D6904(void) { SetGpuReg(REG_OFFSET_WININ, 0x3F); SetGpuReg(REG_OFFSET_WINOUT, 0x3F); } -void sub_81D691C(u8 taskId) +static void sub_81D691C(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D750C(); @@ -1336,22 +1348,22 @@ void sub_81D691C(u8 taskId) } } -u8 sub_81D6984(void) +static u8 sub_81D6984(void) { u8 spriteId; s16 *data; - spriteId = CreateSprite(&gUnknown_0862A72C, 88, 72, 3); + spriteId = CreateSprite(&sUnknown_0862A72C, 88, 72, 3); gSprites[spriteId].callback = sub_81D6A20; data = gSprites[spriteId].data; - data[0] = CreateSprite(&gUnknown_0862A72C, 56, 104, 3); - data[1] = CreateSprite(&gUnknown_0862A750, 75, 101, 0); - data[2] = CreateSprite(&gUnknown_0862A774, 109, 114, 1); + data[0] = CreateSprite(&sUnknown_0862A72C, 56, 104, 3); + data[1] = CreateSprite(&sUnknown_0862A750, 75, 101, 0); + data[2] = CreateSprite(&sUnknown_0862A774, 109, 114, 1); StartSpriteAnim(&gSprites[data[0]], 1); return spriteId; } -void sub_81D6A20(struct Sprite *sprite) +static void sub_81D6A20(struct Sprite *sprite) { s16 *data = sprite->data; data[5]++; @@ -1388,25 +1400,25 @@ void sub_81D6A20(struct Sprite *sprite) } } -u8 sub_81D6B7C(void) +static u8 sub_81D6B7C(void) { u8 spriteId; s16 *data; - spriteId = CreateSprite(&gUnknown_0862A81C, 136, 96, 1); + spriteId = CreateSprite(&sUnknown_0862A81C, 136, 96, 1); gSprites[spriteId].callback = sub_81D6D20; data = gSprites[spriteId].data; - data[0] = CreateSprite(&gUnknown_0862A81C, 168, 96, 1) << 8; - data[0] |= CreateSprite(&gUnknown_0862A81C, 136, 112, 1); - data[1] = CreateSprite(&gUnknown_0862A81C, 168, 112, 1) << 8; - data[1] |= CreateSprite(&gUnknown_0862A81C, 136, 128, 1); - data[2] = CreateSprite(&gUnknown_0862A81C, 168, 128, 1) << 8; - data[2] |= CreateSprite(&gUnknown_0862A81C, 104, 128, 2); - data[3] = CreateSprite(&gUnknown_0862A81C, 136, 128, 2) << 8; - data[3] |= CreateSprite(&gUnknown_0862A81C, 184, 128, 0); - data[4] = CreateSprite(&gUnknown_0862A84C, 208, 132, 0) << 8; - data[4] |= CreateSprite(&gUnknown_0862A864, 200, 120, 1); + data[0] = CreateSprite(&sUnknown_0862A81C, 168, 96, 1) << 8; + data[0] |= CreateSprite(&sUnknown_0862A81C, 136, 112, 1); + data[1] = CreateSprite(&sUnknown_0862A81C, 168, 112, 1) << 8; + data[1] |= CreateSprite(&sUnknown_0862A81C, 136, 128, 1); + data[2] = CreateSprite(&sUnknown_0862A81C, 168, 128, 1) << 8; + data[2] |= CreateSprite(&sUnknown_0862A81C, 104, 128, 2); + data[3] = CreateSprite(&sUnknown_0862A81C, 136, 128, 2) << 8; + data[3] |= CreateSprite(&sUnknown_0862A81C, 184, 128, 0); + data[4] = CreateSprite(&sUnknown_0862A84C, 208, 132, 0) << 8; + data[4] |= CreateSprite(&sUnknown_0862A864, 200, 120, 1); StartSpriteAnim(&gSprites[data[0] >> 8], 1); StartSpriteAnim(&gSprites[data[0] & 0xFF], 2); @@ -1420,7 +1432,7 @@ u8 sub_81D6B7C(void) return spriteId; } -void sub_81D6D20(struct Sprite *sprite) +static void sub_81D6D20(struct Sprite *sprite) { s16 *data = sprite->data; data[5]++; @@ -1481,17 +1493,17 @@ void sub_81D6D20(struct Sprite *sprite) } } -void sub_81D6FD0(void) +static void sub_81D6FD0(void) { sub_81D67EC(); ScanlineEffect_InitHBlankDmaTransfer(); } -void sub_81D6FE0(void) +static void sub_81D6FE0(void) { ResetVramOamAndBgCntRegs(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0862A888, ARRAY_COUNT(gUnknown_0862A888)); + InitBgsFromTemplates(0, sUnknown_0862A888, ARRAY_COUNT(sUnknown_0862A888)); SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); @@ -1506,7 +1518,7 @@ void sub_81D6FE0(void) SetGpuReg(REG_OFFSET_BLDCNT, 0); } -void sub_81D706C(void) +static void sub_81D706C(void) { reset_temp_tile_data_buffers(); decompress_and_copy_tile_data_to_vram(0, gRaySceneClouds_Gfx, 0, 0, 0); @@ -1516,24 +1528,24 @@ void sub_81D706C(void) LZDecompressWram(gRaySceneClouds1_Tilemap, sRayScene->tilemapBuffers[1]); LZDecompressWram(gRaySceneClouds3_Tilemap, sRayScene->tilemapBuffers[2]); LoadCompressedPalette(gRaySceneClouds_Pal, 0, 0x40); - LoadCompressedObjectPic(&gUnknown_0862A8C4); - LoadCompressedObjectPic(&gUnknown_0862A8F8); - LoadCompressedObjectPic(&gUnknown_0862A924); - LoadCompressedObjectPic(&gUnknown_0862A9D4); - LoadCompressedObjectPic(&gUnknown_0862AA14); - LoadCompressedObjectPic(&gUnknown_0862AA34); - LoadCompressedObjectPalette(&gUnknown_0862A8CC); - LoadCompressedObjectPalette(&gUnknown_0862A9DC); + LoadCompressedObjectPic(&sUnknown_0862A8C4); + LoadCompressedObjectPic(&sUnknown_0862A8F8); + LoadCompressedObjectPic(&sUnknown_0862A924); + LoadCompressedObjectPic(&sUnknown_0862A9D4); + LoadCompressedObjectPic(&sUnknown_0862AA14); + LoadCompressedObjectPic(&sUnknown_0862AA34); + LoadCompressedObjectPalette(&sUnknown_0862A8CC); + LoadCompressedObjectPalette(&sUnknown_0862A9DC); } -void sub_81D7134(u8 taskId) +static void sub_81D7134(u8 taskId) { s16 *data = gTasks[taskId].data; ScanlineEffect_Clear(); sub_81D6FE0(); sub_81D706C(); CpuFastFill16(0, gScanlineEffectRegBuffers, sizeof(gScanlineEffectRegBuffers)); - ScanlineEffect_SetParams(gUnknown_0862A87C); + ScanlineEffect_SetParams(sUnknown_0862A87C); data[0] = 0; data[1] = CreateTask(sub_81D7228, 0); if (sRayScene->animId == RAY_ANIM_DUO_FIGHT_PRE) @@ -1556,7 +1568,7 @@ void sub_81D7134(u8 taskId) PlaySE(SE_T_OOAME); } -void sub_81D7228(u8 taskId) +static void sub_81D7228(u8 taskId) { s16 i; u16 *data = gTasks[taskId].data; @@ -1615,7 +1627,7 @@ void sub_81D7228(u8 taskId) } } -void sub_81D736C(u8 taskId) +static void sub_81D736C(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D750C(); @@ -1656,33 +1668,33 @@ void sub_81D736C(u8 taskId) } } -void sub_81D7438(void) +static void sub_81D7438(void) { PlaySE(SE_T_KAMI); sub_80A2C44(0x7FFF, 0, 0x10, 0, -1, 0, 0); sub_80A2C44(0xFFFF0000, 0, 0x10, 0, 0, 0, 1); } -void sub_81D7480(void) +static void sub_81D7480(void) { PlaySE(SE_T_KAMI); sub_80A2C44(0x7FFF, 0, 0x10, 0x10, -1, 0, 0); sub_80A2C44(0xFFFF0000, 0, 0x10, 0x10, 0, 0, 1); } -void sub_81D74C8(void) +static void sub_81D74C8(void) { sub_80A2C44(0x7FFF, 4, 0x10, 0, -1, 0, 0); sub_80A2C44(0xFFFF0000, 4, 0x10, 0, 0, 0, 1); } -void sub_81D750C(void) +static void sub_81D750C(void) { ChangeBgX(2, 0x400, 1); ChangeBgY(2, 0x800, 2); } -void sub_81D752C(u8 taskId) +static void sub_81D752C(u8 taskId) { u16 bgY; s16 *data = gTasks[taskId].data; @@ -1700,14 +1712,14 @@ void sub_81D752C(u8 taskId) } } -void sub_81D75B4(u8 taskId, s8 palDelay) +static void sub_81D75B4(u8 taskId, s8 palDelay) { PlaySE(SE_T_OOAME_E); BeginNormalPaletteFade(-1, palDelay, 0, 0x10, 0); gTasks[taskId].func = sub_81D7600; } -void sub_81D7600(u8 taskId) +static void sub_81D7600(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D750C(); @@ -1724,22 +1736,22 @@ void sub_81D7600(u8 taskId) } } -u8 sub_81D7664(void) +static u8 sub_81D7664(void) { u8 spriteId; s16 *data; - spriteId = CreateSprite(&gUnknown_0862A8D4, 98, 72, 3); + spriteId = CreateSprite(&sUnknown_0862A8D4, 98, 72, 3); gSprites[spriteId].callback = sub_81D7700; data = gSprites[spriteId].data; - data[0] = CreateSprite(&gUnknown_0862A8D4, 66, 104, 3); - data[1] = CreateSprite(&gUnknown_0862A900, 85, 101, 0); - data[2] = CreateSprite(&gUnknown_0862A92C, 119, 114, 1); + data[0] = CreateSprite(&sUnknown_0862A8D4, 66, 104, 3); + data[1] = CreateSprite(&sUnknown_0862A900, 85, 101, 0); + data[2] = CreateSprite(&sUnknown_0862A92C, 119, 114, 1); StartSpriteAnim(&gSprites[data[0]], 1); return spriteId; } -void sub_81D7700(struct Sprite *sprite) +static void sub_81D7700(struct Sprite *sprite) { s16 *data = sprite->data; data[5]++; @@ -1776,7 +1788,7 @@ void sub_81D7700(struct Sprite *sprite) } } -void sub_81D7860(struct Sprite *sprite) +static void sub_81D7860(struct Sprite *sprite) { s16 *data = sprite->data; if (sprite->pos1.y <= 160) @@ -1788,25 +1800,25 @@ void sub_81D7860(struct Sprite *sprite) } } -u8 sub_81D78BC(void) +static u8 sub_81D78BC(void) { u8 spriteId; s16 *data; - spriteId = CreateSprite(&gUnknown_0862A9E4, 126, 96, 1); + spriteId = CreateSprite(&sUnknown_0862A9E4, 126, 96, 1); gSprites[spriteId].callback = sub_81D7A60; data = gSprites[spriteId].data; - data[0] = CreateSprite(&gUnknown_0862A9E4, 158, 96, 1) << 8; - data[0] |= CreateSprite(&gUnknown_0862A9E4, 126, 112, 1); - data[1] = CreateSprite(&gUnknown_0862A9E4, 158, 112, 1) << 8; - data[1] |= CreateSprite(&gUnknown_0862A9E4, 126, 128, 1); - data[2] = CreateSprite(&gUnknown_0862A9E4, 158, 128, 1) << 8; - data[2] |= CreateSprite(&gUnknown_0862A9E4, 94, 128, 2); - data[3] = CreateSprite(&gUnknown_0862A9E4, 126, 128, 2) << 8; - data[3] |= CreateSprite(&gUnknown_0862A9E4, 174, 128, 0); - data[4] = CreateSprite(&gUnknown_0862AA1C, 198, 132, 0) << 8; - data[4] |= CreateSprite(&gUnknown_0862AA3C, 190, 120, 1); + data[0] = CreateSprite(&sUnknown_0862A9E4, 158, 96, 1) << 8; + data[0] |= CreateSprite(&sUnknown_0862A9E4, 126, 112, 1); + data[1] = CreateSprite(&sUnknown_0862A9E4, 158, 112, 1) << 8; + data[1] |= CreateSprite(&sUnknown_0862A9E4, 126, 128, 1); + data[2] = CreateSprite(&sUnknown_0862A9E4, 158, 128, 1) << 8; + data[2] |= CreateSprite(&sUnknown_0862A9E4, 94, 128, 2); + data[3] = CreateSprite(&sUnknown_0862A9E4, 126, 128, 2) << 8; + data[3] |= CreateSprite(&sUnknown_0862A9E4, 174, 128, 0); + data[4] = CreateSprite(&sUnknown_0862AA1C, 198, 132, 0) << 8; + data[4] |= CreateSprite(&sUnknown_0862AA3C, 190, 120, 1); StartSpriteAnim(&gSprites[data[0] >> 8], 1); StartSpriteAnim(&gSprites[data[0] & 0xFF], 2); @@ -1820,7 +1832,7 @@ u8 sub_81D78BC(void) return spriteId; } -void sub_81D7A60(struct Sprite *sprite) +static void sub_81D7A60(struct Sprite *sprite) { s16 *data = sprite->data; data[5]++; @@ -1881,7 +1893,7 @@ void sub_81D7A60(struct Sprite *sprite) } } -void sub_81D7D14(struct Sprite *sprite) +static void sub_81D7D14(struct Sprite *sprite) { s16 *data = sprite->data; if (sprite->pos1.y <= 160) @@ -1900,11 +1912,11 @@ void sub_81D7D14(struct Sprite *sprite) } } -void sub_81D7E10(void) +static void sub_81D7E10(void) { ResetVramOamAndBgCntRegs(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(1, gUnknown_0862AA54, ARRAY_COUNT(gUnknown_0862AA54)); + InitBgsFromTemplates(1, sUnknown_0862AA54, ARRAY_COUNT(sUnknown_0862AA54)); SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); @@ -1919,7 +1931,7 @@ void sub_81D7E10(void) SetGpuReg(REG_OFFSET_BLDCNT, 0); } -void sub_81D7E9C(void) +static void sub_81D7E9C(void) { reset_temp_tile_data_buffers(); decompress_and_copy_tile_data_to_vram(0, gRaySceneClouds_Gfx, 0, 0, 0); @@ -1931,11 +1943,11 @@ void sub_81D7E9C(void) LZDecompressWram(gRaySceneOvercast_Tilemap, sRayScene->tilemapBuffers[1]); LZDecompressWram(gRaySceneRayquaza_Tilemap, sRayScene->tilemapBuffers[2]); LoadCompressedPalette(gRaySceneRayquaza_Pal, 0, 0x40); - LoadCompressedObjectPic(&gUnknown_0862AA90); - LoadCompressedObjectPalette(&gUnknown_0862AA98); + LoadCompressedObjectPic(&sUnknown_0862AA90); + LoadCompressedObjectPalette(&sUnknown_0862AA98); } -void sub_81D7F4C(u8 taskId) +static void sub_81D7F4C(u8 taskId) { s16 *data = gTasks[taskId].data; PlayNewMapMusic(MUS_REKKUU_KOURIN); @@ -1951,7 +1963,7 @@ void sub_81D7F4C(u8 taskId) gTasks[taskId].func = sub_81D7FC0; } -void sub_81D7FC0(u8 taskId) +static void sub_81D7FC0(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) @@ -2012,7 +2024,7 @@ void sub_81D7FC0(u8 taskId) } } -void sub_81D8164(u8 taskId) +static void sub_81D8164(u8 taskId) { if (!gPaletteFade.active) { @@ -2023,14 +2035,14 @@ void sub_81D8164(u8 taskId) } } -void sub_81D81A4(u8 taskId) +static void sub_81D81A4(u8 taskId) { s16 *data = gTasks[taskId].data; if ((data[1] & 3) == 0) { - u8 spriteId = CreateSprite(&gUnknown_0862AAA0, - (gUnknown_0862AAB8[data[0]][0] * 4) + 120, - (gUnknown_0862AAB8[data[0]][1] * 4) + 80, + u8 spriteId = CreateSprite(&sUnknown_0862AAA0, + (sUnknown_0862AAB8[data[0]][0] * 4) + 120, + (sUnknown_0862AAB8[data[0]][1] * 4) + 80, 0); gSprites[spriteId].data[0] = (s8)(data[0]); gSprites[spriteId].oam.objMode = 1; @@ -2051,7 +2063,7 @@ void sub_81D81A4(u8 taskId) data[1]++; } -void sub_81D8260(struct Sprite *sprite) +static void sub_81D8260(struct Sprite *sprite) { if (sprite->data[1] == 0) { @@ -2060,19 +2072,19 @@ void sub_81D8260(struct Sprite *sprite) } else { - sprite->pos2.x += gUnknown_0862AAB8[sprite->data[0]][0]; - sprite->pos2.y += gUnknown_0862AAB8[sprite->data[0]][1]; + sprite->pos2.x += sUnknown_0862AAB8[sprite->data[0]][0]; + sprite->pos2.y += sUnknown_0862AAB8[sprite->data[0]][1]; } sprite->data[1]++; sprite->data[1] &= 0xF; } -void sub_81D82B0(void) +static void sub_81D82B0(void) { ResetVramOamAndBgCntRegs(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0862AACC, ARRAY_COUNT(gUnknown_0862AACC)); + InitBgsFromTemplates(0, sUnknown_0862AACC, ARRAY_COUNT(sUnknown_0862AACC)); SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); @@ -2090,7 +2102,7 @@ void sub_81D82B0(void) SetGpuReg(REG_OFFSET_BLDCNT, 0); } -void sub_81D8358(void) +static void sub_81D8358(void) { reset_temp_tile_data_buffers(); decompress_and_copy_tile_data_to_vram(0, gRaySceneRayquazaLight_Gfx, 0, 0, 0); @@ -2106,12 +2118,12 @@ void sub_81D8358(void) LoadCompressedPalette(gRaySceneOvercast2_Pal, 0, 0x40); gPlttBufferUnfaded[0] = RGB_WHITE; gPlttBufferFaded[0] = RGB_WHITE; - LoadCompressedObjectPic(&gUnknown_0862AAFC); - LoadCompressedObjectPic(&gUnknown_0862AB04); - LoadCompressedObjectPalette(&gUnknown_0862AB0C); + LoadCompressedObjectPic(&sUnknown_0862AAFC); + LoadCompressedObjectPic(&sUnknown_0862AB04); + LoadCompressedObjectPalette(&sUnknown_0862AB0C); } -void sub_81D844C(void) +static void sub_81D844C(void) { u16 VCOUNT = GetGpuReg(REG_OFFSET_VCOUNT); if (VCOUNT >= 24 && VCOUNT <= 135 && VCOUNT - 24 <= sRayScene->field_2008) @@ -2135,7 +2147,7 @@ void sub_81D844C(void) } } -void sub_81D84EC(u8 taskId) +static void sub_81D84EC(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D82B0(); @@ -2154,7 +2166,7 @@ void sub_81D84EC(u8 taskId) gTasks[taskId].func = sub_81D857C; } -void sub_81D857C(u8 taskId) +static void sub_81D857C(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) @@ -2213,7 +2225,7 @@ void sub_81D857C(u8 taskId) } } -void sub_81D8684(u8 taskId) +static void sub_81D8684(u8 taskId) { if (!gPaletteFade.active) { @@ -2225,18 +2237,18 @@ void sub_81D8684(u8 taskId) } } -u8 sub_81D86CC(void) +static u8 sub_81D86CC(void) { - u8 spriteId = CreateSprite(&gUnknown_0862AB14, 160, 0, 0); + u8 spriteId = CreateSprite(&sUnknown_0862AB14, 160, 0, 0); s16 *data = gSprites[spriteId].data; - data[0] = CreateSprite(&gUnknown_0862AB2C, 184, -48, 0); + data[0] = CreateSprite(&sUnknown_0862AB2C, 184, -48, 0); gSprites[spriteId].callback = sub_81D874C; gSprites[spriteId].oam.priority = 3; gSprites[data[0]].oam.priority = 3; return spriteId; } -void sub_81D874C(struct Sprite *sprite) +static void sub_81D874C(struct Sprite *sprite) { s16 *data = sprite->data; s16 counter = data[2]; @@ -2290,11 +2302,11 @@ void sub_81D874C(struct Sprite *sprite) data[2]++; } -void sub_81D8828(void) +static void sub_81D8828(void) { ResetVramOamAndBgCntRegs(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0862AB44, ARRAY_COUNT(gUnknown_0862AB44)); + InitBgsFromTemplates(0, sUnknown_0862AB44, ARRAY_COUNT(sUnknown_0862AB44)); SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); @@ -2312,7 +2324,7 @@ void sub_81D8828(void) SetGpuReg(REG_OFFSET_BLDCNT, 0); } -void sub_81D88D0(void) +static void sub_81D88D0(void) { reset_temp_tile_data_buffers(); decompress_and_copy_tile_data_to_vram(1, gRaySceneRayquazaChase_Gfx, 0, 0, 0); @@ -2327,7 +2339,7 @@ void sub_81D88D0(void) LoadCompressedPalette(gRaySceneChase_Pal, 0, 0x80); } -void sub_81D8980(u8 taskId) +static void sub_81D8980(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D8828(); @@ -2341,7 +2353,7 @@ void sub_81D8980(u8 taskId) gTasks[taskId].func = sub_81D89E0; } -void sub_81D89E0(u8 taskId) +static void sub_81D89E0(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D8BB4(); @@ -2393,7 +2405,7 @@ void sub_81D89E0(u8 taskId) } } -void sub_81D8AD8(u8 taskId) +static void sub_81D8AD8(u8 taskId) { s16 *data = gTasks[taskId].data; if ((data[15] & 3) == 0) @@ -2405,7 +2417,7 @@ void sub_81D8AD8(u8 taskId) data[15]++; } -void sub_81D8B2C(u8 taskId) +static void sub_81D8B2C(u8 taskId) { s16 *data = gTasks[taskId].data; if (data[0] == 0) @@ -2426,7 +2438,7 @@ void sub_81D8B2C(u8 taskId) } } -void sub_81D8BB4(void) +static void sub_81D8BB4(void) { ChangeBgX(2, 0x400, 2); ChangeBgY(2, 0x400, 1); @@ -2434,7 +2446,7 @@ void sub_81D8BB4(void) ChangeBgY(0, 0x800, 1); } -void sub_81D8BEC(u8 taskId) +static void sub_81D8BEC(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D8BB4(); @@ -2446,3 +2458,475 @@ void sub_81D8BEC(u8 taskId) gTasks[taskId].func = Task_SetNextAnim; } } + +static void sub_81D8C38(void) +{ + ResetVramOamAndBgCntRegs(); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(1, sUnknown_0862AD08, ARRAY_COUNT(sUnknown_0862AD08)); + SetBgTilemapBuffer(0, sRayScene->tilemapBuffers[0]); + SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); + SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); + ResetAllBgsCoordinates(); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); + schedule_bg_copy_tilemap_to_vram(2); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_WIN0_ON); + ShowBg(0); + ShowBg(1); + ShowBg(2); + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +static void sub_81D8CC4(void) +{ + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(2, gRaySceneHushRing_Gfx, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(0, gRaySceneHushBg_Gfx, 0, 0, 0); + while (free_temp_tile_data_buffers_if_possible()); + + LZDecompressWram(gRaySceneHushRing_Tilemap, sRayScene->tilemapBuffers[1]); + LZDecompressWram(gRaySceneHushBg_Tilemap, sRayScene->tilemapBuffers[0]); + LZDecompressWram(gRaySceneHushRing_Map, sRayScene->tilemapBuffers[2]); + LoadCompressedPalette(gRaySceneHushBg_Pal, 0, 0x60); + LoadCompressedObjectPic(&sUnknown_0862AC28); + LoadCompressedObjectPic(&sUnknown_0862AC30); + LoadCompressedObjectPic(&sUnknown_0862AC38); + LoadCompressedObjectPic(&sUnknown_0862AC40); + LoadCompressedObjectPic(&sUnknown_0862AC48); + LoadCompressedObjectPic(&sUnknown_0862AC50); + LoadCompressedObjectPalette(&sUnknown_0862AC58); + LoadCompressedObjectPalette(&sUnknown_0862AC60); + LoadCompressedObjectPalette(&sUnknown_0862AC68); + LoadCompressedObjectPalette(&sUnknown_0862AC70); +} + +static void sub_81D8DB4(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + sub_81D8C38(); + sub_81D8CC4(); + sub_81D68C8(); + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON); + SetGpuReg(REG_OFFSET_BLDCNT, 0x241); + SetGpuReg(REG_OFFSET_BLDALPHA, 0xE09); + BlendPalettes(-1, 0x10, 0); + SetVBlankCallback(sub_81D67EC); + data[0] = 0; + data[1] = 0; + gTasks[taskId].func = sub_81D8E80; + data[2] = CreateTask(sub_81D8FB0, 0); + gTasks[data[2]].data[0] = 0; + gTasks[data[2]].data[1] = 0; + gTasks[data[2]].data[2] = 0; + gTasks[data[2]].data[3] = 1; + gTasks[data[2]].data[4] = 1; +} + +static void sub_81D8E80(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + switch (data[0]) + { + case 0: + if (data[1] == 8) + { + sub_81D90A8(taskId); + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + data[1] = 0; + data[0]++; + } + else + { + data[1]++; + } + break; + case 1: + if (gSprites[data[5]].callback == sub_81D97E0) + { + if (data[1] == 64) + { + sub_81D94D4(taskId); + sub_81D93D8(taskId); + data[1] = 0; + data[0]++; + } + else + { + data[1]++; + } + } + break; + case 2: + if (data[1] == 448) + { + data[1] = 0; + data[0]++; + } + else + { + data[1]++; + if (data[1] % 144 == 0) + { + sub_80A2C44(0xFFFE, 0, 0x10, 0, -1, 0, 0); + sub_80A2C44(0xFFFF0000, 0, 0x10, 0, 0, 0, 1); + } + } + break; + case 3: + BeginNormalPaletteFade(-1, 4, 0, 0x10, 0); + gTasks[taskId].func = sub_81D9034; + break; + } +} + +static void sub_81D8FB0(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if ((data[0] & 0xF) == 0) + { + SetGpuReg(REG_OFFSET_BLDALPHA, ((data[1] + 14) << 8 & 0x1F00) | ((data[2] + 9) & 0xF)); + data[1] -= data[3]; + data[2] += data[4]; + if (data[1] == -3 || data[1] == 0) + data[3] *= -1; + if (data[2] == 3 || data[2] == 0) + data[4] *= -1; + } + + data[0]++; +} + +static void sub_81D9034(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if (!gPaletteFade.active) + { + StopMapMusic(); + if (data[1] == 0) + { + SetVBlankCallback(NULL); + sub_81D6904(); + ResetSpriteData(); + FreeAllSpritePalettes(); + DestroyTask(data[2]); + } + + if (data[1] == 32) + { + data[1] = 0; + gTasks[taskId].func = Task_SetNextAnim; + } + else + { + data[1]++; + } + } +} + +static void sub_81D90A8(u8 taskId) +{ + s16 *taskData, *spriteData; + + taskData = gTasks[taskId].data; + + taskData[3] = CreateSprite(&sUnknown_0862AC78, 64, 120, 0); + spriteData = gSprites[taskData[3]].data; + spriteData[0] = CreateSprite(&sUnknown_0862AC90, 16, 130, 0); + gSprites[taskData[3]].oam.priority = 1; + gSprites[spriteData[0]].oam.priority = 1; + + taskData[4] = CreateSprite(&sUnknown_0862ACA8, 160, 128, 1); + spriteData = gSprites[taskData[4]].data; + spriteData[0] = CreateSprite(&sUnknown_0862ACA8, 192, 128, 1); + spriteData[1] = CreateSprite(&sUnknown_0862ACA8, 224, 128, 1); + gSprites[taskData[4]].oam.priority = 1; + gSprites[spriteData[0]].oam.priority = 1; + gSprites[spriteData[1]].oam.priority = 1; + StartSpriteAnim(&gSprites[spriteData[0]], 1); + StartSpriteAnim(&gSprites[spriteData[1]], 2); + + taskData[5] = CreateSprite(&sUnknown_0862ACC0, 120, -65, 0); + spriteData = gSprites[taskData[5]].data; + spriteData[0] = CreateSprite(&sUnknown_0862ACD8, 120, -113, 0); + gSprites[taskData[5]].oam.priority = 1; + gSprites[spriteData[0]].oam.priority = 1; +} + +static void sub_81D9274(u8 taskId) +{ + s16 *taskData = gTasks[taskId].data; + + gSprites[taskData[3]].callback = sub_81D9338; + gSprites[taskData[3]].data[4] = 0; + gSprites[taskData[3]].data[5] = 0; + gSprites[taskData[3]].data[6] = 4; + gSprites[taskData[3]].data[7] = 0; + + gSprites[taskData[4]].callback = sub_81D9338; + gSprites[taskData[4]].data[4] = 0; + gSprites[taskData[4]].data[5] = 0; + gSprites[taskData[4]].data[6] = 4; + gSprites[taskData[4]].data[7] = 1; +} + +static void sub_81D9338(struct Sprite *sprite) +{ + if ((sprite->data[4] & 7) == 0) + { + if (sprite->data[7] == 0) + { + sprite->pos1.x -= sprite->data[6]; + gSprites[sprite->data[0]].pos1.x -= sprite->data[6]; + } + else + { + sprite->pos1.x += sprite->data[6]; + gSprites[sprite->data[0]].pos1.x += sprite->data[6]; + gSprites[sprite->data[1]].pos1.x += sprite->data[6]; + } + + sprite->data[5]++; + sprite->data[6] -= sprite->data[5]; + if (sprite->data[5] == 3) + { + sprite->data[4] = 0; + sprite->data[5] = 0; + sprite->data[6] = 0; + sprite->callback = SpriteCallbackDummy; + return; + } + } + + sprite->data[4]++; +} + +static void sub_81D93D8(u8 taskId) +{ + s16 *taskData = gTasks[taskId].data; + gSprites[taskData[3]].callback = sub_81D9420; + StartSpriteAnim(&gSprites[taskData[3]], 1); +} + +static void sub_81D9420(struct Sprite *sprite) +{ + switch (sprite->animCmdIndex) + { + case 0: + case 2: + if (sprite->animDelayCounter % 12 == 0) + { + sprite->pos1.x -= 2; + gSprites[sprite->data[0]].pos1.x -=2; + } + gSprites[sprite->data[0]].pos2.y = 0; + break; + case 1: + case 3: + gSprites[sprite->data[0]].pos2.y = -2; + if ((sprite->animDelayCounter & 15) == 0) + { + sprite->pos1.y++; + gSprites[sprite->data[0]].pos1.y++; + } + break; + } +} + +static void sub_81D94D4(u8 taskId) +{ + s16 *taskData, *spriteData; + + taskData = gTasks[taskId].data; + spriteData = gSprites[taskData[4]].data; + + gSprites[taskData[4]].callback = sub_81D9528; + gSprites[spriteData[0]].callback = sub_81D9528; + gSprites[spriteData[1]].callback = sub_81D9528; +} + +static void sub_81D9528(struct Sprite *sprite) +{ + if ((sprite->data[4] & 3) == 0) + { + if (sprite->pos2.x == 1) + sprite->pos2.x = -1; + else + sprite->pos2.x = 1; + } + if (sprite->data[5] == 128) + { + sprite->data[7] = CreateSprite(&sUnknown_0862ACF0, 152, 132, 0); + gSprites[sprite->data[7]].oam.priority = 1; + sprite->data[7] = CreateSprite(&sUnknown_0862ACF0, 224, 132, 0); + gSprites[sprite->data[7]].oam.priority = 1; + gSprites[sprite->data[7]].hFlip = 1; + sprite->data[5]++; + } + if (sprite->data[5] > 127) + { + if (sprite->pos2.y != 32) + { + sprite->data[6]++; + sprite->pos2.y = sprite->data[6] >> 4; + } + } + else + { + sprite->data[5]++; + } + + if (sprite->data[4] % 64 == 0) + PlaySE(SE_W250); + + sprite->data[4]++; +} + +static void sub_81D961C(struct Sprite *sprite) +{ + s16 counter = sprite->data[7]; + if (counter <= 64) + { + sprite->pos2.y += 2; + gSprites[sprite->data[0]].pos2.y += 2; + if (sprite->data[7] == 64) + { + sub_81D9868(sprite, 1, 0, -48); + sprite->data[4] = 5; + sprite->data[5] = -1; + gSprites[sprite->data[0]].data[4] = 3; + gSprites[sprite->data[0]].data[5] = 5; + } + } + else if (counter <= 111) + { + sub_81D97E0(sprite); + if (sprite->data[4] == 0) + PlaySE(SE_BT_START); + if (sprite->data[4] == -3) + sub_81D9868(sprite, 2, 48, 16); + } + else if (counter == 112) + { + gSprites[sprite->data[0]].data[4] = 7; + gSprites[sprite->data[0]].data[5] = 3; + sub_81D97E0(sprite); + } + else if (counter <= 327) + { + sub_81D97E0(sprite); + } + else if (counter == 328) + { + sub_81D97E0(sprite); + sub_81D9868(sprite, 3, 48, 16); + sprite->pos2.x = 1; + gSprites[sprite->data[0]].pos2.x = 1; + PlayCry1(SPECIES_RAYQUAZA, 0); + CreateTask(sub_81D98B4, 0); + } + else + { + switch (counter) + { + case 376: + sprite->pos2.x = 0; + gSprites[sprite->data[0]].pos2.x = 0; + sub_81D97E0(sprite); + sub_81D9868(sprite, 2, 48, 16); + sprite->callback = sub_81D97E0; + return; + case 352: + sub_81D9274(FindTaskIdByFunc(sub_81D8E80)); + break; + } + } + + if (sprite->data[7] > 328 && (sprite->data[7] & 1) == 0) + { + sprite->pos2.x *= -1; + gSprites[sprite->data[0]].pos2.x = sprite->pos2.x; + } + + sprite->data[7]++; +} + +static void sub_81D97E0(struct Sprite *sprite) +{ + struct Sprite *sprite2 = &gSprites[sprite->data[0]]; + if (!(sprite->data[6] & sprite2->data[4])) + { + sprite->pos2.y += sprite->data[4]; + gSprites[sprite->data[0]].pos2.y += sprite->data[4]; + sprite->data[4] += sprite->data[5]; + if (sprite->data[4] >= sprite2->data[5] || sprite->data[4] <= -sprite2->data[5]) + { + if (sprite->data[4] > sprite2->data[5]) + sprite->data[4] = sprite2->data[5]; + else if (sprite->data[4] < -sprite2->data[5]) + sprite->data[4] = -sprite2->data[5]; + + sprite->data[5] *= -1; + } + } + + sprite->data[6]++; +} + +static void sub_81D9868(struct Sprite *sprite, u8 animNum, s16 x, s16 y) +{ + struct Sprite *sprite2 = &gSprites[sprite->data[0]]; + + sprite2->pos1.x = sprite->pos1.x + x; + sprite2->pos1.y = sprite->pos1.y + y; + + sprite2->pos2.x = sprite->pos2.x; + sprite2->pos2.y = sprite->pos2.y; + + StartSpriteAnim(sprite, animNum); + StartSpriteAnim(sprite2, animNum); +} + +static void sub_81D98B4(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + switch (data[0]) + { + case 0: + SetBgAffine(2, 0x4000, 0x4000, 0x78, 0x40, 0x100, 0x100, 0); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON); + data[4] = 16; + data[0]++; + break; + case 1: + if (data[5] == 8) + PlaySE(SE_JIDO_DOA); + if (data[2] == 2) + { + data[0]++; + } + else + { + data[1] += data[4]; + data[5]++; + if (data[3] % 3 == 0 && data[4] != 4) + data[4] -= 2; + + data[3]++; + SetBgAffine(2, 0x4000, 0x4000, 0x78, 0x40, 0x100 - data[1], 0x100 - data[1], 0); + if (data[1] > 255) + { + data[1] = 0; + data[3] = 0; + data[5] = 0; + data[4] = 16; + data[2]++; + } + } + break; + case 2: + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON); + DestroyTask(taskId); + break; + } +} diff --git a/sym_ewram.txt b/sym_ewram.txt index eb26556c42..459905083b 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1527,4 +1527,4 @@ gUnknown_0203CF58: @ 203CF58 gUnknown_0203CF5C: @ 203CF5C .space 0x4 -sRayScene: @ 203CF60 + .include "src/rayquaza_scene.o" From 9976e21f6a7175a0f31bec39ab8e35c05cd5946b Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 1 Feb 2018 14:53:27 +0100 Subject: [PATCH 4/7] give some names ray scene --- src/rayquaza_scene.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index e326555788..0b97c7986e 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -34,11 +34,11 @@ struct RaySceneStruct static EWRAM_DATA struct RaySceneStruct *sRayScene = NULL; // this file's functions -static void sub_81D7134(u8 taskId); -static void sub_81D7F4C(u8 taskId); -static void sub_81D84EC(u8 taskId); -static void sub_81D8980(u8 taskId); -static void sub_81D8DB4(u8 taskId); +static void Task_DuoFightAnim(u8 taskId); +static void Task_RayTakesFlightAnim(u8 taskId); +static void Task_RayDescendsAnim(u8 taskId); +static void Task_RayChargesAnim(u8 taskId); +static void Task_RayChasesAwayAnim(u8 taskId); static void sub_81D857C(u8 taskId); static void sub_81D8684(u8 taskId); static void sub_81D89E0(u8 taskId); @@ -89,12 +89,12 @@ static void sub_81D9868(struct Sprite *sprite, u8 animNum, s16 x, s16 y); // const rom data static const TaskFunc sTasksForAnimations[] = { - sub_81D7134, // RAY_ANIM_DUO_FIGHT_PRE - sub_81D7134, // RAY_ANIM_DUO_FIGHT - sub_81D7F4C, // RAY_ANIM_TAKES_FLIGHT - sub_81D84EC, // RAY_ANIM_DESCENDS - sub_81D8980, // RAY_ANIM_CHARGES - sub_81D8DB4, // RAY_ANIM_CHACES_AWAY + Task_DuoFightAnim, // RAY_ANIM_DUO_FIGHT_PRE + Task_DuoFightAnim, // RAY_ANIM_DUO_FIGHT + Task_RayTakesFlightAnim, // RAY_ANIM_TAKES_FLIGHT + Task_RayDescendsAnim, // RAY_ANIM_DESCENDS + Task_RayChargesAnim, // RAY_ANIM_CHARGES + Task_RayChasesAwayAnim, // RAY_ANIM_CHACES_AWAY Task_EndAfterFadeScreen // RAY_ANIM_END }; @@ -1538,7 +1538,7 @@ static void sub_81D706C(void) LoadCompressedObjectPalette(&sUnknown_0862A9DC); } -static void sub_81D7134(u8 taskId) +static void Task_DuoFightAnim(u8 taskId) { s16 *data = gTasks[taskId].data; ScanlineEffect_Clear(); @@ -1947,7 +1947,7 @@ static void sub_81D7E9C(void) LoadCompressedObjectPalette(&sUnknown_0862AA98); } -static void sub_81D7F4C(u8 taskId) +static void Task_RayTakesFlightAnim(u8 taskId) { s16 *data = gTasks[taskId].data; PlayNewMapMusic(MUS_REKKUU_KOURIN); @@ -2147,7 +2147,7 @@ static void sub_81D844C(void) } } -static void sub_81D84EC(u8 taskId) +static void Task_RayDescendsAnim(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D82B0(); @@ -2339,7 +2339,7 @@ static void sub_81D88D0(void) LoadCompressedPalette(gRaySceneChase_Pal, 0, 0x80); } -static void sub_81D8980(u8 taskId) +static void Task_RayChargesAnim(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D8828(); @@ -2501,7 +2501,7 @@ static void sub_81D8CC4(void) LoadCompressedObjectPalette(&sUnknown_0862AC70); } -static void sub_81D8DB4(u8 taskId) +static void Task_RayChasesAwayAnim(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D8C38(); From be08cc06f289374e9dd1e5a86fdf73d217360a91 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 1 Feb 2018 15:32:12 +0100 Subject: [PATCH 5/7] more function names in ray scene --- src/rayquaza_scene.c | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index 0b97c7986e..05a0150789 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -40,28 +40,28 @@ static void Task_RayDescendsAnim(u8 taskId); static void Task_RayChargesAnim(u8 taskId); static void Task_RayChasesAwayAnim(u8 taskId); static void sub_81D857C(u8 taskId); -static void sub_81D8684(u8 taskId); +static void Task_RayDescendsEnd(u8 taskId); static void sub_81D89E0(u8 taskId); static void sub_81D8AD8(u8 taskId); static void sub_81D8B2C(u8 taskId); -static void sub_81D8BEC(u8 taskId); +static void Task_RayChargesEnd(u8 taskId); static void sub_81D8E80(u8 taskId); static void sub_81D8FB0(u8 taskId); static void sub_81D7228(u8 taskId); static void sub_81D736C(u8 taskId); static void sub_81D752C(u8 taskId); -static void sub_81D7600(u8 taskId); +static void Task_DuoFightEnd(u8 taskId); static void sub_81D7FC0(u8 taskId); static void sub_81D81A4(u8 taskId); -static void sub_81D8164(u8 taskId); +static void Task_RayTakesFlightEnd(u8 taskId); static void sub_81D94D4(u8 taskId); static void sub_81D93D8(u8 taskId); -static void sub_81D9034(u8 taskId); +static void Task_RayChasesAwayEnd(u8 taskId); static void sub_81D90A8(u8 taskId); static void sub_81D98B4(u8 taskId); static void Task_EndAfterFadeScreen(u8 taskId); -static void sub_81D6774(void); -static void sub_81D67D0(void); +static void CB2_InitRayquazaScene(void); +static void CB2_RayquazaScene(void); static void sub_81D750C(void); static void sub_81D7438(void); static void sub_81D7480(void); @@ -83,7 +83,7 @@ static void sub_81D9528(struct Sprite *sprite); static u8 sub_81D7664(void); static u8 sub_81D78BC(void); static u8 sub_81D86CC(void); -static void sub_81D75B4(u8 taskId, s8 palDelay); +static void DuoFightEnd(u8 taskId, s8 palDelay); static void sub_81D9868(struct Sprite *sprite, u8 animNum, s16 x, s16 y); // const rom data @@ -1238,10 +1238,10 @@ void DoRayquazaScene(u8 animId, bool8 onlyOneAnim, void (*callback)(void)) sRayScene->animId = animId; sRayScene->callback = callback; sRayScene->onlyOneAnim = onlyOneAnim; - SetMainCallback2(sub_81D6774); + SetMainCallback2(CB2_InitRayquazaScene); } -static void sub_81D6774(void) +static void CB2_InitRayquazaScene(void) { SetVBlankHBlankCallbacksToNull(); clear_scheduled_bg_copies_to_vram(); @@ -1252,10 +1252,10 @@ static void sub_81D6774(void) ResetTasks(); FillPalette(0, 0xF0, 0x20); CreateTask(sTasksForAnimations[sRayScene->animId], 0); - SetMainCallback2(sub_81D67D0); + SetMainCallback2(CB2_RayquazaScene); } -static void sub_81D67D0(void) +static void CB2_RayquazaScene(void) { RunTasks(); AnimateSprites(); @@ -1264,7 +1264,7 @@ static void sub_81D67D0(void) UpdatePaletteFade(); } -static void sub_81D67EC(void) +static void VblankCB_RayquazaScene(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -1336,7 +1336,7 @@ static void sub_81D691C(u8 taskId) switch (counter) { case 328: - sub_81D75B4(taskId, 0); + DuoFightEnd(taskId, 0); return; case 148: sub_81D74C8(); @@ -1495,7 +1495,7 @@ static void sub_81D6D20(struct Sprite *sprite) static void sub_81D6FD0(void) { - sub_81D67EC(); + VblankCB_RayquazaScene(); ScanlineEffect_InitHBlankDmaTransfer(); } @@ -1651,7 +1651,7 @@ static void sub_81D736C(u8 taskId) switch (counter) { case 412: - sub_81D75B4(taskId, 2); + DuoFightEnd(taskId, 2); return; case 380: SetGpuReg(REG_OFFSET_BLDCNT, 0x244); @@ -1712,14 +1712,14 @@ static void sub_81D752C(u8 taskId) } } -static void sub_81D75B4(u8 taskId, s8 palDelay) +static void DuoFightEnd(u8 taskId, s8 palDelay) { PlaySE(SE_T_OOAME_E); BeginNormalPaletteFade(-1, palDelay, 0, 0x10, 0); - gTasks[taskId].func = sub_81D7600; + gTasks[taskId].func = Task_DuoFightEnd; } -static void sub_81D7600(u8 taskId) +static void Task_DuoFightEnd(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D750C(); @@ -1956,7 +1956,7 @@ static void Task_RayTakesFlightAnim(u8 taskId) SetGpuReg(REG_OFFSET_BLDCNT, 0x250); SetGpuReg(REG_OFFSET_BLDALPHA, 0x808); BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(sub_81D67EC); + SetVBlankCallback(VblankCB_RayquazaScene); CreateTask(sub_81D81A4, 0); data[0] = 0; data[1] = 0; @@ -2019,12 +2019,12 @@ static void sub_81D7FC0(u8 taskId) case 3: data[2] += 16; SetBgAffine(2, 0x7800, 0x1800, 0x78, data[4] + 32, data[2], data[2], 0); - sub_81D8164(taskId); + Task_RayTakesFlightEnd(taskId); break; } } -static void sub_81D8164(u8 taskId) +static void Task_RayTakesFlightEnd(u8 taskId) { if (!gPaletteFade.active) { @@ -2155,7 +2155,7 @@ static void Task_RayDescendsAnim(u8 taskId) SetGpuRegBits(REG_OFFSET_BLDCNT, 0x1E41); SetGpuReg(REG_OFFSET_BLDALPHA, 0x1000); BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(sub_81D67EC); + SetVBlankCallback(VblankCB_RayquazaScene); sRayScene->field_2008 = 0; sRayScene->field_200A = 0; data[0] = 0; @@ -2220,12 +2220,12 @@ static void sub_81D857C(u8 taskId) break; case 4: BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gTasks[taskId].func = sub_81D8684; + gTasks[taskId].func = Task_RayDescendsEnd; break; } } -static void sub_81D8684(u8 taskId) +static void Task_RayDescendsEnd(u8 taskId) { if (!gPaletteFade.active) { @@ -2346,7 +2346,7 @@ static void Task_RayChargesAnim(u8 taskId) sub_81D88D0(); sub_81D68C8(); BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(sub_81D67EC); + SetVBlankCallback(VblankCB_RayquazaScene); data[0] = 0; data[1] = 0; data[2] = CreateTask(sub_81D8AD8, 0); @@ -2400,7 +2400,7 @@ static void sub_81D89E0(u8 taskId) break; case 3: BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gTasks[taskId].func = sub_81D8BEC; + gTasks[taskId].func = Task_RayChargesEnd; break; } } @@ -2446,7 +2446,7 @@ static void sub_81D8BB4(void) ChangeBgY(0, 0x800, 1); } -static void sub_81D8BEC(u8 taskId) +static void Task_RayChargesEnd(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D8BB4(); @@ -2511,7 +2511,7 @@ static void Task_RayChasesAwayAnim(u8 taskId) SetGpuReg(REG_OFFSET_BLDCNT, 0x241); SetGpuReg(REG_OFFSET_BLDALPHA, 0xE09); BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(sub_81D67EC); + SetVBlankCallback(VblankCB_RayquazaScene); data[0] = 0; data[1] = 0; gTasks[taskId].func = sub_81D8E80; @@ -2575,7 +2575,7 @@ static void sub_81D8E80(u8 taskId) break; case 3: BeginNormalPaletteFade(-1, 4, 0, 0x10, 0); - gTasks[taskId].func = sub_81D9034; + gTasks[taskId].func = Task_RayChasesAwayEnd; break; } } @@ -2597,7 +2597,7 @@ static void sub_81D8FB0(u8 taskId) data[0]++; } -static void sub_81D9034(u8 taskId) +static void Task_RayChasesAwayEnd(u8 taskId) { s16 *data = gTasks[taskId].data; if (!gPaletteFade.active) From af068e74ad55b2c6feb638c790f1f9f0c792f74c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 1 Feb 2018 23:39:53 +0100 Subject: [PATCH 6/7] more function names in ray scene --- src/rayquaza_scene.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index 05a0150789..e2701cd99b 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -39,19 +39,19 @@ static void Task_RayTakesFlightAnim(u8 taskId); static void Task_RayDescendsAnim(u8 taskId); static void Task_RayChargesAnim(u8 taskId); static void Task_RayChasesAwayAnim(u8 taskId); -static void sub_81D857C(u8 taskId); +static void Task_HandleRayDescends(u8 taskId); static void Task_RayDescendsEnd(u8 taskId); -static void sub_81D89E0(u8 taskId); +static void Task_HandleRayCharges(u8 taskId); static void sub_81D8AD8(u8 taskId); static void sub_81D8B2C(u8 taskId); static void Task_RayChargesEnd(u8 taskId); -static void sub_81D8E80(u8 taskId); +static void Task_HandleRayChasesAway(u8 taskId); static void sub_81D8FB0(u8 taskId); static void sub_81D7228(u8 taskId); -static void sub_81D736C(u8 taskId); +static void Task_HandleDuoFight(u8 taskId); static void sub_81D752C(u8 taskId); static void Task_DuoFightEnd(u8 taskId); -static void sub_81D7FC0(u8 taskId); +static void Task_HandleRayTakesFlight(u8 taskId); static void sub_81D81A4(u8 taskId); static void Task_RayTakesFlightEnd(u8 taskId); static void sub_81D94D4(u8 taskId); @@ -1316,7 +1316,7 @@ static void sub_81D6904(void) SetGpuReg(REG_OFFSET_WINOUT, 0x3F); } -static void sub_81D691C(u8 taskId) +static void Task_HandleDuoFightPre(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D750C(); @@ -1493,7 +1493,7 @@ static void sub_81D6D20(struct Sprite *sprite) } } -static void sub_81D6FD0(void) +static void VblankCB_DuoFight(void) { VblankCB_RayquazaScene(); ScanlineEffect_InitHBlankDmaTransfer(); @@ -1552,19 +1552,19 @@ static void Task_DuoFightAnim(u8 taskId) { data[2] = sub_81D6984(); data[3] = sub_81D6B7C(); - gTasks[taskId].func = sub_81D691C; + gTasks[taskId].func = Task_HandleDuoFightPre; } else { data[2] = sub_81D7664(); data[3] = sub_81D78BC(); - gTasks[taskId].func = sub_81D736C; + gTasks[taskId].func = Task_HandleDuoFight; StopMapMusic(); } BlendPalettes(-1, 0x10, 0); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - SetVBlankCallback(sub_81D6FD0); + SetVBlankCallback(VblankCB_DuoFight); PlaySE(SE_T_OOAME); } @@ -1627,7 +1627,7 @@ static void sub_81D7228(u8 taskId) } } -static void sub_81D736C(u8 taskId) +static void Task_HandleDuoFight(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D750C(); @@ -1960,10 +1960,10 @@ static void Task_RayTakesFlightAnim(u8 taskId) CreateTask(sub_81D81A4, 0); data[0] = 0; data[1] = 0; - gTasks[taskId].func = sub_81D7FC0; + gTasks[taskId].func = Task_HandleRayTakesFlight; } -static void sub_81D7FC0(u8 taskId) +static void Task_HandleRayTakesFlight(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) @@ -2163,10 +2163,10 @@ static void Task_RayDescendsAnim(u8 taskId) data[2] = 0; data[3] = 0; data[4] = 0x1000; - gTasks[taskId].func = sub_81D857C; + gTasks[taskId].func = Task_HandleRayDescends; } -static void sub_81D857C(u8 taskId) +static void Task_HandleRayDescends(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) @@ -2350,10 +2350,10 @@ static void Task_RayChargesAnim(u8 taskId) data[0] = 0; data[1] = 0; data[2] = CreateTask(sub_81D8AD8, 0); - gTasks[taskId].func = sub_81D89E0; + gTasks[taskId].func = Task_HandleRayCharges; } -static void sub_81D89E0(u8 taskId) +static void Task_HandleRayCharges(u8 taskId) { s16 *data = gTasks[taskId].data; sub_81D8BB4(); @@ -2514,7 +2514,7 @@ static void Task_RayChasesAwayAnim(u8 taskId) SetVBlankCallback(VblankCB_RayquazaScene); data[0] = 0; data[1] = 0; - gTasks[taskId].func = sub_81D8E80; + gTasks[taskId].func = Task_HandleRayChasesAway; data[2] = CreateTask(sub_81D8FB0, 0); gTasks[data[2]].data[0] = 0; gTasks[data[2]].data[1] = 0; @@ -2523,7 +2523,7 @@ static void Task_RayChasesAwayAnim(u8 taskId) gTasks[data[2]].data[4] = 1; } -static void sub_81D8E80(u8 taskId) +static void Task_HandleRayChasesAway(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) @@ -2837,7 +2837,7 @@ static void sub_81D961C(struct Sprite *sprite) sprite->callback = sub_81D97E0; return; case 352: - sub_81D9274(FindTaskIdByFunc(sub_81D8E80)); + sub_81D9274(FindTaskIdByFunc(Task_HandleRayChasesAway)); break; } } From 593031904b1f90bd6afdf3d9f968c5eebc658823 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 7 Feb 2018 19:47:55 +0100 Subject: [PATCH 7/7] ray changes --- src/rayquaza_scene.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index e2701cd99b..25b9ccd533 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -1264,7 +1264,7 @@ static void CB2_RayquazaScene(void) UpdatePaletteFade(); } -static void VblankCB_RayquazaScene(void) +static void VBlankCB_RayquazaScene(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -1493,9 +1493,9 @@ static void sub_81D6D20(struct Sprite *sprite) } } -static void VblankCB_DuoFight(void) +static void VBlankCB_DuoFight(void) { - VblankCB_RayquazaScene(); + VBlankCB_RayquazaScene(); ScanlineEffect_InitHBlankDmaTransfer(); } @@ -1564,7 +1564,7 @@ static void Task_DuoFightAnim(u8 taskId) BlendPalettes(-1, 0x10, 0); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - SetVBlankCallback(VblankCB_DuoFight); + SetVBlankCallback(VBlankCB_DuoFight); PlaySE(SE_T_OOAME); } @@ -1654,7 +1654,7 @@ static void Task_HandleDuoFight(u8 taskId) DuoFightEnd(taskId, 2); return; case 380: - SetGpuReg(REG_OFFSET_BLDCNT, 0x244); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND); gTasks[data[1]].func = sub_81D752C; gTasks[data[1]].data[0] = 0; gTasks[data[1]].data[2] = data[2]; @@ -1953,10 +1953,10 @@ static void Task_RayTakesFlightAnim(u8 taskId) PlayNewMapMusic(MUS_REKKUU_KOURIN); sub_81D7E10(); sub_81D7E9C(); - SetGpuReg(REG_OFFSET_BLDCNT, 0x250); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, 0x808); BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(VblankCB_RayquazaScene); + SetVBlankCallback(VBlankCB_RayquazaScene); CreateTask(sub_81D81A4, 0); data[0] = 0; data[1] = 0; @@ -2152,10 +2152,10 @@ static void Task_RayDescendsAnim(u8 taskId) s16 *data = gTasks[taskId].data; sub_81D82B0(); sub_81D8358(); - SetGpuRegBits(REG_OFFSET_BLDCNT, 0x1E41); + SetGpuRegBits(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, 0x1000); BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(VblankCB_RayquazaScene); + SetVBlankCallback(VBlankCB_RayquazaScene); sRayScene->field_2008 = 0; sRayScene->field_200A = 0; data[0] = 0; @@ -2346,7 +2346,7 @@ static void Task_RayChargesAnim(u8 taskId) sub_81D88D0(); sub_81D68C8(); BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(VblankCB_RayquazaScene); + SetVBlankCallback(VBlankCB_RayquazaScene); data[0] = 0; data[1] = 0; data[2] = CreateTask(sub_81D8AD8, 0); @@ -2508,10 +2508,10 @@ static void Task_RayChasesAwayAnim(u8 taskId) sub_81D8CC4(); sub_81D68C8(); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON); - SetGpuReg(REG_OFFSET_BLDCNT, 0x241); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, 0xE09); BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(VblankCB_RayquazaScene); + SetVBlankCallback(VBlankCB_RayquazaScene); data[0] = 0; data[1] = 0; gTasks[taskId].func = Task_HandleRayChasesAway;