Forced the external exception check to occur sooner by changing the downcount.

Fixes issue 5825.
This commit is contained in:
skidau 2013-03-25 00:47:44 +11:00
parent bb3ce1f8d3
commit 1d550f4496
3 changed files with 21 additions and 1 deletions

View File

@ -250,6 +250,8 @@ void ScheduleEvent_Threadsafe(int cyclesIntoFuture, int event_type, u64 userdata
if(tsLast)
tsLast->next = ne;
tsLast = ne;
SetDowncount(ne->type, cyclesIntoFuture);
}
// Same as ScheduleEvent_Threadsafe(0, ...) EXCEPT if we are already on the CPU thread
@ -260,6 +262,7 @@ void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata)
{
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
event_types[event_type].callback(userdata, 0);
SetDowncount(event_type, 0);
}
else
ScheduleEvent_Threadsafe(0, event_type, userdata);
@ -413,6 +416,21 @@ void SetMaximumSlice(int maximumSliceLength)
maxSliceLength = maximumSliceLength;
}
void SetDowncount(int event_type, int cycles)
{
if (event_types[event_type].name == "SetToken")
return;
if (cycles == 0)
cycles = 100; // External Exception latency. Paper Mario TTYD freezes in fight scenes if this is zero.
if (downcount > cycles)
{
slicelength -= (downcount - cycles); // Account for cycles already executed by adjusting the slicelength
downcount = cycles;
}
}
void ResetSliceLength()
{
maxSliceLength = MAX_SLICE_LENGTH;

View File

@ -92,6 +92,8 @@ void SetFakeTBStartValue(u64 val);
u64 GetFakeTBStartTicks();
void SetFakeTBStartTicks(u64 val);
void SetDowncount(int event_type, int cycles);
extern int downcount;
extern int slicelength;

View File

@ -144,7 +144,7 @@ void Init()
isHiWatermarkActive = false;
isLoWatermarkActive = false;
et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper);
et_UpdateInterrupts = CoreTiming::RegisterEvent("CPInterrupt", UpdateInterrupts_Wrapper);
}
void Read16(u16& _rReturnValue, const u32 _Address)