pokeemerald/asm/rtc.s

819 lines
16 KiB
ArmAsm
Raw Normal View History

2016-09-03 08:11:29 +02:00
.include "asm/macros.s"
.syntax unified
.text
2015-11-28 03:54:15 +01:00
thumb_func_start GameFreakRTC_ClearIME
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_ClearIME()
GameFreakRTC_ClearIME: @ 802F0CC
2015-11-28 03:54:15 +01:00
ldr r2, =0x03000dce
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
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_RestoreIME()
GameFreakRTC_RestoreIME: @ 802F0E4
2015-11-28 03:54:15 +01:00
ldr r0, =0x04000208
ldr r1, =0x03000dce
ldrh r1, [r1]
strh r1, [r0]
bx lr
.pool
thumb_func_end GameFreakRTC_RestoreIME
thumb_func_start GameFreakRTC_ConvertFromBCD
2016-09-03 04:51:16 +02:00
@ u8 GameFreakRTC_ConvertFromBCD(u8 bcdByte)
GameFreakRTC_ConvertFromBCD: @ 802F0F8
2015-11-28 03:54:15 +01:00
push {lr}
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x9F
2016-01-07 05:23:20 +01:00
bhi _0802F10A
2015-11-28 03:54:15 +01:00
movs r3, 0xF
ands r3, r2
cmp r3, 0x9
2016-01-07 05:23:20 +01:00
bls _0802F10E
_0802F10A:
2015-11-28 03:54:15 +01:00
movs r0, 0xFF
2016-01-07 05:23:20 +01:00
b _0802F11C
_0802F10E:
2015-11-28 03:54:15 +01:00
lsrs r1, r0, 28
movs r0, 0xF
ands r1, r0
lsls r0, r1, 2
adds r0, r1
lsls r0, 1
adds r0, r3
2016-01-07 05:23:20 +01:00
_0802F11C:
2015-11-28 03:54:15 +01:00
pop {r1}
bx r1
thumb_func_end GameFreakRTC_ConvertFromBCD
thumb_func_start GameFreakRTC_IsLeapYear
2016-09-03 04:51:16 +02:00
@ bool8 GameFreakRTC_IsLeapYear(u32 year)
GameFreakRTC_IsLeapYear: @ 802F120
2015-11-28 03:54:15 +01:00
push {r4,lr}
adds r4, r0, 0
movs r0, 0x3
ands r0, r4
cmp r0, 0
2016-01-07 05:23:20 +01:00
bne _0802F138
2015-11-28 03:54:15 +01:00
adds r0, r4, 0
movs r1, 0x64
bl __umodsi3
cmp r0, 0
2016-01-07 05:23:20 +01:00
bne _0802F146
_0802F138:
2015-11-28 03:54:15 +01:00
movs r1, 0xC8
lsls r1, 1
adds r0, r4, 0
bl __umodsi3
cmp r0, 0
2016-01-07 05:23:20 +01:00
bne _0802F14A
_0802F146:
2015-11-28 03:54:15 +01:00
movs r0, 0x1
2016-01-07 05:23:20 +01:00
b _0802F14C
_0802F14A:
2015-11-28 03:54:15 +01:00
movs r0, 0
2016-01-07 05:23:20 +01:00
_0802F14C:
2015-11-28 03:54:15 +01:00
pop {r4}
pop {r1}
bx r1
thumb_func_end GameFreakRTC_IsLeapYear
thumb_func_start GameFreakRTC_ConvertYearMonthDayToNumDays
2016-09-03 04:51:16 +02:00
@ u16 GameFreakRTC_ConvertYearMonthDayToNumDays(u8 year, u8 month, u8 dayOfMonth)
GameFreakRTC_ConvertYearMonthDayToNumDays: @ 802F154
2015-11-28 03:54:15 +01:00
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
2016-01-07 05:23:20 +01:00
blt _0802F192
_0802F170:
2015-11-28 03:54:15 +01:00
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
2016-01-07 05:23:20 +01:00
bne _0802F18C
2015-11-28 03:54:15 +01:00
adds r0, r5, 0x1
lsls r0, 16
lsrs r5, r0, 16
2016-01-07 05:23:20 +01:00
_0802F18C:
2015-11-28 03:54:15 +01:00
subs r4, 0x1
cmp r4, 0
2016-01-07 05:23:20 +01:00
bge _0802F170
_0802F192:
2015-11-28 03:54:15 +01:00
subs r0, r6, 0x1
cmp r0, 0
2016-01-07 05:23:20 +01:00
ble _0802F1AA
2015-11-28 04:14:13 +01:00
ldr r1, =gDaysInEachMonth
2015-11-28 03:54:15 +01:00
adds r4, r0, 0
2016-01-07 05:23:20 +01:00
_0802F19C:
2015-11-28 03:54:15 +01:00
ldm r1!, {r0}
adds r0, r5, r0
lsls r0, 16
lsrs r5, r0, 16
subs r4, 0x1
cmp r4, 0
2016-01-07 05:23:20 +01:00
bne _0802F19C
_0802F1AA:
2015-11-28 03:54:15 +01:00
cmp r6, 0x2
2016-01-07 05:23:20 +01:00
bls _0802F1C2
2015-11-28 03:54:15 +01:00
adds r0, r7, 0
bl GameFreakRTC_IsLeapYear
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
2016-01-07 05:23:20 +01:00
bne _0802F1C2
2015-11-28 03:54:15 +01:00
adds r0, r5, 0x1
lsls r0, 16
lsrs r5, r0, 16
2016-01-07 05:23:20 +01:00
_0802F1C2:
2015-11-28 03:54:15 +01:00
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
2016-09-03 04:51:16 +02:00
@ u16 GameFreakRTC_GetNumDaysInternal(struct RTCInfo *rtc)
GameFreakRTC_GetNumDaysInternal: @ 802F1E0
2015-11-28 03:54:15 +01:00
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 GameFreakRTC_Init
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_Init()
GameFreakRTC_Init: @ 802F21C
2015-11-28 03:54:15 +01:00
push {r4,r5,lr}
ldr r5, =0x03000db8
movs r0, 0
strh r0, [r5]
bl GameFreakRTC_ClearIME
bl RTC_SetReadWrite
bl RTC_Init
ldr r4, =0x03000dcc
strb r0, [r4]
bl GameFreakRTC_RestoreIME
ldrb r4, [r4]
movs r0, 0xF
ands r0, r4
cmp r0, 0x1
2016-01-07 05:23:20 +01:00
beq _0802F250
2015-11-28 03:54:15 +01:00
movs r0, 0x1
strh r0, [r5]
2016-01-07 05:23:20 +01:00
b _0802F26E
2015-11-28 03:54:15 +01:00
.pool
2016-01-07 05:23:20 +01:00
_0802F250:
2015-11-28 03:54:15 +01:00
movs r0, 0xF0
ands r0, r4
cmp r0, 0
2016-01-07 05:23:20 +01:00
beq _0802F25A
2015-11-28 03:54:15 +01:00
movs r0, 0x2
2016-01-07 05:23:20 +01:00
_0802F25A:
2015-11-28 03:54:15 +01:00
strh r0, [r5]
ldr r4, =0x03000dc0
adds r0, r4, 0
bl GameFreakRTC_GetControlRegAndRTCDateTime
adds r0, r4, 0
bl GameFreakRTC_TestForErrors
ldr r1, =0x03000db8
strh r0, [r1]
2016-01-07 05:23:20 +01:00
_0802F26E:
2015-11-28 03:54:15 +01:00
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end GameFreakRTC_Init
thumb_func_start GameFreakRTC_GetErrorFlags
2016-09-03 04:51:16 +02:00
@ u16 GameFreakRTC_GetErrorFlags()
GameFreakRTC_GetErrorFlags: @ 802F27C
2015-11-28 03:54:15 +01:00
ldr r0, =0x03000db8
ldrh r0, [r0]
bx lr
.pool
thumb_func_end GameFreakRTC_GetErrorFlags
thumb_func_start GameFreakRTC_GetRTCDateTime
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_GetRTCDateTime(struct RTCInfo *rtc)
GameFreakRTC_GetRTCDateTime: @ 802F288
2015-11-28 03:54:15 +01:00
push {r4,lr}
adds r2, r0, 0
ldr r0, =0x03000db8
ldrh r1, [r0]
movs r0, 0xFF
lsls r0, 4
ands r0, r1
cmp r0, 0
2016-01-07 05:23:20 +01:00
beq _0802F2AC
2015-11-28 03:54:15 +01:00
adds r1, r2, 0
2015-11-28 04:14:13 +01:00
ldr r0, =gDefaultRTCInfo
2015-11-28 03:54:15 +01:00
ldm r0!, {r2-r4}
stm r1!, {r2-r4}
2016-01-07 05:23:20 +01:00
b _0802F2B2
2015-11-28 03:54:15 +01:00
.pool
2016-01-07 05:23:20 +01:00
_0802F2AC:
2015-11-28 03:54:15 +01:00
adds r0, r2, 0
bl GameFreakRTC_GetControlRegAndRTCDateTime
2016-01-07 05:23:20 +01:00
_0802F2B2:
2015-11-28 03:54:15 +01:00
pop {r4}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_GetRTCDateTime
thumb_func_start GameFreakRTC_GetRTCDateTimeInternal
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_GetRTCDateTimeInternal(struct RTCInfo *rtc)
GameFreakRTC_GetRTCDateTimeInternal: @ 802F2B8
2015-11-28 03:54:15 +01:00
push {r4,lr}
adds r4, r0, 0
bl GameFreakRTC_ClearIME
adds r0, r4, 0
bl RTC_GetDateTime
bl GameFreakRTC_RestoreIME
pop {r4}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_GetRTCDateTimeInternal
thumb_func_start GameFreakRTC_GetControlReg
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_GetControlReg(struct RTCInfo *rtc)
GameFreakRTC_GetControlReg: @ 802F2D0
2015-11-28 03:54:15 +01:00
push {r4,lr}
adds r4, r0, 0
bl GameFreakRTC_ClearIME
adds r0, r4, 0
bl RTC_GetControlReg
bl GameFreakRTC_RestoreIME
pop {r4}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_GetControlReg
thumb_func_start GameFreakRTC_GetControlRegAndRTCDateTime
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_GetControlRegAndRTCDateTime(struct RTCInfo *rtc)
GameFreakRTC_GetControlRegAndRTCDateTime: @ 802F2E8
2015-11-28 03:54:15 +01:00
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
2016-09-03 04:51:16 +02:00
@ u16 GameFreakRTC_TestForErrors(struct RTCInfo *rtc)
GameFreakRTC_TestForErrors: @ 802F2FC
2015-11-28 03:54:15 +01:00
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
2016-01-07 05:23:20 +01:00
bne _0802F322
2015-11-28 03:54:15 +01:00
movs r0, 0x10
orrs r4, r0
2016-01-07 05:23:20 +01:00
_0802F322:
2015-11-28 03:54:15 +01:00
ldrb r0, [r7]
bl GameFreakRTC_ConvertFromBCD
mov r8, r0
cmp r0, 0xFF
2016-01-07 05:23:20 +01:00
bne _0802F336
2015-11-28 03:54:15 +01:00
movs r0, 0x40
orrs r4, r0
lsls r0, r4, 16
lsrs r4, r0, 16
2016-01-07 05:23:20 +01:00
_0802F336:
2015-11-28 03:54:15 +01:00
ldrb r0, [r7, 0x1]
bl GameFreakRTC_ConvertFromBCD
adds r6, r0, 0
cmp r6, 0xFF
2016-01-07 05:23:20 +01:00
beq _0802F34A
2015-11-28 03:54:15 +01:00
cmp r6, 0
2016-01-07 05:23:20 +01:00
beq _0802F34A
2015-11-28 03:54:15 +01:00
cmp r6, 0xC
2016-01-07 05:23:20 +01:00
ble _0802F352
_0802F34A:
2015-11-28 03:54:15 +01:00
movs r0, 0x80
orrs r4, r0
lsls r0, r4, 16
lsrs r4, r0, 16
2016-01-07 05:23:20 +01:00
_0802F352:
2015-11-28 03:54:15 +01:00
ldrb r0, [r7, 0x2]
bl GameFreakRTC_ConvertFromBCD
adds r5, r0, 0
cmp r5, 0xFF
2016-01-07 05:23:20 +01:00
bne _0802F36A
2015-11-28 03:54:15 +01:00
movs r1, 0x80
lsls r1, 1
adds r0, r1, 0
orrs r4, r0
lsls r0, r4, 16
lsrs r4, r0, 16
2016-01-07 05:23:20 +01:00
_0802F36A:
2015-11-28 03:54:15 +01:00
cmp r6, 0x2
2016-01-07 05:23:20 +01:00
bne _0802F384
2015-11-28 03:54:15 +01:00
mov r0, r8
bl GameFreakRTC_IsLeapYear
lsls r0, 24
lsrs r0, 24
2015-11-28 04:14:13 +01:00
ldr r1, =gDaysInEachMonth
2015-11-28 03:54:15 +01:00
ldr r1, [r1, 0x4]
adds r0, r1
2016-01-07 05:23:20 +01:00
b _0802F38E
2015-11-28 03:54:15 +01:00
.pool
2016-01-07 05:23:20 +01:00
_0802F384:
2015-11-28 04:14:13 +01:00
ldr r0, =gDaysInEachMonth
2015-11-28 03:54:15 +01:00
subs r1, r6, 0x1
lsls r1, 2
adds r1, r0
ldr r0, [r1]
2016-01-07 05:23:20 +01:00
_0802F38E:
2015-11-28 03:54:15 +01:00
cmp r5, r0
2016-01-07 05:23:20 +01:00
ble _0802F39E
2015-11-28 03:54:15 +01:00
movs r1, 0x80
lsls r1, 1
adds r0, r1, 0
orrs r4, r0
lsls r0, r4, 16
lsrs r4, r0, 16
2016-01-07 05:23:20 +01:00
_0802F39E:
2015-11-28 03:54:15 +01:00
ldrb r0, [r7, 0x4]
bl GameFreakRTC_ConvertFromBCD
adds r5, r0, 0
cmp r5, 0x18
2016-01-07 05:23:20 +01:00
ble _0802F3B6
2015-11-28 03:54:15 +01:00
movs r1, 0x80
lsls r1, 2
adds r0, r1, 0
orrs r4, r0
lsls r0, r4, 16
lsrs r4, r0, 16
2016-01-07 05:23:20 +01:00
_0802F3B6:
2015-11-28 03:54:15 +01:00
ldrb r0, [r7, 0x5]
bl GameFreakRTC_ConvertFromBCD
adds r5, r0, 0
cmp r5, 0x3C
2016-01-07 05:23:20 +01:00
ble _0802F3CE
2015-11-28 03:54:15 +01:00
movs r1, 0x80
lsls r1, 3
adds r0, r1, 0
orrs r4, r0
lsls r0, r4, 16
lsrs r4, r0, 16
2016-01-07 05:23:20 +01:00
_0802F3CE:
2015-11-28 03:54:15 +01:00
ldrb r0, [r7, 0x6]
bl GameFreakRTC_ConvertFromBCD
adds r5, r0, 0
cmp r5, 0x3C
2016-01-07 05:23:20 +01:00
ble _0802F3E6
2015-11-28 03:54:15 +01:00
movs r1, 0x80
lsls r1, 4
adds r0, r1, 0
orrs r4, r0
lsls r0, r4, 16
lsrs r4, r0, 16
2016-01-07 05:23:20 +01:00
_0802F3E6:
2015-11-28 03:54:15 +01:00
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
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_Reset()
GameFreakRTC_Reset: @ 802F3F8
2015-11-28 03:54:15 +01:00
push {lr}
bl GameFreakRTC_ClearIME
bl RTC_Reset
bl GameFreakRTC_RestoreIME
pop {r0}
bx r0
thumb_func_end GameFreakRTC_Reset
thumb_func_start GameFreakRTC_FormatDecimalTimeString
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_FormatDecimalTimeString(u8 *dest, s32 hour, s32 minute, s32 second)
GameFreakRTC_FormatDecimalTimeString: @ 802F40C
2015-11-28 03:54:15 +01:00
push {r4-r6,lr}
adds r5, r2, 0
adds r6, r3, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToDecimalString
movs r4, 0xF0
strb r4, [r0]
adds r0, 0x1
adds r1, r5, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToDecimalString
strb r4, [r0]
adds r0, 0x1
adds r1, r6, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToDecimalString
movs r1, 0xFF
strb r1, [r0]
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_FormatDecimalTimeString
thumb_func_start GameFreakRTC_FormatHexTimeString
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_FormatHexTimeString(u8 *dest, s32 hour, s32 minute, s32 second)
GameFreakRTC_FormatHexTimeString: @ 802F444
2015-11-28 03:54:15 +01:00
push {r4-r6,lr}
adds r5, r2, 0
adds r6, r3, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToHexString
movs r4, 0xF0
strb r4, [r0]
adds r0, 0x1
adds r1, r5, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToHexString
strb r4, [r0]
adds r0, 0x1
adds r1, r6, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToHexString
movs r1, 0xFF
strb r1, [r0]
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_FormatHexTimeString
thumb_func_start GameFreakRTC_FormatHexTimeStringFromRTCInfo
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_FormatHexTimeStringFromRTCInfo()
GameFreakRTC_FormatHexTimeStringFromRTCInfo: @ 802F47C
2015-11-28 03:54:15 +01:00
push {lr}
ldr r3, =0x03000dc0
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
2015-11-28 03:54:15 +01:00
thumb_func_start GameFreakRTC_FormatDecimalYearMonthDayString
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_FormatDecimalYearMonthDayString(u8 *dest, s32 year, s32 month, s32 dayOfMonth)
GameFreakRTC_FormatDecimalYearMonthDayString: @ 802F494
2015-11-28 03:54:15 +01:00
push {r4-r6,lr}
adds r5, r2, 0
adds r6, r3, 0
movs r2, 0x2
movs r3, 0x4
bl ConvertIntToDecimalString
movs r4, 0xAE
strb r4, [r0]
adds r0, 0x1
adds r1, r5, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToDecimalString
strb r4, [r0]
adds r0, 0x1
adds r1, r6, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToDecimalString
movs r1, 0xFF
strb r1, [r0]
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_FormatDecimalYearMonthDayString
thumb_func_start GameFreakRTC_FormatHexYearMonthDayString
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_FormatHexYearMonthDayString(u8 *dest, s32 year, s32 month, s32 dayOfMonth)
GameFreakRTC_FormatHexYearMonthDayString: @ 802F4CC
2015-11-28 03:54:15 +01:00
push {r4-r6,lr}
adds r5, r2, 0
adds r6, r3, 0
movs r2, 0x2
movs r3, 0x4
bl ConvertIntToHexString
movs r4, 0xAE
strb r4, [r0]
adds r0, 0x1
adds r1, r5, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToHexString
strb r4, [r0]
adds r0, 0x1
adds r1, r6, 0
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToHexString
movs r1, 0xFF
strb r1, [r0]
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_FormatHexYearMonthDayString
thumb_func_start GameFreakRTC_GetRTCDelta
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_GetRTCDelta(RTCInfo *rtc, GameDateTime *delta, GameDateTime *dateTime)
GameFreakRTC_GetRTCDelta: @ 802F504
2015-11-28 03:54:15 +01:00
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
2016-01-07 05:23:20 +01:00
bge _0802F556
2015-11-28 03:54:15 +01:00
adds r0, r1, 0
adds r0, 0x3C
strb r0, [r7, 0x4]
ldrb r0, [r7, 0x3]
subs r0, 0x1
strb r0, [r7, 0x3]
2016-01-07 05:23:20 +01:00
_0802F556:
2015-11-28 03:54:15 +01:00
ldrb r1, [r7, 0x3]
movs r0, 0x3
ldrsb r0, [r7, r0]
cmp r0, 0
2016-01-07 05:23:20 +01:00
bge _0802F56C
2015-11-28 03:54:15 +01:00
adds r0, r1, 0
adds r0, 0x3C
strb r0, [r7, 0x3]
ldrb r0, [r7, 0x2]
subs r0, 0x1
strb r0, [r7, 0x2]
2016-01-07 05:23:20 +01:00
_0802F56C:
2015-11-28 03:54:15 +01:00
ldrb r1, [r7, 0x2]
movs r0, 0x2
ldrsb r0, [r7, r0]
cmp r0, 0
2016-01-07 05:23:20 +01:00
bge _0802F582
2015-11-28 03:54:15 +01:00
adds r0, r1, 0
adds r0, 0x18
strb r0, [r7, 0x2]
ldrh r0, [r7]
subs r0, 0x1
strh r0, [r7]
2016-01-07 05:23:20 +01:00
_0802F582:
2015-11-28 03:54:15 +01:00
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_GetRTCDelta
thumb_func_start GameFreakRTC_CalcLocalDateTime
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_CalcLocalDateTime()
GameFreakRTC_CalcLocalDateTime: @ 802F588
2015-11-28 03:54:15 +01:00
push {r4,lr}
ldr r4, =0x03000dc0
adds r0, r4, 0
bl GameFreakRTC_GetRTCDateTime
ldr r1, =0x03005cf8
ldr r0, =0x03005d90
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
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_CalcRTCToLocalDelta_DayZero(u8 hour, u8 minute)
GameFreakRTC_CalcRTCToLocalDelta_DayZero: @ 802F5B4
2015-11-28 03:54:15 +01:00
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
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_CalcRTCToLocalDelta(u16 numDays, u8 hour, u8 minute, u8 second)
GameFreakRTC_CalcRTCToLocalDelta: @ 802F5C8
2015-11-28 03:54:15 +01:00
push {r4,r5,lr}
ldr r4, =0x03005cf8
strh r0, [r4]
strb r1, [r4, 0x2]
strb r2, [r4, 0x3]
strb r3, [r4, 0x4]
ldr r5, =0x03000dc0
adds r0, r5, 0
bl GameFreakRTC_GetRTCDateTime
ldr r0, =0x03005d90
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
2016-09-03 04:51:16 +02:00
@ void GameFreakRTC_GetDelta(GameDateTime *delta, GameDateTime *dateTime1, GameDateTime *dateTime2)
GameFreakRTC_GetDelta: @ 802F5FC
2015-11-28 03:54:15 +01:00
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
2016-01-07 05:23:20 +01:00
bge _0802F630
2015-11-28 03:54:15 +01:00
adds r0, r5, 0
adds r0, 0x3C
strb r0, [r4, 0x4]
subs r0, r6, 0x1
strb r0, [r4, 0x3]
2016-01-07 05:23:20 +01:00
_0802F630:
2015-11-28 03:54:15 +01:00
ldrb r1, [r4, 0x3]
movs r0, 0x3
ldrsb r0, [r4, r0]
cmp r0, 0
2016-01-07 05:23:20 +01:00
bge _0802F646
2015-11-28 03:54:15 +01:00
adds r0, r1, 0
adds r0, 0x3C
strb r0, [r4, 0x3]
ldrb r0, [r4, 0x2]
subs r0, 0x1
strb r0, [r4, 0x2]
2016-01-07 05:23:20 +01:00
_0802F646:
2015-11-28 03:54:15 +01:00
ldrb r1, [r4, 0x2]
movs r0, 0x2
ldrsb r0, [r4, r0]
cmp r0, 0
2016-01-07 05:23:20 +01:00
bge _0802F65C
2015-11-28 03:54:15 +01:00
adds r0, r1, 0
adds r0, 0x18
strb r0, [r4, 0x2]
ldrh r0, [r4]
subs r0, 0x1
strh r0, [r4]
2016-01-07 05:23:20 +01:00
_0802F65C:
2015-11-28 03:54:15 +01:00
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end GameFreakRTC_GetDelta
thumb_func_start GameFreakRTC_GetNumMinutes
2016-09-03 04:51:16 +02:00
@ u16 GameFreakRTC_GetNumMinutes()
GameFreakRTC_GetNumMinutes: @ 802F664
2015-11-28 03:54:15 +01:00
push {r4,lr}
ldr r4, =0x03000dc0
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
2016-09-03 04:51:16 +02:00
@ u16 GameFreakRTC_GetNumDays()
GameFreakRTC_GetNumDays: @ 802F69C
2015-11-28 03:54:15 +01:00
push {lr}
ldr r0, =0x03000dc0
bl GameFreakRTC_GetNumDaysInternal
lsls r0, 16
lsrs r0, 16
pop {r1}
bx r1
.pool
thumb_func_end GameFreakRTC_GetNumDays
2016-09-03 08:11:29 +02:00
.align 2, 0 @ Don't pad with nop.