GBA: Ability to use an external source for the RTC

This commit is contained in:
Jeffrey Pfau 2014-12-26 01:37:24 -08:00
parent 90a3872552
commit 63d4929c0c
4 changed files with 17 additions and 1 deletions

View File

@ -242,7 +242,14 @@ unsigned _rtcOutput(struct GBACartridgeGPIO* gpio) {
}
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);

View File

@ -23,4 +23,10 @@ struct GBALuminanceSource {
uint8_t (*readLuminance)(struct GBALuminanceSource*);
};
struct GBARTCSource {
void (*sample)(struct GBARTCSource*);
time_t (*unixTime)(struct GBARTCSource*);
};
#endif

View File

@ -156,6 +156,8 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) {
gba->springIRQ = 0;
gba->keySource = 0;
gba->rotationSource = 0;
gba->luminanceSource = 0;
gba->rtcSource = 0;
gba->rumble = 0;
gba->rr = 0;

View File

@ -116,6 +116,7 @@ struct GBA {
uint32_t busyLoop;
struct GBARotationSource* rotationSource;
struct GBALuminanceSource* luminanceSource;
struct GBARTCSource* rtcSource;
struct GBARumble* rumble;
struct GBARRContext* rr;