-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathepsonio.c
129 lines (98 loc) · 2.28 KB
/
epsonio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "compiler.h"
#include "cpucore.h"
#include "pccore.h"
#include "iocore.h"
// EPSONê—pƒ|[ƒg 0c00`
static void bankselect(void) {
if (epsonio.bankioen & 0x02) {
CPU_ITFBANK = 1;
TRACEOUT(("EPSON ITF - Enable"));
}
else {
CPU_ITFBANK = 0;
TRACEOUT(("EPSON ITF - Disable"));
}
}
// ---- I/O
static void IOOUTCALL epsonio_o043d(UINT port, REG8 dat) {
switch(dat) {
case 0x00:
if (epsonio.bankioen & 0x01) {
epsonio.bankioen &= ~0x02;
bankselect();
}
break;
case 0x02:
if (epsonio.bankioen & 0x01) {
epsonio.bankioen |= 0x02;
bankselect();
}
break;
case 0x10:
CPU_ITFBANK = 1;
break;
case 0x12:
CPU_ITFBANK = 0;
break;
}
(void)port;
}
static void IOOUTCALL epsonio_o043f(UINT port, REG8 dat) {
switch(dat) {
case 0x40:
epsonio.bankioen &= ~0x01;
break;
case 0x42:
epsonio.bankioen |= 0x01;
break;
}
(void)port;
}
static void IOOUTCALL epsonio_oc07(UINT port, REG8 dat) {
TRACEOUT(("EPSON ROM MODE - %.2x", dat));
switch(dat) {
case 0x2a: // 0010|1010
case 0x2b:
CopyMemory(mem + 0x1e8000, mem + 0x1c8000, 0x18000);
break;
case 0x2c: // 0010|1100
case 0x2d:
CopyMemory(mem + 0x1e8000, mem + 0x0e8000, 0x10000);
CopyMemory(mem + 0x1f8000, mem + 0x1c0000, 0x08000);
break;
case 0xa6: // 1010|0110
CopyMemory(mem + 0x1c8000, mem + 0x0e8000, 0x10000);
CopyMemory(mem + 0x1d8000, mem + 0x1c0000, 0x08000);
CopyMemory(mem + 0x1e8000, mem + 0x0e8000, 0x10000);
CopyMemory(mem + 0x1f8000, mem + 0x1c0000, 0x08000);
break;
case 0xe6: // 1110|0110
CopyMemory(mem + 0x1d8000, mem + 0x1c0000, 0x08000);
CopyMemory(mem + 0x1f8000, mem + 0x1c0000, 0x08000);
break;
}
(void)port;
}
static REG8 IOINPCALL epsonio_ic03(UINT port) {
(void)port;
return(epsonio.cpumode);
}
static REG8 IOINPCALL epsonio_ic13(UINT port) {
(void)port;
return(0x00);
}
// ---- I/F
void epsonio_reset(const NP2CFG *pConfig) {
epsonio.cpumode = 'R';
(void)pConfig;
}
void epsonio_bind(void) {
if (pccore.model & PCMODEL_EPSON) {
iocore_attachout(0x043d, epsonio_o043d);
iocore_attachout(0x043f, epsonio_o043f);
iocore_attachout(0x0c07, epsonio_oc07);
iocore_attachinp(0x0c03, epsonio_ic03);
iocore_attachinp(0x0c13, epsonio_ic13);
iocore_attachinp(0x0c14, epsonio_ic13);
}
}