diff --git a/asm/reset_rtc_screen.s b/asm/reset_rtc_screen.s deleted file mode 100644 index b314afbf5..000000000 --- a/asm/reset_rtc_screen.s +++ /dev/null @@ -1,1342 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_809E8E8 -sub_809E8E8: @ 809E8E8 - push {lr} - adds r3, r0, 0 - ldr r2, =gTasks - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r2, 0xC - ldrsh r1, [r0, r2] - movs r2, 0x30 - ldrsh r0, [r3, r2] - cmp r1, r0 - beq _0809E9FE - strh r1, [r3, 0x30] - subs r0, r1, 0x1 - cmp r0, 0x5 - bhi _0809E9FE - lsls r0, 2 - ldr r1, =_0809E920 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0809E920: - .4byte _0809E938 - .4byte _0809E95C - .4byte _0809E980 - .4byte _0809E9A4 - .4byte _0809E9CE - .4byte _0809E9F8 -_0809E938: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0x1 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x41 - ands r0, r1 - strb r0, [r2] - movs r0, 0x35 - b _0809E9C6 -_0809E95C: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0x1 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x41 - ands r0, r1 - strb r0, [r2] - movs r0, 0x56 - b _0809E9C6 -_0809E980: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0x1 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x41 - ands r0, r1 - strb r0, [r2] - movs r0, 0x65 - b _0809E9C6 -_0809E9A4: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0x1 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x41 - ands r0, r1 - strb r0, [r2] - movs r0, 0x74 -_0809E9C6: - strh r0, [r3, 0x20] - movs r0, 0x44 - strh r0, [r3, 0x22] - b _0809E9FE -_0809E9CE: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0x2 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x42 - ands r0, r1 - strb r0, [r2] - movs r0, 0x99 - strh r0, [r3, 0x20] - movs r0, 0x50 - strh r0, [r3, 0x22] - b _0809E9FE -_0809E9F8: - adds r0, r3, 0 - bl DestroySprite -_0809E9FE: - pop {r0} - bx r0 - thumb_func_end sub_809E8E8 - - thumb_func_start sub_809EA04 -sub_809EA04: @ 809EA04 - push {lr} - adds r3, r0, 0 - ldr r2, =gTasks - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r2, 0xC - ldrsh r1, [r0, r2] - movs r2, 0x30 - ldrsh r0, [r3, r2] - cmp r1, r0 - beq _0809EAFE - strh r1, [r3, 0x30] - subs r0, r1, 0x1 - cmp r0, 0x5 - bhi _0809EAFE - lsls r0, 2 - ldr r1, =_0809EA3C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0809EA3C: - .4byte _0809EA54 - .4byte _0809EA78 - .4byte _0809EA9C - .4byte _0809EAC0 - .4byte _0809EAEA - .4byte _0809EAF8 -_0809EA54: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x40 - ands r0, r1 - strb r0, [r2] - movs r0, 0x35 - b _0809EAE2 -_0809EA78: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x40 - ands r0, r1 - strb r0, [r2] - movs r0, 0x56 - b _0809EAE2 -_0809EA9C: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x40 - ands r0, r1 - strb r0, [r2] - movs r0, 0x65 - b _0809EAE2 -_0809EAC0: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r1, r3, 0 - adds r1, 0x2A - movs r0, 0 - strb r0, [r1] - subs r2, 0x12 - ldrb r1, [r2] - subs r0, 0x40 - ands r0, r1 - strb r0, [r2] - movs r0, 0x74 -_0809EAE2: - strh r0, [r3, 0x20] - movs r0, 0x5C - strh r0, [r3, 0x22] - b _0809EAFE -_0809EAEA: - adds r0, r3, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - b _0809EAFE -_0809EAF8: - adds r0, r3, 0 - bl DestroySprite -_0809EAFE: - pop {r0} - bx r0 - thumb_func_end sub_809EA04 - - thumb_func_start sub_809EB04 -sub_809EB04: @ 809EB04 - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gUnknown_085104C4 - bl LoadSpritePalette - ldr r0, =gSpriteTemplate_85104F0 - mov r8, r0 - movs r1, 0x35 - movs r2, 0x44 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r1, r0, 24 - ldr r6, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r4, r6, 0 - adds r4, 0x1C - adds r2, r0, r4 - ldr r1, =sub_809E8E8 - str r1, [r2] - adds r0, r6 - strh r5, [r0, 0x2E] - ldr r1, =0x0000ffff - strh r1, [r0, 0x30] - mov r0, r8 - movs r1, 0x35 - movs r2, 0x44 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r1, r0, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r4, r0, r4 - ldr r1, =sub_809EA04 - str r1, [r4] - adds r0, r6 - strh r5, [r0, 0x2E] - movs r1, 0x1 - negs r1, r1 - strh r1, [r0, 0x30] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_809EB04 - - thumb_func_start sub_809EB8C -sub_809EB8C: @ 809EB8C - push {lr} - ldr r0, =gUnknown_085104C4 - ldrh r0, [r0, 0x4] - bl FreeSpritePaletteByTag - pop {r0} - bx r0 - .pool - thumb_func_end sub_809EB8C - - thumb_func_start sub_809EBA0 -sub_809EBA0: @ 809EBA0 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - movs r1, 0 - bl sub_8198070 - adds r0, r4, 0 - bl RemoveWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_809EBA0 - - thumb_func_start sub_809EBC4 -sub_809EBC4: @ 809EBC4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - mov r10, r0 - adds r0, r1, 0 - mov r9, r2 - adds r1, r3, 0 - ldr r5, [sp, 0x30] - ldr r6, [sp, 0x34] - ldr r2, [sp, 0x38] - mov r8, r2 - mov r2, r10 - lsls r2, 24 - lsrs r2, 24 - mov r10, r2 - lsls r3, r0, 24 - lsrs r3, 24 - str r3, [sp, 0xC] - mov r0, r9 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r1, 16 - lsrs r1, 16 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - mov r2, r8 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - ldr r7, =gStringVar4 - ldr r4, =gStringVar1 - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x4 - bl ConvertIntToDecimalStringN - adds r0, r7, 0 - adds r1, r4, 0 - bl StringCopy - adds r7, r0, 0 - ldr r1, =gText_Day - bl StringCopy - adds r7, r0, 0 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - adds r0, r7, 0 - adds r1, r4, 0 - bl StringCopy - adds r7, r0, 0 - ldr r5, =gText_Colon3 - adds r1, r5, 0 - bl StringCopy - adds r7, r0, 0 - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - adds r0, r7, 0 - adds r1, r4, 0 - bl StringCopy - adds r7, r0, 0 - adds r1, r5, 0 - bl StringCopy - adds r7, r0, 0 - adds r0, r4, 0 - mov r1, r8 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - adds r0, r7, 0 - adds r1, r4, 0 - bl StringCopy - ldr r2, =gStringVar4 - mov r0, r9 - str r0, [sp] - movs r0, 0xFF - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - mov r0, r10 - movs r1, 0x1 - ldr r3, [sp, 0xC] - bl PrintTextOnWindow - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_809EBC4 - - thumb_func_start sub_809ECB4 -sub_809ECB4: @ 809ECB4 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0xC - adds r4, r0, 0 - mov r9, r1 - adds r5, r2, 0 - adds r6, r3, 0 - ldr r0, [sp, 0x24] - mov r8, r0 - lsls r4, 24 - lsrs r4, 24 - mov r0, r9 - lsls r0, 16 - lsrs r0, 16 - mov r9, r0 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r2, 0x85 - lsls r2, 2 - adds r0, r4, 0 - movs r1, 0 - movs r3, 0xE - bl SetWindowBorderStyle - str r5, [sp] - str r6, [sp, 0x4] - mov r0, r8 - str r0, [sp, 0x8] - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x1 - mov r3, r9 - bl sub_809EBC4 - ldr r2, =gText_Confirm2 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - adds r0, r4, 0 - movs r1, 0x1 - movs r3, 0x7E - bl PrintTextOnWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - add sp, 0xC - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_809ECB4 - - thumb_func_start sub_809ED38 -sub_809ED38: @ 809ED38 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r3, 16 - lsrs r3, 16 - adds r1, r3, 0 - movs r0, 0x80 - ands r0, r3 - cmp r0, 0 - beq _0809ED52 - ldrh r0, [r4] - subs r0, 0x1 - b _0809ED6C -_0809ED52: - movs r0, 0x40 - ands r0, r3 - cmp r0, 0 - beq _0809ED60 - ldrh r0, [r4] - adds r0, 0x1 - b _0809ED8A -_0809ED60: - movs r0, 0x20 - ands r0, r3 - cmp r0, 0 - beq _0809ED7A - ldrh r0, [r4] - subs r0, 0xA -_0809ED6C: - strh r0, [r4] - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, r5 - bge _0809ED96 - strh r2, [r4] - b _0809ED96 -_0809ED7A: - movs r0, 0x10 - ands r1, r0 - cmp r1, 0 - bne _0809ED86 - movs r0, 0 - b _0809ED98 -_0809ED86: - ldrh r0, [r4] - adds r0, 0xA -_0809ED8A: - strh r0, [r4] - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, r2 - ble _0809ED96 - strh r5, [r4] -_0809ED96: - movs r0, 0x1 -_0809ED98: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_809ED38 - - thumb_func_start sub_809EDA0 -sub_809EDA0: @ 809EDA0 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r0, 0x1 - strh r0, [r1, 0x8] - bx lr - .pool - thumb_func_end sub_809EDA0 - - thumb_func_start sub_809EDB8 -sub_809EDB8: @ 809EDB8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r5, =gTasks + 0x8 - adds r0, r4, r5 - ldrb r0, [r0, 0x10] - bl sub_809EBA0 - bl sub_809EB8C - subs r5, 0x8 - adds r4, r5 - ldr r0, =sub_809EDA0 - str r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_809EDB8 - - thumb_func_start sub_809EDE8 -sub_809EDE8: @ 809EDE8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0xC - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r7, r0, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 - adds r5, r7, r0 - ldrb r4, [r5, 0x4] - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - ldr r1, =gUnknown_08510420 - 0x4 - adds r2, r0, r1 - ldr r1, =gMain - ldrh r3, [r1, 0x2E] - movs r0, 0x2 - ands r0, r3 - mov r12, r1 - cmp r0, 0 - beq _0809EE3C - mov r0, r8 - subs r0, 0x8 - adds r0, r7, r0 - ldr r1, =sub_809EDB8 - str r1, [r0] - movs r0, 0 - strh r0, [r5, 0x2] - movs r0, 0x6 - b _0809EE5C - .pool -_0809EE3C: - movs r0, 0x10 - ands r0, r3 - cmp r0, 0 - beq _0809EE4A - ldrb r0, [r2, 0x7] - cmp r0, 0 - bne _0809EE5C -_0809EE4A: - mov r3, r12 - ldrh r1, [r3, 0x2E] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0809EE66 - ldrb r0, [r2, 0x6] - cmp r0, 0 - beq _0809EE66 -_0809EE5C: - strh r0, [r5, 0x4] - movs r0, 0x5 - bl PlaySE - b _0809EEF4 -_0809EE66: - cmp r4, 0x5 - bne _0809EEB4 - mov r0, r12 - ldrh r1, [r0, 0x2E] - movs r4, 0x1 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _0809EEF4 - ldr r1, =gLocalTime - ldrh r0, [r5, 0x6] - strh r0, [r1] - ldrh r0, [r5, 0x8] - strb r0, [r1, 0x2] - ldrh r0, [r5, 0xA] - strb r0, [r1, 0x3] - ldrh r0, [r5, 0xC] - strb r0, [r1, 0x4] - movs r0, 0x5 - bl PlaySE - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_809EDB8 - str r1, [r0] - strh r4, [r5, 0x2] - movs r0, 0x6 - strh r0, [r5, 0x4] - b _0809EEF4 - .pool -_0809EEB4: - ldrb r0, [r2] - lsls r0, 1 - adds r0, r5, r0 - ldrh r1, [r2, 0x2] - ldrh r2, [r2, 0x4] - mov r3, r12 - ldrh r4, [r3, 0x30] - movs r3, 0xC0 - ands r3, r4 - bl sub_809ED38 - cmp r0, 0 - beq _0809EEF4 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r5, 0x10] - ldrh r3, [r5, 0x6] - ldrb r1, [r5, 0x8] - str r1, [sp] - ldrb r1, [r5, 0xA] - str r1, [sp, 0x4] - ldrb r1, [r5, 0xC] - str r1, [sp, 0x8] - movs r1, 0 - movs r2, 0x1 - bl sub_809EBC4 - ldrb r0, [r5, 0x10] - movs r1, 0x2 - bl CopyWindowToVram -_0809EEF4: - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_809EDE8 - - thumb_func_start sub_809EF00 -sub_809EF00: @ 809EF00 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x4 - mov r8, r0 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r6, r0, 2 - add r6, r8 - lsls r6, 3 - ldr r0, =gTasks + 0x8 - mov r9, r0 - adds r5, r6, r0 - movs r0, 0 - strh r0, [r5] - ldr r1, =gLocalTime - ldrh r0, [r1] - strh r0, [r5, 0x6] - movs r0, 0x2 - ldrsb r0, [r1, r0] - strh r0, [r5, 0x8] - movs r0, 0x3 - ldrsb r0, [r1, r0] - strh r0, [r5, 0xA] - movs r0, 0x4 - ldrsb r0, [r1, r0] - strh r0, [r5, 0xC] - ldr r0, =gUnknown_08510420 - bl AddWindow - strh r0, [r5, 0x10] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r5, 0x6] - ldrb r2, [r5, 0x8] - ldrb r3, [r5, 0xA] - ldrb r4, [r5, 0xC] - str r4, [sp] - bl sub_809ECB4 - mov r0, r8 - bl sub_809EB04 - movs r0, 0x2 - strh r0, [r5, 0x4] - movs r0, 0x8 - negs r0, r0 - add r9, r0 - add r6, r9 - ldr r0, =sub_809EDE8 - str r0, [r6] - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_809EF00 - - thumb_func_start sub_809EF88 -sub_809EF88: @ 809EF88 - push {r4-r7,lr} - sub sp, 0x4 - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r0, 0 - bl SetVBlankCallback - movs r2, 0xA0 - lsls r2, 19 - mov r1, sp - movs r0, 0 - strh r0, [r1] - ldr r1, =0x040000d4 - mov r0, sp - str r0, [r1] - str r2, [r1, 0x4] - ldr r0, =0x81000200 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r2, 0xC0 - lsls r2, 19 - movs r3, 0xC0 - lsls r3, 9 - mov r4, sp - movs r6, 0 - movs r5, 0x80 - lsls r5, 5 - ldr r7, =0x81000800 - movs r0, 0x81 - lsls r0, 24 - mov r12, r0 -_0809EFCA: - strh r6, [r4] - mov r0, sp - str r0, [r1] - str r2, [r1, 0x4] - str r7, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r2, r5 - subs r3, r5 - cmp r3, r5 - bhi _0809EFCA - strh r6, [r4] - mov r0, sp - str r0, [r1] - str r2, [r1, 0x4] - lsrs r0, r3, 1 - mov r2, r12 - orrs r0, r2 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r0, 0 - movs r1, 0x80 - bl ResetOamRange - bl LoadOam - bl ScanlineEffect_Stop - bl ScanlineEffect_Clear - bl ResetSpriteData - bl ResetTasks - bl ResetPaletteFade - bl sub_809F048 - ldr r0, =sub_809F0AC - bl SetVBlankCallback - ldr r0, =sub_809F090 - bl SetMainCallback2 - ldr r0, =sub_809F200 - movs r1, 0x50 - bl CreateTask - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_809EF88 - - thumb_func_start sub_809F048 -sub_809F048: @ 809F048 - push {lr} - bl clear_scheduled_bg_copies_to_vram - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_08510404 - movs r0, 0 - movs r2, 0x1 - bl InitBgsFromTemplates - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - ldr r0, =gUnknown_08510408 - bl InitWindows - bl DeactivateAllTextPrinters - bl sub_81973A4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_809F048 - - thumb_func_start sub_809F090 -sub_809F090: @ 809F090 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl do_scheduled_bg_tilemap_copies_to_vram - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_809F090 - - thumb_func_start sub_809F0AC -sub_809F0AC: @ 809F0AC - push {lr} - bl ProcessSpriteCopyRequests - bl LoadOam - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_809F0AC - - thumb_func_start sub_809F0C0 -sub_809F0C0: @ 809F0C0 - push {r4,lr} - sub sp, 0xC - adds r4, r0, 0 - movs r2, 0x80 - lsls r2, 2 - movs r0, 0x1 - movs r1, 0 - movs r3, 0xF - bl sub_8197B1C - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0 - bl PrintTextOnWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_809F0C0 - - thumb_func_start sub_809F0F8 -sub_809F0F8: @ 809F0F8 - push {r4-r7,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r7, r0, 24 - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - movs r0, 0 - ldrsh r5, [r6, r0] - cmp r5, 0 - beq _0809F11C - cmp r5, 0x1 - beq _0809F1B2 - b _0809F1F8 - .pool -_0809F11C: - movs r2, 0x85 - lsls r2, 2 - movs r0, 0 - movs r1, 0 - movs r3, 0xE - bl SetWindowBorderStyle - ldr r2, =gText_PresentTime - movs r0, 0x1 - str r0, [sp] - movs r4, 0xFF - str r4, [sp, 0x4] - str r5, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - ldr r1, =gLocalTime - ldrh r3, [r1] - ldrb r0, [r1, 0x2] - str r0, [sp] - ldrb r0, [r1, 0x3] - str r0, [sp, 0x4] - ldrb r0, [r1, 0x4] - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0 - movs r2, 0x11 - bl sub_809EBC4 - ldr r2, =gText_PreviousTime - movs r0, 0x21 - str r0, [sp] - str r4, [sp, 0x4] - str r5, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xA0 - ldrh r3, [r0] - adds r0, 0x2 - ldrb r0, [r0] - str r0, [sp] - adds r0, r1, 0 - adds r0, 0xA3 - ldrb r0, [r0] - str r0, [sp, 0x4] - adds r0, r1, 0 - adds r0, 0xA4 - ldrb r0, [r0] - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0 - movs r2, 0x31 - bl sub_809EBC4 - ldr r0, =gText_ResetRTCConfirmCancel - bl sub_809F0C0 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldrh r0, [r6] - adds r0, 0x1 - strh r0, [r6] -_0809F1B2: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0809F1E4 - adds r0, r7, 0 - bl DestroyTask - bl DoSoftReset - b _0809F1F8 - .pool -_0809F1E4: - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0809F1F8 - movs r0, 0x5 - bl PlaySE - adds r0, r7, 0 - bl DestroyTask -_0809F1F8: - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_809F0F8 - - thumb_func_start sub_809F200 -sub_809F200: @ 809F200 - 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, 0x6 - bls _0809F21C - b _0809F404 -_0809F21C: - lsls r0, 2 - ldr r1, =_0809F230 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0809F230: - .4byte _0809F24C - .4byte _0809F268 - .4byte _0809F2B4 - .4byte _0809F310 - .4byte _0809F398 - .4byte _0809F3C8 - .4byte _0809F3EA -_0809F24C: - movs r0, 0x1 - negs r0, r0 - ldr r1, =0x0000ffff - str r1, [sp] - movs r1, 0x1 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r0, 0x1 - strh r0, [r5] - b _0809F404 - .pool -_0809F268: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0809F276 - b _0809F404 -_0809F276: - ldr r0, =gSaveFileStatus - ldrh r0, [r0] - cmp r0, 0 - beq _0809F282 - cmp r0, 0x2 - bne _0809F29C -_0809F282: - ldr r0, =gText_NoSaveFileCantSetTime - bl sub_809F0C0 - movs r0, 0x5 - strh r0, [r5] - b _0809F404 - .pool -_0809F29C: - bl RtcCalcLocalTime - ldr r0, =sub_809F0F8 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x2] - b _0809F334 - .pool -_0809F2B4: - ldr r2, =gTasks - movs r0, 0x2 - ldrsh r1, [r5, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x4] - cmp r0, 0x1 - bne _0809F2CA - b _0809F404 -_0809F2CA: - movs r0, 0 - movs r1, 0 - bl sub_8198070 - ldr r0, =gText_PleaseResetTime - bl sub_809F0C0 - ldr r2, =gLocalTime - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - adds r0, 0xA0 - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r2] - str r1, [r2, 0x4] - ldr r0, =sub_809EF00 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x2] - movs r0, 0x3 - strh r0, [r5] - b _0809F404 - .pool -_0809F310: - ldr r2, =gTasks - movs r0, 0x2 - ldrsh r1, [r5, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r1, r0, r2 - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0 - beq _0809F404 - movs r2, 0xA - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _0809F340 - ldrb r0, [r5, 0x2] - bl DestroyTask -_0809F334: - movs r0, 0x2 - strh r0, [r5] - b _0809F404 - .pool -_0809F340: - ldrb r0, [r5, 0x2] - bl DestroyTask - bl RtcReset - ldr r4, =gLocalTime - movs r1, 0 - ldrsh r0, [r4, r1] - movs r1, 0x2 - ldrsb r1, [r4, r1] - movs r2, 0x3 - ldrsb r2, [r4, r2] - movs r3, 0x4 - ldrsb r3, [r4, r3] - bl RtcCalcLocalTimeOffset - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - adds r2, 0xA0 - ldr r0, [r4] - ldr r1, [r4, 0x4] - str r0, [r2] - str r1, [r2, 0x4] - ldr r0, =0x00004040 - ldrh r1, [r4] - bl VarSet - bl DisableResetRTC - ldr r0, =gText_ClockHasBeenReset - bl sub_809F0C0 - movs r0, 0x4 - strh r0, [r5] - b _0809F404 - .pool -_0809F398: - movs r0, 0 - bl TrySavingData - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809F3B8 - ldr r0, =gText_SaveCompleted - bl sub_809F0C0 - movs r0, 0x49 - bl PlaySE - b _0809F3C4 - .pool -_0809F3B8: - ldr r0, =gText_SaveFailed - bl sub_809F0C0 - movs r0, 0x16 - bl PlaySE -_0809F3C4: - movs r0, 0x5 - strh r0, [r5] -_0809F3C8: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0809F404 - movs r0, 0x1 - negs r0, r0 - ldr r1, =0x0000ffff - str r1, [sp] - movs r1, 0x1 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - movs r0, 0x6 - strh r0, [r5] -_0809F3EA: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0809F404 - adds r0, r4, 0 - bl DestroyTask - bl FreeAllWindowBuffers - bl DoSoftReset -_0809F404: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_809F200 - - thumb_func_start sub_809F41C -sub_809F41C: @ 809F41C - push {lr} - ldr r0, =0x00000861 - bl FlagSet - movs r0, 0x86 - lsls r0, 4 - bl FlagSet - ldr r0, =0x00000862 - bl FlagSet - pop {r0} - bx r0 - .pool - thumb_func_end sub_809F41C - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/title_screen.s b/asm/title_screen.s index 32594424a..9a494c321 100644 --- a/asm/title_screen.s +++ b/asm/title_screen.s @@ -1243,7 +1243,7 @@ c2_reset_rtc_screen_1: @ 80AAF0C lsls r0, 24 cmp r0, 0 bne _080AAF1E - ldr r0, =sub_809EF88 + ldr r0, =CB2_InitResetRtcScreen bl SetMainCallback2 _080AAF1E: pop {r0} diff --git a/data/reset_rtc_screen.s b/data/reset_rtc_screen.s deleted file mode 100644 index 6d3964da8..000000000 --- a/data/reset_rtc_screen.s +++ /dev/null @@ -1,78 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_08510404:: @ 8510404 struct BgTemplate - .4byte 0x000001f0 - - .align 2 -gUnknown_08510408:: @ 8510408 - window_template 0x00, 0x01, 0x01, 0x13, 0x09, 0x0f, 0x0155 - window_template 0x00, 0x02, 0x0f, 0x1b, 0x04, 0x0f, 0x00e9 - null_window_template - - .align 2 -gUnknown_08510420:: @ 8510420 - window_template 0x00, 0x04, 0x09, 0x15, 0x02, 0x0f, 0x00bf - - .align 2 -gUnknown_08510428:: @ 8510428 - .byte 3, 0, 1, 0, 15, 39, 0, 2, 0, 0, 0, 0 - .byte 4, 0, 0, 0, 23, 0, 1, 3, 0, 0, 0, 0 - .byte 5, 0, 0, 0, 59, 0, 2, 4, 0, 0, 0, 0 - .byte 6, 0, 0, 0, 59, 0, 3, 5, 0, 0, 0, 0 - .byte 7, 0, 0, 0, 0, 0, 4, 0, 6, 0, 0, 0 - - .align 2 -gOamData_08510464:: @ 8510464 - .2byte 0x0000 - .2byte 0x0000 - .2byte 0x0000 - - .align 2 -gResetRtcScreen_DownArrowGfx:: @ 851046C - .incbin "graphics/misc/reset_rtc_screen_downarrow.4bpp" - - .align 2 -gResetRtcScreen_RightArrowGfx:: @ 851048C - .incbin "graphics/misc/reset_rtc_screen_rightarrow.4bpp" - - .align 2 -gResetRtcScreen_ArrowPal: @ 85104AC - .incbin "graphics/misc/reset_rtc_screen_arrow.gbapal" - - .align 2 -gSpriteImageTable_85104B4:: @ 85104B4 - obj_frame_tiles gResetRtcScreen_DownArrowGfx, 0x20 - obj_frame_tiles gResetRtcScreen_RightArrowGfx, 0x20 - - .align 2 -gUnknown_085104C4:: @ 85104C4 - obj_pal gResetRtcScreen_ArrowPal, 0x1000 - - .align 2 -gSpriteAnim_85104CC:: @ 85104CC - obj_image_anim_frame 0, 30 - obj_image_anim_jump 0 - - .align 2 -gSpriteAnim_85104D4: @ 85104D4 - obj_image_anim_frame 0, 30, OBJ_IMAGE_ANIM_V_FLIP - obj_image_anim_jump 0 - - .align 2 -gSpriteAnim_85104DC:: @ 85104DC - obj_image_anim_frame 1, 30 - obj_image_anim_jump 0 - - .align 2 -gSpriteAnimTable_85104E4:: @ 85104E4 - .4byte gSpriteAnim_85104CC - .4byte gSpriteAnim_85104D4 - .4byte gSpriteAnim_85104DC - - .align 2 -gSpriteTemplate_85104F0:: @ 85104F0 - spr_template 0xFFFF, 0x1000, gOamData_08510464, gSpriteAnimTable_85104E4, gSpriteImageTable_85104B4, gDummySpriteAffineAnimTable, SpriteCallbackDummy diff --git a/include/reset_rtc_screen.h b/include/reset_rtc_screen.h new file mode 100644 index 000000000..5807dec99 --- /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/strings.h b/include/strings.h index 305007c5d..33f306c41 100644 --- a/include/strings.h +++ b/include/strings.h @@ -152,6 +152,19 @@ extern const u8 gText_EggNickname[]; extern const u8 gText_Pokemon[]; extern const u8 gText_InGameClockUsable[]; +// reset rtc screen texts +extern const u8 gText_Day[]; +extern const u8 gText_Colon3[]; +extern const u8 gText_Confirm2[]; +extern const u8 gText_PresentTime[]; +extern const u8 gText_PreviousTime[]; +extern const u8 gText_ResetRTCConfirmCancel[]; +extern const u8 gText_NoSaveFileCantSetTime[]; +extern const u8 gText_PleaseResetTime[]; +extern const u8 gText_ClockHasBeenReset[]; +extern const u8 gText_SaveCompleted[]; +extern const u8 gText_SaveFailed[]; + // menu texts extern const u8 gText_MenuPokedex[]; extern const u8 gText_MenuPokemon[]; diff --git a/ld_script.txt b/ld_script.txt index 345afb27f..8bcafd0f2 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -108,7 +108,7 @@ SECTIONS { src/coord_event_weather.o(.text); asm/field_tasks.o(.text); src/clock.o(.text); - asm/reset_rtc_screen.o(.text); + src/reset_rtc_screen.o(.text); src/start_menu.o(.text); asm/start_menu.o(.text); src/tileset_anims.o(.text); @@ -409,7 +409,7 @@ SECTIONS { src/scrcmd.o(.rodata); src/coord_event_weather.o(.rodata); data/field_tasks.o(.rodata); - data/reset_rtc_screen.o(.rodata); + src/reset_rtc_screen.o(.rodata); src/start_menu.o(.rodata); src/tileset_anims.o(.rodata); src/palette.o(.rodata); diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c new file mode 100644 index 000000000..16cc72166 --- /dev/null +++ b/src/reset_rtc_screen.c @@ -0,0 +1,640 @@ +#include "global.h" +#include "reset_rtc_screen.h" +#include "event_data.h" +#include "main.h" +#include "menu.h" +#include "palette.h" +#include "rtc.h" +#include "save.h" +#include "sprite.h" +#include "constants/songs.h" +#include "sound.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "text.h" +#include "scanline_effect.h" +#include "bg.h" +#include "window.h" +#include "gpu_regs.h" +#include "new_menu_helpers.h" + +struct ResetRtcStruct +{ + /*0x0*/ u8 dataIndex; + /*0x2*/ u16 minVal; + /*0x4*/ u16 maxVal; + /*0x6*/ u8 left; + /*0x7*/ u8 right; + /*0x8*/ u8 unk8; +}; + +// this file's functions +static void CB2_ResetRtcScreen(void); +static void VBlankCB(void); +static void Task_ResetRtcScreen(u8 taskId); +static void sub_809F048(void); + +// const rom data +static const struct BgTemplate sBackgroundTemplates[] = +{ + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + } +}; + +static const struct WindowTemplate sUnknown_08510408[] = +{ + {0x00, 0x01, 0x01, 0x13, 0x09, 0x0f, 0x0155}, + {0x00, 0x02, 0x0f, 0x1b, 0x04, 0x0f, 0x00e9}, + DUMMY_WIN_TEMPLATE +}; + +static const struct WindowTemplate sUnknown_08510420 = {0x00, 0x04, 0x09, 0x15, 0x02, 0x0f, 0x00bf}; + +static const struct ResetRtcStruct sUnknown_08510428[5] = +{ + { + .dataIndex = 3, + .minVal = 1, + .maxVal = 9999, + .left = 0, + .right = 2, + .unk8 = 0, + }, + { + .dataIndex = 4, + .minVal = 0, + .maxVal = 23, + .left = 1, + .right = 3, + .unk8 = 0, + }, + { + .dataIndex = 5, + .minVal = 0, + .maxVal = 59, + .left = 2, + .right = 4, + .unk8 = 0, + }, + { + .dataIndex = 6, + .minVal = 0, + .maxVal = 59, + .left = 3, + .right = 5, + .unk8 = 0, + }, + { + .dataIndex = 7, + .minVal = 0, + .maxVal = 0, + .left = 4, + .right = 0, + .unk8 = 6, + }, +}; + +static const struct OamData sOamData_08510464 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const u8 sResetRtcScreen_DownArrowGfx[] = INCBIN_U8("graphics/misc/reset_rtc_screen_downarrow.4bpp"); +static const u8 sResetRtcScreen_RightArrowGfx[] = INCBIN_U8("graphics/misc/reset_rtc_screen_rightarrow.4bpp"); +static const u16 sResetRtcScreen_ArrowPal[] = INCBIN_U16("graphics/misc/reset_rtc_screen_arrow.gbapal"); + +static const struct SpriteFrameImage sSpriteImageTable_85104B4[] = +{ + obj_frame_tiles(sResetRtcScreen_DownArrowGfx), + obj_frame_tiles(sResetRtcScreen_RightArrowGfx) +}; + +static const struct SpritePalette sSpritePalette_Arrow = +{ + sResetRtcScreen_ArrowPal, 0x1000 +}; + +static const union AnimCmd sSpriteAnim_85104CC[] = +{ + ANIMCMD_FRAME(0, 30), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sSpriteAnim_85104D4[] = +{ + ANIMCMD_FRAME(0, 158, .vFlip = TRUE), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sSpriteAnim_85104DC[] = +{ + ANIMCMD_FRAME(1, 30), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd *const sSpriteAnimTable_85104E4[] = +{ + sSpriteAnim_85104CC, + sSpriteAnim_85104D4, + sSpriteAnim_85104DC, +}; + +static const struct SpriteTemplate sSpriteTemplate_85104F0 = +{ + .tileTag = 0xFFFF, + .paletteTag = 0x1000, + .oam = &sOamData_08510464, + .anims = sSpriteAnimTable_85104E4, + .images = sSpriteImageTable_85104B4, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +// code +static void SpriteCB_ResetRtcCusor0(struct Sprite *sprite) +{ + int state = gTasks[sprite->data[0]].data[2]; + if (state != sprite->data[1]) + { + sprite->data[1] = state; + switch (state) + { + case 1: + sprite->invisible = FALSE; + sprite->animNum = 1; + sprite->animDelayCounter = 0; + sprite->pos1.x = 53; + sprite->pos1.y = 68; + break; + case 2: + sprite->invisible = FALSE; + sprite->animNum = 1; + sprite->animDelayCounter = 0; + sprite->pos1.x = 86; + sprite->pos1.y = 68; + break; + case 3: + sprite->invisible = FALSE; + sprite->animNum = 1; + sprite->animDelayCounter = 0; + sprite->pos1.x = 101; + sprite->pos1.y = 68; + break; + case 4: + sprite->invisible = FALSE; + sprite->animNum = 1; + sprite->animDelayCounter = 0; + sprite->pos1.x = 116; + sprite->pos1.y = 68; + break; + case 5: + sprite->invisible = FALSE; + sprite->animNum = 2; + sprite->animDelayCounter = 0; + sprite->pos1.x = 153; + sprite->pos1.y = 80; + break; + case 6: + DestroySprite(sprite); + break; + } + } +} + +static void SpriteCB_ResetRtcCusor1(struct Sprite *sprite) +{ + int state = gTasks[sprite->data[0]].data[2]; + if (state != sprite->data[1]) + { + sprite->data[1] = state; + switch (state) + { + case 1: + sprite->invisible = FALSE; + sprite->animNum = 0; + sprite->animDelayCounter = 0; + sprite->pos1.x = 53; + sprite->pos1.y = 92; + break; + case 2: + sprite->invisible = FALSE; + sprite->animNum = 0; + sprite->animDelayCounter = 0; + sprite->pos1.x = 86; + sprite->pos1.y = 92; + break; + case 3: + sprite->invisible = FALSE; + sprite->animNum = 0; + sprite->animDelayCounter = 0; + sprite->pos1.x = 101; + sprite->pos1.y = 92; + break; + case 4: + sprite->invisible = FALSE; + sprite->animNum = 0; + sprite->animDelayCounter = 0; + sprite->pos1.x = 116; + sprite->pos1.y = 92; + break; + case 5: + sprite->invisible = TRUE; + break; + case 6: + DestroySprite(sprite); + break; + } + } +} + +static void CreateCursor(u8 taskId) +{ + u32 spriteId; + + LoadSpritePalette(&sSpritePalette_Arrow); + + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_85104F0, 53, 68, 0); + gSprites[spriteId].callback = SpriteCB_ResetRtcCusor0; + gSprites[spriteId].data[0] = taskId; + gSprites[spriteId].data[1] = -1; + + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_85104F0, 53, 68, 0); + gSprites[spriteId].callback = SpriteCB_ResetRtcCusor1; + gSprites[spriteId].data[0] = taskId; + gSprites[spriteId].data[1] = -1; +} + +static void FreeCursorPalette(void) +{ + FreeSpritePaletteByTag(sSpritePalette_Arrow.tag); +} + +static void HideChooseTimeWindow(u8 windowId) +{ + sub_8198070(windowId, FALSE); + RemoveWindow(windowId); + schedule_bg_copy_tilemap_to_vram(0); +} + +static void PrintTime(u8 windowId, u8 x, u8 y, u16 days, u8 hours, u8 minutes, u8 seconds) +{ + u8 *dest = gStringVar4; + + ConvertIntToDecimalStringN(gStringVar1, days, 1, 4); + dest = StringCopy(dest, gStringVar1); + dest = StringCopy(dest, gText_Day); + + ConvertIntToDecimalStringN(gStringVar1, hours, 1, 3); + dest = StringCopy(dest, gStringVar1); + dest = StringCopy(dest, gText_Colon3); + + ConvertIntToDecimalStringN(gStringVar1, minutes, 2, 2); + dest = StringCopy(dest, gStringVar1); + dest = StringCopy(dest, gText_Colon3); + + ConvertIntToDecimalStringN(gStringVar1, seconds, 2, 2); + dest = StringCopy(dest, gStringVar1); + + PrintTextOnWindow(windowId, 1, gStringVar4, x, y, TEXT_SPEED_FF, NULL); +} + +static void ShowChooseTimeWindow(u8 windowId, u16 days, u8 hours, u8 minutes, u8 seconds) +{ + SetWindowBorderStyle(windowId, FALSE, 0x214, 0xE); + PrintTime(windowId, 0, 1, days, hours, minutes, seconds); + PrintTextOnWindow(windowId, 1, gText_Confirm2, 126, 1, 0, NULL); + schedule_bg_copy_tilemap_to_vram(0); +} + +static bool32 MoveTimeUpDown(s16 *val, int minVal, int maxVal, u16 keys) +{ + if (keys & DPAD_DOWN) + { + (*val)--; + if (*val < minVal) + *val = maxVal; + } + else if (keys & DPAD_UP) + { + (*val)++; + if (*val > maxVal) + *val = minVal; + } + else if (keys & DPAD_LEFT) + { + *val -= 10; + if (*val < minVal) + *val = maxVal; + } + else if (keys & DPAD_RIGHT) + { + *val += 10; + if (*val > maxVal) + *val = minVal; + } + else + { + return FALSE; + } + + return TRUE; +} + +static void Task_ResetRtc_3(u8 taskId) +{ + gTasks[taskId].data[0] = 1; +} + +static void Task_ResetRtc_2(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + HideChooseTimeWindow(data[8]); + FreeCursorPalette(); + gTasks[taskId].func = Task_ResetRtc_3; +} + +static void Task_ResetRtc_1(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + u8 selection = data[2]; + const struct ResetRtcStruct *selectionInfo = &sUnknown_08510428[selection - 1]; + + if (gMain.newKeys & B_BUTTON) + { + gTasks[taskId].func = Task_ResetRtc_2; + data[1] = 0; + data[2] = 6; + PlaySE(SE_SELECT); + return; + } + + if (gMain.newKeys & DPAD_RIGHT) + { + if (selectionInfo->right) + { + data[2] = selectionInfo->right; + PlaySE(SE_SELECT); + return; + } + } + + if (gMain.newKeys & DPAD_LEFT) + { + if (selectionInfo->left) + { + data[2] = selectionInfo->left; + PlaySE(SE_SELECT); + return; + } + } + + if (selection == 5) + { + if (gMain.newKeys & A_BUTTON) + { + gLocalTime.days = data[3]; + gLocalTime.hours = data[4]; + gLocalTime.minutes = data[5]; + gLocalTime.seconds = data[6]; + PlaySE(SE_SELECT); + gTasks[taskId].func = Task_ResetRtc_2; + data[1] = 1; + data[2] = 6; + } + } + else if (MoveTimeUpDown(&data[selectionInfo->dataIndex], selectionInfo->minVal, selectionInfo->maxVal, gMain.newAndRepeatedKeys & (DPAD_UP | DPAD_DOWN))) + { + PlaySE(SE_SELECT); + PrintTime(data[8], 0, 1, data[3], data[4], data[5], data[6]); + CopyWindowToVram(data[8], 2); + } +} + +static void Task_ResetRtc_0(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + data[0] = 0; + data[3] = gLocalTime.days; + data[4] = gLocalTime.hours; + data[5] = gLocalTime.minutes; + data[6] = gLocalTime.seconds; + data[8] = AddWindow(&sUnknown_08510420); + ShowChooseTimeWindow(data[8], data[3], data[4], data[5], data[6]); + CreateCursor(taskId); + data[2] = 2; + gTasks[taskId].func = Task_ResetRtc_1; +} + +void CB2_InitResetRtcScreen(void) +{ + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetVBlankCallback(NULL); + DmaClear16(3, PLTT, PLTT_SIZE); + DmaFillLarge16(3, 0, (u8 *)VRAM, 0x18000, 0x1000); + ResetOamRange(0, 128); + LoadOam(); + ScanlineEffect_Stop(); + ScanlineEffect_Clear(); + ResetSpriteData(); + ResetTasks(); + ResetPaletteFade(); + sub_809F048(); + SetVBlankCallback(VBlankCB); + SetMainCallback2(CB2_ResetRtcScreen); + CreateTask(Task_ResetRtcScreen, 80); +} + +static void sub_809F048(void) +{ + clear_scheduled_bg_copies_to_vram(); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, sBackgroundTemplates, ARRAY_COUNT(sBackgroundTemplates)); + schedule_bg_copy_tilemap_to_vram(0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ShowBg(0); + InitWindows(sUnknown_08510408); + DeactivateAllTextPrinters(); + sub_81973A4(); +} + +static void CB2_ResetRtcScreen(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + do_scheduled_bg_tilemap_copies_to_vram(); + UpdatePaletteFade(); +} + +static void VBlankCB(void) +{ + ProcessSpriteCopyRequests(); + LoadOam(); + TransferPlttBuffer(); +} + +static void ShowMessage(const u8 *str) +{ + sub_8197B1C(1, FALSE, 0x200, 0xF); + PrintTextOnWindow(1, 1, str, 0, 1, 0, NULL); + schedule_bg_copy_tilemap_to_vram(0); +} + +static void Task_ShowResetRtcPrompt(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + SetWindowBorderStyle(0, FALSE, 0x214, 0xE); + PrintTextOnWindow(0, 1, gText_PresentTime, 0, 1, TEXT_SPEED_FF, 0); + PrintTime( + 0, + 0, + 17, + gLocalTime.days, + gLocalTime.hours, + gLocalTime.minutes, + gLocalTime.seconds); + PrintTextOnWindow(0, 1, gText_PreviousTime, 0, 33, TEXT_SPEED_FF, 0); + PrintTime( + 0, + 0, + 49, + gSaveBlock2Ptr->lastBerryTreeUpdate.days, + gSaveBlock2Ptr->lastBerryTreeUpdate.hours, + gSaveBlock2Ptr->lastBerryTreeUpdate.minutes, + gSaveBlock2Ptr->lastBerryTreeUpdate.seconds); + ShowMessage(gText_ResetRTCConfirmCancel); + CopyWindowToVram(0, 2); + schedule_bg_copy_tilemap_to_vram(0); + data[0]++; + case 1: + if (gMain.newKeys & B_BUTTON) + { + DestroyTask(taskId); + DoSoftReset(); + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + DestroyTask(taskId); + } + break; + } +} + +static void Task_ResetRtcScreen(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + BeginNormalPaletteFade(-1, 1, 0x10, 0, 0xFFFF); + data[0] = 1; + break; + case 1: + if (!gPaletteFade.active) + { + if (gSaveFileStatus == 0 || gSaveFileStatus == 2) + { + ShowMessage(gText_NoSaveFileCantSetTime); + data[0] = 5; + } + else + { + RtcCalcLocalTime(); + data[1] = CreateTask(Task_ShowResetRtcPrompt, 80); + data[0] = 2; + } + } + break; + case 2: + if (gTasks[data[1]].isActive != TRUE) + { + sub_8198070(0, FALSE); + ShowMessage(gText_PleaseResetTime); + gLocalTime = gSaveBlock2Ptr->lastBerryTreeUpdate; + data[1] = CreateTask(Task_ResetRtc_0, 80); + data[0] = 3; + } + break; + case 3: + if (gTasks[data[1]].data[0]) + { + if (!gTasks[data[1]].data[1]) + { + DestroyTask(data[1]); + data[0] = 2; + } + else + { + DestroyTask(data[1]); + RtcReset(); + RtcCalcLocalTimeOffset( + gLocalTime.days, + gLocalTime.hours, + gLocalTime.minutes, + gLocalTime.seconds); + gSaveBlock2Ptr->lastBerryTreeUpdate = gLocalTime; + VarSet(VAR_DAYS, gLocalTime.days); + DisableResetRTC(); + ShowMessage(gText_ClockHasBeenReset); + data[0] = 4; + } + } + break; + case 4: + if (TrySavingData(0) == 1) + { + ShowMessage(gText_SaveCompleted); + PlaySE(SE_PINPON); + } + else + { + ShowMessage(gText_SaveFailed); + PlaySE(SE_BOO); + } + data[0] = 5; + case 5: + if (gMain.newKeys & A_BUTTON) + { + BeginNormalPaletteFade(-1, 1, 0, 0x10, 0xFFFF); + data[0] = 6; + } + else + { + break; + } + case 6: + if (!gPaletteFade.active) + { + DestroyTask(taskId); + FreeAllWindowBuffers(); + DoSoftReset(); + } + } +} diff --git a/src/start_menu.c b/src/start_menu.c index a820cd992..7671a3e22 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -120,6 +120,13 @@ const struct WindowTemplate gUnknown_085105AC[] = const struct WindowTemplate gUnknown_085105BC = {0, 1, 1, 0xE, 0xA, 0xF, 8}; // code +void SetDexPokemonPokenavFlags(void) // unused +{ + FlagSet(FLAG_SYS_POKEDEX_GET); + FlagSet(FLAG_SYS_POKEMON_GET); + FlagSet(FLAG_SYS_POKENAV_GET); +} + void BuildStartMenuActions(void) { sNumStartMenuActions = 0;