--- np2/io/epsonio.c 2003/12/26 22:24:06 1.1 +++ np2/io/epsonio.c 2004/01/05 06:05:11 1.2 @@ -1,18 +1,97 @@ #include "compiler.h" +#include "cpucore.h" #include "pccore.h" #include "iocore.h" // EPSONÀìÍѥݡ¼¥È 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 REG8 IOINPCALL epcpuio_ic03(UINT port) { +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; + } +} + +static void IOOUTCALL epsonio_o043f(UINT port, REG8 dat) { + + switch(dat) { + case 0x40: + epsonio.bankioen &= ~0x01; + break; + + case 0x42: + epsonio.bankioen |= 0x01; + break; + } +} + +static void IOOUTCALL epsonio_oc07(UINT port, REG8 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; + } +} + +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 @@ -23,6 +102,13 @@ void epsonio_reset(void) { void epsonio_bind(void) { - iocore_attachinp(0x0c03, epcpuio_ic03); + if (pc.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); + } }