|
|
| version 1.1, 2004/08/01 05:31:32 | version 1.8, 2004/08/15 07:52:16 |
|---|---|
| Line 2 | Line 2 |
| #include "z80core.h" | #include "z80core.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "x1_io.h" | #include "ievent.h" |
| #include "x1_fdc.h" | |
| void z80dmap(void) { | |
| UINT16 *off1; | |
| UINT16 *off2; | |
| REG8 flag1; | |
| REG8 flag2; | |
| UINT addr; | |
| REG8 dat; | |
| if (!dma.working) { | |
| return; | |
| } | |
| if (dma.WR[0] & 4) { | |
| off1 = &dma.CNT_A.w; | |
| flag1 = dma.WR[1]; | |
| off2 = &dma.CNT_B.w; | |
| flag2 = dma.WR[2]; | |
| } | |
| else { | |
| off2 = &dma.CNT_A.w; | |
| flag2 = dma.WR[1]; | |
| off1 = &dma.CNT_B.w; | |
| flag1 = dma.WR[2]; | |
| } | |
| do { // dma_lp | |
| if (dma.increment) { | |
| if (!(flag1 & 0x20)) { | |
| *off1 += (flag1 & 0x10)?1:-1; | |
| } | |
| if (!(flag2 & 0x20)) { | |
| *off2 += (flag2 & 0x10)?1:-1; | |
| } | |
| } | |
| dma.increment = 1; | |
| addr = *off1; | |
| if (flag1 & 8) { | |
| dat = iocore_inp(addr); | |
| } | |
| else { | |
| dat = z80mem_read8(addr); | |
| } | |
| if (dma.cmd & 1) { | |
| addr = *off2; | |
| if (flag2 & 8) { | |
| iocore_out(addr, dat); | |
| } | |
| else { | |
| TRACEOUT(("dma!")); | |
| z80mem_write8(addr, dat); | |
| } | |
| } | |
| if (dma.cmd & 2) { | |
| if (!((dat ^ dma.MACH_BYT) & (~dma.MASK_BYT))) { | |
| dma.working = FALSE; | |
| dma.MACH_FLG = 1; | |
| } | |
| } | |
| dma.BYT_N.w++; | |
| if (dma.BYT_N.w == 0) { | |
| dma.working = FALSE; | |
| dma.ENDB_FLG = 1; | |
| goto intr; | |
| } | |
| if ((dma.BYT_L.w) && (dma.BYT_L.w != 0xffff) && (dma.BYT_N.w >= (dma.BYT_L.w + 1))) { | |
| dma.working = FALSE; | |
| dma.ENDB_FLG = 1; | |
| goto intr; | |
| } | |
| if (!dma.working) { | |
| return; | |
| } | |
| } while(dma.mode); | |
| return; | |
| intr: | |
| if (dma.INT_ENBL) { | |
| ievent_set(IEVENT_DMA); | |
| } | |
| } | |
| #if 0 // old | |
| LABEL void z80dmap(void) { | LABEL void z80dmap(void) { |
| __asm { | __asm { |
| Line 46 dma_lp: cmp dma.ENDB_FLG, 0 | Line 133 dma_lp: cmp dma.ENDB_FLG, 0 |
| jne dmalpend | jne dmalpend |
| dma_lpst: | dma_lpst: |
| push ecx | push ecx |
| push edx | |
| movzx ecx, word ptr [ebx] | movzx ecx, word ptr [ebx] |
| test dl, 8 | test dl, 8 |
| jne dma_inport | jne dma_inport |
| push edx | |
| call memrd8_ecx_al | call memrd8_ecx_al |
| pop edx | dmasrcend: pop edx |
| dmasrcend: pop ecx | pop ecx |
| test dma.DMA_CMND, 1 | test dma.DMA_CMND, 1 |
| je dmadstend | je dmadstend |
| Line 140 dma_intrpt: jmp z80x_interrupt | Line 227 dma_intrpt: jmp z80x_interrupt |
| dmaintrptend: ret | dmaintrptend: ret |
| dma_inport: push edx | dma_inport: call iocore_inp |
| push ebx | |
| cmp cx, 0ffbh | |
| jne Z80inport | |
| mov fdcdummyread, 0 | |
| Z80inport: call iocore_inp | |
| pop ebx | |
| pop edx | |
| jmp dmasrcend | jmp dmasrcend |
| dma_outport: push ebx | dma_outport: call iocore_out |
| cmp cx, 0ffbh | |
| jne Z80outport | |
| cmp ppi.IO_MODE, 0 | |
| jne Z80outport | |
| mov fdcdummyread, 0 | |
| Z80outport: call iocore_out | |
| pop ebx | |
| jmp dmadstend | jmp dmadstend |
| } | } |
| } | } |
| #endif | |