- Pico.m.scanline, SekCyclesDone(), SekPc);\r
-\r
- if ((source&0xe00000)==0xe00000) { pd=(u16 *)(Pico.ram+(source&0xfffe)); pdend=(u16 *)(Pico.ram+0x10000); } // Ram\r
- else if(source<Pico.romsize) { pd=(u16 *)(Pico.rom+(source&~1)); pdend=(u16 *)(Pico.rom+Pico.romsize); } // Rom\r
- else return; // Invalid source address\r
-\r
-#if 0\r
- // CPU is stopped during DMA, so we burn some cycles to compensate that\r
- if((Pico.video.status&8)||!(Pico.video.reg[1]&0x40)) { // vblank?\r
- burn = (len*(((488<<8)/167))>>8); // very approximate\r
- if(!(Pico.video.status&8)) burn+=burn>>1; // a hack for Legend of Galahad\r
- } else burn = DmaSlowBurn(len);\r
- SekCyclesBurn(burn);\r
-#else\r
- Pico.m.dma_bytes += len;\r
-#endif\r
- //if(!(Pico.video.status&8))\r
-// SekEndRun(0);\r
- //Pico.m.dma_endcycles = 0;//SekCyclesLeft;\r
- //Pico.m.dma_endcycles -= Pico.m.dma_endcycles>>3; // hack\r
- SekSetCyclesLeft(SekCyclesLeft - CheckDMA());\r
-// CheckDMA();\r
-// dprintf("DmaSlow burn: %i @ %06x", burn, SekPc);\r
+ SekCyclesDone(), SekPc);\r
+\r
+ if(Pico.m.scanline != -1) {\r
+ Pico.m.dma_xfers += len;\r
+ if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCyclesBurn(CheckDMA());\r
+ else SekSetCyclesLeftNoMCD(SekCyclesLeftNoMCD - CheckDMA());\r
+ } else {\r
+ // be approximate in non-accurate mode\r
+ SekSetCyclesLeft(SekCyclesLeft - (len*(((488<<8)/167))>>8));\r
+ }\r
+\r
+ if ((source&0xe00000)==0xe00000) { // Ram\r
+ pd=(u16 *)(Pico.ram+(source&0xfffe));\r
+ pdend=(u16 *)(Pico.ram+0x10000);\r
+ } else if(PicoMCD & 1) {\r
+ elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", Pico_mcd->s68k_regs[3]);\r
+ if(source<0x20000) { // Bios area\r
+ pd=(u16 *)(Pico_mcd->bios+(source&~1));\r
+ pdend=(u16 *)(Pico_mcd->bios+0x20000);\r
+ } else if ((source&0xfc0000)==0x200000) { // Word Ram\r
+ source -= 2;\r
+ if (!(Pico_mcd->s68k_regs[3]&4)) { // 2M mode\r
+ pd=(u16 *)(Pico_mcd->word_ram2M+(source&0x3fffe));\r
+ pdend=(u16 *)(Pico_mcd->word_ram2M+0x40000);\r
+ } else {\r
+ if (source < 0x220000) { // 1M mode\r
+ int bank = Pico_mcd->s68k_regs[3]&1;\r
+ pd=(u16 *)(Pico_mcd->word_ram1M[bank]+(source&0x1fffe));\r
+ pdend=(u16 *)(Pico_mcd->word_ram1M[bank]+0x20000);\r
+ } else {\r
+ DmaSlowCell(source, a, len, inc);\r
+ return;\r
+ }\r
+ }\r
+ } else if ((source&0xfe0000)==0x020000) { // Prg Ram\r
+ u8 *prg_ram = Pico_mcd->prg_ram_b[Pico_mcd->s68k_regs[3]>>6];\r
+ pd=(u16 *)(prg_ram+(source&0x1fffe));\r
+ pdend=(u16 *)(prg_ram+0x20000);\r
+ } else {\r
+ elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow FIXME: unsupported src");\r
+ return;\r
+ }\r
+ } else {\r
+ if(source<Pico.romsize) { // Rom\r
+ pd=(u16 *)(Pico.rom+(source&~1));\r
+ pdend=(u16 *)(Pico.rom+Pico.romsize);\r
+ } else {\r
+ elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow: invalid dma src");\r
+ return;\r
+ }\r
+ }\r
+\r
+ // overflow protection, might break something..\r
+ if (len > pdend - pd) {\r
+ len = pdend - pd;\r
+ elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow overflow");\r
+ }\r