--- np2/io/dmac.c 2004/01/29 09:41:50 1.8 +++ np2/io/dmac.c 2005/02/07 14:46:11 1.12 @@ -1,4 +1,5 @@ #include "compiler.h" +#include "cpucore.h" #include "pccore.h" #include "iocore.h" #include "sound.h" @@ -32,7 +33,11 @@ static const DMAPROC dmaproc[] = { {dma_dummyout, dma_dummyin, dma_dummyproc}, // SASI #endif {dma_dummyout, dma_dummyin, dma_dummyproc}, // SCSI +#if !defined(DISABLE_SOUND) {dma_dummyout, dma_dummyin, cs4231dmafunc}, // CS4231 +#else + {dma_dummyout, dma_dummyin, dma_dummyproc}, // SASI +#endif }; @@ -52,7 +57,7 @@ void dmac_check(void) { if (!(dmac.work & bit)) { dmac.work |= bit; if (ch->proc.extproc(DMAEXT_START)) { - dmac.stat &= ~bit; // ver0.27 + dmac.stat &= ~bit; dmac.working |= bit; workchg = TRUE; } @@ -74,6 +79,35 @@ void dmac_check(void) { } } +UINT dmac_getdatas(DMACH dmach, UINT8 *buf, UINT size) { + + UINT leng; + UINT32 addr; + UINT i; + + leng = min(dmach->leng.w, size); + if (leng) { + addr = dmach->adrs.d; // + mask + if (!(dmach->mode & 0x20)) { // dir + + for (i=0; iadrs.d += leng; + } + else { // dir - + for (i=0; iadrs.d -= leng; + } + dmach->leng.w -= leng; + if (dmach->leng.w == 0) { + dmach->proc.extproc(DMAEXT_END); + } + } + return(leng); +} + // ---- I/O @@ -84,7 +118,7 @@ static void IOOUTCALL dmac_o01(UINT port dmach = dmac.dmach + ((port >> 2) & 3); lh = dmac.lh; - dmac.lh = lh ^ 1; + dmac.lh = (UINT8)(lh ^ 1); dmach->adrs.b[lh + DMA32_LOW] = dat; dmach->adrsorg.b[lh] = dat; } @@ -154,7 +188,21 @@ static void IOOUTCALL dmac_o21(UINT port DMACH dmach; dmach = dmac.dmach + (((port >> 1) + 1) & 3); +#if defined(CPUCORE_IA32) + dmach->adrs.b[DMA32_HIGH + DMA16_LOW] = dat; +#else + // IA16では ver0.75で無効、ver0.76で修正 dmach->adrs.b[DMA32_HIGH + DMA16_LOW] = dat & 0x0f; +#endif +} + +static void IOOUTCALL dmac_o29(UINT port, REG8 dat) { + + DMACH dmach; + + dmach = dmac.dmach + (dat & 3); + dmach->bound = dat; + (void)port; } static REG8 IOINPCALL dmac_i01(UINT port) { @@ -200,8 +248,9 @@ static const IOINP dmaci00[16] = { dmac_i11, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; -static const IOOUT dmaco21[4] = { - dmac_o21, dmac_o21, dmac_o21, dmac_o21}; +static const IOOUT dmaco21[8] = { + dmac_o21, dmac_o21, dmac_o21, dmac_o21, + dmac_o29, NULL, NULL, NULL}; void dmac_reset(void) { @@ -216,7 +265,7 @@ void dmac_bind(void) { iocore_attachsysoutex(0x0001, 0x0ce1, dmaco00, 16); iocore_attachsysinpex(0x0001, 0x0ce1, dmaci00, 16); - iocore_attachsysoutex(0x0021, 0x0cf1, dmaco21, 4); + iocore_attachsysoutex(0x0021, 0x0cf1, dmaco21, 8); } @@ -237,10 +286,10 @@ static void dmacset(REG8 channel) { } dev++; } - if (dmadev >= sizeof(dmaproc) / sizeof(DMAPROC)) { + if (dmadev >= NELEMENTS(dmaproc)) { dmadev = 0; } - TRACEOUT(("dmac set %d - %d", channel, dmadev)); +// TRACEOUT(("dmac set %d - %d", channel, dmadev)); dmac.dmach[channel].proc = dmaproc[dmadev]; } @@ -257,7 +306,7 @@ void dmac_attach(REG8 device, REG8 chann dmac_detach(device); - if (dmac.devices < (sizeof(dmac.device) / sizeof(DMADEV))) { + if (dmac.devices < NELEMENTS(dmac.device)) { dmac.device[dmac.devices].device = device; dmac.device[dmac.devices].channel = channel; dmac.devices++;