PCem

view src/wd76c10.c @ 139:eee628bf93de

Serial controller is no longer reset when serial port/IRQ updated - fixes mouse on 430VX in Windows 98.
author TomW
date Thu Jul 31 15:57:24 2014 +0100
parents 923b243eba54
children
line source
1 #include "ibm.h"
2 #include "fdc.h"
3 #include "io.h"
4 #include "mem.h"
5 #include "serial.h"
6 #include "wd76c10.h"
8 static uint16_t wd76c10_0092;
9 static uint16_t wd76c10_2072;
10 static uint16_t wd76c10_2872;
11 static uint16_t wd76c10_5872;
13 uint16_t wd76c10_read(uint16_t port, void *priv)
14 {
15 switch (port)
16 {
17 case 0x0092:
18 return wd76c10_0092;
20 case 0x2072:
21 return wd76c10_2072;
23 case 0x2872:
24 return wd76c10_2872;
26 case 0x5872:
27 return wd76c10_5872;
28 }
29 return 0;
30 }
32 void wd76c10_write(uint16_t port, uint16_t val, void *priv)
33 {
34 pclog("WD76C10 write %04X %04X\n", port, val);
35 switch (port)
36 {
37 case 0x0092:
38 wd76c10_0092 = val;
40 mem_a20_alt = val & 2;
41 mem_a20_recalc();
42 break;
44 case 0x2072:
45 wd76c10_2072 = val;
47 switch ((val >> 5) & 7)
48 {
49 case 1: serial1_set(0x3f8, 4); break;
50 case 2: serial1_set(0x2f8, 4); break;
51 case 3: serial1_set(0x3e8, 4); break;
52 case 4: serial1_set(0x2e8, 4); break;
53 }
54 switch ((val >> 1) & 7)
55 {
56 case 1: serial2_set(0x3f8, 3); break;
57 case 2: serial2_set(0x2f8, 3); break;
58 case 3: serial2_set(0x3e8, 3); break;
59 case 4: serial2_set(0x2e8, 3); break;
60 }
61 break;
63 case 0x2872:
64 wd76c10_2872 = val;
66 fdc_remove();
67 if (!(val & 1))
68 fdc_add();
69 break;
71 case 0x5872:
72 wd76c10_5872 = val;
73 break;
74 }
75 }
77 uint8_t wd76c10_readb(uint16_t port, void *priv)
78 {
79 if (port & 1)
80 return wd76c10_read(port & ~1, priv) >> 8;
81 return wd76c10_read(port, priv) & 0xff;
82 }
84 void wd76c10_writeb(uint16_t port, uint8_t val, void *priv)
85 {
86 uint16_t temp = wd76c10_read(port, priv);
87 if (port & 1)
88 wd76c10_write(port & ~1, (temp & 0x00ff) | (val << 8), priv);
89 else
90 wd76c10_write(port , (temp & 0xff00) | val, priv);
91 }
93 void wd76c10_init()
94 {
95 io_sethandler(0x0092, 0x0002, wd76c10_readb, wd76c10_read, NULL, wd76c10_writeb, wd76c10_write, NULL, NULL);
96 io_sethandler(0x2072, 0x0002, wd76c10_readb, wd76c10_read, NULL, wd76c10_writeb, wd76c10_write, NULL, NULL);
97 io_sethandler(0x2872, 0x0002, wd76c10_readb, wd76c10_read, NULL, wd76c10_writeb, wd76c10_write, NULL, NULL);
98 io_sethandler(0x5872, 0x0002, wd76c10_readb, wd76c10_read, NULL, wd76c10_writeb, wd76c10_write, NULL, NULL);
99 }