diff --git a/asm/intro.s b/asm/intro.s index 3e95c6ec79..a0149851e0 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -59,7 +59,7 @@ sub_816CC54: @ 816CC54 lsls r0, 24 cmp r0, 0 bne _0816CC66 - ldr r0, =c2_title_screen_1 + ldr r0, =CB2_InitTitleScreen bl SetMainCallback2 _0816CC66: pop {r0} @@ -337,13 +337,13 @@ _0816CEFA: .pool thumb_func_end c2_copyright_1 - thumb_func_start c2_show_copyright_and_intro_again_2 -c2_show_copyright_and_intro_again_2: @ 816CF0C + thumb_func_start CB2_InitCopyrightScreenAfterTitleScreen +CB2_InitCopyrightScreenAfterTitleScreen: @ 816CF0C push {lr} bl do_copyright_screen pop {r0} bx r0 - thumb_func_end c2_show_copyright_and_intro_again_2 + thumb_func_end CB2_InitCopyrightScreenAfterTitleScreen thumb_func_start task_intro_1 @ void task_intro_1(int task_id) diff --git a/asm/link.s b/asm/link.s index a3d621601d..de0ec51a19 100644 --- a/asm/link.s +++ b/asm/link.s @@ -28867,7 +28867,7 @@ sub_80186A4: @ 80186A4 movs r0, 0x3 bl GetBgTilemapBuffer bl Free - ldr r0, =c2_title_screen_1 + ldr r0, =CB2_InitTitleScreen bl SetMainCallback2 pop {r0} bx r0 diff --git a/asm/main_menu.s b/asm/main_menu.s index 08e0c3103f..9c6cd1253c 100644 --- a/asm/main_menu.s +++ b/asm/main_menu.s @@ -1608,7 +1608,7 @@ _08030578: ldr r0, =gUnknown_02022D06 strh r4, [r0] bl FreeAllWindowBuffers - ldr r0, =c2_title_screen_1 + ldr r0, =CB2_InitTitleScreen bl SetMainCallback2 adds r0, r5, 0 bl DestroyTask diff --git a/asm/reset_rtc_screen.s b/asm/reset_rtc_screen.s index b314afbf5e..5877ff00ec 100644 --- a/asm/reset_rtc_screen.s +++ b/asm/reset_rtc_screen.s @@ -830,8 +830,8 @@ sub_809EF00: @ 809EF00 .pool thumb_func_end sub_809EF00 - thumb_func_start sub_809EF88 -sub_809EF88: @ 809EF88 + thumb_func_start CB2_InitResetRtcScreen +CB2_InitResetRtcScreen: @ 809EF88 push {r4-r7,lr} sub sp, 0x4 movs r0, 0 @@ -905,7 +905,7 @@ _0809EFCA: pop {r0} bx r0 .pool - thumb_func_end sub_809EF88 + thumb_func_end CB2_InitResetRtcScreen thumb_func_start sub_809F048 sub_809F048: @ 809F048 diff --git a/asm/title_screen.s b/asm/title_screen.s deleted file mode 100644 index 32594424a8..0000000000 --- a/asm/title_screen.s +++ /dev/null @@ -1,1321 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80AA40C -sub_80AA40C: @ 80AA40C - push {lr} - adds r3, r0, 0 - ldr r2, =gTasks - movs r0, 0x30 - ldrsh r1, [r3, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r1, 0xA - ldrsh r0, [r0, r1] - cmp r0, 0 - beq _080AA43C - ldrb r0, [r3, 0x1] - movs r1, 0xD - negs r1, r1 - ands r1, r0 - strb r1, [r3, 0x1] - movs r0, 0x42 - strh r0, [r3, 0x22] - b _080AA46A - .pool -_080AA43C: - ldrh r1, [r3, 0x22] - movs r2, 0x22 - ldrsh r0, [r3, r2] - cmp r0, 0x42 - beq _080AA44A - adds r0, r1, 0x1 - strh r0, [r3, 0x22] -_080AA44A: - ldrh r1, [r3, 0x2E] - movs r2, 0x2E - ldrsh r0, [r3, r2] - cmp r0, 0 - beq _080AA458 - subs r0, r1, 0x1 - strh r0, [r3, 0x2E] -_080AA458: - ldr r0, =gUnknown_0853FF70 - movs r2, 0x2E - ldrsh r1, [r3, r2] - lsls r1, 1 - adds r1, r0 - ldrh r1, [r1] - movs r0, 0x52 - bl SetGpuReg -_080AA46A: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80AA40C - - thumb_func_start sub_80AA474 -sub_80AA474: @ 80AA474 - push {lr} - adds r3, r0, 0 - ldr r2, =gTasks - movs r0, 0x30 - ldrsh r1, [r3, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r1, 0xA - ldrsh r0, [r0, r1] - cmp r0, 0 - beq _080AA4A0 - ldrb r0, [r3, 0x1] - movs r1, 0xD - negs r1, r1 - ands r1, r0 - strb r1, [r3, 0x1] - movs r0, 0x42 - b _080AA4AC - .pool -_080AA4A0: - ldrh r1, [r3, 0x22] - movs r2, 0x22 - ldrsh r0, [r3, r2] - cmp r0, 0x42 - beq _080AA4AE - adds r0, r1, 0x1 -_080AA4AC: - strh r0, [r3, 0x22] -_080AA4AE: - pop {r0} - bx r0 - thumb_func_end sub_80AA474 - - thumb_func_start sub_80AA4B4 -sub_80AA4B4: @ 80AA4B4 - push {lr} - adds r2, r0, 0 - movs r1, 0x2E - ldrsh r0, [r2, r1] - cmp r0, 0x1 - bne _080AA4DC - ldrh r0, [r2, 0x30] - adds r0, 0x1 - strh r0, [r2, 0x30] - movs r1, 0x10 - ands r0, r1 - cmp r0, 0 - bne _080AA4DC - adds r0, r2, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - b _080AA4E8 -_080AA4DC: - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_080AA4E8: - pop {r0} - bx r0 - thumb_func_end sub_80AA4B4 - - thumb_func_start sub_80AA4EC -sub_80AA4EC: @ 80AA4EC - push {r4-r7,lr} - lsls r0, 16 - ldr r2, =0xffc00000 - adds r0, r2 - lsrs r0, 16 - movs r6, 0 - lsls r7, r1, 16 -_080AA4FA: - lsls r5, r0, 16 - asrs r5, 16 - ldr r0, =gUnknown_085400D8 - adds r1, r5, 0 - asrs r2, r7, 16 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - adds r0, r4, 0 - adds r1, r6, 0 - bl StartSpriteAnim - movs r0, 0x1 - strh r0, [r4, 0x2E] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r5, 0x20 - lsls r5, 16 - lsrs r0, r5, 16 - cmp r6, 0x4 - bls _080AA4FA - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80AA4EC - - thumb_func_start sub_80AA548 -sub_80AA548: @ 80AA548 - push {r4-r6,lr} - lsls r0, 16 - ldr r2, =0xffc00000 - adds r0, r2 - lsrs r0, 16 - movs r5, 0 - lsls r6, r1, 16 -_080AA556: - lsls r4, r0, 16 - asrs r4, 16 - ldr r0, =gUnknown_085400D8 - adds r1, r4, 0 - asrs r2, r6, 16 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r1, r5, 0x5 - lsls r1, 24 - lsrs r1, 24 - adds r0, r2, 0 - bl StartSpriteAnim - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x20 - lsls r4, 16 - lsrs r0, r4, 16 - cmp r5, 0x4 - bls _080AA556 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80AA548 - - thumb_func_start title_screen_logo_shine_obj_callback_type1 -@ void title_screen_logo_shine_obj_callback_type1(struct obj *obj) -title_screen_logo_shine_obj_callback_type1: @ 80AA5A4 - push {r4,lr} - adds r3, r0, 0 - ldrh r2, [r3, 0x20] - movs r0, 0x20 - ldrsh r1, [r3, r0] - ldr r0, =0x0000010f - cmp r1, r0 - bgt _080AA63C - movs r4, 0x2E - ldrsh r0, [r3, r4] - adds r4, r2, 0 - cmp r0, 0 - beq _080AA630 - cmp r1, 0x77 - bgt _080AA5E0 - ldrh r1, [r3, 0x30] - movs r2, 0x30 - ldrsh r0, [r3, r2] - cmp r0, 0x1E - bgt _080AA5F8 - adds r1, 0x1 - strh r1, [r3, 0x30] - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0x1E - bgt _080AA5F8 - adds r0, r1, 0x1 - b _080AA5F6 - .pool -_080AA5E0: - ldrh r1, [r3, 0x30] - movs r4, 0x30 - ldrsh r0, [r3, r4] - cmp r0, 0 - beq _080AA5F8 - subs r0, r1, 0x1 - strh r0, [r3, 0x30] - lsls r0, 16 - cmp r0, 0 - beq _080AA5F8 - subs r0, r1, 0x2 -_080AA5F6: - strh r0, [r3, 0x30] -_080AA5F8: - ldrh r1, [r3, 0x30] - movs r0, 0x1F - ands r0, r1 - lsls r2, r0, 10 - lsls r1, r0, 5 - adds r2, r1 - orrs r2, r0 - movs r1, 0x20 - ldrsh r0, [r3, r1] - ldrh r4, [r3, 0x20] - cmp r0, 0x84 - beq _080AA61C - cmp r0, 0x88 - beq _080AA61C - cmp r0, 0x8C - beq _080AA61C - cmp r0, 0x90 - bne _080AA62C -_080AA61C: - ldr r1, =gPlttBufferFaded - ldr r0, =0x000033f8 - strh r0, [r1] - b _080AA630 - .pool -_080AA62C: - ldr r0, =gPlttBufferFaded - strh r2, [r0] -_080AA630: - adds r0, r4, 0x4 - strh r0, [r3, 0x20] - b _080AA648 - .pool -_080AA63C: - ldr r1, =gPlttBufferFaded - movs r0, 0 - strh r0, [r1] - adds r0, r3, 0 - bl DestroySprite -_080AA648: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end title_screen_logo_shine_obj_callback_type1 - - thumb_func_start title_screen_logo_shine_obj_callback_type2 -@ void title_screen_logo_shine_obj_callback_type2(struct obj *obj) -title_screen_logo_shine_obj_callback_type2: @ 80AA654 - push {lr} - adds r2, r0, 0 - ldrh r3, [r2, 0x20] - movs r0, 0x20 - ldrsh r1, [r2, r0] - ldr r0, =0x0000010f - cmp r1, r0 - bgt _080AA670 - adds r0, r3, 0 - adds r0, 0x8 - strh r0, [r2, 0x20] - b _080AA676 - .pool -_080AA670: - adds r0, r2, 0 - bl DestroySprite -_080AA676: - pop {r0} - bx r0 - thumb_func_end title_screen_logo_shine_obj_callback_type2 - - thumb_func_start title_screen_add_logo_shine_obj -@ void title_screen_add_logo_shine_obj(int a1) -title_screen_add_logo_shine_obj: @ 80AA67C - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x1 - beq _080AA6D0 - cmp r5, 0x1 - bgt _080AA698 - cmp r5, 0 - beq _080AA69C - b _080AA766 -_080AA698: - cmp r5, 0x2 - bne _080AA766 -_080AA69C: - ldr r0, =gUnknown_08540124 - movs r1, 0 - movs r2, 0x44 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r2, [r0, 0x1] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - movs r2, 0x8 - orrs r1, r2 - strb r1, [r0, 0x1] - strh r5, [r0, 0x2E] - b _080AA766 - .pool -_080AA6D0: - ldr r0, =gUnknown_08540124 - mov r9, r0 - movs r1, 0 - movs r2, 0x44 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - ldr r6, =gSprites - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r6 - ldrb r2, [r1, 0x1] - movs r4, 0xD - negs r4, r4 - adds r0, r4, 0 - ands r0, r2 - movs r2, 0x8 - mov r8, r2 - mov r2, r8 - orrs r0, r2 - strb r0, [r1, 0x1] - strh r5, [r1, 0x2E] - adds r1, 0x3E - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] - mov r0, r9 - movs r1, 0 - movs r2, 0x44 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r5, r6, 0 - adds r5, 0x1C - adds r0, r1, r5 - ldr r2, =title_screen_logo_shine_obj_callback_type2 - mov r10, r2 - str r2, [r0] - adds r1, r6 - ldrb r2, [r1, 0x1] - adds r0, r4, 0 - ands r0, r2 - mov r2, r8 - orrs r0, r2 - strb r0, [r1, 0x1] - movs r1, 0x50 - negs r1, r1 - mov r0, r9 - movs r2, 0x44 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r5, r0, r5 - mov r1, r10 - str r1, [r5] - adds r0, r6 - ldrb r1, [r0, 0x1] - ands r4, r1 - mov r2, r8 - orrs r4, r2 - strb r4, [r0, 0x1] -_080AA766: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end title_screen_add_logo_shine_obj - - thumb_func_start title_screen_vblank_callback -@ void title_screen_vblank_callback() -title_screen_vblank_callback: @ 80AA780 - push {lr} - bl ScanlineEffect_InitHBlankDmaTransfer - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - ldr r0, =gBattle_BG1_Y - ldrh r1, [r0] - movs r0, 0x16 - bl SetGpuReg - pop {r0} - bx r0 - .pool - thumb_func_end title_screen_vblank_callback - - thumb_func_start c2_title_screen_1 -@ void c2_title_screen_1() -c2_title_screen_1: @ 80AA7A4 - push {r4,lr} - sub sp, 0x14 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x5 - bhi _080AA7E0 - lsls r0, 2 - ldr r1, =_080AA7C8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080AA7C8: - .4byte _080AA7E0 - .4byte _080AA8C4 - .4byte _080AA998 - .4byte _080AA9E0 - .4byte _080AAA14 - .4byte _080AAAF0 -_080AA7E0: - movs r0, 0 - bl SetVBlankCallback - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - movs r1, 0xA0 - lsls r1, 19 - ldr r2, =0x00007fff - adds r0, r2, 0 - strh r0, [r1] - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r0, 0xC - movs r1, 0 - bl SetGpuReg - movs r0, 0xA - movs r1, 0 - bl SetGpuReg - movs r0, 0x8 - movs r1, 0 - bl SetGpuReg - movs r0, 0x18 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1A - movs r1, 0 - bl SetGpuReg - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - movs r0, 0x16 - movs r1, 0 - bl SetGpuReg - movs r0, 0x10 - movs r1, 0 - bl SetGpuReg - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg - add r1, sp, 0xC - movs r0, 0 - strh r0, [r1] - ldr r1, =0x040000d4 - add r0, sp, 0xC - str r0, [r1] - movs r0, 0xC0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x8100c000 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r2, 0 - str r2, [sp, 0x10] - add r0, sp, 0x10 - str r0, [r1] - movs r0, 0xE0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x85000100 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - add r0, sp, 0xC - strh r2, [r0] - str r0, [r1] - ldr r0, =0x05000002 - str r0, [r1, 0x4] - ldr r0, =0x810001ff - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - bl ResetPaletteFade - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - b _080AAB1E - .pool -_080AA8C4: - ldr r0, =gTitleScreenPokemonLogoGfx - movs r1, 0xC0 - lsls r1, 19 - bl LZ77UnCompVram - ldr r0, =gUnknown_08DE0644 - ldr r1, =0x06004800 - bl LZ77UnCompVram - ldr r0, =gTitleScreenBgPalettes - movs r2, 0xF0 - lsls r2, 1 - movs r1, 0 - bl LoadPalette - ldr r0, =gTitleScreenRayquazaGfx - ldr r1, =0x06008000 - bl LZ77UnCompVram - ldr r0, =gTitleScreenRayquazaTilemap - ldr r1, =0x0600d000 - bl LZ77UnCompVram - ldr r0, =gTitleScreenCloudsGfx - ldr r1, =0x0600c000 - bl LZ77UnCompVram - ldr r0, =gUnknown_08DDE458 - ldr r1, =0x0600d800 - bl LZ77UnCompVram - bl ScanlineEffect_Stop - bl ResetTasks - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x9 - strb r0, [r1] - ldr r0, =gUnknown_08540048 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085400F0 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0854013C - bl LoadCompressedObjectPic - ldr r0, =gTitleScreenEmeraldVersionPal - movs r1, 0x80 - lsls r1, 1 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_08540100 - bl LoadSpritePalette - ldr r0, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r2 - movs r1, 0x2 - strb r1, [r0] - b _080AAB1E - .pool -_080AA998: - ldr r0, =task_title_screen_1 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r2, 0 - movs r0, 0x80 - lsls r0, 1 - strh r0, [r1, 0x8] - strh r2, [r1, 0xA] - ldr r0, =0x0000fff0 - strh r0, [r1, 0xC] - subs r0, 0x10 - strh r0, [r1, 0xE] - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0x3 - strb r1, [r0] - b _080AAB1E - .pool -_080AA9E0: - movs r0, 0x1 - negs r0, r0 - ldr r1, =0x0000ffff - str r1, [sp] - movs r1, 0x1 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =title_screen_vblank_callback - bl SetVBlankCallback - ldr r0, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r2 - movs r1, 0x4 - strb r1, [r0] - b _080AAB1E - .pool -_080AAA14: - movs r2, 0x80 - lsls r2, 1 - movs r0, 0x78 - movs r1, 0x50 - movs r3, 0 - bl sub_816F2A8 - movs r1, 0xE3 - lsls r1, 8 - movs r0, 0x28 - bl SetGpuReg - ldr r4, =0x0000ffff - movs r0, 0x2A - adds r1, r4, 0 - bl SetGpuReg - movs r1, 0xE0 - lsls r1, 8 - movs r0, 0x2C - bl SetGpuReg - movs r0, 0x2E - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x42 - movs r1, 0 - bl SetGpuReg - movs r0, 0x46 - movs r1, 0 - bl SetGpuReg - ldr r1, =0x00001f1f - movs r0, 0x48 - bl SetGpuReg - ldr r1, =0x00003f1f - movs r0, 0x4A - bl SetGpuReg - movs r0, 0x50 - movs r1, 0x84 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0xC - bl SetGpuReg - ldr r1, =0x00001a0b - movs r0, 0x8 - bl SetGpuReg - ldr r1, =0x00001b0e - movs r0, 0xA - bl SetGpuReg - ldr r1, =0x00004981 - movs r0, 0xC - bl SetGpuReg - movs r0, 0x1 - bl EnableInterrupts - ldr r1, =0x0000b441 - movs r0, 0 - bl SetGpuReg - ldr r0, =0x0000019d - bl m4aSongNumStart - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0x5 - strb r1, [r0] - b _080AAB1E - .pool -_080AAAF0: - bl UpdatePaletteFade - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _080AAB1E - movs r0, 0 - bl title_screen_add_logo_shine_obj - str r4, [sp] - movs r0, 0x4 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0xA0 - movs r2, 0x4 - movs r3, 0x4 - bl ScanlineEffect_InitWave - ldr r0, =c2_title_screen_2 - bl SetMainCallback2 -_080AAB1E: - add sp, 0x14 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end c2_title_screen_1 - - thumb_func_start c2_title_screen_2 -@ void c2_title_screen_2() -c2_title_screen_2: @ 80AAB2C - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end c2_title_screen_2 - - thumb_func_start task_title_screen_1 -@ void task_title_screen_1(int task_id) -task_title_screen_1: @ 80AAB44 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0xF - ands r0, r1 - ldr r6, =gTasks - cmp r0, 0 - bne _080AAB6A - lsls r0, r5, 2 - adds r1, r0, r5 - lsls r1, 3 - adds r1, r6 - movs r2, 0xA - ldrsh r1, [r1, r2] - adds r4, r0, 0 - cmp r1, 0 - beq _080AAB7C -_080AAB6A: - lsls r3, r5, 2 - adds r0, r3, r5 - lsls r0, 3 - adds r0, r6 - movs r2, 0 - movs r1, 0x1 - strh r1, [r0, 0xA] - strh r2, [r0, 0x8] - adds r4, r3, 0 -_080AAB7C: - adds r0, r4, r5 - lsls r0, 3 - adds r6, r0, r6 - movs r1, 0x8 - ldrsh r0, [r6, r1] - cmp r0, 0 - beq _080AABC0 - ldrh r0, [r6, 0x8] - cmp r0, 0xB0 - bne _080AABA0 - movs r0, 0x1 - bl title_screen_add_logo_shine_obj - b _080AABAA - .pool -_080AABA0: - cmp r0, 0x40 - bne _080AABAA - movs r0, 0x2 - bl title_screen_add_logo_shine_obj -_080AABAA: - ldr r0, =gTasks - adds r1, r4, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - subs r0, 0x1 - strh r0, [r1, 0x8] - b _080AAC32 - .pool -_080AABC0: - ldr r1, =0x00001441 - movs r0, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0 - bl SetGpuReg - ldr r1, =0x00003f50 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - ldr r0, =gUnknown_08540018 - movs r1, 0x62 - movs r2, 0x2 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - movs r0, 0x40 - strh r0, [r1, 0x2E] - strh r5, [r1, 0x30] - ldr r0, =gUnknown_08540030 - movs r1, 0xA2 - movs r2, 0x2 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - strh r5, [r1, 0x30] - movs r0, 0x90 - strh r0, [r6, 0x8] - ldr r0, =task_title_screen_2 - str r0, [r6] -_080AAC32: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end task_title_screen_1 - - thumb_func_start task_title_screen_2 -@ void task_title_screen_2(int task_id) -task_title_screen_2: @ 80AAC50 - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0xF - ands r0, r1 - ldr r2, =gTasks - cmp r0, 0 - bne _080AAC76 - lsls r0, r4, 2 - adds r1, r0, r4 - lsls r1, 3 - adds r1, r2 - movs r3, 0xA - ldrsh r1, [r1, r3] - adds r6, r0, 0 - cmp r1, 0 - beq _080AAC88 -_080AAC76: - lsls r3, r4, 2 - adds r0, r3, r4 - lsls r0, 3 - adds r0, r2 - movs r2, 0 - movs r1, 0x1 - strh r1, [r0, 0xA] - strh r2, [r0, 0x8] - adds r6, r3, 0 -_080AAC88: - ldr r1, =gTasks - adds r0, r6, r4 - lsls r0, 3 - adds r5, r0, r1 - ldrh r0, [r5, 0x8] - movs r1, 0x8 - ldrsh r7, [r5, r1] - cmp r7, 0 - beq _080AACA8 - subs r0, 0x1 - strh r0, [r5, 0x8] - b _080AACE2 - .pool -_080AACA8: - movs r0, 0x1 - strh r0, [r5, 0xA] - ldr r1, =0x00002142 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x00000f06 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - ldr r1, =0x00001741 - movs r0, 0 - bl SetGpuReg - movs r0, 0x80 - movs r1, 0x6C - bl sub_80AA4EC - movs r0, 0x80 - movs r1, 0x94 - bl sub_80AA548 - strh r7, [r5, 0x10] - ldr r0, =task_title_screen_3 - str r0, [r5] -_080AACE2: - ldr r2, =gTasks - adds r0, r6, r4 - lsls r0, 3 - adds r3, r0, r2 - ldrh r1, [r3, 0x8] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _080AAD02 - ldrh r1, [r3, 0xC] - movs r5, 0xC - ldrsh r0, [r3, r5] - cmp r0, 0 - beq _080AAD02 - adds r0, r1, 0x1 - strh r0, [r3, 0xC] -_080AAD02: - adds r0, r6, r4 - lsls r0, 3 - adds r3, r0, r2 - ldrh r1, [r3, 0x8] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080AAD20 - ldrh r1, [r3, 0xE] - movs r5, 0xE - ldrsh r0, [r3, r5] - cmp r0, 0 - beq _080AAD20 - adds r0, r1, 0x1 - strh r0, [r3, 0xE] -_080AAD20: - adds r4, r6, r4 - lsls r4, 3 - adds r4, r2 - movs r0, 0xE - ldrsh r1, [r4, r0] - lsls r5, r1, 8 - lsls r1, 24 - lsrs r1, 16 - movs r0, 0x2C - bl SetGpuReg - lsrs r5, 16 - movs r0, 0x2E - adds r1, r5, 0 - bl SetGpuReg - movs r0, 0xF - strh r0, [r4, 0x12] - movs r0, 0x6 - strh r0, [r4, 0x14] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task_title_screen_2 - - thumb_func_start task_title_screen_3 -@ void task_title_screen_3(int task_id) -task_title_screen_3: @ 80AAD64 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, =gMain - ldrh r1, [r2, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080AAD84 - movs r0, 0x8 - ands r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - beq _080AADB0 -_080AAD84: - movs r0, 0x4 - bl FadeOutBGM - movs r0, 0x1 - negs r0, r0 - ldr r1, =0x0000ffff - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =Cb2_GoToMainMenu - bl SetMainCallback2 - b _080AAE98 - .pool -_080AADB0: - ldrh r1, [r2, 0x2C] - movs r0, 0x46 - ands r0, r1 - cmp r0, 0x46 - bne _080AADC8 - ldr r0, =c2_clear_save_data_screen_1 - bl SetMainCallback2 - b _080AAE98 - .pool -_080AADC8: - movs r0, 0x26 - ands r0, r1 - cmp r0, 0x26 - bne _080AADFC - bl CanResetRTC - cmp r0, 0x1 - bne _080AADFC - movs r0, 0x4 - bl FadeOutBGM - movs r0, 0x1 - negs r0, r0 - str r4, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =c2_reset_rtc_screen_1 - bl SetMainCallback2 - b _080AAE98 - .pool -_080AADFC: - ldr r0, =gMain - ldrh r1, [r0, 0x2C] - movs r0, 0x6 - ands r0, r1 - cmp r0, 0x6 - bne _080AAE30 - movs r0, 0x4 - bl FadeOutBGM - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =c2_berry_program_update_screen_1 - bl SetMainCallback2 - b _080AAE98 - .pool -_080AAE30: - movs r0, 0x2C - movs r1, 0 - bl SetGpuReg - movs r0, 0x2E - movs r1, 0 - bl SetGpuReg - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r3, r0, r1 - ldrh r0, [r3, 0x8] - adds r0, 0x1 - strh r0, [r3, 0x8] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080AAE72 - ldrh r0, [r3, 0x10] - adds r0, 0x1 - strh r0, [r3, 0x10] - ldr r2, =gBattle_BG1_Y - movs r1, 0x10 - ldrsh r0, [r3, r1] - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - strh r0, [r2] - ldr r1, =gBattle_BG1_X - movs r0, 0 - strh r0, [r1] -_080AAE72: - ldrb r0, [r3, 0x8] - bl title_screen_update_rayquaza_ring_palette - ldr r0, =gMPlayInfo_BGM - ldr r1, =0x0000ffff - ldrh r0, [r0, 0x4] - cmp r0, 0 - bne _080AAE98 - movs r0, 0x1 - negs r0, r0 - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =c2_show_copyright_and_intro_again_1 - bl SetMainCallback2 -_080AAE98: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task_title_screen_3 - - thumb_func_start Cb2_GoToMainMenu -Cb2_GoToMainMenu: @ 80AAEB8 - push {lr} - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _080AAECA - ldr r0, =CB2_InitMainMenu - bl SetMainCallback2 -_080AAECA: - pop {r0} - bx r0 - .pool - thumb_func_end Cb2_GoToMainMenu - - thumb_func_start c2_show_copyright_and_intro_again_1 -c2_show_copyright_and_intro_again_1: @ 80AAED4 - push {lr} - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _080AAEE6 - ldr r0, =c2_show_copyright_and_intro_again_2 - bl SetMainCallback2 -_080AAEE6: - pop {r0} - bx r0 - .pool - thumb_func_end c2_show_copyright_and_intro_again_1 - - thumb_func_start c2_clear_save_data_screen_1 -c2_clear_save_data_screen_1: @ 80AAEF0 - push {lr} - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _080AAF02 - ldr r0, =CB2_InitClearSaveDataScreen - bl SetMainCallback2 -_080AAF02: - pop {r0} - bx r0 - .pool - thumb_func_end c2_clear_save_data_screen_1 - - thumb_func_start c2_reset_rtc_screen_1 -c2_reset_rtc_screen_1: @ 80AAF0C - push {lr} - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _080AAF1E - ldr r0, =sub_809EF88 - bl SetMainCallback2 -_080AAF1E: - pop {r0} - bx r0 - .pool - thumb_func_end c2_reset_rtc_screen_1 - - thumb_func_start c2_berry_program_update_screen_1 -c2_berry_program_update_screen_1: @ 80AAF28 - push {lr} - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _080AAF3E - bl m4aMPlayAllStop - ldr r0, =InitBerryFixProgram - bl SetMainCallback2 -_080AAF3E: - pop {r0} - bx r0 - .pool - thumb_func_end c2_berry_program_update_screen_1 - - thumb_func_start title_screen_update_rayquaza_ring_palette -@ void title_screen_update_rayquaza_ring_palette(u8 a1) -title_screen_update_rayquaza_ring_palette: @ 80AAF48 - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r1, r0, 24 - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _080AAF9C - adds r0, r1, 0 - movs r1, 0x80 - bl Cos - lsls r0, 16 - asrs r0, 16 - adds r2, r0, 0 - adds r2, 0x80 - lsls r0, r2, 5 - subs r0, r2 - cmp r0, 0 - bge _080AAF72 - adds r0, 0xFF -_080AAF72: - asrs r0, 8 - movs r3, 0x1F - subs r1, r3, r0 - movs r0, 0x16 - muls r0, r2 - cmp r0, 0 - bge _080AAF82 - adds r0, 0xFF -_080AAF82: - asrs r0, 8 - subs r0, r3, r0 - lsls r0, 5 - orrs r1, r0 - movs r0, 0xC0 - lsls r0, 6 - orrs r1, r0 - mov r0, sp - strh r1, [r0] - movs r1, 0xEF - movs r2, 0x2 - bl LoadPalette -_080AAF9C: - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end title_screen_update_rayquaza_ring_palette - - .align 2, 0 @ Don't pad with nop. diff --git a/data/title_screen.s b/data/title_screen.s deleted file mode 100644 index b07464ce97..0000000000 --- a/data/title_screen.s +++ /dev/null @@ -1,163 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - - .incbin "graphics/title_screen/unk_853EF78.gbapal" - - .align 2 -gTitleScreenRayquazaGfx:: @ 853F058 - .incbin "graphics/title_screen/rayquaza.4bpp.lz" - - .align 2 -gTitleScreenRayquazaTilemap:: @ 853F83C - .incbin "graphics/title_screen/rayquaza.bin.lz" - - .align 2 -gTitleScreenLogoShineGfx:: @ 853FB3C - .incbin "graphics/title_screen/logo_shine.4bpp.lz" - - .align 2 -gTitleScreenCloudsGfx:: @ 853FC8C - .incbin "graphics/title_screen/clouds.4bpp.lz" - - .align 2 -gUnknown_0853FF70:: @ 853FF70 - .2byte 0x0010, 0x0110, 0x0210, 0x0310, 0x0410, 0x0510, 0x0610, 0x0710 - .2byte 0x0810, 0x0910, 0x0a10, 0x0b10, 0x0c10, 0x0d10, 0x0e10, 0x0f10 - .2byte 0x100f, 0x100e, 0x100d, 0x100c, 0x100b, 0x100a, 0x1009, 0x1008 - .2byte 0x1007, 0x1006, 0x1005, 0x1004, 0x1003, 0x1002, 0x1001, 0x1000 - .2byte 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000 - .2byte 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000 - .2byte 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000 - .2byte 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000 - - .align 2 -gUnknown_0853FFF0:: @ 853FFF0 - .byte 0xa0, 0x60, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00 - - .align 2 -gUnknown_0853FFF8:: @ 853FFF8 - .byte 0xa0, 0x60, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00 - - .align 2 -gUnknown_08540000:: @ 8540000 - .2byte 0x0000, 0x001e, 0xffff, 0x0000 - - .align 2 -gUnknown_08540008:: @ 8540008 - .2byte 0x0040, 0x001e, 0xffff, 0x0000 - - .align 2 -gUnknown_08540010:: @ 8540010 - .4byte gUnknown_08540000 - - .align 2 -gUnknown_08540014:: @ 8540014 - .4byte gUnknown_08540008 - - .align 2 -gUnknown_08540018:: @ 8540018 - spr_template 0x03e8, 0x03e8, gUnknown_0853FFF0, gUnknown_08540010, NULL, gDummySpriteAffineAnimTable, sub_80AA40C - - .align 2 -gUnknown_08540030:: @ 8540030 - spr_template 0x03e8, 0x03e8, gUnknown_0853FFF8, gUnknown_08540014, NULL, gDummySpriteAffineAnimTable, sub_80AA474 - - .align 2 -gUnknown_08540048:: @ 8540048 - obj_tiles gTitleScreenEmeraldVersionGfx, 0x1000, 0x03e8 - null_obj_tiles - - .align 2 -gUnknown_08540058:: @ 8540058 - .byte 0xa0, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00 - - .align 2 -gUnknown_08540060:: @ 8540060 - .2byte 0x0001, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_08540068:: @ 8540068 - .2byte 0x0005, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_08540070:: @ 8540070 - .2byte 0x0009, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_08540078:: @ 8540078 - .2byte 0x000d, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_08540080:: @ 8540080 - .2byte 0x0011, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_08540088:: @ 8540088 - .2byte 0x0015, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_08540090:: @ 8540090 - .2byte 0x0019, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_08540098:: @ 8540098 - .2byte 0x001d, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_085400A0:: @ 85400A0 - .2byte 0x0021, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_085400A8:: @ 85400A8 - .2byte 0x0025, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_085400B0:: @ 85400B0 - .4byte gUnknown_08540060 - .4byte gUnknown_08540068 - .4byte gUnknown_08540070 - .4byte gUnknown_08540078 - .4byte gUnknown_08540080 - .4byte gUnknown_08540088 - .4byte gUnknown_08540090 - .4byte gUnknown_08540098 - .4byte gUnknown_085400A0 - .4byte gUnknown_085400A8 - - .align 2 -gUnknown_085400D8:: @ 85400D8 - spr_template 0x03e9, 0x03e9, gUnknown_08540058, gUnknown_085400B0, NULL, gDummySpriteAffineAnimTable, sub_80AA4B4 - - .align 2 -gUnknown_085400F0:: @ 85400F0 - obj_tiles gTitleScreenPressStartGfx, 0x0520, 0x03e9 - null_obj_tiles - - .align 2 -gUnknown_08540100:: @ 8540100 - obj_pal gTitleScreenPressStartPal, 0x03e9 - null_obj_pal - - .align 2 -gUnknown_08540110:: @ 8540110 - .byte 0xa0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00 - - .align 2 -gUnknown_08540118:: @ 8540118 - .2byte 0x0000, 0x0004, 0xffff, 0x0000 - - .align 2 -gUnknown_08540120:: @ 8540120 - .4byte gUnknown_08540118 - - .align 2 -gUnknown_08540124:: @ 8540124 - spr_template 0x03ea, 0x03e9, gUnknown_08540110, gUnknown_08540120, NULL, gDummySpriteAffineAnimTable, title_screen_logo_shine_obj_callback_type1 - - .align 2 -gUnknown_0854013C:: @ 854013C - obj_tiles gTitleScreenLogoShineGfx, 0x0800, 0x03ea - null_obj_tiles diff --git a/include/berry_fix_program.h b/include/berry_fix_program.h new file mode 100644 index 0000000000..6c31a0c8b0 --- /dev/null +++ b/include/berry_fix_program.h @@ -0,0 +1,6 @@ +#ifndef GUARD_BERRY_FIX_PROGRAM_H +#define GUARD_BERRY_FIX_PROGRAM_H + +void CB2_InitBerryFixProgram(void); + +#endif // GUARD_BERRY_FIX_PROGRAM_H diff --git a/include/clear_save_data_menu.h b/include/clear_save_data_menu.h new file mode 100644 index 0000000000..86ba99849c --- /dev/null +++ b/include/clear_save_data_menu.h @@ -0,0 +1,6 @@ +#ifndef GUARD_CLEAR_SAVE_DATA_MENU_H +#define GUARD_CLEAR_SAVE_DATA_MENU_H + +void CB2_InitClearSaveDataScreen(void); + +#endif // GUARD_CLEAR_SAVE_DATA_MENU_H diff --git a/include/constants/rgb.h b/include/constants/rgb.h index 2c22df32a4..8b323799fd 100644 --- a/include/constants/rgb.h +++ b/include/constants/rgb.h @@ -2,6 +2,7 @@ #define GUARD_RGB_H #define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10)) +#define _RGB(r, g, b) ((((b) & 0x1F) << 10) + (((g) & 0x1F) << 5) + ((r) & 0x1F)) #define RGB_BLACK RGB(0, 0, 0) #define RGB_WHITE RGB(31, 31, 31) diff --git a/include/intro.h b/include/intro.h new file mode 100644 index 0000000000..53a4464181 --- /dev/null +++ b/include/intro.h @@ -0,0 +1,8 @@ +#ifndef GUARD_INTRO_H +#define GUARD_INTRO_H + +void CB2_InitCopyrightScreenAfterBootup(void); +void CB2_InitCopyrightScreenAfterTitleScreen(void); +void sub_816F2A8(u16, u16, u16, u16); + +#endif // GUARD_INTRO_H diff --git a/include/main_menu.h b/include/main_menu.h new file mode 100644 index 0000000000..08cd913dcb --- /dev/null +++ b/include/main_menu.h @@ -0,0 +1,6 @@ +#ifndef GUARD_MAIN_MENU_H +#define GUARD_MAIN_MENU_H + +void CB2_InitMainMenu(void); + +#endif // GUARD_MAIN_MENU_H diff --git a/include/reset_rtc_screen.h b/include/reset_rtc_screen.h new file mode 100644 index 0000000000..5807dec992 --- /dev/null +++ b/include/reset_rtc_screen.h @@ -0,0 +1,6 @@ +#ifndef GUARD_RESET_RTC_SCREEN_H +#define GUARD_RESET_RTC_SCREEN_H + +void CB2_InitResetRtcScreen(void); + +#endif // GUARD_RESET_RTC_SCREEN_H diff --git a/include/title_screen.h b/include/title_screen.h new file mode 100644 index 0000000000..b660792fce --- /dev/null +++ b/include/title_screen.h @@ -0,0 +1,8 @@ +#ifndef GUARD_TITLE_SCREEN_H +#define GUARD_TITLE_SCREEN_H + +extern const u16 gUnknown_0853FF70[]; + +void CB2_InitTitleScreen(void); + +#endif // GUARD_TITLE_SCREEN_H diff --git a/ld_script.txt b/ld_script.txt index 345afb27fc..3327dcb171 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -119,7 +119,7 @@ SECTIONS { src/task.o(.text); src/reshow_battle_screen.o(.text); asm/battle_anim_80A9C70.o(.text); - asm/title_screen.o(.text); + src/title_screen.o(.text); asm/field_screen.o(.text); src/battle_setup.o(.text); asm/cable_club.o(.text); @@ -419,7 +419,7 @@ SECTIONS { data/rom_8525F58.o(.rodata); data/map_events.o(.rodata); data/battle_anim_80A9C70.o(.rodata); - data/title_screen.o(.rodata); + src/title_screen.o(.rodata); data/field_screen.o(.rodata); src/battle_setup.o(.rodata); data/cable_club.o(.rodata); diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c index 7b968a221b..8b1cd6a370 100644 --- a/src/berry_fix_program.c +++ b/src/berry_fix_program.c @@ -133,7 +133,7 @@ extern const u8 gMultiBootProgram_BerryGlitchFix_End[]; // .text -void InitBerryFixProgram(void) +void CB2_InitBerryFixProgram(void) { DisableInterrupts(0xFFFF); EnableInterrupts(0x0001); diff --git a/src/title_screen.c b/src/title_screen.c new file mode 100644 index 0000000000..4e25c8152c --- /dev/null +++ b/src/title_screen.c @@ -0,0 +1,783 @@ +#include "global.h" +#include "title_screen.h" +#include "sprite.h" +#include "gba/m4a_internal.h" +#include "clear_save_data_menu.h" +#include "decompress.h" +#include "event_data.h" +#include "intro.h" +#include "m4a.h" +#include "main.h" +#include "main_menu.h" +#include "palette.h" +#include "reset_rtc_screen.h" +#include "berry_fix_program.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "scanline_effect.h" +#include "gpu_regs.h" +#include "trig.h" +#include "constants/rgb.h" + +#define VERSION_BANNER_SHAPE 1 +#define VERSION_BANNER_RIGHT_TILEOFFSET 64 +#define VERSION_BANNER_BYTES 0x1000 +#define VERSION_BANNER_LEFT_X 98 +#define VERSION_BANNER_RIGHT_X 162 +#define VERSION_BANNER_Y 2 +#define VERSION_BANNER_Y_GOAL 66 +#define START_BANNER_X 128 + +#define CLEAR_SAVE_BUTTON_COMBO (B_BUTTON | SELECT_BUTTON | DPAD_UP) +#define RESET_RTC_BUTTON_COMBO (B_BUTTON | SELECT_BUTTON | DPAD_LEFT) +#define BERRY_UPDATE_BUTTON_COMBO (B_BUTTON | SELECT_BUTTON) +#define A_B_START_SELECT (A_BUTTON | B_BUTTON | START_BUTTON | SELECT_BUTTON) + +extern struct MusicPlayerInfo gMPlayInfo_BGM; +extern u16 gBattle_BG1_X; +extern u16 gBattle_BG1_Y; + +extern const u8 gTitleScreenEmeraldVersionGfx[]; +extern const u8 gTitleScreenPressStartGfx[]; +extern const u8 gTitleScreenPokemonLogoGfx[]; +extern const u8 gUnknown_08DE0644[]; +extern const u8 gUnknown_08DDE458[]; +extern const u16 gTitleScreenBgPalettes[]; +extern const u16 gTitleScreenPressStartPal[]; +extern const u16 gTitleScreenEmeraldVersionPal[]; + +// this file's functions +static void MainCB2(void); +static void Task_TitleScreenPhase1(u8); +static void Task_TitleScreenPhase2(u8); +static void Task_TitleScreenPhase3(u8); +static void CB2_GoToMainMenu(void); +static void CB2_GoToClearSaveDataScreen(void); +static void CB2_GoToResetRtcScreen(void); +static void CB2_GoToBerryFixScreen(void); +static void CB2_GoToCopyrightScreen(void); +static void UpdateLegendaryMarkingColor(u8); + +static void SpriteCB_VersionBannerLeft(struct Sprite *sprite); +static void SpriteCB_VersionBannerRight(struct Sprite *sprite); +static void SpriteCB_PressStartCopyrightBanner(struct Sprite *sprite); +static void SpriteCB_PokemonLogoShine(struct Sprite *sprite); + +// const rom data +static const u16 sUnusedUnknownPal[] = INCBIN_U16("graphics/title_screen/unk_853EF78.gbapal"); + +static const u8 sTitleScreenRayquazaGfx[] = INCBIN_U8("graphics/title_screen/rayquaza.4bpp.lz"); +static const u8 sTitleScreenRayquazaTilemap[] = INCBIN_U8("graphics/title_screen/rayquaza.bin.lz"); +static const u8 sTitleScreenLogoShineGfx[] = INCBIN_U8("graphics/title_screen/logo_shine.4bpp.lz"); +static const u8 sTitleScreenCloudsGfx[] = INCBIN_U8("graphics/title_screen/clouds.4bpp.lz"); + +const u16 gUnknown_0853FF70[] = +{ + 0x0010, 0x0110, 0x0210, 0x0310, 0x0410, 0x0510, 0x0610, 0x0710, + 0x0810, 0x0910, 0x0a10, 0x0b10, 0x0c10, 0x0d10, 0x0e10, 0x0f10, + 0x100f, 0x100e, 0x100d, 0x100c, 0x100b, 0x100a, 0x1009, 0x1008, + 0x1007, 0x1006, 0x1005, 0x1004, 0x1003, 0x1002, 0x1001, 0x1000, + 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, + 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, + 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, + 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, +}; + +static const struct OamData sVersionBannerLeftOamData = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 1, + .shape = VERSION_BANNER_SHAPE, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const struct OamData sVersionBannerRightOamData = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 1, + .shape = VERSION_BANNER_SHAPE, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sVersionBannerLeftAnimSequence[] = +{ + ANIMCMD_FRAME(0, 30), + ANIMCMD_END, +}; + +static const union AnimCmd sVersionBannerRightAnimSequence[] = +{ + ANIMCMD_FRAME(VERSION_BANNER_RIGHT_TILEOFFSET, 30), + ANIMCMD_END, +}; + +static const union AnimCmd *const sVersionBannerLeftAnimTable[] = +{ + sVersionBannerLeftAnimSequence, +}; + +static const union AnimCmd *const sVersionBannerRightAnimTable[] = +{ + sVersionBannerRightAnimSequence, +}; + +static const struct SpriteTemplate sVersionBannerLeftSpriteTemplate = +{ + .tileTag = 1000, + .paletteTag = 1000, + .oam = &sVersionBannerLeftOamData, + .anims = sVersionBannerLeftAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_VersionBannerLeft, +}; + +static const struct SpriteTemplate sVersionBannerRightSpriteTemplate = +{ + .tileTag = 1000, + .paletteTag = 1000, + .oam = &sVersionBannerRightOamData, + .anims = sVersionBannerRightAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_VersionBannerRight, +}; + +static const struct CompressedSpriteSheet sSpriteSheet_EmeraldVersion[] = +{ + {gTitleScreenEmeraldVersionGfx, VERSION_BANNER_BYTES, 1000}, + {NULL}, +}; + +static const struct OamData sOamData_CopyrightBanner = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sCopyrightBannerAnim0[] = +{ + ANIMCMD_FRAME(1, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim1[] = +{ + ANIMCMD_FRAME(5, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim2[] = +{ + ANIMCMD_FRAME(9, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim3[] = +{ + ANIMCMD_FRAME(13, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim4[] = +{ + ANIMCMD_FRAME(17, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim5[] = +{ + ANIMCMD_FRAME(21, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim6[] = +{ + ANIMCMD_FRAME(25, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim7[] = +{ + ANIMCMD_FRAME(29, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim8[] = +{ + ANIMCMD_FRAME(33, 4), + ANIMCMD_END, +}; +static const union AnimCmd sCopyrightBannerAnim9[] = +{ + ANIMCMD_FRAME(37, 4), + ANIMCMD_END, +}; + +static const union AnimCmd *const sStartCopyrightBannerAnimTable[] = +{ + sCopyrightBannerAnim0, + sCopyrightBannerAnim1, + sCopyrightBannerAnim2, + sCopyrightBannerAnim3, + sCopyrightBannerAnim4, + sCopyrightBannerAnim5, + sCopyrightBannerAnim6, + sCopyrightBannerAnim7, + sCopyrightBannerAnim8, + sCopyrightBannerAnim9, +}; + +static const struct SpriteTemplate sStartCopyrightBannerSpriteTemplate = +{ + .tileTag = 1001, + .paletteTag = 1001, + .oam = &sOamData_CopyrightBanner, + .anims = sStartCopyrightBannerAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_PressStartCopyrightBanner, +}; + +static const struct CompressedSpriteSheet sSpriteSheet_PressStart[] = +{ + {gTitleScreenPressStartGfx, 0x520, 1001}, + {NULL}, +}; + +static const struct SpritePalette sSpritePalette_PressStart[] = +{ + {gTitleScreenPressStartPal, 1001}, + {NULL}, +}; + +static const struct OamData sPokemonLogoShineOamData = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sPokemonLogoShineAnimSequence[] = +{ + ANIMCMD_FRAME(0, 4), + ANIMCMD_END, +}; + +static const union AnimCmd *const sPokemonLogoShineAnimTable[] = +{ + sPokemonLogoShineAnimSequence, +}; + +static const struct SpriteTemplate sPokemonLogoShineSpriteTemplate = +{ + .tileTag = 1002, + .paletteTag = 1001, + .oam = &sPokemonLogoShineOamData, + .anims = sPokemonLogoShineAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_PokemonLogoShine, +}; + +static const struct CompressedSpriteSheet sPokemonLogoShineSpriteSheet[] = +{ + {sTitleScreenLogoShineGfx, 0x800, 1002}, + {NULL}, +}; + +// code +static void SpriteCB_VersionBannerLeft(struct Sprite *sprite) +{ + if (gTasks[sprite->data[1]].data[1] != 0) + { + sprite->oam.objMode = 0; + sprite->pos1.y = VERSION_BANNER_Y_GOAL; + } + else + { + if (sprite->pos1.y != VERSION_BANNER_Y_GOAL) + sprite->pos1.y++; + if (sprite->data[0] != 0) + sprite->data[0]--; + SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0853FF70[sprite->data[0]]); + } +} + +static void SpriteCB_VersionBannerRight(struct Sprite *sprite) +{ + if (gTasks[sprite->data[1]].data[1] != 0) + { + sprite->oam.objMode = 0; + sprite->pos1.y = VERSION_BANNER_Y_GOAL; + } + else + { + if (sprite->pos1.y != VERSION_BANNER_Y_GOAL) + sprite->pos1.y++; + } +} + +static void SpriteCB_PressStartCopyrightBanner(struct Sprite *sprite) +{ + if (sprite->data[0] == 1) + { + sprite->data[1]++; + // Alternate between hidden and shown every 16th frame + if (sprite->data[1] & 0x10) + sprite->invisible = FALSE; + else + sprite->invisible = TRUE; + } + else + { + sprite->invisible = FALSE; + } +} + +static void CreatePressStartBanner(s16 x, s16 y) +{ + u8 i; + u8 spriteId; + + x -= 64; + for (i = 0; i < 5; i++, x += 32) + { + spriteId = CreateSprite(&sStartCopyrightBannerSpriteTemplate, x, y, 0); + StartSpriteAnim(&gSprites[spriteId], i); + gSprites[spriteId].data[0] = 1; + } +} + +static void CreateCopyrightBanner(s16 x, s16 y) +{ + u8 i; + u8 spriteId; + + x -= 64; + for (i = 0; i < 5; i++, x += 32) + { + spriteId = CreateSprite(&sStartCopyrightBannerSpriteTemplate, x, y, 0); + StartSpriteAnim(&gSprites[spriteId], i + 5); + } +} + +static void SpriteCB_PokemonLogoShine(struct Sprite *sprite) +{ + if (sprite->pos1.x < 272) + { + if (sprite->data[0]) // Flash background + { + u16 backgroundColor; + + if (sprite->pos1.x < DISPLAY_WIDTH / 2) + { + // Brighten background color + if (sprite->data[1] < 31) + sprite->data[1]++; + if (sprite->data[1] < 31) + sprite->data[1]++; + } + else + { + // Darken background color + if (sprite->data[1] != 0) + sprite->data[1]--; + if (sprite->data[1] != 0) + sprite->data[1]--; + } + + backgroundColor = _RGB(sprite->data[1], sprite->data[1], sprite->data[1]); + if (sprite->pos1.x == DISPLAY_WIDTH / 2 + 12 + || sprite->pos1.x == DISPLAY_WIDTH / 2 + 16 + || sprite->pos1.x == DISPLAY_WIDTH / 2 + 20 + || sprite->pos1.x == DISPLAY_WIDTH / 2 + 24) + gPlttBufferFaded[0] = RGB(24, 31, 12); + else + gPlttBufferFaded[0] = backgroundColor; + } + sprite->pos1.x += 4; + } + else + { + gPlttBufferFaded[0] = RGB_BLACK; + DestroySprite(sprite); + } +} + +static void SpriteCB_PokemonLogoShine2(struct Sprite *sprite) +{ + if (sprite->pos1.x < 272) + sprite->pos1.x += 8; + else + DestroySprite(sprite); +} + +static void StartPokemonLogoShine(u8 flashBg) +{ + u8 spriteId; + + switch (flashBg) + { + case 0: + case 2: + spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0); + gSprites[spriteId].oam.objMode = 2; + gSprites[spriteId].data[0] = flashBg; + break; + case 1: + spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0); + gSprites[spriteId].oam.objMode = 2; + gSprites[spriteId].data[0] = flashBg; + gSprites[spriteId].invisible = TRUE; + + spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0); + gSprites[spriteId].callback = SpriteCB_PokemonLogoShine2; + gSprites[spriteId].oam.objMode = 2; + + spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, -80, 68, 0); + gSprites[spriteId].callback = SpriteCB_PokemonLogoShine2; + gSprites[spriteId].oam.objMode = 2; + break; + } +} + +static void VBlankCB(void) +{ + ScanlineEffect_InitHBlankDmaTransfer(); + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); + SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); +} + +#define tCounter data[0] +#define tSkipToNext data[1] + +void CB2_InitTitleScreen(void) +{ + switch (gMain.state) + { + default: + case 0: + SetVBlankCallback(NULL); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + *((u16 *)PLTT) = RGB_WHITE; + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_BG2CNT, 0); + SetGpuReg(REG_OFFSET_BG1CNT, 0); + SetGpuReg(REG_OFFSET_BG0CNT, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + DmaFill16(3, 0, (void *)VRAM, VRAM_SIZE); + DmaFill32(3, 0, (void *)OAM, OAM_SIZE); + DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); + ResetPaletteFade(); + gMain.state = 1; + break; + case 1: + LZ77UnCompVram(gTitleScreenPokemonLogoGfx, (void *)VRAM); + LZ77UnCompVram(gUnknown_08DE0644, (void *)(VRAM + 0x4800)); + LoadPalette(gTitleScreenBgPalettes, 0, 0x1E0); + LZ77UnCompVram(sTitleScreenRayquazaGfx, (void *)(VRAM + 0x8000)); + LZ77UnCompVram(sTitleScreenRayquazaTilemap, (void *)(VRAM + 0xD000)); + LZ77UnCompVram(sTitleScreenCloudsGfx, (void *)(VRAM + 0xC000)); + LZ77UnCompVram(gUnknown_08DDE458, (void *)(VRAM + 0xD800)); + ScanlineEffect_Stop(); + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 9; + LoadCompressedObjectPic(&sSpriteSheet_EmeraldVersion[0]); + LoadCompressedObjectPic(&sSpriteSheet_PressStart[0]); + LoadCompressedObjectPic(&sPokemonLogoShineSpriteSheet[0]); + LoadPalette(gTitleScreenEmeraldVersionPal, 0x100, 0x20); + LoadSpritePalette(&sSpritePalette_PressStart[0]); + gMain.state = 2; + break; + case 2: + { + u8 taskId = CreateTask(Task_TitleScreenPhase1, 0); + + gTasks[taskId].tCounter = 256; + gTasks[taskId].tSkipToNext = FALSE; + gTasks[taskId].data[2] = -16; + gTasks[taskId].data[3] = -32; + gMain.state = 3; + break; + } + case 3: + BeginNormalPaletteFade(-1, 1, 0x10, 0, 0xFFFF); + SetVBlankCallback(VBlankCB); + gMain.state = 4; + break; + case 4: + sub_816F2A8(0x78, 0x50, 0x100, 0); + SetGpuReg(REG_OFFSET_BG2X_L, -29 * 256); + SetGpuReg(REG_OFFSET_BG2X_H, -1); + SetGpuReg(REG_OFFSET_BG2Y_L, -32 * 256); + SetGpuReg(REG_OFFSET_BG2Y_H, -1); + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WIN1H, 0); + SetGpuReg(REG_OFFSET_WIN1V, 0); + SetGpuReg(REG_OFFSET_WININ, 0x1F1F); + SetGpuReg(REG_OFFSET_WINOUT, 0x3F1F); + SetGpuReg(REG_OFFSET_BLDCNT, 0x84); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0xC); + SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(26) | BGCNT_16COLOR | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(27) | BGCNT_16COLOR | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(9) | BGCNT_256COLOR | BGCNT_AFF256x256); + EnableInterrupts(INTR_FLAG_VBLANK); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 + | DISPCNT_OBJ_1D_MAP + | DISPCNT_BG2_ON + | DISPCNT_OBJ_ON + | DISPCNT_WIN0_ON + | DISPCNT_OBJWIN_ON); + m4aSongNumStart(0x19D); + gMain.state = 5; + break; + case 5: + if (!UpdatePaletteFade()) + { + StartPokemonLogoShine(0); + ScanlineEffect_InitWave(0, DISPLAY_HEIGHT, 4, 4, 0, SCANLINE_EFFECT_REG_BG1HOFS, TRUE); + SetMainCallback2(MainCB2); + } + break; + } +} + +static void MainCB2(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +// Shine the Pokemon logo two more times, and fade in the version banner +static void Task_TitleScreenPhase1(u8 taskId) +{ + // Skip to next phase when A, B, Start, or Select is pressed + if ((gMain.newKeys & A_B_START_SELECT) || gTasks[taskId].data[1] != 0) + { + gTasks[taskId].tSkipToNext = TRUE; + gTasks[taskId].tCounter = 0; + } + + if (gTasks[taskId].tCounter != 0) + { + u16 frameNum = gTasks[taskId].tCounter; + if (frameNum == 176) + StartPokemonLogoShine(1); + else if (frameNum == 64) + StartPokemonLogoShine(2); + + gTasks[taskId].tCounter--; + } + else + { + u8 spriteId; + + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON); + SetGpuReg(REG_OFFSET_WININ, 0); + SetGpuReg(REG_OFFSET_WINOUT, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0x3F50); + SetGpuReg(REG_OFFSET_BLDALPHA, 0x10); + SetGpuReg(REG_OFFSET_BLDY, 0); + + // Create left side of version banner + spriteId = CreateSprite(&sVersionBannerLeftSpriteTemplate, VERSION_BANNER_LEFT_X, VERSION_BANNER_Y, 0); + gSprites[spriteId].data[0] = 64; + gSprites[spriteId].data[1] = taskId; + + // Create right side of version banner + spriteId = CreateSprite(&sVersionBannerRightSpriteTemplate, VERSION_BANNER_RIGHT_X, VERSION_BANNER_Y, 0); + gSprites[spriteId].data[1] = taskId; + + gTasks[taskId].tCounter = 144; + gTasks[taskId].func = Task_TitleScreenPhase2; + } +} + +// Create "Press Start" and copyright banners, and slide Pokemon logo up +static void Task_TitleScreenPhase2(u8 taskId) +{ + u32 yPos; + + // Skip to next phase when A, B, Start, or Select is pressed + if ((gMain.newKeys & A_B_START_SELECT) || gTasks[taskId].tSkipToNext) + { + gTasks[taskId].tSkipToNext = TRUE; + gTasks[taskId].tCounter = 0; + } + + if (gTasks[taskId].tCounter != 0) + { + gTasks[taskId].tCounter--; + } + else + { + gTasks[taskId].tSkipToNext = TRUE; + SetGpuReg(REG_OFFSET_BLDCNT, 0x2142); + SetGpuReg(REG_OFFSET_BLDALPHA, 0xF06); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 + | DISPCNT_OBJ_1D_MAP + | DISPCNT_BG0_ON + | DISPCNT_BG1_ON + | DISPCNT_BG2_ON + | DISPCNT_OBJ_ON); + CreatePressStartBanner(START_BANNER_X, 108); + CreateCopyrightBanner(START_BANNER_X, 148); + gTasks[taskId].data[4] = 0; + gTasks[taskId].func = Task_TitleScreenPhase3; + } + + if (!(gTasks[taskId].tCounter & 3) && gTasks[taskId].data[2] != 0) + gTasks[taskId].data[2]++; + if (!(gTasks[taskId].tCounter & 1) && gTasks[taskId].data[3] != 0) + gTasks[taskId].data[3]++; + + // Slide Pokemon logo up + yPos = gTasks[taskId].data[3] * 256; + SetGpuReg(REG_OFFSET_BG2Y_L, yPos); + SetGpuReg(REG_OFFSET_BG2Y_H, yPos / 0x10000); + + gTasks[taskId].data[5] = 15; + gTasks[taskId].data[6] = 6; +} + +// Show Rayquaza silhouette and process main title screen input +static void Task_TitleScreenPhase3(u8 taskId) +{ + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & START_BUTTON)) + { + FadeOutBGM(4); + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0xFFFF); + SetMainCallback2(CB2_GoToMainMenu); + } + else if ((gMain.heldKeys & CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO) + { + SetMainCallback2(CB2_GoToClearSaveDataScreen); + } + else if ((gMain.heldKeys & RESET_RTC_BUTTON_COMBO) == RESET_RTC_BUTTON_COMBO + && CanResetRTC() == TRUE) + { + FadeOutBGM(4); + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + SetMainCallback2(CB2_GoToResetRtcScreen); + } + else if ((gMain.heldKeys & BERRY_UPDATE_BUTTON_COMBO) == BERRY_UPDATE_BUTTON_COMBO) + { + FadeOutBGM(4); + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + SetMainCallback2(CB2_GoToBerryFixScreen); + } + else + { + SetGpuReg(REG_OFFSET_BG2Y_L, 0); + SetGpuReg(REG_OFFSET_BG2Y_H, 0); + gTasks[taskId].tCounter++; + if (gTasks[taskId].tCounter & 1) + { + gTasks[taskId].data[4]++; + gBattle_BG1_Y = gTasks[taskId].data[4] / 2; + gBattle_BG1_X = 0; + } + UpdateLegendaryMarkingColor(gTasks[taskId].tCounter); + if ((gMPlayInfo_BGM.status & 0xFFFF) == 0) + { + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0xFFFF); + SetMainCallback2(CB2_GoToCopyrightScreen); + } + } +} + +static void CB2_GoToMainMenu(void) +{ + if (!UpdatePaletteFade()) + SetMainCallback2(CB2_InitMainMenu); +} + +static void CB2_GoToCopyrightScreen(void) +{ + if (!UpdatePaletteFade()) + SetMainCallback2(CB2_InitCopyrightScreenAfterTitleScreen); +} + +static void CB2_GoToClearSaveDataScreen(void) +{ + if (!UpdatePaletteFade()) + SetMainCallback2(CB2_InitClearSaveDataScreen); +} + +static void CB2_GoToResetRtcScreen(void) +{ + if (!UpdatePaletteFade()) + SetMainCallback2(CB2_InitResetRtcScreen); +} + +static void CB2_GoToBerryFixScreen(void) +{ + if (!UpdatePaletteFade()) + { + m4aMPlayAllStop(); + SetMainCallback2(CB2_InitBerryFixProgram); + } +} + +static void UpdateLegendaryMarkingColor(u8 frameNum) +{ + if ((frameNum % 4) == 0) // Change color every 4th frame + { + s32 intensity = Cos(frameNum, 128) + 128; + s32 r = 31 - ((intensity * 32 - intensity) / 256); + s32 g = 31 - (intensity * 22 / 256); + s32 b = 12; + + u16 color = RGB(r, g, b); + LoadPalette(&color, 0xEF, sizeof(color)); + } +}