mirror of https://github.com/mgba-emu/mgba.git
GBA: Ability to use an external source for the RTC
This commit is contained in:
parent
90a3872552
commit
63d4929c0c
|
@ -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);
|
||||
|
|
|
@ -23,4 +23,10 @@ struct GBALuminanceSource {
|
|||
uint8_t (*readLuminance)(struct GBALuminanceSource*);
|
||||
};
|
||||
|
||||
struct GBARTCSource {
|
||||
void (*sample)(struct GBARTCSource*);
|
||||
|
||||
time_t (*unixTime)(struct GBARTCSource*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ struct GBA {
|
|||
uint32_t busyLoop;
|
||||
struct GBARotationSource* rotationSource;
|
||||
struct GBALuminanceSource* luminanceSource;
|
||||
struct GBARTCSource* rtcSource;
|
||||
struct GBARumble* rumble;
|
||||
|
||||
struct GBARRContext* rr;
|
||||
|
|
Loading…
Reference in New Issue