diff --git a/src/hardware/keyboard.cpp b/src/hardware/keyboard.cpp index bc4ef238..72511107 100644 --- a/src/hardware/keyboard.cpp +++ b/src/hardware/keyboard.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: keyboard.cpp,v 1.39 2007-06-12 20:22:08 c2woody Exp $ */ +/* $Id: keyboard.cpp,v 1.40 2007-11-18 17:09:15 qbix79 Exp $ */ #include "dosbox.h" #include "keyboard.h" @@ -171,7 +171,7 @@ static void write_p60(Bitu port,Bitu val,Bitu iolen) { } } -static Bit8u port_61_data; +static Bit8u port_61_data = 0; static Bitu read_p61(Bitu port,Bitu iolen) { port_61_data^=0x20; port_61_data^=0x10; diff --git a/src/hardware/timer.cpp b/src/hardware/timer.cpp index 0341bd4e..ffc6b1c1 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.44 2007-06-12 20:22:08 c2woody Exp $ */ +/* $Id: timer.cpp,v 1.45 2007-11-18 17:09:15 qbix79 Exp $ */ #include #include "dosbox.h" @@ -54,6 +54,7 @@ struct PIT_Block { bool go_read_latch; bool new_mode; bool counterstatus_set; + bool counting; }; static PIT_Block pit[3]; @@ -127,7 +128,7 @@ static void counter_latch(Bitu counter) { p->go_read_latch=false; //If gate2 is disabled don't update the read_latch - if(counter == 2 && !gate2) return; + if(counter == 2 && !gate2 && p->mode !=1) return; double index=PIC_FullIndex()-p->start; switch (p->mode) { @@ -147,6 +148,15 @@ static void counter_latch(Bitu counter) { p->read_latch=(Bit16u)(p->cntr-index*(PIT_TICK_RATE/1000.0)); } break; + case 1: // countdown + if(p->counting) { + if (index>p->delay) { // has timed out + p->read_latch = 0xffff; //unconfirmed + } else { + p->read_latch=(Bit16u)(p->cntr-index*(PIT_TICK_RATE/1000.0)); + } + } + break; case 2: /* Rate Generator */ index=fmod(index,(double)p->delay); p->read_latch=(Bit16u)(p->cntr - (index/p->delay)*p->cntr); @@ -282,7 +292,7 @@ static void write_p43(Bitu /*port*/,Bitu val,Bitu /*iolen*/) { pit[latch].counterstatus_set=false; latched_timerstatus_locked=false; } - + pit[latch].counting = false; pit[latch].read_state = (val >> 4) & 0x03; pit[latch].write_state = (val >> 4) & 0x03; Bit8u mode = (val >> 1) & 0x07; @@ -345,13 +355,19 @@ void TIMER_SetGate2(bool in) { pit[2].cntr = pit[2].read_latch; } break; + case 1: + // gate 1 on: reload counter; off: nothing + if(in) { + pit[2].counting = true; + pit[2].start = PIC_FullIndex(); + } + break; case 2: case 3: //If gate is enabled restart counting. If disable store the current read_latch if(in) pit[2].start = PIC_FullIndex(); else counter_latch(2); break; - case 1: case 4: case 5: LOG(LOG_MISC,LOG_WARN)("unsupported gate 2 mode %x",mode); @@ -401,13 +417,14 @@ public: pit[2].cntr=1320; pit[2].go_read_latch=true; pit[2].counterstatus_set = false; + pit[2].counting = false; pit[0].delay=(1000.0f/((float)PIT_TICK_RATE/(float)pit[0].cntr)); pit[1].delay=(1000.0f/((float)PIT_TICK_RATE/(float)pit[1].cntr)); pit[2].delay=(1000.0f/((float)PIT_TICK_RATE/(float)pit[2].cntr)); latched_timerstatus_locked=false; - gate2 = true; + gate2 = false; PIC_AddEvent(PIT0_Event,pit[0].delay); } ~TIMER(){