Process events when idle or switching threads.
Fixes hrydgard/ppsspp#104, so things execute more accurately.
This commit is contained in:
parent
998104e2eb
commit
a2ee736793
2 changed files with 23 additions and 1 deletions
|
@ -500,6 +500,20 @@ void Idle(int maxIdle)
|
|||
if (maxIdle != 0 && cyclesDown > maxIdle)
|
||||
cyclesDown = maxIdle;
|
||||
|
||||
if (first && cyclesDown > 0)
|
||||
{
|
||||
int cyclesExecuted = slicelength - downcount;
|
||||
int cyclesNextEvent = (int) (first->time - globalTimer);
|
||||
|
||||
if (cyclesNextEvent < cyclesExecuted + cyclesDown)
|
||||
{
|
||||
cyclesDown = cyclesNextEvent - cyclesExecuted;
|
||||
// Now, now... no time machines, please.
|
||||
if (cyclesDown < 0)
|
||||
cyclesDown = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG(CPU, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(CPU_HZ * 0.001f));
|
||||
|
||||
idledCycles += cyclesDown;
|
||||
|
@ -520,7 +534,7 @@ std::string GetScheduledEventsSummary()
|
|||
if (!name)
|
||||
name = "[unknown]";
|
||||
char temp[512];
|
||||
sprintf(temp, "%s : %i %08x%08x\n", event_types[ptr->type].name, (int)ptr->time, (u32)(ptr->userdata >> 32), (u32)(ptr->userdata));
|
||||
sprintf(temp, "%s : %i %08x%08x\n", name, (int)ptr->time, (u32)(ptr->userdata >> 32), (u32)(ptr->userdata));
|
||||
text += temp;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue