PCem
changeset 35:7f9686ece79d
PIT timers can now be restarted using GATE input - CPU speed detection on SiS496/497 now works.
Added missing port 0x61 to Olivetti M24 - PC speaker now works on that machine.
Some code tidying.
| author | TomW |
|---|---|
| date | Fri Nov 08 22:32:34 2013 +0000 |
| parents | 35e71a08b4ed |
| children | 3150e4f3c1a3 |
| files | src/386.c src/808x.c src/ibm.h src/keyboard_amstrad.c src/keyboard_at.c src/keyboard_olim24.c src/keyboard_xt.c src/pit.c src/pit.h |
| diffstat | 9 files changed, 57 insertions(+), 26 deletions(-) [+] |
line diff
1.1 --- a/src/386.c Wed Nov 06 19:46:49 2013 +0000 1.2 +++ b/src/386.c Fri Nov 08 22:32:34 2013 +0000 1.3 @@ -1418,10 +1418,11 @@ 1.4 keyboard_at_poll(); 1.5 }*/ 1.6 1.7 - pit.c[0]-=cycdiff; 1.8 - pit.c[1]-=cycdiff; 1.9 - if (ppi.pb&1) pit.c[2]-=cycdiff; 1.10 - if ((pit.c[0]<1)||(pit.c[1]<1)||(pit.c[2]<1)) pit_poll(); 1.11 + pit.c[0] -= cycdiff; 1.12 + pit.c[1] -= cycdiff; 1.13 + if (pit.gate[2]) pit.c[2] -= cycdiff; 1.14 + if ((pit.c[0] < 1) || (pit.c[1] < 1) || (pit.c[2] < 1)) pit_poll(); 1.15 + 1.16 timer_clock(cycdiff); 1.17 } 1.18 }
2.1 --- a/src/808x.c Wed Nov 06 19:46:49 2013 +0000 2.2 +++ b/src/808x.c Fri Nov 08 22:32:34 2013 +0000 2.3 @@ -819,7 +819,7 @@ 2.4 current_diff += diff; 2.5 pit.c[0] -= diff; 2.6 pit.c[1] -= diff; 2.7 - if (ppi.pb & 1) pit.c[2] -= diff; 2.8 + if (pit.gate[2]) pit.c[2] -= diff; 2.9 if ((pit.c[0] < 1) || (pit.c[1] < 1) || (pit.c[2] < 1)) pit_poll(); 2.10 2.11 timer_clock(diff);
3.1 --- a/src/ibm.h Wed Nov 06 19:46:49 2013 +0000 3.2 +++ b/src/ibm.h Fri Nov 08 22:32:34 2013 +0000 3.3 @@ -198,6 +198,7 @@ 3.4 int thit[3]; 3.5 int delay[3]; 3.6 int rereadlatch[3]; 3.7 + int gate[3]; 3.8 } PIT; 3.9 3.10 PIT pit;
4.1 --- a/src/keyboard_amstrad.c Wed Nov 06 19:46:49 2013 +0000 4.2 +++ b/src/keyboard_amstrad.c Fri Nov 08 22:32:34 2013 +0000 4.3 @@ -2,6 +2,7 @@ 4.4 #include "io.h" 4.5 #include "mem.h" 4.6 #include "pic.h" 4.7 +#include "pit.h" 4.8 #include "sound.h" 4.9 #include "timer.h" 4.10 4.11 @@ -59,10 +60,7 @@ 4.12 void keyboard_amstrad_write(uint16_t port, uint8_t val, void *priv) 4.13 { 4.14 pclog("keyboard_amstrad : write %04X %02X %02X\n", port, val, keyboard_amstrad.pb); 4.15 -/* if (ram[8] == 0xc3) 4.16 - { 4.17 - output = 3; 4.18 - }*/ 4.19 + 4.20 switch (port) 4.21 { 4.22 case 0x61: 4.23 @@ -75,16 +73,13 @@ 4.24 keyboard_amstrad.pb = val; 4.25 ppi.pb = val; 4.26 4.27 -/* if (AMSTRADIO) 4.28 - keyboard_amstrad.s2 = val & 4; 4.29 - else 4.30 - keyboard_amstrad.s2 = val & 8;*/ 4.31 gated = ((val & 3) == 3); 4.32 if (gated) 4.33 - wasgated = 1; 4.34 - 4.35 + wasgated = 1; 4.36 + pit_set_gate(2, val & 1); 4.37 + 4.38 if (val & 0x80) 4.39 - keyboard_amstrad.pa = 0; 4.40 + keyboard_amstrad.pa = 0; 4.41 break; 4.42 4.43 case 0x63:
5.1 --- a/src/keyboard_at.c Wed Nov 06 19:46:49 2013 +0000 5.2 +++ b/src/keyboard_at.c Fri Nov 08 22:32:34 2013 +0000 5.3 @@ -2,6 +2,7 @@ 5.4 #include "io.h" 5.5 #include "mem.h" 5.6 #include "pic.h" 5.7 +#include "pit.h" 5.8 #include "sound.h" 5.9 #include "timer.h" 5.10 5.11 @@ -268,9 +269,11 @@ 5.12 break; 5.13 5.14 case 0x61: 5.15 - ppi.pb=val; 5.16 - gated=((val&3)==3); 5.17 - if (gated) wasgated=1; 5.18 + ppi.pb = val; 5.19 + gated = ((val & 3) == 3); 5.20 + if (gated) 5.21 + wasgated = 1; 5.22 + pit_set_gate(2, val & 1); 5.23 break; 5.24 5.25 case 0x64:
6.1 --- a/src/keyboard_olim24.c Wed Nov 06 19:46:49 2013 +0000 6.2 +++ b/src/keyboard_olim24.c Fri Nov 08 22:32:34 2013 +0000 6.3 @@ -3,6 +3,7 @@ 6.4 #include "mem.h" 6.5 #include "mouse.h" 6.6 #include "pic.h" 6.7 +#include "sound.h" 6.8 #include "timer.h" 6.9 6.10 #include "keyboard.h" 6.11 @@ -137,7 +138,16 @@ 6.12 } 6.13 } 6.14 6.15 - break; 6.16 + break; 6.17 + 6.18 + case 0x61: 6.19 + ppi.pb = val; 6.20 + 6.21 + gated = ((val & 3) == 3); 6.22 + if (gated) 6.23 + wasgated = 1; 6.24 + pit_set_gate(2, val & 1); 6.25 + break; 6.26 } 6.27 } 6.28 6.29 @@ -164,6 +174,9 @@ 6.30 } 6.31 break; 6.32 6.33 + case 0x61: 6.34 + return ppi.pb; 6.35 + 6.36 case 0x64: 6.37 temp = keyboard_olim24.status; 6.38 keyboard_olim24.status &= ~(STAT_RTIMEOUT | STAT_TTIMEOUT); 6.39 @@ -279,7 +292,7 @@ 6.40 void keyboard_olim24_init() 6.41 { 6.42 //return; 6.43 - io_sethandler(0x0060, 0x0001, keyboard_olim24_read, NULL, NULL, keyboard_olim24_write, NULL, NULL, NULL); 6.44 + io_sethandler(0x0060, 0x0002, keyboard_olim24_read, NULL, NULL, keyboard_olim24_write, NULL, NULL, NULL); 6.45 io_sethandler(0x0064, 0x0001, keyboard_olim24_read, NULL, NULL, keyboard_olim24_write, NULL, NULL, NULL); 6.46 keyboard_olim24_reset(); 6.47 keyboard_send = keyboard_olim24_adddata;
7.1 --- a/src/keyboard_xt.c Wed Nov 06 19:46:49 2013 +0000 7.2 +++ b/src/keyboard_xt.c Fri Nov 08 22:32:34 2013 +0000 7.3 @@ -72,13 +72,11 @@ 7.4 } 7.5 keyboard_xt.pb = val; 7.6 ppi.pb = val; 7.7 -/* if (AMSTRADIO) 7.8 - keyboard_xt.s2 = val & 4; 7.9 - else 7.10 - keyboard_xt.s2 = val & 8;*/ 7.11 + 7.12 gated = ((val & 3) == 3); 7.13 if (gated) 7.14 - wasgated = 1; 7.15 + wasgated = 1; 7.16 + pit_set_gate(2, val & 1); 7.17 7.18 if (val & 0x80) 7.19 {
8.1 --- a/src/pit.c Wed Nov 06 19:46:49 2013 +0000 8.2 +++ b/src/pit.c Fri Nov 08 22:32:34 2013 +0000 8.3 @@ -302,7 +302,26 @@ 8.4 } 8.5 } 8.6 8.7 +void pit_set_gate(int channel, int gate) 8.8 +{ 8.9 + if (gate && !pit.gate[channel]) 8.10 + { 8.11 + switch (pit.m[channel]) 8.12 + { 8.13 + case 1: /*Hardware retriggerable one-shot*/ 8.14 + case 2: /*Rate generator*/ 8.15 + case 3: /*Square wave mode*/ 8.16 + case 5: /*Hardware triggered strobe (retriggerable)*/ 8.17 + pit.c[channel] = pit.l[2] * PITCONST; 8.18 + break; 8.19 + } 8.20 + } 8.21 + pit.gate[channel] = gate; 8.22 +} 8.23 + 8.24 void pit_init() 8.25 { 8.26 io_sethandler(0x0040, 0x0004, pit_read, NULL, NULL, pit_write, NULL, NULL, NULL); 8.27 + pit.gate[0] = pit.gate[1] = 1; 8.28 + pit.gate[2] = 0; 8.29 }
