mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #3729 from unknownbrackets/rtc
Start sceRtc at now, not 1970
This commit is contained in:
commit
7ebb6bc802
1 changed files with 6 additions and 1 deletions
|
@ -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 + rtcBaseTime.tv_usec + 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 + rtcBaseTime.tv_usec + rtcMagicOffset;
|
||||
|
||||
p.DoMarker("sceRtc");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue