]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Support XT Timer Gate 2 in dosbox cpu mode.
authorToni Wilen <twilen@winuae.net>
Sat, 5 Sep 2015 10:24:07 +0000 (13:24 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 5 Sep 2015 10:24:07 +0000 (13:24 +0300)
dosbox/timer.cpp
x86.cpp

index 9a4319458890a4bdfeaa29d9cdef45a3472a67d9..373dad10bff1518beeb47e8919c05989d03e0697 100644 (file)
@@ -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 69aef5b078266e1c71744d62c2dc4b59a1121a47..19c828e1530b1f76f8a7e270c3ccb9098287aa7c 100644 (file)
--- 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;