Go Back   The PokéCommunity Forums > ROM Hacking > Research & Development
Reload this Page Development Christmas Present for PC! Your very own RTC for FR and LG

Notices
For all updates, view the main page.

Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!
Research & Development programs in this forum are subject to moderator approval before they are displayed.



Reply
 
Thread Tools
  #1    
Old December 24th, 2009 (11:08 PM). Edited December 28th, 2009 by interdpth.
interdpth interdpth is offline
I've seen things, man.
 
Join Date: Jul 2004
Posts: 275

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

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


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

__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote

Relevant Advertising!

  #2    
Old December 25th, 2009 (12:17 PM). Edited December 25th, 2009 by ZodiacDaGreat.
ZodiacDaGreat's Avatar
ZodiacDaGreat ZodiacDaGreat is offline
Working on a Mobile System
 
Join Date: Feb 2007
Location: South Pacific
Age: 23
Gender: Male
Nature: Relaxed
Posts: 429
Send a message via ICQ to ZodiacDaGreat

So, it's approved uh? Well, here's my contribution. Merry Christmas guys

Spoiler:
Code:
@ Fire Red RTC Hack
@ Version 1.0.2
@ By ZodiacDaGreat
@ ----------------------------------------------------------------
.code 16
.thumb

.org 0x000000 .Main: push {r4}

@ RTC Part bl .SetupRTC ldr r0, .IWRAMRTC bl .ManipulateRTC

@ Part of the original routine ldr r4, .UnkFunc1 bl .BranchLink lsl r0, r0, #0x18 cmp r0, #0x0 bne .Endme

ldr r4, .UnkFunc2 bl .BranchLink

.Endme: ldr r4, .Return

.BranchLink: bx r4

@ ---------------------------------------------------------------- @ Seting Up RTC .SetupRTC: push {r4, r5, lr} ldr r3, .IOPORTCNT mov r2, #0x1 strh r2, [r3] @ Enable RTC

mov r5, #0x5 sub r3, r3, #0x4 @ r3 = IOPORTDATA strh r2, [r3] strh r5, [r3]

ldr r4, .IOPORTDIRECTION mov r3, #0x7 strh r3, [r4]

mov r0, #0x63 bl .RTCFunc1

strh r5, [r4] bl .RTCFunc2

ldr r3, .Temp strh r0, [r3] pop {r4, r5, pc}

@ ---------------------------------------------------------------- .RTCFunc1: push {r4-r7, lr} ldr r1, .IOPORTDATA lsl r4, r0, #0x1 @ r4 = 0xC6 mov r7, #0x2 mov r0, #0x7 @ Counter mov r6, #0x4 mov r5, #0x5 .Loop1: mov r2, r4 asr r2, r0 and r2, r7 mov r3, r2 orr r3, r6 orr r2, r5

lsl r3, r3, #0x10 @ Prevents overflow lsl r2, r2, #0x10 lsr r3, r3, #0x10 lsr r2, r2, #0x10

strh r3, [r1] strh r3, [r1] strh r3, [r1] strh r2, [r1]

sub r0, r0, #0x1 bcs .Loop1 pop {r4-r7, pc}

@ ---------------------------------------------------------------- .RTCFunc2: push {r4-r6, lr} ldr r2, .IOPORTDATA mov r0, #0x0 mov r4, #0x0 mov r1, #0x4 mov r6, #0x5 mov r5, #0x2 .Loop2: strh r1, [r2] strh r1, [r2] strh r1, [r2] strh r1, [r2] strh r1, [r2] strh r6, [r2]

ldrh r3, [r2] and r3, r3, r5 lsl r3, r0 add r0, r0, #0x1 orr r4, r3 cmp r0, #0x8 bne .Loop2 asr r0, r4, #0x1 pop {r4-r6, pc}

@ ---------------------------------------------------------------- .ManipulateRTC: push {r4-r6, lr} ldr r2, .IOPORTDATA ldr r5, .IOPORTDIRECTION mov r1, #0x1 mov r3, #0x7 mov r4, #0x5 strh r1, [r2] mov r6, r0 strh r3, [r5] strh r1, [r2] strh r4, [r2]

mov r0, #0x65 bl .RTCFunc1

strh r4, [r5] mov r5, #0x0

.Loop3: bl .RTCFunc2 add r4, r6, r5 add r5, r5, #0x1 strb r0, [r4] cmp r5, #0x4 bne .Loop3

ldr r3, .IOPORTDIRECTION mov r2, #0x5 strh r2, [r3]

