From bc4bb5b32e68d225bd714dc36e24a75bc6c3cab4 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Fri, 16 Feb 2018 13:08:21 -0600 Subject: [PATCH] Start intro_credits_graphics decomp --- asm/intro_credits_graphics.s | 618 ------------------------------- include/intro_credits_graphics.h | 5 +- ld_script.txt | 1 + src/intro_credits_graphics.c | 486 +++++++++++++++++++++++- 4 files changed, 488 insertions(+), 622 deletions(-) diff --git a/asm/intro_credits_graphics.s b/asm/intro_credits_graphics.s index 3187138ce..aef83f35b 100644 --- a/asm/intro_credits_graphics.s +++ b/asm/intro_credits_graphics.s @@ -5,624 +5,6 @@ .text - thumb_func_start load_intro_part2_graphics -load_intro_part2_graphics: @ 817B064 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gUnknown_085F0740 - ldr r1, =0x06004000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F0BC0 - ldr r1, =0x06007800 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F06E0 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - cmp r4, 0 - beq _0817B08C - cmp r4, 0x1 - beq _0817B0EC -_0817B08C: - ldr r0, =gUnknown_085F0DBC - movs r1, 0xC0 - lsls r1, 19 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F1398 - ldr r1, =0x06003000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F0CFC - movs r1, 0 - movs r2, 0x60 - bl LoadPalette - ldr r0, =gUnknown_085F5064 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085F1668 - movs r1, 0x80 - lsls r1, 1 - movs r2, 0x20 - bl LoadPalette - bl sub_817B76C - b _0817B11E - .pool -_0817B0EC: - ldr r0, =gUnknown_085F1824 - movs r1, 0xC0 - lsls r1, 19 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F1EAC - ldr r1, =0x06003000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F17E4 - movs r1, 0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_085F50EC - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085F21B0 - movs r1, 0x80 - lsls r1, 1 - movs r2, 0x20 - bl LoadPalette - bl sub_817B788 -_0817B11E: - ldr r1, =gUnknown_0203BD28 - movs r0, 0 - strh r0, [r1] - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x8 - strb r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end load_intro_part2_graphics - - thumb_func_start sub_817B150 -sub_817B150: @ 817B150 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0817B162 - cmp r0, 0x1 - ble _0817B162 - cmp r0, 0x2 - beq _0817B194 -_0817B162: - ldr r1, =0x00000603 - movs r0, 0xE - bl SetGpuReg - ldr r1, =0x00000702 - movs r0, 0xC - bl SetGpuReg - ldr r1, =0x00000f05 - movs r0, 0xA - bl SetGpuReg - movs r1, 0xF2 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - b _0817B1B6 - .pool -_0817B194: - ldr r1, =0x00000603 - movs r0, 0xE - bl SetGpuReg - ldr r1, =0x00000702 - movs r0, 0xC - bl SetGpuReg - ldr r1, =0x00000f05 - movs r0, 0xA - bl SetGpuReg - movs r1, 0xF2 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg -_0817B1B6: - pop {r0} - bx r0 - .pool - thumb_func_end sub_817B150 - - thumb_func_start sub_817B1C8 -sub_817B1C8: @ 817B1C8 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gUnknown_085F0740 - ldr r1, =0x06004000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F0BC0 - ldr r1, =0x06007800 - bl LZ77UnCompVram - cmp r4, 0x4 - bhi _0817B214 - lsls r0, r4, 2 - ldr r1, =_0817B200 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0817B200: - .4byte _0817B214 - .4byte _0817B270 - .4byte _0817B2DC - .4byte _0817B2DC - .4byte _0817B334 -_0817B214: - ldr r0, =gUnknown_085F06E0 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_085F0DBC - movs r1, 0xC0 - lsls r1, 19 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F1398 - ldr r1, =0x06003000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F0CFC - movs r1, 0 - movs r2, 0x60 - bl LoadPalette - ldr r0, =gUnknown_085F5064 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085F16A8 - ldr r1, =0x06010000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F1668 - b _0817B2A6 - .pool -_0817B270: - ldr r0, =gUnknown_085F0700 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_085F0DBC - movs r1, 0xC0 - lsls r1, 19 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F1398 - ldr r1, =0x06003000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F0D5C - movs r1, 0 - movs r2, 0x60 - bl LoadPalette - ldr r0, =gUnknown_085F5064 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085F16A8 - ldr r1, =0x06010000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F1688 -_0817B2A6: - movs r1, 0x80 - lsls r1, 1 - movs r2, 0x20 - bl LoadPalette - bl sub_817B76C - b _0817B370 - .pool -_0817B2DC: - ldr r0, =gUnknown_085F0700 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_085F1824 - movs r1, 0xC0 - lsls r1, 19 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F1EAC - ldr r1, =0x06003000 - bl LZ77UnCompVram - ldr r4, =gUnknown_085F1804 - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_085F50EC - bl LoadCompressedObjectPic - movs r1, 0x80 - lsls r1, 1 - adds r0, r4, 0 - movs r2, 0x20 - bl LoadPalette - bl sub_817B788 - b _0817B370 - .pool -_0817B334: - ldr r0, =gUnknown_085F0720 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_085F235C - movs r1, 0xC0 - lsls r1, 19 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F2568 - ldr r1, =0x06003000 - bl LZ77UnCompVram - ldr r0, =gUnknown_085F231C - movs r1, 0 - movs r2, 0x40 - bl LoadPalette - ldr r0, =gUnknown_085F5180 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085F2548 - movs r1, 0x80 - lsls r1, 1 - movs r2, 0x20 - bl LoadPalette - bl sub_817B7A4 -_0817B370: - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x8 - strb r0, [r1] - ldr r1, =gUnknown_0203BD28 - movs r0, 0 - strh r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817B1C8 - - thumb_func_start sub_817B3A8 -sub_817B3A8: @ 817B3A8 - push {lr} - ldr r1, =0x00000603 - movs r0, 0xE - bl SetGpuReg - ldr r1, =0x00000702 - movs r0, 0xC - bl SetGpuReg - ldr r1, =0x00000f05 - movs r0, 0xA - bl SetGpuReg - movs r1, 0xFA - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - pop {r0} - bx r0 - .pool - thumb_func_end sub_817B3A8 - - thumb_func_start sub_817B3DC -sub_817B3DC: @ 817B3DC - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - mov r8, r2 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 16 - lsrs r6, 16 - mov r0, r8 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsls r3, 16 - lsrs r3, 16 - ldr r1, =sub_817B458 - mov r9, r1 - mov r0, r9 - movs r1, 0 - str r3, [sp] - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r2, 0 - strh r5, [r0, 0x8] - strh r6, [r0, 0xA] - strh r2, [r0, 0xC] - strh r2, [r0, 0xE] - mov r1, r8 - strh r1, [r0, 0x10] - strh r2, [r0, 0x12] - strh r2, [r0, 0x14] - ldr r3, [sp] - strh r3, [r0, 0x16] - movs r1, 0x8 - strh r1, [r0, 0x18] - strh r2, [r0, 0x1A] - adds r0, r4, 0 - bl _call_via_r9 - adds r0, r4, 0 - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_817B3DC - - thumb_func_start sub_817B458 -sub_817B458: @ 817B458 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - ldrh r0, [r4, 0xA] - lsls r2, r0, 16 - cmp r2, 0 - beq _0817B4A0 - movs r1, 0xC - ldrsh r0, [r4, r1] - lsls r0, 16 - ldrh r1, [r4, 0xE] - adds r1, r0, r1 - lsrs r0, r2, 12 - subs r1, r0 - asrs r0, r1, 16 - strh r0, [r4, 0xC] - strh r1, [r4, 0xE] - ldrh r1, [r4, 0xC] - movs r0, 0x14 - bl SetGpuReg - ldr r2, =gUnknown_0203BD24 - ldr r0, =gUnknown_0203BD26 - ldrh r1, [r0] - ldrh r2, [r2] - adds r1, r2 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x16 - bl SetGpuReg -_0817B4A0: - ldrh r0, [r4, 0x10] - lsls r2, r0, 16 - cmp r2, 0 - beq _0817B4FA - movs r1, 0x12 - ldrsh r0, [r4, r1] - lsls r0, 16 - ldrh r1, [r4, 0x14] - adds r1, r0, r1 - lsrs r0, r2, 12 - subs r1, r0 - asrs r0, r1, 16 - strh r0, [r4, 0x12] - strh r1, [r4, 0x14] - ldrh r1, [r4, 0x12] - movs r0, 0x18 - bl SetGpuReg - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0817B4F0 - ldr r2, =gUnknown_0203BD24 - ldr r0, =gUnknown_0203BD26 - ldrh r1, [r0] - ldrh r2, [r2] - adds r1, r2 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x1A - bl SetGpuReg - b _0817B4FA - .pool -_0817B4F0: - ldr r0, =gUnknown_0203BD24 - ldrh r1, [r0] - movs r0, 0x1A - bl SetGpuReg -_0817B4FA: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r2, r1, r0 - ldrh r0, [r2, 0x16] - lsls r3, r0, 16 - cmp r3, 0 - beq _0817B532 - movs r1, 0x18 - ldrsh r0, [r2, r1] - lsls r0, 16 - ldrh r1, [r2, 0x1A] - adds r1, r0, r1 - lsrs r0, r3, 12 - subs r1, r0 - asrs r0, r1, 16 - strh r0, [r2, 0x18] - strh r1, [r2, 0x1A] - ldrh r1, [r2, 0x18] - movs r0, 0x1C - bl SetGpuReg - ldr r0, =gUnknown_0203BD24 - ldrh r1, [r0] - movs r0, 0x1E - bl SetGpuReg -_0817B532: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817B458 - - thumb_func_start sub_817B540 -sub_817B540: @ 817B540 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0817B620 - cmp r0, 0x1 - ble _0817B554 - cmp r0, 0x2 - beq _0817B5B8 -_0817B554: - ldr r0, =gMain - ldr r2, [r0, 0x20] - movs r0, 0x3 - ands r0, r2 - cmp r0, 0 - bne _0817B620 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0817B620 - movs r0, 0x4 - ands r2, r0 - cmp r2, 0 - beq _0817B58C - ldr r2, =gPlttBufferUnfaded - ldrh r1, [r2, 0x12] - mov r0, sp - strh r1, [r0] - ldrh r1, [r2, 0x14] - b _0817B596 - .pool -_0817B58C: - ldr r2, =gPlttBufferUnfaded - ldrh r1, [r2, 0x14] - mov r0, sp - strh r1, [r0] - ldrh r1, [r2, 0x12] -_0817B596: - adds r0, 0x2 - strh r1, [r0] - adds r4, r0, 0 - mov r0, sp - movs r1, 0x9 - movs r2, 0x2 - bl LoadPalette - adds r0, r4, 0 - movs r1, 0xA - movs r2, 0x2 - bl LoadPalette - b _0817B620 - .pool -_0817B5B8: - ldr r0, =gMain - ldr r2, [r0, 0x20] - movs r0, 0x3 - ands r0, r2 - cmp r0, 0 - bne _0817B620 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0817B620 - movs r0, 0x4 - ands r2, r0 - cmp r2, 0 - beq _0817B5F8 - mov r1, sp - ldr r2, =0x00003d27 - adds r0, r2, 0 - strh r0, [r1] - adds r1, 0x2 - ldr r2, =0x00000295 - b _0817B606 - .pool -_0817B5F8: - mov r1, sp - movs r2, 0xC7 - lsls r2, 2 - adds r0, r2, 0 - strh r0, [r1] - adds r1, 0x2 - ldr r2, =0x00003d27 -_0817B606: - adds r0, r2, 0 - strh r0, [r1] - adds r4, r1, 0 - mov r0, sp - movs r1, 0xC - movs r2, 0x2 - bl LoadPalette - adds r0, r4, 0 - movs r1, 0xD - movs r2, 0x2 - bl LoadPalette -_0817B620: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817B540 - - thumb_func_start sub_817B62C -sub_817B62C: @ 817B62C - push {lr} - adds r2, r0, 0 - ldr r0, =gUnknown_0203BD28 - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x2 - beq _0817B690 - cmp r0, 0 - beq _0817B64C - adds r0, r2, 0 - bl DestroySprite - b _0817B690 - .pool -_0817B64C: - movs r1, 0x20 - ldrsh r0, [r2, r1] - lsls r0, 16 - ldrh r1, [r2, 0x32] - orrs r0, r1 - ldrh r1, [r2, 0x30] - adds r0, r1 - asrs r1, r0, 16 - strh r1, [r2, 0x20] - strh r0, [r2, 0x32] - cmp r1, 0xFF - ble _0817B668 - ldr r0, =0x0000ffe0 - strh r0, [r2, 0x20] -_0817B668: - movs r1, 0x2E - ldrsh r0, [r2, r1] - cmp r0, 0 - beq _0817B688 - ldr r1, =gUnknown_0203BD24 - ldr r0, =gUnknown_0203BD26 - ldrh r0, [r0] - ldrh r1, [r1] - adds r0, r1 - b _0817B68C - .pool -_0817B688: - ldr r0, =gUnknown_0203BD24 - ldrh r0, [r0] -_0817B68C: - negs r0, r0 - strh r0, [r2, 0x26] -_0817B690: - pop {r0} - bx r0 - .pool - thumb_func_end sub_817B62C - thumb_func_start sub_817B698 sub_817B698: @ 817B698 push {r4-r7,lr} diff --git a/include/intro_credits_graphics.h b/include/intro_credits_graphics.h index 4e5d025a5..07c2e51a0 100644 --- a/include/intro_credits_graphics.h +++ b/include/intro_credits_graphics.h @@ -2,8 +2,8 @@ #define GUARD_INTRO_CREDITS_GRAPHICS_H extern u16 gUnknown_0203BD24; -extern u16 gUnknown_0203BD26; -extern u16 gUnknown_0203BD28; +extern s16 gUnknown_0203BD26; +extern s16 gUnknown_0203BD28; extern const struct CompressedSpriteSheet gIntro2BrendanSpriteSheet[]; extern const struct CompressedSpriteSheet gIntro2MaySpriteSheet[]; @@ -14,6 +14,7 @@ extern const struct SpritePalette gUnknown_085F530C[]; void load_intro_part2_graphics(u8 a); void sub_817B150(u8 a); u8 sub_817B3DC(u8 a, u16 b, u16 c, u16 d); +void sub_817B458(u8); void sub_817B540(u8); u8 intro_create_brendan_sprite(s16 a, s16 b); u8 intro_create_may_sprite(s16 a, s16 b); diff --git a/ld_script.txt b/ld_script.txt index e282cd418..6bae74b38 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -232,6 +232,7 @@ SECTIONS { src/braille_puzzles.o(.text); src/pokeblock_feed.o(.text); src/clear_save_data_screen.o(.text); + src/intro_credits_graphics.o(.text); asm/intro_credits_graphics.o(.text); src/evolution_graphics.o(.text); src/bard_music.o(.text); diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c index b287f6b10..a3f4f36c2 100644 --- a/src/intro_credits_graphics.c +++ b/src/intro_credits_graphics.c @@ -1,5 +1,487 @@ #include "global.h" +#include "intro_credits_graphics.h" +#include "palette.h" +#include "decompress.h" +#include "gpu_regs.h" +#include "task.h" +#include "main.h" EWRAM_DATA u16 gUnknown_0203BD24 = 0; -EWRAM_DATA u16 gUnknown_0203BD26 = 0; -EWRAM_DATA u16 gUnknown_0203BD28 = 0; +EWRAM_DATA s16 gUnknown_0203BD26 = 0; +EWRAM_DATA s16 gUnknown_0203BD28 = 0; + +extern const u16 gUnknown_085F06E0[]/* = INCBIN_U16("graphics/intro/intro2_grass.gbapal")*/; +extern const u16 gUnknown_085F0700[]/* = INCBIN_U16("graphics/intro/intro2_grass_afternoon.gbapal")*/; +extern const u16 gUnknown_085F0720[]/* = INCBIN_U16("graphics/intro/intro2_grass_night.gbapal")*/; +extern const u8 gUnknown_085F0740[]/* = INCBIN_U8("graphics/intro/intro2_grass.4bpp.lz")*/; +extern const u8 gUnknown_085F0BC0[]/* = INCBIN_U8("graphics/intro/intro2_grass_map.bin.lz")*/; +extern const u16 gUnknown_085F0CFC[]/* = INCBIN_U16("graphics/intro/8412818.gbapal")*/; +extern const u16 gUnknown_085F0D5C[]/* = INCBIN_U16("graphics/intro/8412878.gbapal")*/; +extern const u8 gUnknown_085F0DBC[]/* = INCBIN_U8("graphics/intro/intro2_bgclouds.4bpp.lz")*/; +extern const u8 gUnknown_085F1398[]/* = INCBIN_U8("graphics/intro/intro2_bgclouds_map.bin.lz")*/; +extern const u16 gUnknown_085F1668[]/* = INCBIN_U16("graphics/intro/intro2_bgclouds.gbapal")*/; +extern const u16 gUnknown_085F1688[]/* = INCBIN_U16("graphics/intro/intro2_bgclouds_afternoon.gbapal")*/; +extern const u8 gUnknown_085F16A8[]/* = INCBIN_U8("graphics/intro/intro2_bgclouds2.4bpp.lz")*/; +extern const u16 gUnknown_085F17E4[]/* = INCBIN_U16("graphics/intro/intro2_bgtrees2.gbapal")*/; +extern const u16 gUnknown_085F1804[]/* = INCBIN_U16("graphics/intro/intro2_bgtrees2_afternoon.gbapal")*/; +extern const u8 gUnknown_085F1824[]/* = INCBIN_U8("graphics/intro/intro2_bgtrees.4bpp.lz")*/; +extern const u8 gUnknown_085F1EAC[]/* = INCBIN_U8("graphics/intro/intro2_bgtrees_map.bin.lz")*/; +extern const u16 gUnknown_085F21B0[]/* = INCBIN_U16("graphics/intro/intro2_bgtrees.gbapal")*/; +extern const u8 gIntro2TreeTiles[]/* = INCBIN_U8("graphics/intro/intro2_bgtreessmall.4bpp.lz")*/; +extern const u16 gUnknown_085F231C[]/* = INCBIN_U16("graphics/intro/8413E38.gbapal")*/; +extern const u8 gUnknown_085F235C[]/* = INCBIN_U8("graphics/intro/intro2_bgnight.4bpp.lz")*/; // only used in credits, coupled with intro because bicycle sequence +extern const u16 gUnknown_085F2548[]/* = INCBIN_U16("graphics/intro/intro2_bgnight.gbapal")*/; +extern const u8 gUnknown_085F2568[]/* = INCBIN_U8("graphics/intro/intro2_bgnight_map.bin.lz")*/; +extern const u8 gIntro2NightTiles[]/* = INCBIN_U8("graphics/intro/intro2_night.4bpp.lz")*/; +extern const u16 gIntro2BrendanPalette[]/* = INCBIN_U16("graphics/intro/intro2_brendan.gbapal")*/; +extern const u8 gIntro2BrendanTiles[]/* = INCBIN_U8("graphics/intro/intro2_brendan.4bpp.lz")*/; +extern const u16 gIntro2MayPalette[]/* = INCBIN_U16("graphics/intro/intro2_may.gbapal")*/; +extern const u16 gUnknown_08414F90[0xF0]/* = {0}*/; +extern const u8 gIntro2MayTiles[]/* = INCBIN_U8("graphics/intro/intro2_may.4bpp.lz")*/; +extern const u8 gIntro2BicycleTiles[]/* = INCBIN_U8("graphics/intro/intro2_bicycle.4bpp.lz")*/; +extern const u16 gIntro2LatiosPalette[]/* = INCBIN_U16("graphics/intro/intro2_latios.gbapal")*/; +extern const u8 gIntro2LatiosTiles[]/* = INCBIN_U8("graphics/intro/intro2_latios.4bpp.lz")*/; +extern const u16 gIntro2LatiasPalette[]/* = INCBIN_U16("graphics/intro/intro2_latias.gbapal")*/; +extern const u8 gIntro2LatiasTiles[]/* = INCBIN_U8("graphics/intro/intro2_latias.4bpp.lz")*/; + +extern const struct CompressedSpriteSheet gUnknown_085F5064[]/* = { + { gUnknown_085F16A8, 0x400, 2000 }, + {} +}*/; + +extern const struct CompressedSpriteSheet gUnknown_085F50EC[]/* = { + { gIntro2TreeTiles, 0x400, 2000 }, + {} +}*/; + +extern const struct CompressedSpriteSheet gUnknown_085F5180[]/* = { + { gIntro2NightTiles, 0x400, 2000 }, + {} +}*/; + +void sub_817B76C(); +void sub_817B788(); +void sub_817B7A4(); + +void load_intro_part2_graphics(u8 a) +{ + LZ77UnCompVram(&gUnknown_085F0740, (void *)(VRAM + 0x4000)); + LZ77UnCompVram(&gUnknown_085F0BC0, (void *)(VRAM + 0x7800)); + LoadPalette(&gUnknown_085F06E0, 240, 32); + switch (a) + { + case 0: + default: + LZ77UnCompVram(&gUnknown_085F0DBC, (void *)(VRAM)); + LZ77UnCompVram(&gUnknown_085F1398, (void *)(VRAM + 0x3000)); + LoadPalette(&gUnknown_085F0CFC, 0, 96); + LoadCompressedObjectPic(gUnknown_085F5064); + LoadPalette(&gUnknown_085F1668, 256, 32); + sub_817B76C(); + break; + case 1: + LZ77UnCompVram(&gUnknown_085F1824, (void *)(VRAM)); + LZ77UnCompVram(&gUnknown_085F1EAC, (void *)(VRAM + 0x3000)); + LoadPalette(&gUnknown_085F17E4, 0, 32); + LoadCompressedObjectPic(gUnknown_085F50EC); + LoadPalette(&gUnknown_085F21B0, 256, 32); + sub_817B788(); + break; + } + gUnknown_0203BD28 = 0; + gReservedSpritePaletteCount = 8; +} + +void sub_817B150(u8 a) +{ + switch (a) + { + default: + case 0: + SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) + | BGCNT_CHARBASE(0) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(6) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) + | BGCNT_CHARBASE(0) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(7) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) + | BGCNT_CHARBASE(1) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(15) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 + | DISPCNT_OBJ_1D_MAP + | DISPCNT_BG1_ON + | DISPCNT_BG2_ON + | DISPCNT_BG3_ON + | DISPCNT_OBJ_ON); + break; + case 1: + SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) + | BGCNT_CHARBASE(0) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(6) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) + | BGCNT_CHARBASE(0) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(7) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) + | BGCNT_CHARBASE(1) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(15) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 + | DISPCNT_OBJ_1D_MAP + | DISPCNT_BG1_ON + | DISPCNT_BG2_ON + | DISPCNT_BG3_ON + | DISPCNT_OBJ_ON); + break; + case 2: + SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) + | BGCNT_CHARBASE(0) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(6) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) + | BGCNT_CHARBASE(0) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(7) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) + | BGCNT_CHARBASE(1) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(15) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 + | DISPCNT_OBJ_1D_MAP + | DISPCNT_BG1_ON + | DISPCNT_BG2_ON + | DISPCNT_BG3_ON + | DISPCNT_OBJ_ON); + break; + } +} + +void sub_817B1C8(u8 a) +{ + LZ77UnCompVram(&gUnknown_085F0740, (void *)(VRAM + 0x4000)); + LZ77UnCompVram(&gUnknown_085F0BC0, (void *)(VRAM + 0x7800)); + switch (a) + { + case 0: + default: + LoadPalette(&gUnknown_085F06E0, 240, 32); + LZ77UnCompVram(&gUnknown_085F0DBC, (void *)(VRAM)); + LZ77UnCompVram(&gUnknown_085F1398, (void *)(VRAM + 0x3000)); + LoadPalette(&gUnknown_085F0CFC, 0, 96); + LoadCompressedObjectPic(gUnknown_085F5064); + LZ77UnCompVram(&gUnknown_085F16A8, (void *)(VRAM + 0x10000)); + LoadPalette(&gUnknown_085F1668, 256, 32); + sub_817B76C(); + break; + case 1: + LoadPalette(&gUnknown_085F0700, 240, 32); + LZ77UnCompVram(&gUnknown_085F0DBC, (void *)(VRAM)); + LZ77UnCompVram(&gUnknown_085F1398, (void *)(VRAM + 0x3000)); + LoadPalette(&gUnknown_085F0D5C, 0, 96); + LoadCompressedObjectPic(gUnknown_085F5064); + LZ77UnCompVram(&gUnknown_085F16A8, (void *)(VRAM + 0x10000)); + LoadPalette(&gUnknown_085F1688, 256, 32); + sub_817B76C(); + break; + case 2: + case 3: + LoadPalette(&gUnknown_085F0700, 240, 32); + LZ77UnCompVram(&gUnknown_085F1824, (void *)(VRAM)); + LZ77UnCompVram(&gUnknown_085F1EAC, (void *)(VRAM + 0x3000)); + LoadPalette(&gUnknown_085F1804, 0, 32); + LoadCompressedObjectPic(gUnknown_085F50EC); + LoadPalette(&gUnknown_085F1804, 256, 32); + sub_817B788(); + break; + case 4: + LoadPalette(&gUnknown_085F0720, 240, 32); + LZ77UnCompVram(&gUnknown_085F235C, (void *)(VRAM)); + LZ77UnCompVram(&gUnknown_085F2568, (void *)(VRAM + 0x3000)); + LoadPalette(&gUnknown_085F231C, 0, 64); + LoadCompressedObjectPic(gUnknown_085F5180); + LoadPalette(&gUnknown_085F2548, 256, 32); + sub_817B7A4(); + break; + } + gReservedSpritePaletteCount = 8; + gUnknown_0203BD28 = 0; +} + +void sub_817B3A8(u8 a) +{ + SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) + | BGCNT_CHARBASE(0) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(6) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) + | BGCNT_CHARBASE(0) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(7) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) + | BGCNT_CHARBASE(1) + | BGCNT_16COLOR + | BGCNT_SCREENBASE(15) + | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 + | DISPCNT_OBJ_1D_MAP + | DISPCNT_BG_ALL_ON + | DISPCNT_OBJ_ON); +} + +u8 sub_817B3DC(u8 a, u16 b, u16 c, u16 d) +{ + u8 taskId = CreateTask(&sub_817B458, 0); + + gTasks[taskId].data[0] = a; + gTasks[taskId].data[1] = b; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[4] = c; + gTasks[taskId].data[5] = 0; + gTasks[taskId].data[6] = 0; + gTasks[taskId].data[7] = d; + gTasks[taskId].data[8] = 8; + gTasks[taskId].data[9] = 0; + sub_817B458(taskId); + return taskId; +} + +#ifdef NONMATCHING +void sub_817B458(u8 taskId) +{ + s16 r4; + s32 r2; + + r4 = gTasks[taskId].data[1]; + if (r4 != 0) + { + r2 = (gTasks[taskId].data[2] << 16) + (u16)gTasks[taskId].data[3]; + r2 -= (u16)r4 << 4; + gTasks[taskId].data[2] = r2 >> 16; + gTasks[taskId].data[3] = r2; + SetGpuReg(REG_OFFSET_BG1HOFS, gTasks[taskId].data[2]); + SetGpuReg(REG_OFFSET_BG1VOFS, gUnknown_0203BD24 + gUnknown_0203BD26); + } + + r4 = gTasks[taskId].data[4]; + if (r4 != 0) + { + r2 = (gTasks[taskId].data[5] << 16) + (u16)gTasks[taskId].data[6]; + r2 -= (u16)r4 << 4; + gTasks[taskId].data[5] = r2 >> 16; + gTasks[taskId].data[6] = r2; + SetGpuReg(REG_OFFSET_BG2HOFS, gTasks[taskId].data[5]); + if (gTasks[taskId].data[0] != 0) + SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_0203BD24 + gUnknown_0203BD26); + else + SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_0203BD24); + } + + r4 = gTasks[taskId].data[7]; + if (r4 != 0) + { + r2 = (gTasks[taskId].data[8] << 16) + (u16)gTasks[taskId].data[9]; + r2 -= (u16)r4 << 4; + gTasks[taskId].data[8] = r2 >> 16; + gTasks[taskId].data[9] = r2; + SetGpuReg(REG_OFFSET_BG3HOFS, gTasks[taskId].data[8]); + SetGpuReg(REG_OFFSET_BG3VOFS, gUnknown_0203BD24); + } +} +#else +ASM_DIRECT +void sub_817B458(u8 taskId) +{ + asm("push {r4,r5,lr}\n\ + lsl r0, #24\n\ + lsr r5, r0, #24\n\ + ldr r1, =gTasks\n\ + lsl r0, r5, #2\n\ + add r0, r5\n\ + lsl r0, #3\n\ + add r4, r0, r1\n\ + ldrh r0, [r4, #0xA]\n\ + lsl r2, r0, #16\n\ + cmp r2, #0\n\ + beq _0817B4A0\n\ + mov r1, #0xC\n\ + ldrsh r0, [r4, r1]\n\ + lsl r0, #16\n\ + ldrh r1, [r4, #0xE]\n\ + add r1, r0, r1\n\ + lsr r0, r2, #12\n\ + sub r1, r0\n\ + asr r0, r1, #16\n\ + strh r0, [r4, #0xC]\n\ + strh r1, [r4, #0xE]\n\ + ldrh r1, [r4, #0xC]\n\ + mov r0, #0x14\n\ + bl SetGpuReg\n\ + ldr r2, =gUnknown_0203BD24\n\ + ldr r0, =gUnknown_0203BD26\n\ + ldrh r1, [r0]\n\ + ldrh r2, [r2]\n\ + add r1, r2\n\ + lsl r1, #16\n\ + lsr r1, #16\n\ + mov r0, #0x16\n\ + bl SetGpuReg\n\ +_0817B4A0:\n\ + ldrh r0, [r4, #0x10]\n\ + lsl r2, r0, #16\n\ + cmp r2, #0\n\ + beq _0817B4FA\n\ + mov r1, #0x12\n\ + ldrsh r0, [r4, r1]\n\ + lsl r0, #16\n\ + ldrh r1, [r4, #0x14]\n\ + add r1, r0, r1\n\ + lsr r0, r2, #12\n\ + sub r1, r0\n\ + asr r0, r1, #16\n\ + strh r0, [r4, #0x12]\n\ + strh r1, [r4, #0x14]\n\ + ldrh r1, [r4, #0x12]\n\ + mov r0, #0x18\n\ + bl SetGpuReg\n\ + mov r1, #0x8\n\ + ldrsh r0, [r4, r1]\n\ + cmp r0, #0\n\ + beq _0817B4F0\n\ + ldr r2, =gUnknown_0203BD24\n\ + ldr r0, =gUnknown_0203BD26\n\ + ldrh r1, [r0]\n\ + ldrh r2, [r2]\n\ + add r1, r2\n\ + lsl r1, #16\n\ + lsr r1, #16\n\ + mov r0, #0x1A\n\ + bl SetGpuReg\n\ + b _0817B4FA\n\ + .pool\n\ +_0817B4F0:\n\ + ldr r0, =gUnknown_0203BD24\n\ + ldrh r1, [r0]\n\ + mov r0, #0x1A\n\ + bl SetGpuReg\n\ +_0817B4FA:\n\ + ldr r0, =gTasks\n\ + lsl r1, r5, #2\n\ + add r1, r5\n\ + lsl r1, #3\n\ + add r2, r1, r0\n\ + ldrh r0, [r2, #0x16]\n\ + lsl r3, r0, #16\n\ + cmp r3, #0\n\ + beq _0817B532\n\ + mov r1, #0x18\n\ + ldrsh r0, [r2, r1]\n\ + lsl r0, #16\n\ + ldrh r1, [r2, #0x1A]\n\ + add r1, r0, r1\n\ + lsr r0, r3, #12\n\ + sub r1, r0\n\ + asr r0, r1, #16\n\ + strh r0, [r2, #0x18]\n\ + strh r1, [r2, #0x1A]\n\ + ldrh r1, [r2, #0x18]\n\ + mov r0, #0x1C\n\ + bl SetGpuReg\n\ + ldr r0, =gUnknown_0203BD24\n\ + ldrh r1, [r0]\n\ + mov r0, #0x1E\n\ + bl SetGpuReg\n\ +_0817B532:\n\ + pop {r4,r5}\n\ + pop {r0}\n\ + bx r0\n\ + .pool"); +} +#endif // NONMATCHING + +void sub_817B540(u8 mode) +{ + u16 x; + u16 y; + switch (mode) + { + case 0: + default: + /* stuff */ + if (gMain.vblankCounter1 & 3 || gPaletteFade.active) + break; + if (gMain.vblankCounter1 & 4) + { + x = gPlttBufferUnfaded[9]; + y = gPlttBufferUnfaded[10]; + } + else + { + x = gPlttBufferUnfaded[10]; + y = gPlttBufferUnfaded[9]; + } + LoadPalette(&x, 9, 2); + LoadPalette(&y, 10, 2); + break; + case 2: + if (gMain.vblankCounter1 & 3 || gPaletteFade.active) + break; + if (gMain.vblankCounter1 & 4) + { + x = 0x3D27; + y = 0x295; + } + else + { + x = 0x31C; + y = 0x3D27; + } + LoadPalette(&x, 12, 2); + LoadPalette(&y, 13, 2); + break; + case 1: + break; + } +} + +void sub_817B62C(struct Sprite *sprite) +{ + s32 var; + s16 var2 = gUnknown_0203BD28; + + if (var2 != 2) + { + switch (var2) + { + default: + DestroySprite(sprite); + break; + case 0: + var = ((sprite->pos1.x << 16) | (u16)sprite->data[2]) + (u16)sprite->data[1]; + sprite->pos1.x = var >> 16; + sprite->data[2] = var; + if (sprite->pos1.x > 0xFF) + sprite->pos1.x = -0x20; + if (sprite->data[0]) + sprite->pos2.y = -(gUnknown_0203BD24 + gUnknown_0203BD26); + else + sprite->pos2.y = -gUnknown_0203BD24; + break; + } + } +}