Add fix for dungle schatten 1. Implement timer mode 1. Flip gate2 default value (h-a-l-9000)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3049
This commit is contained in:
parent
10b39bc067
commit
28c34f2b04
2 changed files with 24 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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 <math.h>
|
||||
#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(){
|
||||
|
|
Loading…
Add table
Reference in a new issue