mirror of https://github.com/mgba-emu/mgba.git
Vita: Work around broken mktime implementation in Vita SDK (fixes #2876)
This commit is contained in:
parent
1b85fb3de5
commit
e8ef801a3e
1
CHANGES
1
CHANGES
|
@ -33,6 +33,7 @@ Other fixes:
|
|||
- Scripting: Fix receiving packets for client sockets
|
||||
- Scripting: Fix empty receive calls returning unknown error on Windows
|
||||
- Scripting: Return proper callback ID from socket.add
|
||||
- Vita: Work around broken mktime implementation in Vita SDK (fixes mgba.io/i/2876)
|
||||
Misc:
|
||||
- Core: Handle relative paths for saves, screenshots, etc consistently (fixes mgba.io/i/2826)
|
||||
- GB Serialize: Add missing savestate support for MBC6 and NT (newer)
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
#include <mgba-util/memory.h>
|
||||
#include <mgba-util/vfs.h>
|
||||
|
||||
#ifdef PSP2
|
||||
#include <psp2/rtc.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
@ -637,6 +641,9 @@ void GBASavedataRTCRead(struct GBASavedata* savedata) {
|
|||
}
|
||||
LOAD_64LE(savedata->gpio->rtc.lastLatch, 0, &buffer.lastLatch);
|
||||
|
||||
time_t rtcTime;
|
||||
|
||||
#ifndef PSP2
|
||||
struct tm date;
|
||||
date.tm_year = _unBCD(savedata->gpio->rtc.time[0]) + 100;
|
||||
date.tm_mon = _unBCD(savedata->gpio->rtc.time[1]) - 1;
|
||||
|
@ -645,8 +652,40 @@ void GBASavedataRTCRead(struct GBASavedata* savedata) {
|
|||
date.tm_min = _unBCD(savedata->gpio->rtc.time[5]);
|
||||
date.tm_sec = _unBCD(savedata->gpio->rtc.time[6]);
|
||||
date.tm_isdst = -1;
|
||||
rtcTime = mktime(&date);
|
||||
#else
|
||||
struct SceDateTime date;
|
||||
date.year = _unBCD(savedata->gpio->rtc.time[0]) + 2000;
|
||||
date.month = _unBCD(savedata->gpio->rtc.time[1]);
|
||||
date.day = _unBCD(savedata->gpio->rtc.time[2]);
|
||||
date.hour = _unBCD(savedata->gpio->rtc.time[4]);
|
||||
date.minute = _unBCD(savedata->gpio->rtc.time[5]);
|
||||
date.second = _unBCD(savedata->gpio->rtc.time[6]);
|
||||
date.microsecond = 0;
|
||||
|
||||
savedata->gpio->rtc.offset = savedata->gpio->rtc.lastLatch - mktime(&date);
|
||||
struct SceRtcTick tick;
|
||||
int res;
|
||||
res = sceRtcConvertDateTimeToTick(&date, &tick);
|
||||
if (res < 0) {
|
||||
mLOG(GBA_SAVE, ERROR, "sceRtcConvertDateTimeToTick %lx", res);
|
||||
}
|
||||
res = sceRtcConvertLocalTimeToUtc(&tick, &tick);
|
||||
if (res < 0) {
|
||||
mLOG(GBA_SAVE, ERROR, "sceRtcConvertUtcToLocalTime %lx", res);
|
||||
}
|
||||
res = sceRtcConvertTickToDateTime(&tick, &date);
|
||||
if (res < 0) {
|
||||
mLOG(GBA_SAVE, ERROR, "sceRtcConvertTickToDateTime %lx", res);
|
||||
}
|
||||
res = sceRtcConvertDateTimeToTime_t(&date, &rtcTime);
|
||||
if (res < 0) {
|
||||
mLOG(GBA_SAVE, ERROR, "sceRtcConvertDateTimeToTime_t %lx", res);
|
||||
}
|
||||
#endif
|
||||
|
||||
savedata->gpio->rtc.offset = savedata->gpio->rtc.lastLatch - rtcTime;
|
||||
|
||||
mLOG(GBA_SAVE, ERROR, "Savegame time offset set to %li", savedata->gpio->rtc.offset);
|
||||
}
|
||||
|
||||
void GBASavedataSerialize(const struct GBASavedata* savedata, struct GBASerializedState* state) {
|
||||
|
|
|
@ -28,6 +28,7 @@ set(OS_LIB -lvita2d -l${M_LIBRARY}
|
|||
-lScePgf_stub
|
||||
-lScePhotoExport_stub
|
||||
-lScePower_stub
|
||||
-lSceRtc_stub
|
||||
-lSceSysmodule_stub
|
||||
-lSceTouch_stub)
|
||||
set(OS_LIB ${OS_LIB} PARENT_SCOPE)
|
||||
|
|
Loading…
Reference in New Issue