mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
decompile rtc
This commit is contained in:
parent
b5fea95a46
commit
048700fe57
10
asm/clock.s
10
asm/clock.s
@ -10,11 +10,11 @@ sub_809E778: @ 809E778
|
||||
push {lr}
|
||||
ldr r0, =0x00000895
|
||||
bl FlagSet
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
bl RtcCalcLocalTime
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r2, [r0]
|
||||
adds r2, 0xA0
|
||||
ldr r3, =gUnknown_03005CF8
|
||||
ldr r3, =gLocalTime
|
||||
ldr r0, [r3]
|
||||
ldr r1, [r3, 0x4]
|
||||
str r0, [r2]
|
||||
@ -39,8 +39,8 @@ sub_809E7B0: @ 809E7B0
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _0809E7DA
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
ldr r4, =gUnknown_03005CF8
|
||||
bl RtcCalcLocalTime
|
||||
ldr r4, =gLocalTime
|
||||
adds r0, r4, 0
|
||||
bl sub_809E7E8
|
||||
adds r0, r4, 0
|
||||
@ -111,7 +111,7 @@ sub_809E858: @ 809E858
|
||||
adds r1, 0xA0
|
||||
mov r0, sp
|
||||
adds r2, r5, 0
|
||||
bl GameFreakRTC_GetDelta
|
||||
bl CalcTimeDifference
|
||||
mov r0, sp
|
||||
movs r2, 0
|
||||
ldrsh r1, [r0, r2]
|
||||
|
@ -479,7 +479,7 @@ Task_MainMenuCheckBattery: @ 802FAB0
|
||||
movs r0, 0x54
|
||||
movs r1, 0x7
|
||||
bl SetGpuReg
|
||||
bl GameFreakRTC_GetErrorFlags
|
||||
bl RtcGetErrorStatus
|
||||
movs r1, 0xFF
|
||||
lsls r1, 4
|
||||
ands r1, r0
|
||||
|
@ -256,7 +256,7 @@ NewGameInitData: @ 80844A0
|
||||
cmp r0, 0x2
|
||||
bne _080844B2
|
||||
_080844AE:
|
||||
bl GameFreakRTC_Reset
|
||||
bl RtcReset
|
||||
_080844B2:
|
||||
ldr r1, =gUnknown_020322D4
|
||||
movs r0, 0x1
|
||||
|
@ -2507,8 +2507,8 @@ _0806D1DC:
|
||||
adds r0, r3
|
||||
b _0806D228
|
||||
_0806D1E6:
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
bl RtcCalcLocalTime
|
||||
ldr r0, =gLocalTime
|
||||
ldrb r0, [r0, 0x2]
|
||||
subs r0, 0xC
|
||||
lsls r0, 24
|
||||
@ -2525,8 +2525,8 @@ _0806D202:
|
||||
b _0806D21E
|
||||
.pool
|
||||
_0806D208:
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
bl RtcCalcLocalTime
|
||||
ldr r0, =gLocalTime
|
||||
ldrb r0, [r0, 0x2]
|
||||
cmp r0, 0xB
|
||||
bls _0806D216
|
||||
|
@ -707,7 +707,7 @@ _0809EE66:
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _0809EEF4
|
||||
ldr r1, =gUnknown_03005CF8
|
||||
ldr r1, =gLocalTime
|
||||
ldrh r0, [r5, 0x6]
|
||||
strh r0, [r1]
|
||||
ldrh r0, [r5, 0x8]
|
||||
@ -787,7 +787,7 @@ sub_809EF00: @ 809EF00
|
||||
adds r5, r6, r0
|
||||
movs r0, 0
|
||||
strh r0, [r5]
|
||||
ldr r1, =gUnknown_03005CF8
|
||||
ldr r1, =gLocalTime
|
||||
ldrh r0, [r1]
|
||||
strh r0, [r5, 0x6]
|
||||
movs r0, 0x2
|
||||
@ -1021,7 +1021,7 @@ _0809F11C:
|
||||
movs r1, 0x1
|
||||
movs r3, 0
|
||||
bl Print
|
||||
ldr r1, =gUnknown_03005CF8
|
||||
ldr r1, =gLocalTime
|
||||
ldrh r3, [r1]
|
||||
ldrb r0, [r1, 0x2]
|
||||
str r0, [sp]
|
||||
@ -1168,7 +1168,7 @@ _0809F282:
|
||||
b _0809F404
|
||||
.pool
|
||||
_0809F29C:
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
bl RtcCalcLocalTime
|
||||
ldr r0, =sub_809F0F8
|
||||
movs r1, 0x50
|
||||
bl CreateTask
|
||||
@ -1195,7 +1195,7 @@ _0809F2CA:
|
||||
bl sub_8198070
|
||||
ldr r0, =gUnknown_085ECA38
|
||||
bl sub_809F0C0
|
||||
ldr r2, =gUnknown_03005CF8
|
||||
ldr r2, =gLocalTime
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r0, [r0]
|
||||
adds r0, 0xA0
|
||||
@ -1239,8 +1239,8 @@ _0809F334:
|
||||
_0809F340:
|
||||
ldrb r0, [r5, 0x2]
|
||||
bl DestroyTask
|
||||
bl GameFreakRTC_Reset
|
||||
ldr r4, =gUnknown_03005CF8
|
||||
bl RtcReset
|
||||
ldr r4, =gLocalTime
|
||||
movs r1, 0
|
||||
ldrsh r0, [r4, r1]
|
||||
movs r1, 0x2
|
||||
@ -1249,7 +1249,7 @@ _0809F340:
|
||||
ldrsb r2, [r4, r2]
|
||||
movs r3, 0x4
|
||||
ldrsb r3, [r4, r3]
|
||||
bl GameFreakRTC_CalcRTCToLocalDelta
|
||||
bl RtcCalcLocalTimeOffset
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r2, [r0]
|
||||
adds r2, 0xA0
|
||||
|
10
asm/rom6.s
10
asm/rom6.s
@ -4321,9 +4321,9 @@ sub_8137988: @ 8137988
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _081379CE
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
bl RtcCalcLocalTime
|
||||
ldr r1, =gUnknown_085B2B44
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
ldr r0, =gLocalTime
|
||||
ldrb r0, [r0, 0x2]
|
||||
lsls r0, 24
|
||||
asrs r0, 24
|
||||
@ -6517,7 +6517,7 @@ sub_8138BC8: @ 8138BC8
|
||||
thumb_func_start sub_8138BDC
|
||||
sub_8138BDC: @ 8138BDC
|
||||
push {lr}
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
ldr r0, =gLocalTime
|
||||
movs r1, 0
|
||||
ldrsh r0, [r0, r1]
|
||||
movs r1, 0x7
|
||||
@ -7960,7 +7960,7 @@ sub_813970C: @ 813970C
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
adds r3, r0, 0
|
||||
ldr r2, =gUnknown_03005CF8
|
||||
ldr r2, =gLocalTime
|
||||
movs r1, 0
|
||||
ldrsh r0, [r2, r1]
|
||||
subs r0, r3
|
||||
@ -7993,7 +7993,7 @@ _0813974C:
|
||||
sub_8139754: @ 8139754
|
||||
push {r4,lr}
|
||||
ldr r0, =0x000040c2
|
||||
ldr r4, =gUnknown_03005CF8
|
||||
ldr r4, =gLocalTime
|
||||
ldrh r1, [r4]
|
||||
bl VarSet
|
||||
ldrh r0, [r4]
|
||||
|
@ -31564,8 +31564,8 @@ _08195E06:
|
||||
thumb_func_start sub_8195E10
|
||||
sub_8195E10: @ 8195E10
|
||||
push {lr}
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
bl RtcCalcLocalTime
|
||||
ldr r0, =gLocalTime
|
||||
bl sub_8195E34
|
||||
ldr r1, =gUnknown_0203CD80
|
||||
adds r0, 0xA
|
||||
@ -31602,8 +31602,8 @@ sub_8195E34: @ 8195E34
|
||||
thumb_func_start sub_8195E58
|
||||
sub_8195E58: @ 8195E58
|
||||
push {lr}
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
bl RtcCalcLocalTime
|
||||
ldr r0, =gLocalTime
|
||||
bl sub_8195E34
|
||||
adds r1, r0, 0
|
||||
ldr r2, =gUnknown_0203CD80
|
||||
@ -33538,7 +33538,7 @@ sub_8196D74: @ 8196D74
|
||||
bl sub_8196D4C
|
||||
cmp r0, 0x4
|
||||
ble _08196DF4
|
||||
bl GameFreakRTC_GetNumDays
|
||||
bl RtcGetLocalDayCount
|
||||
adds r4, r0, 0
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r0, [r0]
|
||||
|
@ -383,7 +383,7 @@ _081405B6:
|
||||
lsrs r4, r0, 24
|
||||
cmp r4, 0x5
|
||||
bls _0814056C
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
bl RtcCalcLocalTime
|
||||
add sp, 0x8
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
@ -1770,7 +1770,7 @@ _081411AC:
|
||||
beq _08141214
|
||||
b _08141280
|
||||
_081411B2:
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
ldr r0, =gLocalTime
|
||||
ldrb r0, [r0, 0x2]
|
||||
subs r0, 0x4
|
||||
lsls r0, 24
|
||||
@ -1817,7 +1817,7 @@ _08141200:
|
||||
b _0814133A
|
||||
.pool
|
||||
_08141214:
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
ldr r0, =gLocalTime
|
||||
ldrb r0, [r0, 0x2]
|
||||
subs r0, 0x4
|
||||
lsls r0, 24
|
||||
@ -1868,7 +1868,7 @@ _08141268:
|
||||
b _0814133A
|
||||
.pool
|
||||
_08141280:
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
ldr r0, =gLocalTime
|
||||
ldrb r0, [r0, 0x2]
|
||||
subs r0, 0x4
|
||||
lsls r0, 24
|
||||
@ -2020,7 +2020,7 @@ sub_8141344: @ 8141344
|
||||
subs r0, r4
|
||||
lsls r0, 24
|
||||
lsrs r4, r0, 24
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
ldr r0, =gLocalTime
|
||||
ldrb r0, [r0, 0x2]
|
||||
lsls r0, 24
|
||||
asrs r0, 24
|
||||
|
819
asm/rtc.s
819
asm/rtc.s
@ -1,819 +0,0 @@
|
||||
.include "asm/macros.inc"
|
||||
.include "constants/constants.inc"
|
||||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start GameFreakRTC_ClearIME
|
||||
@ void GameFreakRTC_ClearIME()
|
||||
GameFreakRTC_ClearIME: @ 802F0CC
|
||||
ldr r2, =gUnknown_03000DCE
|
||||
ldr r1, =0x04000208
|
||||
ldrh r0, [r1]
|
||||
strh r0, [r2]
|
||||
movs r0, 0
|
||||
strh r0, [r1]
|
||||
bx lr
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_ClearIME
|
||||
|
||||
thumb_func_start GameFreakRTC_RestoreIME
|
||||
@ void GameFreakRTC_RestoreIME()
|
||||
GameFreakRTC_RestoreIME: @ 802F0E4
|
||||
ldr r0, =0x04000208
|
||||
ldr r1, =gUnknown_03000DCE
|
||||
ldrh r1, [r1]
|
||||
strh r1, [r0]
|
||||
bx lr
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_RestoreIME
|
||||
|
||||
thumb_func_start GameFreakRTC_ConvertFromBCD
|
||||
@ u8 GameFreakRTC_ConvertFromBCD(u8 bcdByte)
|
||||
GameFreakRTC_ConvertFromBCD: @ 802F0F8
|
||||
push {lr}
|
||||
lsls r0, 24
|
||||
lsrs r2, r0, 24
|
||||
cmp r2, 0x9F
|
||||
bhi _0802F10A
|
||||
movs r3, 0xF
|
||||
ands r3, r2
|
||||
cmp r3, 0x9
|
||||
bls _0802F10E
|
||||
_0802F10A:
|
||||
movs r0, 0xFF
|
||||
b _0802F11C
|
||||
_0802F10E:
|
||||
lsrs r1, r0, 28
|
||||
movs r0, 0xF
|
||||
ands r1, r0
|
||||
lsls r0, r1, 2
|
||||
adds r0, r1
|
||||
lsls r0, 1
|
||||
adds r0, r3
|
||||
_0802F11C:
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end GameFreakRTC_ConvertFromBCD
|
||||
|
||||
thumb_func_start GameFreakRTC_IsLeapYear
|
||||
@ bool8 GameFreakRTC_IsLeapYear(u32 year)
|
||||
GameFreakRTC_IsLeapYear: @ 802F120
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
movs r0, 0x3
|
||||
ands r0, r4
|
||||
cmp r0, 0
|
||||
bne _0802F138
|
||||
adds r0, r4, 0
|
||||
movs r1, 0x64
|
||||
bl __umodsi3
|
||||
cmp r0, 0
|
||||
bne _0802F146
|
||||
_0802F138:
|
||||
movs r1, 0xC8
|
||||
lsls r1, 1
|
||||
adds r0, r4, 0
|
||||
bl __umodsi3
|
||||
cmp r0, 0
|
||||
bne _0802F14A
|
||||
_0802F146:
|
||||
movs r0, 0x1
|
||||
b _0802F14C
|
||||
_0802F14A:
|
||||
movs r0, 0
|
||||
_0802F14C:
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end GameFreakRTC_IsLeapYear
|
||||
|
||||
thumb_func_start GameFreakRTC_ConvertYearMonthDayToNumDays
|
||||
@ u16 GameFreakRTC_ConvertYearMonthDayToNumDays(u8 year, u8 month, u8 dayOfMonth)
|
||||
GameFreakRTC_ConvertYearMonthDayToNumDays: @ 802F154
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
lsls r0, 24
|
||||
lsrs r7, r0, 24
|
||||
lsls r1, 24
|
||||
lsrs r6, r1, 24
|
||||
lsls r2, 24
|
||||
lsrs r2, 24
|
||||
mov r8, r2
|
||||
movs r5, 0
|
||||
subs r4, r7, 0x1
|
||||
cmp r4, 0
|
||||
blt _0802F192
|
||||
_0802F170:
|
||||
ldr r1, =0x0000016d
|
||||
adds r0, r5, r1
|
||||
lsls r0, 16
|
||||
lsrs r5, r0, 16
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_IsLeapYear
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
cmp r0, 0x1
|
||||
bne _0802F18C
|
||||
adds r0, r5, 0x1
|
||||
lsls r0, 16
|
||||
lsrs r5, r0, 16
|
||||
_0802F18C:
|
||||
subs r4, 0x1
|
||||
cmp r4, 0
|
||||
bge _0802F170
|
||||
_0802F192:
|
||||
subs r0, r6, 0x1
|
||||
cmp r0, 0
|
||||
ble _0802F1AA
|
||||
ldr r1, =gDaysInEachMonth
|
||||
adds r4, r0, 0
|
||||
_0802F19C:
|
||||
ldm r1!, {r0}
|
||||
adds r0, r5, r0
|
||||
lsls r0, 16
|
||||
lsrs r5, r0, 16
|
||||
subs r4, 0x1
|
||||
cmp r4, 0
|
||||
bne _0802F19C
|
||||
_0802F1AA:
|
||||
cmp r6, 0x2
|
||||
bls _0802F1C2
|
||||
adds r0, r7, 0
|
||||
bl GameFreakRTC_IsLeapYear
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
cmp r0, 0x1
|
||||
bne _0802F1C2
|
||||
adds r0, r5, 0x1
|
||||
lsls r0, 16
|
||||
lsrs r5, r0, 16
|
||||
_0802F1C2:
|
||||
mov r1, r8
|
||||
adds r0, r5, r1
|
||||
lsls r0, 16
|
||||
lsrs r5, r0, 16
|
||||
adds r0, r5, 0
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_ConvertYearMonthDayToNumDays
|
||||
|
||||
thumb_func_start GameFreakRTC_GetNumDaysInternal
|
||||
@ u16 GameFreakRTC_GetNumDaysInternal(struct RTCInfo *rtc)
|
||||
GameFreakRTC_GetNumDaysInternal: @ 802F1E0
|
||||
push {r4-r6,lr}
|
||||
adds r6, r0, 0
|
||||
ldrb r0, [r6]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
adds r5, r0, 0
|
||||
lsls r5, 24
|
||||
lsrs r5, 24
|
||||
ldrb r0, [r6, 0x1]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
adds r4, r0, 0
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
ldrb r0, [r6, 0x2]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
adds r2, r0, 0
|
||||
lsls r2, 24
|
||||
lsrs r2, 24
|
||||
adds r0, r5, 0
|
||||
adds r1, r4, 0
|
||||
bl GameFreakRTC_ConvertYearMonthDayToNumDays
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
pop {r4-r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end GameFreakRTC_GetNumDaysInternal
|
||||
|
||||
thumb_func_start RtcInit
|
||||
@ void GameFreakRTC_Init()
|
||||
RtcInit: @ 802F21C
|
||||
push {r4,r5,lr}
|
||||
ldr r5, =gUnknown_03000DB8
|
||||
movs r0, 0
|
||||
strh r0, [r5]
|
||||
bl GameFreakRTC_ClearIME
|
||||
bl SiiRtcUnprotect
|
||||
bl SiiRtcProbe
|
||||
ldr r4, =gUnknown_03000DCC
|
||||
strb r0, [r4]
|
||||
bl GameFreakRTC_RestoreIME
|
||||
ldrb r4, [r4]
|
||||
movs r0, 0xF
|
||||
ands r0, r4
|
||||
cmp r0, 0x1
|
||||
beq _0802F250
|
||||
movs r0, 0x1
|
||||
strh r0, [r5]
|
||||
b _0802F26E
|
||||
.pool
|
||||
_0802F250:
|
||||
movs r0, 0xF0
|
||||
ands r0, r4
|
||||
cmp r0, 0
|
||||
beq _0802F25A
|
||||
movs r0, 0x2
|
||||
_0802F25A:
|
||||
strh r0, [r5]
|
||||
ldr r4, =gUnknown_03000DC0
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_GetControlRegAndRTCDateTime
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_TestForErrors
|
||||
ldr r1, =gUnknown_03000DB8
|
||||
strh r0, [r1]
|
||||
_0802F26E:
|
||||
pop {r4,r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end RtcInit
|
||||
|
||||
thumb_func_start GameFreakRTC_GetErrorFlags
|
||||
@ u16 GameFreakRTC_GetErrorFlags()
|
||||
GameFreakRTC_GetErrorFlags: @ 802F27C
|
||||
ldr r0, =gUnknown_03000DB8
|
||||
ldrh r0, [r0]
|
||||
bx lr
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_GetErrorFlags
|
||||
|
||||
thumb_func_start GameFreakRTC_GetRTCDateTime
|
||||
@ void GameFreakRTC_GetRTCDateTime(struct RTCInfo *rtc)
|
||||
GameFreakRTC_GetRTCDateTime: @ 802F288
|
||||
push {r4,lr}
|
||||
adds r2, r0, 0
|
||||
ldr r0, =gUnknown_03000DB8
|
||||
ldrh r1, [r0]
|
||||
movs r0, 0xFF
|
||||
lsls r0, 4
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _0802F2AC
|
||||
adds r1, r2, 0
|
||||
ldr r0, =gDefaultRTCInfo
|
||||
ldm r0!, {r2-r4}
|
||||
stm r1!, {r2-r4}
|
||||
b _0802F2B2
|
||||
.pool
|
||||
_0802F2AC:
|
||||
adds r0, r2, 0
|
||||
bl GameFreakRTC_GetControlRegAndRTCDateTime
|
||||
_0802F2B2:
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_GetRTCDateTime
|
||||
|
||||
thumb_func_start GameFreakRTC_GetRTCDateTimeInternal
|
||||
@ void GameFreakRTC_GetRTCDateTimeInternal(struct RTCInfo *rtc)
|
||||
GameFreakRTC_GetRTCDateTimeInternal: @ 802F2B8
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl GameFreakRTC_ClearIME
|
||||
adds r0, r4, 0
|
||||
bl SiiRtcGetDateTime
|
||||
bl GameFreakRTC_RestoreIME
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_GetRTCDateTimeInternal
|
||||
|
||||
thumb_func_start GameFreakRTC_GetControlReg
|
||||
@ void GameFreakRTC_GetControlReg(struct RTCInfo *rtc)
|
||||
GameFreakRTC_GetControlReg: @ 802F2D0
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl GameFreakRTC_ClearIME
|
||||
adds r0, r4, 0
|
||||
bl SiiRtcGetStatus
|
||||
bl GameFreakRTC_RestoreIME
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_GetControlReg
|
||||
|
||||
thumb_func_start GameFreakRTC_GetControlRegAndRTCDateTime
|
||||
@ void GameFreakRTC_GetControlRegAndRTCDateTime(struct RTCInfo *rtc)
|
||||
GameFreakRTC_GetControlRegAndRTCDateTime: @ 802F2E8
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl GameFreakRTC_GetControlReg
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_GetRTCDateTimeInternal
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_GetControlRegAndRTCDateTime
|
||||
|
||||
thumb_func_start GameFreakRTC_TestForErrors
|
||||
@ u16 GameFreakRTC_TestForErrors(struct RTCInfo *rtc)
|
||||
GameFreakRTC_TestForErrors: @ 802F2FC
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
adds r7, r0, 0
|
||||
ldrb r1, [r7, 0x7]
|
||||
movs r0, 0x80
|
||||
ands r0, r1
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
negs r0, r0
|
||||
asrs r4, r0, 31
|
||||
movs r0, 0x20
|
||||
ands r4, r0
|
||||
movs r0, 0x40
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
bne _0802F322
|
||||
movs r0, 0x10
|
||||
orrs r4, r0
|
||||
_0802F322:
|
||||
ldrb r0, [r7]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
mov r8, r0
|
||||
cmp r0, 0xFF
|
||||
bne _0802F336
|
||||
movs r0, 0x40
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 16
|
||||
lsrs r4, r0, 16
|
||||
_0802F336:
|
||||
ldrb r0, [r7, 0x1]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
adds r6, r0, 0
|
||||
cmp r6, 0xFF
|
||||
beq _0802F34A
|
||||
cmp r6, 0
|
||||
beq _0802F34A
|
||||
cmp r6, 0xC
|
||||
ble _0802F352
|
||||
_0802F34A:
|
||||
movs r0, 0x80
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 16
|
||||
lsrs r4, r0, 16
|
||||
_0802F352:
|
||||
ldrb r0, [r7, 0x2]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
adds r5, r0, 0
|
||||
cmp r5, 0xFF
|
||||
bne _0802F36A
|
||||
movs r1, 0x80
|
||||
lsls r1, 1
|
||||
adds r0, r1, 0
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 16
|
||||
lsrs r4, r0, 16
|
||||
_0802F36A:
|
||||
cmp r6, 0x2
|
||||
bne _0802F384
|
||||
mov r0, r8
|
||||
bl GameFreakRTC_IsLeapYear
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
ldr r1, =gDaysInEachMonth
|
||||
ldr r1, [r1, 0x4]
|
||||
adds r0, r1
|
||||
b _0802F38E
|
||||
.pool
|
||||
_0802F384:
|
||||
ldr r0, =gDaysInEachMonth
|
||||
subs r1, r6, 0x1
|
||||
lsls r1, 2
|
||||
adds r1, r0
|
||||
ldr r0, [r1]
|
||||
_0802F38E:
|
||||
cmp r5, r0
|
||||
ble _0802F39E
|
||||
movs r1, 0x80
|
||||
lsls r1, 1
|
||||
adds r0, r1, 0
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 16
|
||||
lsrs r4, r0, 16
|
||||
_0802F39E:
|
||||
ldrb r0, [r7, 0x4]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
adds r5, r0, 0
|
||||
cmp r5, 0x18
|
||||
ble _0802F3B6
|
||||
movs r1, 0x80
|
||||
lsls r1, 2
|
||||
adds r0, r1, 0
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 16
|
||||
lsrs r4, r0, 16
|
||||
_0802F3B6:
|
||||
ldrb r0, [r7, 0x5]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
adds r5, r0, 0
|
||||
cmp r5, 0x3C
|
||||
ble _0802F3CE
|
||||
movs r1, 0x80
|
||||
lsls r1, 3
|
||||
adds r0, r1, 0
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 16
|
||||
lsrs r4, r0, 16
|
||||
_0802F3CE:
|
||||
ldrb r0, [r7, 0x6]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
adds r5, r0, 0
|
||||
cmp r5, 0x3C
|
||||
ble _0802F3E6
|
||||
movs r1, 0x80
|
||||
lsls r1, 4
|
||||
adds r0, r1, 0
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 16
|
||||
lsrs r4, r0, 16
|
||||
_0802F3E6:
|
||||
adds r0, r4, 0
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_TestForErrors
|
||||
|
||||
thumb_func_start GameFreakRTC_Reset
|
||||
@ void GameFreakRTC_Reset()
|
||||
GameFreakRTC_Reset: @ 802F3F8
|
||||
push {lr}
|
||||
bl GameFreakRTC_ClearIME
|
||||
bl SiiRtcReset
|
||||
bl GameFreakRTC_RestoreIME
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_Reset
|
||||
|
||||
thumb_func_start GameFreakRTC_FormatDecimalTimeString
|
||||
@ void GameFreakRTC_FormatDecimalTimeString(u8 *dest, s32 hour, s32 minute, s32 second)
|
||||
GameFreakRTC_FormatDecimalTimeString: @ 802F40C
|
||||
push {r4-r6,lr}
|
||||
adds r5, r2, 0
|
||||
adds r6, r3, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToDecimalStringN
|
||||
movs r4, 0xF0
|
||||
strb r4, [r0]
|
||||
adds r0, 0x1
|
||||
adds r1, r5, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToDecimalStringN
|
||||
strb r4, [r0]
|
||||
adds r0, 0x1
|
||||
adds r1, r6, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToDecimalStringN
|
||||
movs r1, 0xFF
|
||||
strb r1, [r0]
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_FormatDecimalTimeString
|
||||
|
||||
thumb_func_start GameFreakRTC_FormatHexTimeString
|
||||
@ void GameFreakRTC_FormatHexTimeString(u8 *dest, s32 hour, s32 minute, s32 second)
|
||||
GameFreakRTC_FormatHexTimeString: @ 802F444
|
||||
push {r4-r6,lr}
|
||||
adds r5, r2, 0
|
||||
adds r6, r3, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToHexStringN
|
||||
movs r4, 0xF0
|
||||
strb r4, [r0]
|
||||
adds r0, 0x1
|
||||
adds r1, r5, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToHexStringN
|
||||
strb r4, [r0]
|
||||
adds r0, 0x1
|
||||
adds r1, r6, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToHexStringN
|
||||
movs r1, 0xFF
|
||||
strb r1, [r0]
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_FormatHexTimeString
|
||||
|
||||
thumb_func_start GameFreakRTC_FormatHexTimeStringFromRTCInfo
|
||||
@ void GameFreakRTC_FormatHexTimeStringFromRTCInfo()
|
||||
GameFreakRTC_FormatHexTimeStringFromRTCInfo: @ 802F47C
|
||||
push {lr}
|
||||
ldr r3, =gUnknown_03000DC0
|
||||
ldrb r1, [r3, 0x4]
|
||||
ldrb r2, [r3, 0x5]
|
||||
ldrb r3, [r3, 0x6]
|
||||
bl GameFreakRTC_FormatHexTimeString
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_FormatHexTimeStringFromRTCInfo
|
||||
|
||||
thumb_func_start GameFreakRTC_FormatDecimalYearMonthDayString
|
||||
@ void GameFreakRTC_FormatDecimalYearMonthDayString(u8 *dest, s32 year, s32 month, s32 dayOfMonth)
|
||||
GameFreakRTC_FormatDecimalYearMonthDayString: @ 802F494
|
||||
push {r4-r6,lr}
|
||||
adds r5, r2, 0
|
||||
adds r6, r3, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x4
|
||||
bl ConvertIntToDecimalStringN
|
||||
movs r4, 0xAE
|
||||
strb r4, [r0]
|
||||
adds r0, 0x1
|
||||
adds r1, r5, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToDecimalStringN
|
||||
strb r4, [r0]
|
||||
adds r0, 0x1
|
||||
adds r1, r6, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToDecimalStringN
|
||||
movs r1, 0xFF
|
||||
strb r1, [r0]
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_FormatDecimalYearMonthDayString
|
||||
|
||||
thumb_func_start GameFreakRTC_FormatHexYearMonthDayString
|
||||
@ void GameFreakRTC_FormatHexYearMonthDayString(u8 *dest, s32 year, s32 month, s32 dayOfMonth)
|
||||
GameFreakRTC_FormatHexYearMonthDayString: @ 802F4CC
|
||||
push {r4-r6,lr}
|
||||
adds r5, r2, 0
|
||||
adds r6, r3, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x4
|
||||
bl ConvertIntToHexStringN
|
||||
movs r4, 0xAE
|
||||
strb r4, [r0]
|
||||
adds r0, 0x1
|
||||
adds r1, r5, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToHexStringN
|
||||
strb r4, [r0]
|
||||
adds r0, 0x1
|
||||
adds r1, r6, 0
|
||||
movs r2, 0x2
|
||||
movs r3, 0x2
|
||||
bl ConvertIntToHexStringN
|
||||
movs r1, 0xFF
|
||||
strb r1, [r0]
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_FormatHexYearMonthDayString
|
||||
|
||||
thumb_func_start GameFreakRTC_GetRTCDelta
|
||||
@ void GameFreakRTC_GetRTCDelta(RTCInfo *rtc, GameDateTime *delta, GameDateTime *dateTime)
|
||||
GameFreakRTC_GetRTCDelta: @ 802F504
|
||||
push {r4-r7,lr}
|
||||
adds r5, r0, 0
|
||||
adds r7, r1, 0
|
||||
adds r6, r2, 0
|
||||
bl GameFreakRTC_GetNumDaysInternal
|
||||
adds r4, r0, 0
|
||||
lsls r4, 16
|
||||
lsrs r4, 16
|
||||
ldrb r0, [r5, 0x6]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
ldrb r1, [r6, 0x4]
|
||||
subs r0, r1
|
||||
strb r0, [r7, 0x4]
|
||||
ldrb r0, [r5, 0x5]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
ldrb r1, [r6, 0x3]
|
||||
subs r0, r1
|
||||
strb r0, [r7, 0x3]
|
||||
ldrb r0, [r5, 0x4]
|
||||
bl GameFreakRTC_ConvertFromBCD
|
||||
ldrb r1, [r6, 0x2]
|
||||
subs r0, r1
|
||||
strb r0, [r7, 0x2]
|
||||
ldrh r0, [r6]
|
||||
subs r4, r0
|
||||
strh r4, [r7]
|
||||
ldrb r1, [r7, 0x4]
|
||||
movs r0, 0x4
|
||||
ldrsb r0, [r7, r0]
|
||||
cmp r0, 0
|
||||
bge _0802F556
|
||||
adds r0, r1, 0
|
||||
adds r0, 0x3C
|
||||
strb r0, [r7, 0x4]
|
||||
ldrb r0, [r7, 0x3]
|
||||
subs r0, 0x1
|
||||
strb r0, [r7, 0x3]
|
||||
_0802F556:
|
||||
ldrb r1, [r7, 0x3]
|
||||
movs r0, 0x3
|
||||
ldrsb r0, [r7, r0]
|
||||
cmp r0, 0
|
||||
bge _0802F56C
|
||||
adds r0, r1, 0
|
||||
adds r0, 0x3C
|
||||
strb r0, [r7, 0x3]
|
||||
ldrb r0, [r7, 0x2]
|
||||
subs r0, 0x1
|
||||
strb r0, [r7, 0x2]
|
||||
_0802F56C:
|
||||
ldrb r1, [r7, 0x2]
|
||||
movs r0, 0x2
|
||||
ldrsb r0, [r7, r0]
|
||||
cmp r0, 0
|
||||
bge _0802F582
|
||||
adds r0, r1, 0
|
||||
adds r0, 0x18
|
||||
strb r0, [r7, 0x2]
|
||||
ldrh r0, [r7]
|
||||
subs r0, 0x1
|
||||
strh r0, [r7]
|
||||
_0802F582:
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_GetRTCDelta
|
||||
|
||||
thumb_func_start GameFreakRTC_CalcLocalDateTime
|
||||
@ void GameFreakRTC_CalcLocalDateTime()
|
||||
GameFreakRTC_CalcLocalDateTime: @ 802F588
|
||||
push {r4,lr}
|
||||
ldr r4, =gUnknown_03000DC0
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_GetRTCDateTime
|
||||
ldr r1, =gUnknown_03005CF8
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r2, [r0]
|
||||
adds r2, 0x98
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_GetRTCDelta
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_CalcLocalDateTime
|
||||
|
||||
thumb_func_start GameFreakRTC_CalcRTCToLocalDelta_DayZero
|
||||
@ void GameFreakRTC_CalcRTCToLocalDelta_DayZero(u8 hour, u8 minute)
|
||||
GameFreakRTC_CalcRTCToLocalDelta_DayZero: @ 802F5B4
|
||||
push {lr}
|
||||
adds r3, r0, 0
|
||||
adds r2, r1, 0
|
||||
movs r0, 0
|
||||
adds r1, r3, 0
|
||||
movs r3, 0
|
||||
bl GameFreakRTC_CalcRTCToLocalDelta
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_CalcRTCToLocalDelta_DayZero
|
||||
|
||||
thumb_func_start GameFreakRTC_CalcRTCToLocalDelta
|
||||
@ void GameFreakRTC_CalcRTCToLocalDelta(u16 numDays, u8 hour, u8 minute, u8 second)
|
||||
GameFreakRTC_CalcRTCToLocalDelta: @ 802F5C8
|
||||
push {r4,r5,lr}
|
||||
ldr r4, =gUnknown_03005CF8
|
||||
strh r0, [r4]
|
||||
strb r1, [r4, 0x2]
|
||||
strb r2, [r4, 0x3]
|
||||
strb r3, [r4, 0x4]
|
||||
ldr r5, =gUnknown_03000DC0
|
||||
adds r0, r5, 0
|
||||
bl GameFreakRTC_GetRTCDateTime
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r1, [r0]
|
||||
adds r1, 0x98
|
||||
adds r0, r5, 0
|
||||
adds r2, r4, 0
|
||||
bl GameFreakRTC_GetRTCDelta
|
||||
pop {r4,r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_CalcRTCToLocalDelta
|
||||
|
||||
thumb_func_start GameFreakRTC_GetDelta
|
||||
@ void GameFreakRTC_GetDelta(GameDateTime *delta, GameDateTime *dateTime1, GameDateTime *dateTime2)
|
||||
GameFreakRTC_GetDelta: @ 802F5FC
|
||||
push {r4-r6,lr}
|
||||
adds r4, r0, 0
|
||||
ldrb r3, [r2, 0x4]
|
||||
ldrb r0, [r1, 0x4]
|
||||
subs r5, r3, r0
|
||||
strb r5, [r4, 0x4]
|
||||
ldrb r3, [r2, 0x3]
|
||||
ldrb r0, [r1, 0x3]
|
||||
subs r6, r3, r0
|
||||
strb r6, [r4, 0x3]
|
||||
ldrb r0, [r2, 0x2]
|
||||
ldrb r3, [r1, 0x2]
|
||||
subs r0, r3
|
||||
strb r0, [r4, 0x2]
|
||||
ldrh r0, [r2]
|
||||
ldrh r1, [r1]
|
||||
subs r0, r1
|
||||
strh r0, [r4]
|
||||
lsls r0, r5, 24
|
||||
cmp r0, 0
|
||||
bge _0802F630
|
||||
adds r0, r5, 0
|
||||
adds r0, 0x3C
|
||||
strb r0, [r4, 0x4]
|
||||
subs r0, r6, 0x1
|
||||
strb r0, [r4, 0x3]
|
||||
_0802F630:
|
||||
ldrb r1, [r4, 0x3]
|
||||
movs r0, 0x3
|
||||
ldrsb r0, [r4, r0]
|
||||
cmp r0, 0
|
||||
bge _0802F646
|
||||
adds r0, r1, 0
|
||||
adds r0, 0x3C
|
||||
strb r0, [r4, 0x3]
|
||||
ldrb r0, [r4, 0x2]
|
||||
subs r0, 0x1
|
||||
strb r0, [r4, 0x2]
|
||||
_0802F646:
|
||||
ldrb r1, [r4, 0x2]
|
||||
movs r0, 0x2
|
||||
ldrsb r0, [r4, r0]
|
||||
cmp r0, 0
|
||||
bge _0802F65C
|
||||
adds r0, r1, 0
|
||||
adds r0, 0x18
|
||||
strb r0, [r4, 0x2]
|
||||
ldrh r0, [r4]
|
||||
subs r0, 0x1
|
||||
strh r0, [r4]
|
||||
_0802F65C:
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end GameFreakRTC_GetDelta
|
||||
|
||||
thumb_func_start GameFreakRTC_GetNumMinutes
|
||||
@ u16 GameFreakRTC_GetNumMinutes()
|
||||
GameFreakRTC_GetNumMinutes: @ 802F664
|
||||
push {r4,lr}
|
||||
ldr r4, =gUnknown_03000DC0
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_GetRTCDateTime
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_GetNumDaysInternal
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
lsls r1, r0, 1
|
||||
adds r1, r0
|
||||
lsls r0, r1, 4
|
||||
subs r0, r1
|
||||
lsls r0, 5
|
||||
ldrb r2, [r4, 0x4]
|
||||
lsls r1, r2, 4
|
||||
subs r1, r2
|
||||
lsls r1, 2
|
||||
adds r0, r1
|
||||
ldrb r4, [r4, 0x5]
|
||||
adds r0, r4
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_GetNumMinutes
|
||||
|
||||
thumb_func_start GameFreakRTC_GetNumDays
|
||||
@ u16 GameFreakRTC_GetNumDays()
|
||||
GameFreakRTC_GetNumDays: @ 802F69C
|
||||
push {lr}
|
||||
ldr r0, =gUnknown_03000DC0
|
||||
bl GameFreakRTC_GetNumDaysInternal
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end GameFreakRTC_GetNumDays
|
||||
|
||||
.align 2, 0 @ Don't pad with nop.
|
@ -1507,7 +1507,7 @@ s2C_unknown: @ 8099DD8
|
||||
lsls r1, 24
|
||||
lsrs r1, 24
|
||||
adds r0, r4, 0
|
||||
bl GameFreakRTC_CalcRTCToLocalDelta_DayZero
|
||||
bl RtcInitLocalTimeOffset
|
||||
movs r0, 0
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
@ -1528,9 +1528,9 @@ s2D_unknown: @ 8099E10
|
||||
@ int s2E_unknown(script_env *env)
|
||||
s2E_unknown: @ 8099E1C
|
||||
push {lr}
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
bl RtcCalcLocalTime
|
||||
ldr r2, =gSpecialVar_0x8000
|
||||
ldr r1, =gUnknown_03005CF8
|
||||
ldr r1, =gLocalTime
|
||||
movs r0, 0x2
|
||||
ldrsb r0, [r1, r0]
|
||||
strh r0, [r2]
|
||||
|
2
asm/tv.s
2
asm/tv.s
@ -5676,7 +5676,7 @@ _080EEF84:
|
||||
adds r1, r2
|
||||
movs r0, 0x2
|
||||
strb r0, [r1]
|
||||
ldr r0, =gUnknown_03005CF8
|
||||
ldr r0, =gLocalTime
|
||||
ldrb r0, [r0, 0x2]
|
||||
lsls r0, 24
|
||||
asrs r0, 24
|
||||
|
@ -785,7 +785,7 @@ sub_8134EA4: @ 8134EA4
|
||||
ldrsh r0, [r4, r1]
|
||||
movs r2, 0xE
|
||||
ldrsh r1, [r4, r2]
|
||||
bl GameFreakRTC_CalcRTCToLocalDelta_DayZero
|
||||
bl RtcInitLocalTimeOffset
|
||||
movs r0, 0x1
|
||||
negs r0, r0
|
||||
movs r1, 0
|
||||
@ -1128,13 +1128,13 @@ sub_8135130: @ 8135130
|
||||
adds r4, r0, 0
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
bl GameFreakRTC_CalcLocalDateTime
|
||||
bl RtcCalcLocalTime
|
||||
ldr r1, =gTasks
|
||||
lsls r0, r4, 2
|
||||
adds r0, r4
|
||||
lsls r0, 3
|
||||
adds r6, r0, r1
|
||||
ldr r5, =gUnknown_03005CF8
|
||||
ldr r5, =gLocalTime
|
||||
movs r0, 0x2
|
||||
ldrsb r0, [r5, r0]
|
||||
strh r0, [r6, 0xC]
|
||||
|
@ -1,5 +1,5 @@
|
||||
.align 2
|
||||
gDefaultRTCInfo:: @ 82FECC0
|
||||
sRtcDummy:: @ 82FECC0
|
||||
.byte 0 @ year
|
||||
.byte 1 @ month
|
||||
.byte 1 @ day of month
|
||||
@ -13,7 +13,7 @@ gDefaultRTCInfo:: @ 82FECC0
|
||||
.2byte 0 @ padding
|
||||
|
||||
.align 2
|
||||
gDaysInEachMonth:: @ 82FECCC
|
||||
sNumDaysInMonths:: @ 82FECCC
|
||||
.4byte 31 @ January
|
||||
.4byte 28 @ February
|
||||
.4byte 31 @ March
|
||||
|
@ -87,6 +87,14 @@ struct UCoords16
|
||||
u16 y;
|
||||
};
|
||||
|
||||
struct Time
|
||||
{
|
||||
/*0x00*/ s16 days;
|
||||
/*0x02*/ s8 hours;
|
||||
/*0x03*/ s8 minutes;
|
||||
/*0x04*/ s8 seconds;
|
||||
};
|
||||
|
||||
struct Pokedex
|
||||
{
|
||||
/*0x00*/ u8 order;
|
||||
@ -118,6 +126,9 @@ struct SaveBlock2
|
||||
u16 optionsBattleSceneOff:1; // whether battle animations are disabled
|
||||
u16 regionMapZoom:1; // whether the map is zoomed in
|
||||
/*0x18*/ struct Pokedex pokedex;
|
||||
/*0x90*/ u8 filler_90[0x8];
|
||||
/*0x98*/ struct Time localTimeOffset;
|
||||
/*0xA0*/ struct Time lastBerryTreeUpdate;
|
||||
};
|
||||
|
||||
extern struct SaveBlock2 *gSaveBlock2Ptr;
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef GUARD_POKEMON_H
|
||||
#define GUARD_POKEMON_H
|
||||
|
||||
#define MON_DATA_PERSONALITY 0
|
||||
#define MON_DATA_OT_ID 1
|
||||
#define MON_DATA_NICKNAME 2
|
||||
@ -309,3 +312,5 @@ struct BattleMove
|
||||
u32 GetMonData();
|
||||
|
||||
u8 pokemon_species_get_gender_info(u16 species, u32 personality);
|
||||
|
||||
#endif // GUARD_POKEMON_H
|
||||
|
@ -22,7 +22,7 @@ extern struct Time gLocalTime;
|
||||
void RtcDisableInterrupts(void);
|
||||
void RtcRestoreInterrupts(void);
|
||||
u32 ConvertBcdToBinary(u8 bcd);
|
||||
bool8 IsLeapYear(u8 year);
|
||||
bool8 IsLeapYear(u32 year);
|
||||
u16 ConvertDateToDayCount(u8 year, u8 month, u8 day);
|
||||
u16 RtcGetDayCount(struct SiiRtcInfo *rtc);
|
||||
void RtcInit(void);
|
||||
|
@ -49,7 +49,7 @@ SECTIONS {
|
||||
src/sprite.o(.text);
|
||||
src/string_util.o(.text);
|
||||
asm/link.o(.text);
|
||||
asm/rtc.o(.text);
|
||||
src/rtc.o(.text);
|
||||
asm/main_menu.o(.text);
|
||||
asm/rom3.o(.text);
|
||||
src/decompress.o(.text);
|
||||
|
329
src/rtc.c
Normal file
329
src/rtc.c
Normal file
@ -0,0 +1,329 @@
|
||||
#include "global.h"
|
||||
#include "rtc.h"
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
|
||||
extern u16 sErrorStatus;
|
||||
extern struct SiiRtcInfo sRtc;
|
||||
extern u8 sProbeResult;
|
||||
extern u16 sSavedIme;
|
||||
|
||||
extern struct Time gLocalTime;
|
||||
|
||||
extern const struct SiiRtcInfo sRtcDummy;
|
||||
|
||||
extern const s32 sNumDaysInMonths[12];
|
||||
|
||||
void RtcDisableInterrupts(void)
|
||||
{
|
||||
sSavedIme = REG_IME;
|
||||
REG_IME = 0;
|
||||
}
|
||||
|
||||
void RtcRestoreInterrupts(void)
|
||||
{
|
||||
REG_IME = sSavedIme;
|
||||
}
|
||||
|
||||
u32 ConvertBcdToBinary(u8 bcd)
|
||||
{
|
||||
if (bcd > 0x9F)
|
||||
return 0xFF;
|
||||
|
||||
if ((bcd & 0xF) <= 9)
|
||||
return (10 * ((bcd >> 4) & 0xF)) + (bcd & 0xF);
|
||||
else
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
bool8 IsLeapYear(u32 year)
|
||||
{
|
||||
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u16 ConvertDateToDayCount(u8 year, u8 month, u8 day)
|
||||
{
|
||||
s32 i;
|
||||
u16 dayCount = 0;
|
||||
|
||||
for (i = year - 1; i >= 0; i--)
|
||||
{
|
||||
dayCount += 365;
|
||||
|
||||
if (IsLeapYear(i) == TRUE)
|
||||
dayCount++;
|
||||
}
|
||||
|
||||
for (i = 0; i < month - 1; i++)
|
||||
dayCount += sNumDaysInMonths[i];
|
||||
|
||||
if (month > MONTH_FEB && IsLeapYear(year) == TRUE)
|
||||
dayCount++;
|
||||
|
||||
dayCount += day;
|
||||
|
||||
return dayCount;
|
||||
}
|
||||
|
||||
u16 RtcGetDayCount(struct SiiRtcInfo *rtc)
|
||||
{
|
||||
u8 year = ConvertBcdToBinary(rtc->year);
|
||||
u8 month = ConvertBcdToBinary(rtc->month);
|
||||
u8 day = ConvertBcdToBinary(rtc->day);
|
||||
return ConvertDateToDayCount(year, month, day);
|
||||
}
|
||||
|
||||
void RtcInit(void)
|
||||
{
|
||||
sErrorStatus = 0;
|
||||
|
||||
RtcDisableInterrupts();
|
||||
SiiRtcUnprotect();
|
||||
sProbeResult = SiiRtcProbe();
|
||||
RtcRestoreInterrupts();
|
||||
|
||||
if ((sProbeResult & 0xF) != 1)
|
||||
{
|
||||
sErrorStatus = RTC_INIT_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sProbeResult & 0xF0)
|
||||
sErrorStatus = RTC_INIT_WARNING;
|
||||
else
|
||||
sErrorStatus = 0;
|
||||
|
||||
RtcGetRawInfo(&sRtc);
|
||||
sErrorStatus = RtcCheckInfo(&sRtc);
|
||||
}
|
||||
|
||||
u16 RtcGetErrorStatus(void)
|
||||
{
|
||||
return sErrorStatus;
|
||||
}
|
||||
|
||||
void RtcGetInfo(struct SiiRtcInfo *rtc)
|
||||
{
|
||||
if (sErrorStatus & RTC_ERR_FLAG_MASK)
|
||||
*rtc = sRtcDummy;
|
||||
else
|
||||
RtcGetRawInfo(rtc);
|
||||
}
|
||||
|
||||
void RtcGetDateTime(struct SiiRtcInfo *rtc)
|
||||
{
|
||||
RtcDisableInterrupts();
|
||||
SiiRtcGetDateTime(rtc);
|
||||
RtcRestoreInterrupts();
|
||||
}
|
||||
|
||||
void RtcGetStatus(struct SiiRtcInfo *rtc)
|
||||
{
|
||||
RtcDisableInterrupts();
|
||||
SiiRtcGetStatus(rtc);
|
||||
RtcRestoreInterrupts();
|
||||
}
|
||||
|
||||
void RtcGetRawInfo(struct SiiRtcInfo *rtc)
|
||||
{
|
||||
RtcGetStatus(rtc);
|
||||
RtcGetDateTime(rtc);
|
||||
}
|
||||
|
||||
u16 RtcCheckInfo(struct SiiRtcInfo *rtc)
|
||||
{
|
||||
u16 errorFlags = 0;
|
||||
s32 year;
|
||||
s32 month;
|
||||
s32 value;
|
||||
|
||||
if (rtc->status & SIIRTCINFO_POWER)
|
||||
errorFlags |= RTC_ERR_POWER_FAILURE;
|
||||
|
||||
if (!(rtc->status & SIIRTCINFO_24HOUR))
|
||||
errorFlags |= RTC_ERR_12HOUR_CLOCK;
|
||||
|
||||
year = ConvertBcdToBinary(rtc->year);
|
||||
|
||||
if (year == 0xFF)
|
||||
errorFlags |= RTC_ERR_INVALID_YEAR;
|
||||
|
||||
month = ConvertBcdToBinary(rtc->month);
|
||||
|
||||
if (month == 0xFF || month == 0 || month > 12)
|
||||
errorFlags |= RTC_ERR_INVALID_MONTH;
|
||||
|
||||
value = ConvertBcdToBinary(rtc->day);
|
||||
|
||||
if (value == 0xFF)
|
||||
errorFlags |= RTC_ERR_INVALID_DAY;
|
||||
|
||||
if (month == MONTH_FEB)
|
||||
{
|
||||
if (value > IsLeapYear(year) + sNumDaysInMonths[month - 1])
|
||||
errorFlags |= RTC_ERR_INVALID_DAY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value > sNumDaysInMonths[month - 1])
|
||||
errorFlags |= RTC_ERR_INVALID_DAY;
|
||||
}
|
||||
|
||||
value = ConvertBcdToBinary(rtc->hour);
|
||||
|
||||
if (value > 24)
|
||||
errorFlags |= RTC_ERR_INVALID_HOUR;
|
||||
|
||||
value = ConvertBcdToBinary(rtc->minute);
|
||||
|
||||
if (value > 60)
|
||||
errorFlags |= RTC_ERR_INVALID_MINUTE;
|
||||
|
||||
value = ConvertBcdToBinary(rtc->second);
|
||||
|
||||
if (value > 60)
|
||||
errorFlags |= RTC_ERR_INVALID_SECOND;
|
||||
|
||||
return errorFlags;
|
||||
}
|
||||
|
||||
void RtcReset(void)
|
||||
{
|
||||
RtcDisableInterrupts();
|
||||
SiiRtcReset();
|
||||
RtcRestoreInterrupts();
|
||||
}
|
||||
|
||||
void FormatDecimalTime(u8 *dest, s32 hour, s32 minute, s32 second)
|
||||
{
|
||||
dest = ConvertIntToDecimalStringN(dest, hour, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest++ = CHAR_COLON;
|
||||
dest = ConvertIntToDecimalStringN(dest, minute, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest++ = CHAR_COLON;
|
||||
dest = ConvertIntToDecimalStringN(dest, second, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest = EOS;
|
||||
}
|
||||
|
||||
void FormatHexTime(u8 *dest, s32 hour, s32 minute, s32 second)
|
||||
{
|
||||
dest = ConvertIntToHexStringN(dest, hour, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest++ = CHAR_COLON;
|
||||
dest = ConvertIntToHexStringN(dest, minute, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest++ = CHAR_COLON;
|
||||
dest = ConvertIntToHexStringN(dest, second, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest = EOS;
|
||||
}
|
||||
|
||||
void FormatHexRtcTime(u8 *dest)
|
||||
{
|
||||
FormatHexTime(dest, sRtc.hour, sRtc.minute, sRtc.second);
|
||||
}
|
||||
|
||||
void FormatDecimalDate(u8 *dest, s32 year, s32 month, s32 day)
|
||||
{
|
||||
dest = ConvertIntToDecimalStringN(dest, year, STR_CONV_MODE_LEADING_ZEROS, 4);
|
||||
*dest++ = CHAR_HYPHEN;
|
||||
dest = ConvertIntToDecimalStringN(dest, month, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest++ = CHAR_HYPHEN;
|
||||
dest = ConvertIntToDecimalStringN(dest, day, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest = EOS;
|
||||
}
|
||||
|
||||
void FormatHexDate(u8 *dest, s32 year, s32 month, s32 day)
|
||||
{
|
||||
dest = ConvertIntToHexStringN(dest, year, STR_CONV_MODE_LEADING_ZEROS, 4);
|
||||
*dest++ = CHAR_HYPHEN;
|
||||
dest = ConvertIntToHexStringN(dest, month, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest++ = CHAR_HYPHEN;
|
||||
dest = ConvertIntToHexStringN(dest, day, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
*dest = EOS;
|
||||
}
|
||||
|
||||
void RtcCalcTimeDifference(struct SiiRtcInfo *rtc, struct Time *result, struct Time *t)
|
||||
{
|
||||
u16 days = RtcGetDayCount(rtc);
|
||||
result->seconds = ConvertBcdToBinary(rtc->second) - t->seconds;
|
||||
result->minutes = ConvertBcdToBinary(rtc->minute) - t->minutes;
|
||||
result->hours = ConvertBcdToBinary(rtc->hour) - t->hours;
|
||||
result->days = days - t->days;
|
||||
|
||||
if (result->seconds < 0)
|
||||
{
|
||||
result->seconds += 60;
|
||||
--result->minutes;
|
||||
}
|
||||
|
||||
if (result->minutes < 0)
|
||||
{
|
||||
result->minutes += 60;
|
||||
--result->hours;
|
||||
}
|
||||
|
||||
if (result->hours < 0)
|
||||
{
|
||||
result->hours += 24;
|
||||
--result->days;
|
||||
}
|
||||
}
|
||||
|
||||
void RtcCalcLocalTime(void)
|
||||
{
|
||||
RtcGetInfo(&sRtc);
|
||||
RtcCalcTimeDifference(&sRtc, &gLocalTime, &gSaveBlock2Ptr->localTimeOffset);
|
||||
}
|
||||
|
||||
void RtcInitLocalTimeOffset(s32 hour, s32 minute)
|
||||
{
|
||||
RtcCalcLocalTimeOffset(0, hour, minute, 0);
|
||||
}
|
||||
|
||||
void RtcCalcLocalTimeOffset(s32 days, s32 hours, s32 minutes, s32 seconds)
|
||||
{
|
||||
gLocalTime.days = days;
|
||||
gLocalTime.hours = hours;
|
||||
gLocalTime.minutes = minutes;
|
||||
gLocalTime.seconds = seconds;
|
||||
RtcGetInfo(&sRtc);
|
||||
RtcCalcTimeDifference(&sRtc, &gSaveBlock2Ptr->localTimeOffset, &gLocalTime);
|
||||
}
|
||||
|
||||
void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2)
|
||||
{
|
||||
result->seconds = t2->seconds - t1->seconds;
|
||||
result->minutes = t2->minutes - t1->minutes;
|
||||
result->hours = t2->hours - t1->hours;
|
||||
result->days = t2->days - t1->days;
|
||||
|
||||
if (result->seconds < 0)
|
||||
{
|
||||
result->seconds += 60;
|
||||
--result->minutes;
|
||||
}
|
||||
|
||||
if (result->minutes < 0)
|
||||
{
|
||||
result->minutes += 60;
|
||||
--result->hours;
|
||||
}
|
||||
|
||||
if (result->hours < 0)
|
||||
{
|
||||
result->hours += 24;
|
||||
--result->days;
|
||||
}
|
||||
}
|
||||
|
||||
u32 RtcGetMinuteCount(void)
|
||||
{
|
||||
RtcGetInfo(&sRtc);
|
||||
return (24 * 60) * RtcGetDayCount(&sRtc) + 60 * sRtc.hour + sRtc.minute;
|
||||
}
|
||||
|
||||
u16 RtcGetLocalDayCount(void)
|
||||
{
|
||||
return RtcGetDayCount(&sRtc);
|
||||
}
|
||||
|
@ -112,16 +112,16 @@ gUnknown_03000DAC: @ 3000DAC
|
||||
gUnknown_03000DB0: @ 3000DB0
|
||||
.space 0x8
|
||||
|
||||
gUnknown_03000DB8: @ 3000DB8
|
||||
sErrorStatus: @ 3000DB8
|
||||
.space 0x8
|
||||
|
||||
gUnknown_03000DC0: @ 3000DC0
|
||||
sRtc: @ 3000DC0
|
||||
.space 0xC
|
||||
|
||||
gUnknown_03000DCC: @ 3000DCC
|
||||
sProbeResult: @ 3000DCC
|
||||
.space 0x2
|
||||
|
||||
gUnknown_03000DCE: @ 3000DCE
|
||||
sSavedIme: @ 3000DCE
|
||||
.space 0x2
|
||||
|
||||
gUnknown_03000DD0: @ 3000DD0
|
||||
|
@ -201,7 +201,7 @@ gUnknown_03005CD5: @ 3005CD5
|
||||
gUnknown_03005CDE: @ 3005CDE
|
||||
.space 0x1A
|
||||
|
||||
gUnknown_03005CF8: @ 3005CF8
|
||||
gLocalTime: @ 3005CF8
|
||||
.space 0x8
|
||||
|
||||
gUnknown_03005D00: @ 3005D00
|
||||
|
Loading…
Reference in New Issue
Block a user