.Loop4: bl .RTCFunc2 add r4, r6, r5 add r5, r5, #0x1 strb r0, [r4] cmp r5, #0x7 bne .Loop4

mov r0, #0x0 pop {r4-r6, pc}

@ ---------------------------------------------------------------- .align 2 .UnkFunc1: .word 0x0800B179 .UnkFunc2: .word 0x08000511 .Return: .word 0x080004bF

.Temp: .word 0x03007E5C .IWRAMRTC: .word 0x03004038 .IOPORTDATA: .word 0x080000C4 .IOPORTDIRECTION: .word 0x080000C6 .IOPORTCNT: .word 0x080000C8

@ ---------------------------------------------------------------- @ Put 00B5 0148 0047 0000 [Reverse Address+1] 0000 10BC at 0x4B0


Remember to credit me if you use my code, it's for Fire Red. The RTC is at 0x03004038. The format is:
[Year][Month][Date][Filler][Hour][Month][Date]
They are all a byte each in size.

Thanks to
HackMew - For RTC tips and hints on how it works

__________________
Reply With Quote
  #3    
Old December 25th, 2009 (12:52 PM).
helloNL helloNL is offline
 
Join Date: Oct 2009
Gender: Male
Posts: 37

what i dont understand is what does it do?

Reply With Quote
  #4    
Old December 25th, 2009 (12:53 PM).
558122_DG's Avatar
558122_DG 558122_DG is offline
Learning how to make mistakes
 
Join Date: Nov 2009
Gender: Male
Posts: 739

hmmm, nice present although all it did was destroy what little understanding i had of asm

__________________
This signature has been disabled.
Spoilers are forbidden in signatures
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Reply With Quote
  #5    
Old December 25th, 2009 (12:55 PM).
.Seth's Avatar
.Seth .Seth is offline

.explorer.

Crystal Tier
 
Join Date: Jun 2008
Location: A capacitor in a power supply board.
Gender: Male
Nature: Quiet
Posts: 1,645

Nice job, interdpth. Many of us have desired an RTC for the FireRed and Leafgreen versions.

I'll put it to use right away. ;)

Reply With Quote
  #6    
Old December 25th, 2009 (2:52 PM).
diegoisawesome's Avatar
diegoisawesome diegoisawesome is offline
Oh god the bees
Silver Tier
 
Join Date: Dec 2007
Location: :noitacoL
Age: 19
Gender: Male
Nature: Naive
Posts: 997

Quote originally posted by ZodiacDaGreat:
So, it's approved uh? Well, here's my contribution. Merry Christmas guys

Spoiler:
@ Fire Red RTC Hack
@ Version 1.0.2
@ By ZodiacDaGreat
@ ----------------------------------------------------------------
.code 16
.thumb

.org 0x000000
.Main:
push {r4}

@ RTC Part
bl .SetupRTC
ldr r0, .IWRAMRTC
bl .ManipulateRTC

@ Part of the original routine
ldr r4, .UnkFunc1
bl .BranchLink
lsl r0, r0, #0x18
cmp r0, #0x0
bne .Endme

ldr r4, .UnkFunc2
bl .BranchLink

.Endme:
ldr r4, .Return

.BranchLink:
bx r4

@ ----------------------------------------------------------------
@ Seting Up RTC
.SetupRTC:
push {r4, r5, lr}
ldr r3, .IOPORTCNT
mov r2, #0x1
strh r2, [r3] @ Enable RTC

mov r5, #0x5
sub r3, r3, #0x4 @ r3 = IOPORTDATA
strh r2, [r3]
strh r5, [r3]

ldr r4, .IOPORTDIRECTION
mov r3, #0x7
strh r3, [r4]

mov r0, #0x63
bl .RTCFunc1

strh r5, [r4]
bl .RTCFunc2

ldr r3, .Temp
strh r0, [r3]
pop {r4, r5, pc}

@ ----------------------------------------------------------------
.RTCFunc1:
push {r4-r7, lr}
ldr r1, .IOPORTDATA
lsl r4, r0, #0x1 @ r4 = 0xC6
mov r7, #0x2
mov r0, #0x7 @ Counter
mov r6, #0x4
mov r5, #0x5
.Loop1:
mov r2, r4
asr r2, r0
and r2, r7
mov r3, r2
orr r3, r6
orr r2, r5

lsl r3, r3, #0x10 @ Prevents overflow
lsl r2, r2, #0x10
lsr r3, r3, #0x10
lsr r2, r2, #0x10

strh r3, [r1]
strh r3, [r1]
strh r3, [r1]
strh r2, [r1]

sub r0, r0, #0x1
bcs .Loop1
pop {r4-r7, pc}

