interdpth
I've seen things, man.
- 275
- Posts
- 20
- Years
- Seen Jun 8, 2021
Added it to my hack earlier so I decided to just go and release.
Be sure to give me full credit.
Edit: I'm a hypocrite lolollo
I fudged my sources somehow and were unable to recover them properly.
Here's the ASM
So here's the patch.
Download the IPS patch
I am not posting an example script, and to anyone else, PLEASE DO NOT POST AN EXAMPLE SCRIPT ANYWHERE except in your own hack
Why? Because then i'd see "RTC IN MY HACK" and properly my slightly modified example script. So you'll have to make your own from the data below, sorry for the earlier trouble.
I use No$GBA and vba-m for testing. :)
Patches on to the games main loop at 0x41E. Then executes my code at 0xb01000.
The time it gives you is stored at 0x300553C
In the following format.
Year u16
skip a byte
month u8
day u8
Day of week(mon-sun/1-7) u8
Hour u8
minute u8
second u8
at 0x3005537
is
u8 dayofweek;
u8 hours;
u8 minutes;
use that when you create your time setter function. code auto compensates(I didn't and don't plan on a date thing you can do that on your own)
Please give me credit.
Thanks to kawai/ZodiacDaGreat for helping me with an example script.
Merry Christmas everyone
Be sure to give me full credit.
Edit: I'm a hypocrite lolollo
I fudged my sources somehow and were unable to recover them properly.
Here's the ASM
Spoiler:
Code:
.thumb
.org 0x00041E
LDR R3, off_8000424
MOV PC, R3
@ End of function sub_80003A4
@ ---------------------------------------------------------------------------
NOP
@ ---------------------------------------------------------------------------
off_8000424: .long 0x8B01000
.org 0xB01000 @ CODE XREF: sub_80003A4+7Cj
@ DATA XREF: sub_80003A4+7Ao ...
BL AgbMain
LDR R0, var1
LDRB R0, [R0]
LDR R3, off_8B01018
CMP R0, #0
BNE loc_8B01016
LDRH R1, [R7,#0x28]
MOV R0, #1
AND R0, R1
LDR R3, off_8B0101C
loc_8B01016: @ CODE XREF: sub_80003A4+B00C68j
MOV PC, R3
@ ---------------------------------------------------------------------------
var1: .long 0x3003530
off_8B01018: .long 0x8000445 @ DATA XREF: sub_80003A4+B00C64r
off_8B0101C: .long 0x800042D @ DATA XREF: sub_80003A4+B00C70r
rtc_cmd: @ CODE XREF: rtc_get+18p
@ RTC_TurnOn+18p
PUSH {R4-R7,LR} @ Alternative name is '.gcc2_compiled.'
LSL R4, R0, #1
MOV R3, #7
MOV R7, #2
LDR R2, off_80001F8
MOV R6, #4
MOV R5, #5
loc_80001D2: @ CODE XREF: rtc_cmd+2Aj
MOV R0, R4
ASR R0, R3
AND R0, R7
LSL R0, R0, #0x10
LSR R0, R0, #0x10
MOV R1, R0
ORR R1, R6
STRH R1, [R2]
STRH R1, [R2]
STRH R1, [R2]
ORR R0, R5
STRH R0, [R2]
SUB R3, #1
CMP R3, #0
BGE loc_80001D2
MOV R0, #0
POP {R4-R7}
POP {R1}
BX R1
@ End of function rtc_cmd
@ ---------------------------------------------------------------------------
off_80001F8: .long 0x80000C4 @ DATA XREF: rtc_cmd+8r
@ =============== S U B R O U T I N E =======================================
rtc_data:
PUSH {R4-R7,LR}
MOV R4, R0
LSL R4, R4, #1
MOV R3, #0
MOV R7, #2
LDR R2, off_8000234
MOV R6, #4
MOV R5, #5
loc_800020C: @ CODE XREF: rtc_data+2Cj
MOV R0, R4
ASR R0, R3
AND R0, R7
LSL R0, R0, #0x10
LSR R0, R0, #0x10
MOV R1, R0
ORR R1, R6
STRH R1, [R2]
STRH R1, [R2]
STRH R1, [R2]
ORR R0, R5
STRH R0, [R2]
ADD R3, #1
CMP R3, #7
BLE loc_800020C
MOV R0, #0
POP {R4-R7}
POP {R1}
BX R1
@ End of function rtc_data
@ ---------------------------------------------------------------------------
.align 4
off_8000234: .long 0x80000C4 @ DATA XREF: rtc_data+Ar
@ =============== S U B R O U T I N E =======================================
rtc_read: @ CODE XREF: rtc_get:loc_80002AAp
@ rtc_get:loc_80002C2p ...
PUSH {R4-R7,LR}
MOV R5, #0
MOV R2, #0
LDR R3, off_8000274
MOV R6, #4
MOV R7, #5
MOV R0, #2
MOV R12, R0
loc_8000248: @ CODE XREF: rtc_read+30j
ADD R4, R2, #1
MOV R0, #4
loc_800024C: @ CODE XREF: rtc_read+1Aj
STRH R6, [R3]
SUB R0, #1
CMP R0, #0
BGE loc_800024C
STRH R7, [R3]
LDRH R1, [R3]
MOV R0, R12
AND R0, R1
LSL R0, R0, #0x10
LSR R0, R0, #0x10
LSL R0, R2
ORR R5, R0
MOV R2, R4
CMP R2, #7
BLE loc_8000248
ASR R5, R5, #1
MOV R0, R5
POP {R4-R7}
POP {R1}
BX R1
@ End of function rtc_read
@ ---------------------------------------------------------------------------
off_8000274: .long 0x80000C4 @ DATA XREF: rtc_read+6r
@ =============== S U B R O U T I N E =======================================
rtc_check: @ CODE XREF: RTC_TurnOn+26p docode+2p
LDR R0, off_8000284
LDR R0, [R0]
CMP R0, #0
BEQ locret_8000282
MOV R0, #1
locret_8000282: @ CODE XREF: rtc_check+6j
BX LR
@ End of function rtc_check
@ ---------------------------------------------------------------------------
off_8000284: .long 0x3005547 @ DATA XREF: rtc_checkr
@ =============== S U B R O U T I N E =======================================
rtc_get: @ CODE XREF: RTC_TurnOn+30p
@ RTC_GetTime+36p
PUSH {R4-R6,LR}
MOV R6, R0
LDR R1, off_80002D8
MOV R2, #1
STRH R2, [R1]
LDR R5, off_80002DC
MOV R0, #7
STRH R0, [R5]
STRH R2, [R1]
MOV R4, #5
STRH R4, [R1]
MOV R0, #0x65
BL rtc_cmd
STRH R4, [R5]
MOV R4, R6
MOV R5, #3
loc_80002AA: @ CODE XREF: rtc_get+2Ej
BL rtc_read
STRB R0, [R4]
ADD R4, #1
SUB R5, #1
CMP R5, #0
BGE loc_80002AA
LDR R1, off_80002DC
MOV R0, #5
STRH R0, [R1]
ADD R4, R6, #4
MOV R5, #2
loc_80002C2: @ CODE XREF: rtc_get+46j
BL rtc_read
STRB R0, [R4]
ADD R4, #1
SUB R5, #1
CMP R5, #0
BGE loc_80002C2
MOV R0, #0
POP {R4-R6}
POP {R1}
BX R1
@ End of function rtc_get
@ ---------------------------------------------------------------------------
off_80002D8: .long 0x80000C4 @ DATA XREF: rtc_get+4r
off_80002DC: .long 0x80000C6 @ DATA XREF: rtc_get+Ar rtc_get+30r
@ =============== S U B R O U T I N E =======================================
RTC_TurnOn: @ CODE XREF: docode+Ap
PUSH {R4,R5,LR}
LDR R0, off_800031C
MOV R1, #1
STRH R1, [R0]
SUB R0, #4
STRH R1, [R0]
MOV R5, #5
STRH R5, [R0]
LDR R4, off_8000320
MOV R0, #7
STRH R0, [R4]
MOV R0, #0x63
BL rtc_cmd
STRH R5, [R4]
BL rtc_read
LDR R1, off_8000324
STR R0, [R1]
BL rtc_check
LDR R1, off_8000328
STR R0, [R1]
LDR R0, off_800032C
BL rtc_get
MOV R0, #0
POP {R4,R5}
POP {R1}
BX R1
@ End of function RTC_TurnOn
@ ---------------------------------------------------------------------------
off_800031C: .long 0x80000C8 @ DATA XREF: RTC_TurnOn+2r
off_8000320: .long 0x80000C6 @ DATA XREF: RTC_TurnOn+10r
off_8000324: .long 0x3005547 @ DATA XREF: RTC_TurnOn+22r
off_8000328: .long 0x3005504 @ DATA XREF: RTC_TurnOn+2Ar
off_800032C: .long 0x3005505 @ DATA XREF: RTC_TurnOn+2Er
@ =============== S U B R O U T I N E =======================================
UNBCD: @ CODE XREF: RTC_GetTime+3Ep
@ RTC_GetTime+4Ep ...
MOV R2, #0xF
AND R2, R0
ASR R0, R0, #4
LSL R1, R0, #2
ADD R1, R1, R0
LSL R1, R1, #1
ADD R2, R2, R1
MOV R0, R2
BX LR
@ End of function UNBCD
@ ---------------------------------------------------------------------------
.align 4
@ =============== S U B R O U T I N E =======================================
RTC_GetTime: @ CODE XREF: docode+10p
var_14 = -0x14
var_13 = -0x13
var_12 = -0x12
var_11 = -0x11
var_10 = -0x10
var_F = -0xF
var_E = -0xE
PUSH {R4,R5,LR}
SUB SP, SP, #8
MOV R5, R0
LDR R0, off_8000370
LDR R0, [R0]
CMP R0, #0
BNE loc_8000378
MOV R1, #0
LDR R0, dword_8000374
STRH R0, [R5]
MOV R0, #6
STRB R0, [R5,#2]
MOV R0, #0x1A
STRB R0, [R5,#3]
MOV R0, #1
STRB R0, [R5,#4]
MOV R0, #0xC
STRB R0, [R5,#5]
STRB R1, [R5,#6]
STRB R1, [R5,#7]
B loc_8000420
@ ---------------------------------------------------------------------------
nop
nop
nop
off_8000370: .long 0x3005504 @ DATA XREF: RTC_GetTime+6r
dword_8000374: .long 0x7D9 @ DATA XREF: RTC_GetTime+10r
@ ---------------------------------------------------------------------------
loc_8000378: @ CODE XREF: RTC_GetTime+Cj
MOV R0, SP
BL rtc_get
MOV R0, SP
LDRB R0, [R0,#0x14+var_14]
BL UNBCD
LDR R1, var2
ADD R0, R0, R1
STRH R0, [R5]
MOV R0, SP
LDRB R0, [R0,#0x14+var_13]
BL UNBCD
STRB R0, [R5,#2]
MOV R0, SP
LDRB R1, [R0,#0x14+var_12]
MOV R4, #0x3F
MOV R0, R4
AND R0, R1
BL UNBCD
STRB R0, [R5,#3]
MOV R0, SP
LDRB R1, [R0,#0x14+var_11]
MOV R0, R4
AND R0, R1
BL UNBCD
STRB R0, [R5,#4]
MOV R0, SP
LDRB R0, [R0,#0x14+var_10]
AND R4, R0
MOV R0, R4
BL UNBCD
STRB R0, [R5,#5]
MOV R0, SP
LDRB R0, [R0,#0x14+var_F]
BL UNBCD
STRB R0, [R5,#6]
MOV R0, SP
LDRB R0, [R0,#0x14+var_E]
BL UNBCD
STRB R0, [R5,#7]
LDR R2, off_800042C
LDRB R3, [R5,#6]
LDRB R0, [R2,#2]
ADD R1, R3, R0
STRB R1, [R5,#6]
LSL R0, R1, #0x18
LSR R0, R0, #0x18
CMP R0, #0x3B
BLS loc_80003F6
MOV R0, R1
SUB R0, #0x3C
STRB R0, [R5,#6]
LDRB R0, [R5,#5]
ADD R0, #1
STRB R0, [R5,#5]
loc_80003F6: @ CODE XREF: RTC_GetTime+A4j
LDRB R3, [R5,#5]
LDRB R0, [R2,#1]
ADD R1, R3, R0
STRB R1, [R5,#5]
LSL R0, R1, #0x18
LSR R0, R0, #0x18
CMP R0, #0x17
BLS loc_8000412
MOV R0, R1
SUB R0, #0x18
STRB R0, [R5,#5]
LDRB R0, [R5,#4]
ADD R0, #1
STRB R0, [R5,#4]
loc_8000412: @ CODE XREF: RTC_GetTime+C0j
LDRB R2, [R2]
LDRB R1, [R5,#4]
ADD R0, R2, R1
MOV R1, #7
BL __modsi3
STRB R0, [R5,#4]
loc_8000420: @ CODE XREF: RTC_GetTime+28j
MOV R0, #0
ADD SP, SP, #8
POP {R4,R5}
POP {R1}
BX R1
@ End of function RTC_GetTime
@ ---------------------------------------------------------------------------
.align 4
off_800042C: .long 0x3005537 @ DATA XREF: RTC_GetTime+94r
@vars
var2: .long 0x7D0
@ =============== S U B R O U T I N E =======================================
docode: @ CODE XREF: AgbMain+2p
PUSH {LR}
BL rtc_check
CMP R0, #0
BNE loc_800043E
BL RTC_TurnOn
loc_800043E: @ CODE XREF: docode+8j
LDR R0, =0x300553D
BL RTC_GetTime
MOV R0, #0
POP {R1}
BX R1
@ End of function docode
@ ---------------------------------------------------------------------------
.align 4
off_800044C: .long 0x300553D @ DATA XREF: docode:loc_800043Er
@ =============== S U B R O U T I N E =======================================
AgbMain: @ CODE XREF: .text:080000ECp
@ DATA XREF: .text:080000E4o ...
PUSH {LR}
BL docode
POP {R0}
BX R0
@ End of function AgbMain
@ ---------------------------------------------------------------------------
.align 4
@ =============== S U B R O U T I N E =======================================
__modsi3: @ CODE XREF: RTC_GetTime+D6p
MOV R3, #1
CMP R1, #0
BEQ Ldiv0
BPL Over1
NEG R1, R1
Over1: @ CODE XREF: __modsi3+6j
PUSH {R4}
PUSH {R0}
CMP R0, #0
BPL Over2
NEG R0, R0
Over2: @ CODE XREF: __modsi3+10j
CMP R0, R1
BCC Lgot_result
@MOV R4, #0x10000000
MOV R4, #1
LSL R4, #8
LSL R4, #4
LSL R4, #0x10
Loop1: @ CODE XREF: __modsi3+28j
CMP R1, R4
BCS Lbignum
CMP R1, R0
BCS Lbignum
LSL R1, R1, #4
LSL R3, R3, #4
B Loop1
@ ---------------------------------------------------------------------------
Lbignum: @ CODE XREF: __modsi3+1Ej __modsi3+22j
LSL R4, R4, #3
Loop2: @ CODE XREF: __modsi3+38j
CMP R1, R4
BCS Loop3
CMP R1, R0
BCS Loop3
LSL R1, R1, #1
LSL R3, R3, #1
B Loop2
@ ---------------------------------------------------------------------------
Loop3: @ CODE XREF: __modsi3+2Ej __modsi3+32j ...
MOV R2, #0
CMP R0, R1
BCC Over3
SUB R0, R0, R1
Over3: @ CODE XREF: __modsi3+3Ej
LSR R4, R1, #1
CMP R0, R4
BCC Over4
SUB R0, R0, R4
MOV R12, R3
MOV R4, #1
ROR R3, R4
ORR R2, R3
MOV R3, R12
Over4: @ CODE XREF: __modsi3+46j
LSR R4, R1, #2
CMP R0, R4
BCC Over5
SUB R0, R0, R4
MOV R12, R3
MOV R4, #2
ROR R3, R4
ORR R2, R3
MOV R3, R12
Over5: @ CODE XREF: __modsi3+58j
LSR R4, R1, #3
CMP R0, R4
BCC Over6
SUB R0, R0, R4
MOV R12, R3
MOV R4, #3
ROR R3, R4
ORR R2, R3
MOV R3, R12
Over6: @ CODE XREF: __modsi3+6Aj
MOV R12, R3
CMP R0, #0
BEQ Over7
LSR R3, R3, #4
BEQ Over7
LSR R1, R1, #4
B Loop3
@ ---------------------------------------------------------------------------
Over7: @ CODE XREF: __modsi3+7Cj __modsi3+80j
@MOV R4, #0xE0000000
MOV R4, #0xE
LSL R4, #8
LSL R4, #4
LSL R4, #0x10
AND R2, R4
BEQ Lgot_result
MOV R3, R12
MOV R4, #3
ROR R3, R4
TST R2, R3
BEQ Over8
LSR R4, R1, #3
ADD R0, R0, R4
Over8: @ CODE XREF: __modsi3+96j
MOV R3, R12
MOV R4, #2
ROR R3, R4
TST R2, R3
BEQ Over9
LSR R4, R1, #2
ADD R0, R0, R4
Over9: @ CODE XREF: __modsi3+A4j
MOV R3, R12
MOV R4, #1
ROR R3, R4
TST R2, R3
BEQ Lgot_result
LSR R4, R1, #1
ADD R0, R0, R4
Lgot_result: @ CODE XREF: __modsi3+16j __modsi3+8Cj ...
POP {R4}
CMP R4, #0
BPL Over10
NEG R0, R0
Over10: @ CODE XREF: __modsi3+BCj
POP {R4}
MOV PC, LR
@ ---------------------------------------------------------------------------
Ldiv0: @ CODE XREF: __modsi3+4j
PUSH {LR}
BL __div0
MOV R0, #0
POP {PC}
@ End of function __modsi3
@ ---------------------------------------------------------------------------
.align 4
@ =============== S U B R O U T I N E =======================================
__div0: @ CODE XREF: __modsi3+C6p
MOV PC, LR
@ End of function __div0
Download the IPS patch
I am not posting an example script, and to anyone else, PLEASE DO NOT POST AN EXAMPLE SCRIPT ANYWHERE except in your own hack
Why? Because then i'd see "RTC IN MY HACK" and properly my slightly modified example script. So you'll have to make your own from the data below, sorry for the earlier trouble.
I use No$GBA and vba-m for testing. :)
Patches on to the games main loop at 0x41E. Then executes my code at 0xb01000.
The time it gives you is stored at 0x300553C
In the following format.
Year u16
skip a byte
month u8
day u8
Day of week(mon-sun/1-7) u8
Hour u8
minute u8
second u8
at 0x3005537
is
u8 dayofweek;
u8 hours;
u8 minutes;
use that when you create your time setter function. code auto compensates(I didn't and don't plan on a date thing you can do that on your own)
Please give me credit.
Thanks to kawai/ZodiacDaGreat for helping me with an example script.
Merry Christmas everyone
Last edited: