From 139456b2d0375962219f7f0d3447208fd65f39b1 Mon Sep 17 00:00:00 2001 From: ripsaw8080 Date: Sat, 20 Apr 2019 22:59:42 +0000 Subject: [PATCH] Make effect of I/O delay more consistent as cycles run out. Prevents flickering in NBA Jam Tournament Edition at higher cycles, and also improves automatic speed limiting in Quake. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4215 --- src/hardware/iohandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/iohandler.cpp b/src/hardware/iohandler.cpp index 4954ae98..af1d0109 100644 --- a/src/hardware/iohandler.cpp +++ b/src/hardware/iohandler.cpp @@ -208,14 +208,14 @@ inline void IO_USEC_write_delay_old() { inline void IO_USEC_read_delay() { Bits delaycyc = CPU_CycleMax/IODELAY_READ_MICROSk; - if(GCC_UNLIKELY(CPU_Cycles < 3*delaycyc)) delaycyc = 0; //Else port acces will set cycles to 0. which might trigger problem with games which read 16 bit values + if(GCC_UNLIKELY(delaycyc > CPU_Cycles)) delaycyc = CPU_Cycles; CPU_Cycles -= delaycyc; CPU_IODelayRemoved += delaycyc; } inline void IO_USEC_write_delay() { Bits delaycyc = CPU_CycleMax/IODELAY_WRITE_MICROSk; - if(GCC_UNLIKELY(CPU_Cycles < 3*delaycyc)) delaycyc=0; + if(GCC_UNLIKELY(delaycyc > CPU_Cycles)) delaycyc = CPU_Cycles; CPU_Cycles -= delaycyc; CPU_IODelayRemoved += delaycyc; }