From cfe3bd2ebcd62af231d2248330c319e2d7da0390 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sat, 2 Sep 2017 10:12:20 +0000 Subject: [PATCH] Lower the max ratio limit slightly. Add a new ratio limit when the cycles are sufficiently high. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4040 --- src/dosbox.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dosbox.cpp b/src/dosbox.cpp index c00a6b8a..82b2d1fa 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -235,10 +235,16 @@ void increaseticks() { //Make it return ticksRemain and set it in the function a double ratioremoved = (double) CPU_IODelayRemoved / (double) cproc; if (ratioremoved < 1.0) { ratio = (Bit32s)((double)ratio * (1 - ratioremoved)); + /* Don't allow very high ratio which can cause us to lock as we don't scale down * for very low ratios. High ratio might result because of timing resolution */ - if (ticksScheduled >= 250 && ticksDone < 10 && ratio > 20480) - ratio = 20480; + if (ticksScheduled >= 250 && ticksDone < 10 && ratio > 16384) + ratio = 16384; + + // Limit the ratio even more when the cycles are already way above the realmode default. + if (ticksScheduled >= 250 && ticksDone < 10 && ratio > 5120 && CPU_CycleMax > 50000) + ratio = 5120; + if (ratio <= 1024) { double r = 2.0 /(1.0 + 1024.0/(static_cast(ratio))); new_cmax = 1 + static_cast(CPU_CycleMax * r);