From 8dbee51bd390a06b7dd2f43db5f1da5e3d34fc53 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 22 Feb 2007 08:32:21 +0000 Subject: [PATCH] Workaround(partly) 16 port acces setting cycles to zero thereby invalidating one of the ports. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2808 --- src/hardware/iohandler.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/hardware/iohandler.cpp b/src/hardware/iohandler.cpp index 5fc3f19a..05fc52fc 100644 --- a/src/hardware/iohandler.cpp +++ b/src/hardware/iohandler.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: iohandler.cpp,v 1.25 2007-02-04 11:10:22 qbix79 Exp $ */ +/* $Id: iohandler.cpp,v 1.26 2007-02-22 08:32:21 qbix79 Exp $ */ #include #include "dosbox.h" @@ -195,18 +195,16 @@ inline void IO_USEC_write_delay_old() { inline void IO_USEC_read_delay() { Bitu delaycyc = CPU_CycleMax/IODELAY_READ_MICROSk; - if(CPU_Cycles > delaycyc) { - CPU_Cycles -= delaycyc; - CPU_IODelayRemoved += delaycyc; - } else CPU_Cycles = 0; + 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 + CPU_Cycles -= delaycyc; + CPU_IODelayRemoved += delaycyc; } inline void IO_USEC_write_delay() { Bitu delaycyc = CPU_CycleMax/IODELAY_WRITE_MICROSk; - if(CPU_Cycles > delaycyc) { - CPU_Cycles -= delaycyc; - CPU_IODelayRemoved += delaycyc; - } else CPU_Cycles = 0; + if(GCC_UNLIKELY(CPU_Cycles < 3*delaycyc)) delaycyc=0; + CPU_Cycles -= delaycyc; + CPU_IODelayRemoved += delaycyc; }