From 8e69b70bf531de21e1baae603d6f5cb92ba2d5a1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 11 Sep 2013 00:12:33 -0700 Subject: [PATCH] Start sceRtc at now, not 1970. --- Core/HLE/sceRtc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceRtc.cpp b/Core/HLE/sceRtc.cpp index 06fa4abf04..f6c16fd569 100644 --- a/Core/HLE/sceRtc.cpp +++ b/Core/HLE/sceRtc.cpp @@ -36,6 +36,7 @@ // This is a base time that everything is relative to. // This way, time doesn't move strangely with savestates, turbo speed, etc. static PSPTimeval rtcBaseTime; +static u64 rtcBaseTicks; // Grabbed from JPSCP // This is the # of microseconds between January 1, 0001 and January 1, 1970. @@ -54,7 +55,7 @@ const int PSP_TIME_INVALID_MICROSECONDS = -7; u64 __RtcGetCurrentTick() { // TODO: It's probably expecting ticks since January 1, 0001? - return cyclesToUs(CoreTiming::GetTicks()) + rtcMagicOffset; + return cyclesToUs(CoreTiming::GetTicks()) + rtcBaseTicks; } #if defined(_WIN32) @@ -113,11 +114,15 @@ void __RtcInit() gettimeofday(&tv, NULL); rtcBaseTime.tv_sec = tv.tv_sec; rtcBaseTime.tv_usec = tv.tv_usec; + // Precalculate the current time in microseconds (rtcMagicOffset is offset to 1970.) + rtcBaseTicks = 1000000ULL * rtcBaseTime.tv_sec + rtcMagicOffset; } void __RtcDoState(PointerWrap &p) { p.Do(rtcBaseTime); + // Update the precalc, pointless to savestate this as it's just based on the other value. + rtcBaseTicks = 1000000ULL * rtcBaseTime.tv_sec + rtcMagicOffset; p.DoMarker("sceRtc"); }