From: Toni Wilen Date: Sat, 5 Sep 2015 10:24:07 +0000 (+0300) Subject: Support XT Timer Gate 2 in dosbox cpu mode. X-Git-Tag: 3200~86 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=211162823e202bbe767dbc166ef1097d46b7d3c0;p=francis%2Fwinuae.git Support XT Timer Gate 2 in dosbox cpu mode. --- diff --git a/dosbox/timer.cpp b/dosbox/timer.cpp index 9a431945..373dad10 100644 --- a/dosbox/timer.cpp +++ b/dosbox/timer.cpp @@ -239,7 +239,11 @@ static void write_latch(Bitu port,Bitu val,Bitu /*iolen*/) { case 0x02: /* Timer hooked to PC-Speaker */ // LOG(LOG_PIT,"PIT 2 Timer at %.3g Hz mode %d",PIT_TICK_RATE/(double)p->cntr,p->mode); // PCSPEAKER_SetCounter(p->cntr,p->mode); - break; + // HACK. A1060 bios hardware diagnostics reads latch with timer gate 2 disabled + // and expects original written value. + if (!gate2) + p->read_latch = p->write_latch; + break; default: LOG(LOG_PIT,LOG_ERROR)("PIT:Illegal timer selected for writing"); } @@ -360,6 +364,14 @@ static void write_p43(Bitu /*port*/,Bitu val,Bitu /*iolen*/) { } } +bool TIMER_GetGate2(void) +{ + if (!gate2) { + return true; + } + return false; +} + void TIMER_SetGate2(bool in) { //No changes if gate doesn't change if(gate2 == in) return; diff --git a/x86.cpp b/x86.cpp index 69aef5b0..19c828e1 100644 --- a/x86.cpp +++ b/x86.cpp @@ -83,6 +83,8 @@ void PIC_Init(Section* sec); void PIC_Destroy(Section* sec); void TIMER_Destroy(Section*); void TIMER_Init(Section* sec); +void TIMER_SetGate2(bool); +bool TIMER_GetGate2(void); static Section_prop *dosbox_sec; Bitu x86_in_keyboard(Bitu port); void x86_out_keyboard(Bitu port, Bitu val); @@ -1812,6 +1814,9 @@ void portout(uint16_t portnum, uint8_t v) if (xb->type >= TYPE_2286) { x86_out_keyboard(0x61, v); } else { + if (xb->dosbox_cpu) { + TIMER_SetGate2(v & 1); + } aio = 0x5f; } break; @@ -2531,8 +2536,16 @@ uint8_t portin(uint16_t portnum) } } v &= ~0x20; - if (!(xb->amiga_io[0x5f] & 1) && i8253.active[2]) - v |= 0x20; + if (!(xb->amiga_io[0x5f] & 1)) { + bool timer2 = false; + if (xb->dosbox_cpu) { + timer2 = TIMER_GetGate2(); + } else { + timer2 = i8253.active[2] != 0; + } + if (timer2) + v |= 0x20; + } //write_log(_T("IN Port C %02x\n"), v); } break;