Improvements to timer hack.

This commit is contained in:
Sacha 2013-11-20 12:55:56 +10:00
parent 5cdfe40c03
commit effca1e4c7
3 changed files with 14 additions and 4 deletions

View file

@ -102,18 +102,27 @@ int GetClockFrequencyMHz()
return CPU_HZ / 1000000;
}
u64 GetGlobalTimeUs()
u64 GetGlobalTimeUsScaled()
{
s64 ticksSinceLast = GetTicks() - lastGlobalTimeTicks;
int freq = GetClockFrequencyMHz();
if (g_Config.bTimerHack) {
float vps;
__DisplayGetVPS(&vps);
if (vps > 5.0f)
freq = (int)(((float)CPU_HZ * vps) / (1000000.0f * 60.0f));
if (vps > 4.0f)
freq *= (vps / 60.0f);
}
s64 usSinceLast = ticksSinceLast / freq;
return lastGlobalTimeUs + usSinceLast;
}
u64 GetGlobalTimeUs()
{
s64 ticksSinceLast = GetTicks() - lastGlobalTimeTicks;
int freq = GetClockFrequencyMHz();
s64 usSinceLast = ticksSinceLast / freq;
return lastGlobalTimeUs + usSinceLast;
}
Event* GetNewEvent()

View file

@ -80,6 +80,7 @@ namespace CoreTiming
u64 GetTicks();
u64 GetIdleTicks();
u64 GetGlobalTimeUs();
u64 GetGlobalTimeUsScaled();
// Returns the event_type identifier.
int RegisterEvent(const char *name, TimedCallback callback);

View file

@ -71,7 +71,7 @@ u32 sceKernelGetSystemTimeLow()
u64 sceKernelGetSystemTimeWide()
{
u64 t = CoreTiming::GetGlobalTimeUs();
u64 t = CoreTiming::GetGlobalTimeUsScaled();
DEBUG_LOG(SCEKERNEL,"%i=sceKernelGetSystemTimeWide()",(u32)t);
hleEatCycles(250);
hleReSchedule("system time");