Be more deterministic about the time.

This way, if a state is loaded, the game doesn't know.
Also, if the host is slow/sped up, it won't get out of sync.
This commit is contained in:
Unknown W. Brackets 2013-01-02 01:09:44 -08:00
parent 4a713309a3
commit 1c156784b6
3 changed files with 27 additions and 5 deletions

View file

@ -30,10 +30,28 @@
#include "../CoreTiming.h"
//////////////////////////////////////////////////////////////////////////
// State
//////////////////////////////////////////////////////////////////////////
// The time when the game started.
time_t start_time;
//////////////////////////////////////////////////////////////////////////
// Other clock stuff
//////////////////////////////////////////////////////////////////////////
void __KernelTimeInit()
{
time(&start_time);
}
void __KernelTimeDoState(PointerWrap &p)
{
p.Do(start_time);
p.DoMarker("sceKernelTime");
}
struct SceKernelSysClock
{
u32 lo;
@ -114,17 +132,16 @@ u32 sceKernelLibcClock()
u32 sceKernelLibcTime(u32 outPtr)
{
time_t t;
time(&t);
u32 t = (u32) start_time + (u32) (CoreTiming::GetTicks() / CPU_HZ);
DEBUG_LOG(HLE, "%i = sceKernelLibcTime(%08X)", (u32) t, outPtr);
DEBUG_LOG(HLE, "%i = sceKernelLibcTime(%08X)", t, outPtr);
if (Memory::IsValidAddress(outPtr))
Memory::Write_U32((u32) t, outPtr);
Memory::Write_U32(t, outPtr);
else if (outPtr != 0)
return 0;
return (u32) t;
return t;
}
void sceKernelLibcGettimeofday()