From 286818762da063f43a355600bf763b04938dd97f Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Tue, 8 Aug 2017 17:34:08 +0000 Subject: [PATCH] Repair a logic error introduced in r3816. Now both cases use an appropriate average. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4029 --- src/dosbox.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/dosbox.cpp b/src/dosbox.cpp index d1c5c253..7308d8c5 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -214,14 +214,13 @@ void increaseticks() { //Make it return ticksRemain and set it in the function a * for very low ratios. High ratio might result because of timing resolution */ if (ticksScheduled >= 250 && ticksDone < 10 && ratio > 20480) ratio = 20480; - Bit64s cmax_scaled = (Bit64s)CPU_CycleMax * (Bit64s)ratio; - /* The auto cycle code seems reliable enough to disable the fast cut back code. - * This should improve the fluency of complex games. - if (ratio <= 1024) - new_cmax = (Bit32s)(cmax_scaled / (Bit64s)1024); - else - */ - new_cmax = (Bit32s)(1 + (CPU_CycleMax >> 1) + cmax_scaled / (Bit64s)2048); + if (ratio <= 1024) { + double r = 2.0 /(1.0 + 1024.0/(static_cast(ratio))); + new_cmax = 1 + static_cast(CPU_CycleMax * r); + } else { + Bit64s cmax_scaled = (Bit64s)CPU_CycleMax * (Bit64s)ratio; + new_cmax = (Bit32s)(1 + (CPU_CycleMax >> 1) + cmax_scaled / (Bit64s)2048); + } } }