X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FVideoPort.c;h=b7a05f0515e97d24d56b0dc1be1e2ae0b8eb2d82;hb=1cd356a33daf2eec34e52c075b06d62866f5fb2f;hp=7f3d009c308b524fcb7fe9eef2eb7add40b6e04b;hpb=312e9ce192d49b4bea2f8a7e3cd2eb91a860564f;p=picodrive.git diff --git a/Pico/VideoPort.c b/Pico/VideoPort.c index 7f3d009..b7a05f0 100644 --- a/Pico/VideoPort.c +++ b/Pico/VideoPort.c @@ -14,6 +14,7 @@ extern const unsigned char hcounts_40[]; extern const unsigned short vcounts[]; extern int rendstatus; +typedef unsigned char u8; typedef unsigned short u16; @@ -58,26 +59,6 @@ static unsigned int VideoRead() return d; } -#if 0 -// calculate the number of cycles 68k->VDP dma operation would take -static int DmaSlowBurn(int len) -{ - // test: Legend of Galahad, Time Killers - int burn,maxlen,line=Pico.m.scanline; - - if(line == -1) line=vcounts[SekCyclesDone()>>8]; - maxlen=(224-line)*18; - if(len <= maxlen) - burn = len*(((488<<8)/18))>>8; - else { - burn = maxlen*(((488<<8)/18))>>8; - burn += (len-maxlen)*(((488<<8)/180))>>8; - } - - return burn; -} -#endif - static int GetDmaLength() { struct PicoVideo *pvid=&Pico.video; @@ -95,7 +76,7 @@ static void DmaSlow(int len) u16 *pd=0, *pdend, *r; unsigned int a=Pico.video.addr, a2, d; unsigned char inc=Pico.video.reg[0xf]; - unsigned int source; // , burn; + unsigned int source; source =Pico.video.reg[0x15]<<1; source|=Pico.video.reg[0x16]<<9; @@ -105,27 +86,54 @@ static void DmaSlow(int len) Pico.video.type, source, a, len, inc, (Pico.video.status&8)||!(Pico.video.reg[1]&0x40), Pico.m.scanline, SekCyclesDone(), SekPc); - if ((source&0xe00000)==0xe00000) { pd=(u16 *)(Pico.ram+(source&0xfffe)); pdend=(u16 *)(Pico.ram+0x10000); } // Ram - else if(source>8); // very approximate - if(!(Pico.video.status&8)) burn+=burn>>1; // a hack for Legend of Galahad - } else burn = DmaSlowBurn(len); - SekCyclesBurn(burn); -#else - Pico.m.dma_bytes += len; -#endif - //if(!(Pico.video.status&8)) -// SekEndRun(0); - //Pico.m.dma_endcycles = 0;//SekCyclesLeft; - //Pico.m.dma_endcycles -= Pico.m.dma_endcycles>>3; // hack - SekSetCyclesLeft(SekCyclesLeft - CheckDMA()); -// CheckDMA(); -// dprintf("DmaSlow burn: %i @ %06x", burn, SekPc); + if(Pico.m.scanline != -1) { + Pico.m.dma_bytes += len; + SekSetCyclesLeft(SekCyclesLeft - CheckDMA()); + } else { + // be approximate in non-accurate mode + SekSetCyclesLeft(SekCyclesLeft - (len*(((488<<8)/167))>>8)); + } + + if ((source&0xe00000)==0xe00000) { // Ram + pd=(u16 *)(Pico.ram+(source&0xfffe)); + pdend=(u16 *)(Pico.ram+0x10000); + } else if(PicoMCD & 1) { + dprintf("DmaSlow CD"); + if(source<0x20000) { // Bios area + pd=(u16 *)(Pico_mcd->bios+(source&~1)); + pdend=(u16 *)(Pico_mcd->bios+0x20000); + } else if ((source&0xfc0000)==0x200000 && (!(Pico_mcd->s68k_regs[3]&4))) { // Word Ram + if (!(Pico_mcd->s68k_regs[3]&4)) { // 2M mode + source -= 2; + pd=(u16 *)(Pico_mcd->word_ram+(source&0x3fffe)); + pdend=(u16 *)(Pico_mcd->word_ram+0x40000); + } else { + dprintf("DmaSlow: unsupported src"); + return; + } + } else if ((source&0xfe0000)==0x020000) { // Prg Ram + u8 *prg_ram = Pico_mcd->prg_ram_b[Pico_mcd->s68k_regs[3]>>6]; + pd=(u16 *)(prg_ram+(source&0x1fffe)); + pdend=(u16 *)(prg_ram+0x20000); + } else { + dprintf("DmaSlow: unsupported src"); + return; + } + } else { + if(source pdend - pd) { + len = pdend - pd; + dprintf("DmaSlow overflow"); + } switch (Pico.video.type) { @@ -139,7 +147,7 @@ static void DmaSlow(int len) // AutoIncrement a=(u16)(a+inc); // didn't src overlap? - if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM + //if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM } rendstatus|=0x10; break; @@ -153,7 +161,7 @@ static void DmaSlow(int len) // AutoIncrement a2+=inc; // didn't src overlap? - if(pd >= pdend) pd-=0x8000; + //if(pd >= pdend) pd-=0x8000; // good dest? if(a2 >= 0x80) break; // Todds Adventures in Slime World / Andre Agassi tennis } @@ -168,7 +176,7 @@ static void DmaSlow(int len) // AutoIncrement a2+=inc; // didn't src overlap? - if(pd >= pdend) pd-=0x8000; + //if(pd >= pdend) pd-=0x8000; // good dest? if(a2 >= 0x80) break; } @@ -189,7 +197,8 @@ static void DmaCopy(int len) dprintf("DmaCopy len %i [%i|%i]", len, Pico.m.scanline, SekCyclesDone()); Pico.m.dma_bytes += len; - Pico.video.status|=2; // dma busy + if(Pico.m.scanline != -1) + Pico.video.status|=2; // dma busy source =Pico.video.reg[0x15]; source|=Pico.video.reg[0x16]<<8; @@ -222,7 +231,8 @@ static void DmaFill(int data) dprintf("DmaFill len %i inc %i [%i|%i]", len, inc, Pico.m.scanline, SekCyclesDone()); Pico.m.dma_bytes += len; - Pico.video.status|=2; // dma busy + if(Pico.m.scanline != -1) + Pico.video.status|=2; // dma busy (in accurate mode) // from Charles MacDonald's genvdp.txt: // Write lower byte to address specified @@ -382,7 +392,7 @@ unsigned int PicoVideoRead(unsigned int a) if(Pico.m.rotate++&8) d|=0x0100; else d|=0x0200; // Toggle fifo full empty (who uses that stuff?) if(!(Pico.video.reg[1]&0x40)) d|=0x0008; // set V-Blank if display is disabled if(SekCyclesLeft < 84+4) d|=0x0004; // H-Blank (Sonic3 vs) - dprintf("sr_read %04x @ %06x [%i|%i]", d, SekPc, Pico.m.scanline, SekCyclesDone()); + // dprintf("sr_read %04x @ %06x [%i|%i]", d, SekPc, Pico.m.scanline, SekCyclesDone()); Pico.video.pending=0; // ctrl port reads clear write-pending flag (Charles MacDonald) @@ -416,7 +426,7 @@ unsigned int PicoVideoRead(unsigned int a) hc=hcounts_40[lineCycles]; else hc=hcounts_32[lineCycles]; - if(lineCycles > 488-12) d++; // Wheel of Fortune + //if(lineCycles > 488-12) d++; // Wheel of Fortune } else { // get approximate V-Counter d=vcounts[SekCyclesDone()>>8];