GBA: Ability to use an external source for the RTC
Jeffrey Pfau jeffrey@endrift.com
Fri, 26 Dec 2014 01:37:24 -0800
4 files changed,
17 insertions(+),
1 deletions(-)
M
src/gba/gba-gpio.c
→
src/gba/gba-gpio.c
@@ -242,7 +242,14 @@ return output;
} void _rtcUpdateClock(struct GBACartridgeGPIO* gpio) { - time_t t = time(0); + time_t t; + struct GBARTCSource* rtc = gpio->p->rtcSource; + if (rtc) { + rtc->sample(rtc); + t = rtc->unixTime(rtc); + } else { + t = time(0); + } struct tm date; #ifdef _WIN32 date = *localtime(&t);
M
src/gba/gba-sensors.h
→
src/gba/gba-sensors.h
@@ -23,4 +23,10 @@
uint8_t (*readLuminance)(struct GBALuminanceSource*); }; +struct GBARTCSource { + void (*sample)(struct GBARTCSource*); + + time_t (*unixTime)(struct GBARTCSource*); +}; + #endif
M
src/gba/gba.c
→
src/gba/gba.c
@@ -156,6 +156,8 @@
gba->springIRQ = 0; gba->keySource = 0; gba->rotationSource = 0; + gba->luminanceSource = 0; + gba->rtcSource = 0; gba->rumble = 0; gba->rr = 0;
M
src/gba/gba.h
→
src/gba/gba.h
@@ -116,6 +116,7 @@ int* keySource;
uint32_t busyLoop; struct GBARotationSource* rotationSource; struct GBALuminanceSource* luminanceSource; + struct GBARTCSource* rtcSource; struct GBARumble* rumble; struct GBARRContext* rr;