--- np2/io/iocore.c 2003/10/16 17:57:49 1.1.1.1 +++ np2/io/iocore.c 2004/01/25 05:41:29 1.6 @@ -1,5 +1,5 @@ #include "compiler.h" -#include "i286.h" +#include "cpucore.h" #include "pccore.h" #include "iocore.h" #include "cbuscore.h" @@ -12,16 +12,15 @@ _ARTIC artic; _CGROM cgrom; _CGWINDOW cgwindow; - _CPUIO cpuio; _CRTC crtc; _DMAC dmac; _EGC egc; - _EXTMEM extmem; + _EPSONIO epsonio; + _EMSIO emsio; _FDC fdc; _GDC gdc; _GDCS gdcs; _GRCG grcg; - _ITF itf; _KEYB keyb; _MOUSEIF mouseif; _NMIIO nmiio; @@ -54,12 +53,12 @@ typedef struct { } _IOCORE, *IOCORE; static _IOCORE iocore; -static BYTE ioterminate[0x100]; +static UINT8 ioterminate[0x100]; // ---- -static void IOOUTCALL defout(UINT port, BYTE dat) { +static void IOOUTCALL defout8(UINT port, REG8 dat) { if ((port & 0xfff0) == cs4231.port) { cs4231io_w8(port, dat); @@ -71,7 +70,7 @@ static void IOOUTCALL defout(UINT port, } } -static BYTE IOINPCALL definp(UINT port) { +static REG8 IOINPCALL definp8(UINT port) { if ((port & 0xfff0) == cs4231.port) { return(cs4231io_r8(port)); @@ -346,7 +345,7 @@ BOOL iocore_attachinp(UINT port, IOINP f void iocore_create(void) { UINT i; -const BYTE *p; +const UINT8 *p; UINT r; ZeroMemory(&iocore, sizeof(iocore)); @@ -355,7 +354,7 @@ const BYTE *p; p = termtbl[i].item; r = termtbl[i].items; do { - ioterminate[*p++] = (BYTE)(i + 1); + ioterminate[*p++] = (UINT8)(i + 1); } while(--r); } } @@ -389,8 +388,8 @@ BOOL iocore_build(void) { goto icbld_err; } for (i=0; i<256; i++) { - cmn->ioout[i] = defout; - cmn->ioinp[i] = definp; + cmn->ioout[i] = defout8; + cmn->ioinp[i] = definp8; } sys = (IOFUNC)listarray_append(iotbl, cmn); if (sys == NULL) { @@ -416,7 +415,7 @@ icbld_err: static const IOCBFN resetfn[] = { // PC-9801 System... - cgrom_reset, cpuio_reset, crtc_reset, + cgrom_reset, crtc_reset, dmac_reset, gdc_reset, fdc_reset, keyboard_reset, nmiio_reset, pic_reset, printif_reset, rs232c_reset, systemport_reset, @@ -426,8 +425,12 @@ static const IOCBFN resetfn[] = { itimer_reset, mouseif_reset, // extend - itf_reset, artic_reset, egc_reset, - extmem_reset, np2sysp_reset}; + artic_reset, egc_reset, np2sysp_reset, + necio_reset, epsonio_reset, +#if !defined(CPUCORE_IA32) + emsio_reset, +#endif + }; static const IOCBFN bindfn[] = { // PC-9801 System... @@ -441,8 +444,12 @@ static const IOCBFN bindfn[] = { itimer_bind, mouseif_bind, // extend - itf_bind, artic_bind, egc_bind, - extmem_bind, np2sysp_bind}; + artic_bind, egc_bind, np2sysp_bind, + necio_bind, epsonio_bind, +#if !defined(CPUCORE_IA32) + emsio_bind, +#endif + }; void iocore_cb(const IOCBFN *cbfn, UINT count) { @@ -463,7 +470,9 @@ void iocore_bind(void) { iocore_cb(bindfn, sizeof(bindfn)/sizeof(IOCBFN)); } -void IOOUTCALL iocore_out8(UINT port, BYTE dat) { +#if !defined(TRACE) + +void IOOUTCALL iocore_out8(UINT port, REG8 dat) { IOFUNC iof; @@ -471,7 +480,7 @@ void IOOUTCALL iocore_out8(UINT port, BY iof->ioout[port & 0xff](port, dat); } -BYTE IOINPCALL iocore_inp8(UINT port) { +REG8 IOINPCALL iocore_inp8(UINT port) { IOFUNC iof; @@ -479,7 +488,36 @@ BYTE IOINPCALL iocore_inp8(UINT port) { return(iof->ioinp[port & 0xff](port)); } -void IOOUTCALL iocore_out16(UINT port, UINT16 dat) { +#else + +void IOOUTCALL iocore_out8(UINT port, REG8 dat) { + + IOFUNC iof; + + if (dat & (~0xff)) { + TRACEOUT(("iocore_out8 - %x %x", port, dat)); + } + iof = iocore.base[(port >> 8) & 0xff]; + iof->ioout[port & 0xff](port, dat); +} + +REG8 IOINPCALL iocore_inp8(UINT port) { + + IOFUNC iof; + REG8 ret; + + iof = iocore.base[(port >> 8) & 0xff]; + ret = iof->ioinp[port & 0xff](port); + + if (ret & (~0xff)) { + TRACEOUT(("iocore_inp8 - %x %x", port, ret)); + } + return(ret); +} + +#endif + +void IOOUTCALL iocore_out16(UINT port, REG16 dat) { IOFUNC iof; @@ -497,21 +535,21 @@ void IOOUTCALL iocore_out16(UINT port, U case TERM_MINUS: case TERM_EXT08: iof = iocore.base[(port >> 8) & 0xff]; - iof->ioout[port & 0xff](port, (BYTE)dat); + iof->ioout[port & 0xff](port, (UINT8)dat); return; } } iof = iocore.base[(port >> 8) & 0xff]; - iof->ioout[port & 0xff](port, (BYTE)dat); + iof->ioout[port & 0xff](port, (UINT8)dat); port++; iof = iocore.base[(port >> 8) & 0xff]; - iof->ioout[port & 0xff](port, (BYTE)(dat >> 8)); + iof->ioout[port & 0xff](port, (UINT8)(dat >> 8)); } -UINT16 IOINPCALL iocore_inp16(UINT port) { +REG16 IOINPCALL iocore_inp16(UINT port) { IOFUNC iof; - BYTE ret; + REG8 ret; if ((port & 0xfffc) == 0x005c) { return(artic_r16(port)); @@ -524,7 +562,7 @@ UINT16 IOINPCALL iocore_inp16(UINT port) case TERM_ACTIVE: ret = iof->ioinp[port & 0xff](port); - return((I286_AX & 0xff00) + ret); + return((CPU_AX & 0xff00) + ret); case TERM_PLUS: ret = iof->ioinp[port & 0xff](port); @@ -544,3 +582,17 @@ UINT16 IOINPCALL iocore_inp16(UINT port) return((UINT16)((iof->ioinp[port & 0xff](port) << 8) + ret)); } +void IOOUTCALL iocore_out32(UINT port, UINT32 dat) { + + iocore_out16(port, (UINT16)dat); + iocore_out16(port+2, (UINT16)(dat >> 16)); +} + +UINT32 IOINPCALL iocore_inp32(UINT port) { + + REG16 ret; + + ret = iocore_inp16(port); + return(ret + (iocore_inp16(port+2) << 16)); +} +