Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gba_console.h>
- #include <gba_interrupt.h>
- #include <gba_systemcalls.h>
- #include <stdio.h>
- #include <stdlib.h>
- void enableRTC(u16 n){*(vu16*)0x80000c8=n;}
- void setRTCwritemode(u16 n){*(vu16*)0x80000c6=n;}//0=read, 2=write
- void setRTCcommand(u8 command){
- *(vu16*)0x80000c4=1; //initialize
- *(vu16*)0x80000c4=5; //start sending
- *(vu16*)0x80000c4=0;
- int i=0;for(;i<8;i++){
- *(vu16*)0x80000c4=((command>>(7-i))<<1)|1; //send from upper bit
- *(vu16*)0x80000c4=0;
- }
- }
- u8 getRTCbyte(){
- u8 ret=0;
- int i=0;for(;i<8;i++){
- *(vu16*)0x80000c4=2|1;
- ret|=(((u8)(*(vu16*)0x80000c4)&2)>>1) << i; //sent from lower bit
- *(vu16*)0x80000c4=0;
- }
- return (ret/16*10)+ret%16;
- }
- int main(){
- irqInit();
- irqEnable(IRQ_VBLANK);
- consoleDemoInit();
- enableRTC(1);
- setRTCwritemode(0);
- setRTCcommand(0x65);
- iprintf("---%u/%02u/%02u %d %02d:%02d:%02d---\n",getRTCbyte()+1900+100,getRTCbyte(),getRTCbyte(),getRTCbyte(),getRTCbyte(),getRTCbyte(),getRTCbyte());
- while(1){VBlankIntrWait();}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement