diff --git a/src/gba/cart/gpio.c b/src/gba/cart/gpio.c index f714cf8..bd341d2 100644 --- a/src/gba/cart/gpio.c +++ b/src/gba/cart/gpio.c @@ -312,7 +312,7 @@ void _rtcUpdateClock(struct GBACartridgeHardware* hw) { t -= hw->rtc.offset; struct tm date; - localtime_r(&t, &date); + gmtime_r(&t, &date); // PlayAgain: UTC, never the host time zone hw->rtc.time[0] = _rtcBCD(date.tm_year - 100); hw->rtc.time[1] = _rtcBCD(date.tm_mon + 1); hw->rtc.time[2] = _rtcBCD(date.tm_mday); diff --git a/src/gba/io.c b/src/gba/io.c index 658036e..693d965 100644 --- a/src/gba/io.c +++ b/src/gba/io.c @@ -1018,6 +1018,9 @@ void GBAIOSerialize(struct GBA* gba, struct GBASerializedState* state) { STORE_32(gba->timers[i].flags, 0, &state->timers[i].flags); } STORE_32(gba->bus, 0, &state->bus); + // PlayAgain: SIOMLT_SEND/SIODATA8 (0x12A) is not in _isValidRegister, so it was + // never saved; a state taken between the game's write and the next transfer lost it. + STORE_16(gba->memory.io[GBA_REG(SIOMLT_SEND)], GBA_REG_SIOMLT_SEND, state->io); GBADMASerialize(gba, state); GBAHardwareSerialize(&gba->memory.hw, state); @@ -1056,6 +1059,12 @@ void GBAIODeserialize(struct GBA* gba, const struct GBASerializedState* state) { } gba->sio.siocnt = gba->memory.io[GBA_REG(SIOCNT)]; GBASIOWriteRCNT(&gba->sio, gba->memory.io[GBA_REG(RCNT)]); + // PlayAgain: WriteRCNT keeps the *current* SC/SD/SI/SO status bits, which + // the link driver owns (ready/slave). Restore the saved ones, or a state loaded + // mid-link into a fresh core reports "not ready" and the game drops the link. + LOAD_16(gba->sio.rcnt, GBA_REG_RCNT, state->io); + LOAD_16(gba->sio.siocnt, GBA_REG_SIOCNT, state->io); + LOAD_16(gba->memory.io[GBA_REG(SIOMLT_SEND)], GBA_REG_SIOMLT_SEND, state->io); LOAD_32(gba->bus, 0, &state->bus); GBADMADeserialize(gba, state); diff --git a/src/gba/savedata.c b/src/gba/savedata.c index fdafa5b..ee448de 100644 --- a/src/gba/savedata.c +++ b/src/gba/savedata.c @@ -676,7 +676,7 @@ void GBASavedataRTCRead(struct GBASavedata* savedata) { date.tm_min = _unBCD(savedata->p->memory.hw.rtc.time[5]); date.tm_sec = _unBCD(savedata->p->memory.hw.rtc.time[6]); date.tm_isdst = -1; - rtcTime = mktime(&date); + rtcTime = timegm(&date); // PlayAgain: UTC, never the host time zone #else struct SceDateTime date; date.year = _unBCD(savedata->p->memory.hw.rtc.time[0]) + 2000;