Skip to content

Commit 9ab8730

Browse files
author
qbix79
committed
Introduce a penalty for a lot of idling, which changes the up and downscale algorithm, as the chance of having errors in the input data is a lot larger when there is a lot of idling. The upscale has its strength reduced and the downscale has it increased.
git-svn-id: http://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4042 ed541006-0bf7-43e9-8c4d-6fc63c346d47
1 parent a283a7f commit 9ab8730

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/dosbox.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ void increaseticks() { //Make it return ticksRemain and set it in the function a
234234
to have smoother auto cycle adjustments */
235235
double ratioremoved = (double) CPU_IODelayRemoved / (double) cproc;
236236
if (ratioremoved < 1.0) {
237-
ratio = (Bit32s)((double)ratio * (1 - ratioremoved));
237+
double ratio_not_removed = 1 - ratioremoved;
238+
ratio = (Bit32s)((double)ratio * ratio_not_removed);
238239

239240
/* Don't allow very high ratio which can cause us to lock as we don't scale down
240241
* for very low ratios. High ratio might result because of timing resolution */
@@ -250,10 +251,12 @@ void increaseticks() { //Make it return ticksRemain and set it in the function a
250251
ratio = 800;
251252

252253
if (ratio <= 1024) {
253-
double r = 2.0 /(1.0 + 1024.0/(static_cast<double>(ratio)));
254+
// ratio_not_removed = 1.0; //enabling this restores the old formula
255+
double r = (1.0 + ratio_not_removed) /(ratio_not_removed + 1024.0/(static_cast<double>(ratio)));
254256
new_cmax = 1 + static_cast<Bit32s>(CPU_CycleMax * r);
255257
} else {
256-
Bit64s cmax_scaled = (Bit64s)CPU_CycleMax * (Bit64s)ratio;
258+
Bit64s ratio_with_removed = (Bit64s) ((((double)ratio - 1024.0) * ratio_not_removed) + 1024.0);
259+
Bit64s cmax_scaled = (Bit64s)CPU_CycleMax * ratio_with_removed;
257260
new_cmax = (Bit32s)(1 + (CPU_CycleMax >> 1) + cmax_scaled / (Bit64s)2048);
258261
}
259262
}

0 commit comments

Comments
 (0)