@ ----------------------------------------------------------------
.RTCFunc2:
push {r4-r6, lr}
ldr r2, .IOPORTDATA
mov r0, #0x0
mov r4, #0x0
mov r1, #0x4
mov r6, #0x5
mov r5, #0x2
.Loop2:
strh r1, [r2]
strh r1, [r2]
strh r1, [r2]
strh r1, [r2]
strh r1, [r2]
strh r6, [r2]

ldrh r3, [r2]
and r3, r3, r5
lsl r3, r0
add r0, r0, #0x1
orr r4, r3
cmp r0, #0x8
bne .Loop2
asr r0, r4, #0x1
pop {r4-r6, pc}

@ ----------------------------------------------------------------
.ManipulateRTC:
push {r4-r6, lr}
ldr r2, .IOPORTDATA
ldr r5, .IOPORTDIRECTION
mov r1, #0x1
mov r3, #0x7
mov r4, #0x5
strh r1, [r2]
mov r6, r0
strh r3, [r5]
strh r1, [r2]
strh r4, [r2]

mov r0, #0x65
bl .RTCFunc1

strh r4, [r5]
mov r5, #0x0

.Loop3:
bl .RTCFunc2
add r4, r6, r5
add r5, r5, #0x1
strb r0, [r4]
cmp r5, #0x4
bne .Loop3

ldr r3, .IOPORTDIRECTION
mov r2, #0x5
strh r2, [r3]

.Loop4:
bl .RTCFunc2
add r4, r6, r5
add r5, r5, #0x1
strb r0, [r4]
cmp r5, #0x7
bne .Loop4

mov r0, #0x0
pop {r4-r6, pc}

@ ----------------------------------------------------------------
.align 2
.UnkFunc1: .word 0x0800B179
.UnkFunc2: .word 0x08000511
.Return: .word 0x080004bF

.Temp: .word 0x03007E5C
.IWRAMRTC: .word 0x03004038
.IOPORTDATA: .word 0x080000C4
.IOPORTDIRECTION: .word 0x080000C6
.IOPORTCNT: .word 0x080000C8

@ ----------------------------------------------------------------
@ Put 00B5 0148 0047 0000 [Reverse Address+1] 0000 10BC at 0x4B0


Remember to credit me if you use my code, it's for Fire Red. The RTC is at 0x03004038. The format is:
[Year][Month][Date][Filler][Hour][Minutes][Seconds]
They are all a byte each in size.

Thanks to
HackMew - For RTC tips and hints on how it works

Um, I think you meant to put that.
EDIT: Also, is it just me, or does this use the Windows clock?
Does this mean that it wouldn't work on an actual GBA?

__________________


My other resources:
My Website
diegoisawesome's MEGA-HUGE XSE Scripting Tutorial
diegoisawesome's Miscellaneous Finds
The Ruins of Alph Puzzles
Diego's Miscellaneous Patches
GBA Intro Manager
The Secret Sauce: Triple-Layer Tiles
Reply With Quote
  #7    
Old December 25th, 2009 (3:20 PM).
Chaos Rush's Avatar
Chaos Rush Chaos Rush is offline
im sexy and i know it
 
Join Date: May 2007
Location: Taylor Swift
Gender: Male
Nature: Adamant
Posts: 1,296

Is this RTC identical to R/S/E? Also, if you were to put a FireRed or LeafGreen rom on a GBA Flashcart, would the RTC work correctly?

__________________

My projects:
Untitled Pokémon fangame (pictured above) | Final Fantasy II NES retranslation | Mother 1/EarthBound Beginnings Color Restoration for GBA
Non-Pokémon hacks I support:
Sonic Classic Heroes
Sonic 3 Complete
Reply With Quote
  #8    
Old December 25th, 2009 (5:30 PM).
interdpth interdpth is offline
I've seen things, man.
 
Join Date: Jul 2004
Posts: 275

Quote originally posted by helloNL:
what i dont understand is what does it do?

I asked you not to post if you don't understand.

Quote originally posted by diegoisawesome:
Um, I think you meant to put that. :P
EDIT: Also, is it just me, or does this use the Windows clock?
Does this mean that it wouldn't work on an actual GBA?

Quote originally posted by AztecFire:
Is this RTC identical to R/S/E? Also, if you were to put a FireRed or LeafGreen rom on a GBA Flashcart, would the RTC work correctly?

I forgot to add some extra data to my post on how to offset the changes, added it, so please refer to it. And yes it should work on the real GBA, the emulators just base it off of a time() call, so it uses your OS's time.

