mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
implement margins for scheduler
hopefully this does not break anything
This commit is contained in:
parent
1471c73ea6
commit
737171c906
15
src/NDS.cpp
15
src/NDS.cpp
@ -88,6 +88,7 @@ u64 FrameStartTimestamp;
|
||||
int CurCPU;
|
||||
|
||||
const s32 kMaxIterationCycles = 64;
|
||||
const s32 kIterationCycleMargin = 8;
|
||||
|
||||
u32 ARM9ClockShift;
|
||||
|
||||
@ -917,7 +918,7 @@ void RelocateSave(const char* path, bool write)
|
||||
|
||||
u64 NextTarget()
|
||||
{
|
||||
u64 ret = SysTimestamp + kMaxIterationCycles;
|
||||
u64 minEvent = UINT64_MAX;
|
||||
|
||||
u32 mask = SchedListMask;
|
||||
for (int i = 0; i < Event_MAX; i++)
|
||||
@ -925,14 +926,19 @@ u64 NextTarget()
|
||||
if (!mask) break;
|
||||
if (mask & 0x1)
|
||||
{
|
||||
if (SchedList[i].Timestamp < ret)
|
||||
ret = SchedList[i].Timestamp;
|
||||
if (SchedList[i].Timestamp < minEvent)
|
||||
minEvent = SchedList[i].Timestamp;
|
||||
}
|
||||
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
u64 max = SysTimestamp + kMaxIterationCycles;
|
||||
|
||||
if (minEvent < max + kIterationCycleMargin)
|
||||
return minEvent;
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
void RunSystem(u64 timestamp)
|
||||
@ -969,7 +975,6 @@ u32 RunFrame()
|
||||
|
||||
while (Running && GPU::TotalScanlines==0)
|
||||
{
|
||||
// TODO: give it some margin, so it can directly do 17 cycles instead of 16 then 1
|
||||
u64 target = NextTarget();
|
||||
ARM9Target = target << ARM9ClockShift;
|
||||
CurCPU = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user