--- np2/io/iocore.c 2003/12/01 10:45:46 1.2 +++ np2/io/iocore.c 2004/07/01 11:42:54 1.19 @@ -1,10 +1,11 @@ #include "compiler.h" -#include "i286.h" +#include "cpucore.h" #include "pccore.h" #include "iocore.h" #include "cbuscore.h" #include "sound.h" #include "fmboard.h" +#include "ideio.h" #include "cs4231io.h" #include "iocore16.tbl" @@ -15,13 +16,15 @@ _CRTC crtc; _DMAC dmac; _EGC egc; - _EXTMEM extmem; + _EPSONIO epsonio; + _EMSIO emsio; _FDC fdc; _GDC gdc; _GDCS gdcs; _GRCG grcg; - _KEYB keyb; + _KEYBRD keybrd; _MOUSEIF mouseif; + _NECIO necio; _NMIIO nmiio; _NP2SYSP np2sysp; _PIC pic; @@ -30,6 +33,10 @@ _SYSPORT sysport; _UPD4990 uPD4990; +#if defined(SUPPORT_PC9821) + _PCIDEV pcidev; +#endif + // ---- @@ -48,35 +55,42 @@ typedef struct { typedef struct { IOFUNC base[256]; + UINT busclock; LISTARRAY iotbl; } _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 !defined(DISABLE_SOUND) if ((port & 0xfff0) == cs4231.port) { cs4231io_w8(port, dat); return; } +#endif if ((port & 0xf0ff) == 0x801e) { dipsw_w8(port, dat); return; } +// TRACEOUT(("defout8 - %x %x %.4x %.4x", port, dat, CPU_CS, CPU_IP)); } -static BYTE IOINPCALL definp(UINT port) { +static REG8 IOINPCALL definp8(UINT port) { +#if !defined(DISABLE_SOUND) if ((port & 0xfff0) == cs4231.port) { return(cs4231io_r8(port)); } +#endif if ((port & 0xf0ff) == 0x801e) { return(dipsw_r8(port)); } +// TRACEOUT(("definp8 - %x %.4x %.4x", port, CPU_CS, CPU_IP)); return(0xff); } @@ -344,7 +358,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)); @@ -353,7 +367,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); } } @@ -387,8 +401,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) { @@ -424,8 +438,12 @@ static const IOCBFN resetfn[] = { itimer_reset, mouseif_reset, // extend - artic_reset, egc_reset, - extmem_reset, np2sysp_reset}; + artic_reset, egc_reset, np2sysp_reset, + necio_reset, epsonio_reset, emsio_reset, +#if defined(SUPPORT_PC9821) + pcidev_reset, +#endif + }; static const IOCBFN bindfn[] = { // PC-9801 System... @@ -439,8 +457,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, emsio_bind, +#if defined(SUPPORT_PC9821) + pcidev_bind, +#endif + }; void iocore_cb(const IOCBFN *cbfn, UINT count) { @@ -458,29 +480,44 @@ void iocore_reset(void) { void iocore_bind(void) { + iocore.busclock = pccore.multiple; iocore_cb(bindfn, sizeof(bindfn)/sizeof(IOCBFN)); } -void IOOUTCALL iocore_out8(UINT port, BYTE dat) { +void IOOUTCALL iocore_out8(UINT port, REG8 dat) { IOFUNC iof; +// TRACEOUT(("iocore_out8(%.2x, %.2x)", port, dat)); + CPU_REMCLOCK -= iocore.busclock; iof = iocore.base[(port >> 8) & 0xff]; iof->ioout[port & 0xff](port, dat); } -BYTE IOINPCALL iocore_inp8(UINT port) { +REG8 IOINPCALL iocore_inp8(UINT port) { IOFUNC iof; + REG8 ret; + CPU_REMCLOCK -= iocore.busclock; iof = iocore.base[(port >> 8) & 0xff]; - return(iof->ioinp[port & 0xff](port)); + ret = iof->ioinp[port & 0xff](port); +// TRACEOUT(("iocore_inp8(%.2x) -> %.2x", port, ret)); + return(ret); } -void IOOUTCALL iocore_out16(UINT port, UINT16 dat) { +void IOOUTCALL iocore_out16(UINT port, REG16 dat) { IOFUNC iof; +// TRACEOUT(("iocore_out16(%.4x, %.4x)", port, dat)); + CPU_REMCLOCK -= iocore.busclock; +#if defined(SUPPORT_IDEIO) + if (port == 0x0640) { + ideio_w16(port, dat); + return; + } +#endif if ((port & 0xfff1) == 0x04a0) { egc_w16(port, dat); return; @@ -495,22 +532,28 @@ 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; + CPU_REMCLOCK -= iocore.busclock; +#if defined(SUPPORT_IDEIO) + if (port == 0x0640) { + return(ideio_r16(port)); + } +#endif if ((port & 0xfffc) == 0x005c) { return(artic_r16(port)); } @@ -522,7 +565,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); @@ -542,3 +585,30 @@ UINT16 IOINPCALL iocore_inp16(UINT port) return((UINT16)((iof->ioinp[port & 0xff](port) << 8) + ret)); } +void IOOUTCALL iocore_out32(UINT port, UINT32 dat) { + + CPU_REMCLOCK -= iocore.busclock; +#if defined(SUPPORT_PC9821) + if ((port & 0xfffb) == 0x0cf8) { + pcidev_w32(port, dat); + return; + } +#endif + iocore_out16(port, (UINT16)dat); + iocore_out16(port+2, (UINT16)(dat >> 16)); +} + +UINT32 IOINPCALL iocore_inp32(UINT port) { + + UINT32 ret; + + CPU_REMCLOCK -= iocore.busclock; +#if defined(SUPPORT_PC9821) + if ((port & 0xfffb) == 0x0cf8) { + return(pcidev_r32(port)); + } +#endif + ret = iocore_inp16(port); + return(ret + (iocore_inp16(port+2) << 16)); +} +