all repos — mgba @ 63d4929c0cbbdb30ea4f9809eb21966a1c6f916b

mGBA Game Boy Advance Emulator

GBA: Ability to use an external source for the RTC
Jeffrey Pfau jeffrey@endrift.com
Fri, 26 Dec 2014 01:37:24 -0800
commit

63d4929c0cbbdb30ea4f9809eb21966a1c6f916b

parent

90a3872552de56c4b98945df29feb9f826e9bbb3

4 files changed, 17 insertions(+), 1 deletions(-)

jump to
M src/gba/gba-gpio.csrc/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.hsrc/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.csrc/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.hsrc/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;