From bc0a6460acfbc09e535bbb3cc297ac3e32699969 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sat, 13 Jan 2007 09:57:25 +0000 Subject: [PATCH] Keeping the timer more in sync.(h-a-l-9000) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2760 --- src/hardware/timer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hardware/timer.cpp b/src/hardware/timer.cpp index dd1cbf97..78256d8f 100644 --- a/src/hardware/timer.cpp +++ b/src/hardware/timer.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: timer.cpp,v 1.41 2007-01-08 19:45:40 qbix79 Exp $ */ +/* $Id: timer.cpp,v 1.42 2007-01-13 09:57:25 qbix79 Exp $ */ #include #include "dosbox.h" @@ -66,8 +66,9 @@ static bool latched_timerstatus_locked; static void PIT0_Event(Bitu /*val*/) { PIC_ActivateIRQ(0); if (pit[0].mode != 0) { - pit[0].start = PIC_FullIndex()-pit[0].delay; // resynchronize - PIC_AddEvent(PIT0_Event,pit[0].delay); + pit[0].start += pit[0].delay; + double error = pit[0].start - PIC_FullIndex(); + PIC_AddEvent(PIT0_Event,pit[0].delay + error); } } @@ -112,6 +113,7 @@ static void status_latch(Bitu counter) { else if(p->read_state==1) latched_timerstatus|=0x10; else if(p->read_state==2) latched_timerstatus|=0x20; if(counter_output(counter)) latched_timerstatus|=0x80; + if(p->new_mode) latched_timerstatus|=0x40; // The first thing that is being read from this counter now is the // counter status. p->counterstatus_set=true;