__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #9    
Old December 25th, 2009 (5:55 PM).
Chaos Rush's Avatar
Chaos Rush Chaos Rush is offline
im sexy and i know it
 
Join Date: May 2007
Location: Taylor Swift
Gender: Male
Nature: Adamant
Posts: 1,296

Quote originally posted by interdpth:
I forgot to add some extra data to my post on how to offset the changes, added it, so please refer to it. And yes it should work on the real GBA, the emulators just base it off of a time() call, so it uses your OS's time.
So this is better than the R/S/E one? That's cool. Since the R/S/E RTC doesn't work on GBA flashcarts, you should see if you can add your FR/LG clock to R/S/E (and remove the clock that comes with R/S/E so then we don't have to see the "internal battery has run dry" message on a GBA flashcart).

__________________

My projects:
Untitled Pokémon fangame (pictured above) | Final Fantasy II NES retranslation | Mother 1/EarthBound Beginnings Color Restoration for GBA
Non-Pokémon hacks I support:
Sonic Classic Heroes
Sonic 3 Complete
Reply With Quote
  #10    
Old December 25th, 2009 (6:25 PM).
ZodiacDaGreat's Avatar
ZodiacDaGreat ZodiacDaGreat is offline
Working on a Mobile System
 
Join Date: Feb 2007
Location: South Pacific
Age: 23
Gender: Male
Nature: Relaxed
Posts: 429
Send a message via ICQ to ZodiacDaGreat

Quote originally posted by AztecFire:
So this is better than the R/S/E one? That's cool. Since the R/S/E RTC doesn't work on GBA flashcarts, you should see if you can add your FR/LG clock to R/S/E (and remove the clock that comes with R/S/E so then we don't have to see the "internal battery has run dry" message on a GBA flashcart).
I guess it depends on whether or not that the flash cart has the RTC chip built in if it doesn't then RTC doesn't work.

__________________
Reply With Quote
  #11    
Old December 25th, 2009 (7:42 PM).
Haku.'s Avatar
Haku. Haku. is offline
(FLAME)...H....A...K..U
 
Join Date: Jan 2008
Location: Singapore :D
Gender: Male
Nature: Quiet
Posts: 386
Send a message via Windows Live Messenger to Haku.

Could anyone care to show me how do i insert this?
At which offset and how do i use it please?
I'm not very good with ASM yet.
Must i use setvar 0x8003 or 0x????.

__________________

Reply With Quote
  #12    
Old December 25th, 2009 (8:03 PM).
interdpth interdpth is offline
I've seen things, man.
 
Join Date: Jul 2004
Posts: 275

I have no clue what you mean.

__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #13    
Old December 25th, 2009 (9:42 PM).
Haku.'s Avatar
Haku. Haku. is offline
(FLAME)...H....A...K..U
 
Join Date: Jan 2008
Location: Singapore :D
Gender: Male
Nature: Quiet
Posts: 386
Send a message via Windows Live Messenger to Haku.

What i meant is, how do i use this?
Must i use callasm [offset] + 1?

__________________

Reply With Quote
  #14    
Old December 25th, 2009 (9:56 PM).
interdpth interdpth is offline
I've seen things, man.
 
Join Date: Jul 2004
Posts: 275

No. You just apply it to the game and it runs every frame.

Did you not read the description?

__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #15    
Old December 25th, 2009 (9:59 PM).
Chaos Rush's Avatar
Chaos Rush Chaos Rush is offline
im sexy and i know it
 
Join Date: May 2007
Location: Taylor Swift
Gender: Male
Nature: Adamant
Posts: 1,296

Quote originally posted by ZodiacDaGreat:
I guess it depends on whether or not that the flash cart has the RTC chip built in if it doesn't then RTC doesn't work.
Well that's a bummer...

Would it ever be possible to add a RTC in R/S/FR/LG/E where it works like G/S/C's RTC?

__________________

My projects:
Untitled Pokémon fangame (pictured above) | Final Fantasy II NES retranslation | Mother 1/EarthBound Beginnings Color Restoration for GBA
Non-Pokémon hacks I support:
Sonic Classic Heroes
Sonic 3 Complete
Reply With Quote
  #16    
Old December 25th, 2009 (10:06 PM).
interdpth interdpth is offline
I've seen things, man.
 
Join Date: Jul 2004
Posts: 275

GSC also has a builtin RTC chip.

__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #17    
Old December 26th, 2009 (4:16 AM).
Darthatron's Avatar
Darthatron Darthatron is offline
巨大なトロール。
Silver Tier
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 24
Gender: Male
Nature: Modest
Posts: 1,152

Quote originally posted by interdpth:
Problem at the moment will be fixed in a few hours

I ruined interdpth's night. Thanks for this by the way, I have been waiting patiently.

__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote
  #18    
Old December 26th, 2009 (7:52 AM).
diegoisawesome's Avatar
diegoisawesome diegoisawesome is offline
Oh god the bees
Silver Tier
 
Join Date: Dec 2007
Location: :noitacoL
Age: 19
Gender: Male
Nature: Naive
Posts: 997

This is the first ASM script I've compiled correctly! The problem was that I was using devkitARM for THUMB scripts!

Hehe, I am so stupid sometimes...

__________________


My other resources:
My Website
diegoisawesome's MEGA-HUGE XSE Scripting Tutorial
diegoisawesome's Miscellaneous Finds
The Ruins of Alph Puzzles
Diego's Miscellaneous Patches
GBA Intro Manager
The Secret Sauce: Triple-Layer Tiles
Reply With Quote
  #19    
Old December 26th, 2009 (8:47 AM).
Destinyfate's Avatar
Destinyfate Destinyfate is offline
☆ Splash
 
Join Date: Sep 2009
Location: Los Angeles,CA
Gender: Male
Nature: Relaxed
Posts: 421
Send a message via Yahoo to Destinyfate Send a message via Skype™ to Destinyfate

thnaks alot merry late christmas lol XD

__________________


ITS ALL OR NOTHING,/LEVEL 32 ON DESTINY/VELOCITYBOLT
Reply With Quote
  #20    
Old December 26th, 2009 (12:18 PM).
interdpth interdpth is offline
I've seen things, man.
 
Join Date: Jul 2004
Posts: 275

Can a mod move this thread and rename it plz

__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #21    
Old December 26th, 2009 (12:56 PM).
mindfreak's Avatar
mindfreak mindfreak is offline
Belgium Rom hacker
 
Join Date: Dec 2007
Posts: 45

To bad you had to post a patch.
It's much more fun trying to assemble this on your own and now almost anyone can use it.
Anyway, merry Christmas and thanks for sharing.

__________________
Reply With Quote
  #22    
Old December 26th, 2009 (12:59 PM).
diegoisawesome's Avatar
diegoisawesome diegoisawesome is offline
Oh god the bees
Silver Tier
 
Join Date: Dec 2007
Location: :noitacoL
Age: 19
Gender: Male
Nature: Naive
Posts: 997

At least me and a few others can be proud that we assembled it! :D
Although I assembled ZodiacDaGreat's because interdpth's is for LeafGreen...

__________________


My other resources:
My Website
diegoisawesome's MEGA-HUGE XSE Scripting Tutorial
diegoisawesome's Miscellaneous Finds
The Ruins of Alph Puzzles
Diego's Miscellaneous Patches
GBA Intro Manager
The Secret Sauce: Triple-Layer Tiles
Reply With Quote
  #23    
Old December 26th, 2009 (2:35 PM).
interdpth interdpth is offline
I've seen things, man.
 
Join Date: Jul 2004
Posts: 275

Zodiac's won't work vanilla. I'm 99% sure my patch will work for FR, I don't have the game otherwise i'd have a ROM for it.

But I messed something up in code before i pasted it, so the code was bad.

Hopefully people will respect my wishes and not post an example script how to use it

Anywho, i'll be having a day and night system based off of MasterMind's code soon. ^_^

Future releases like this will be ASM only. And i'll make sure I don't fudge it up XD

__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #24    
Old December 26th, 2009 (3:17 PM).
mindfreak's Avatar
mindfreak mindfreak is offline
Belgium Rom hacker
 
Join Date: Dec 2007
Posts: 45

Yes I got ZodiacDaGreats clock Working!
Now I've just to find out how I can display it ingame.(interdpths example script)
And somehow I think thats the most difficult part since all the rest was given here.

__________________
Reply With Quote
  #25    
Old December 26th, 2009 (3:17 PM).
pokefreak2's Avatar
pokefreak2 pokefreak2 is offline
I can't believe you read this
 
Join Date: Oct 2008
Location: that information is classified
Age: 18
Nature: Naive
Posts: 85

is this for a script like callsm? or do you just paste the code in the game with hex editor and it runs the RTC? for firered/leafgreen?

__________________
Advanced scripter of


http://www.awsurveys.com/HomeMain.cfm?RefID=Xmouvelianx click on this please it gives my friend money it's not a rick roll and all you do is click on it sign up then leave and then we get 1.25$ ty

http://pokerum.freehostia.com/Forum/Forum/index.php

Copy and paste into your top browser
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 2:32 AM.