diff --git a/asm/rayquaza_scene.s b/asm/rayquaza_scene.s index 611c34f5f..a7614239a 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 c089ec254..37890fb96 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 cb03699a6..41cef4048 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 72aeab94e..44c4d86f4 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; + } +}