X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FVideoPort.c;h=a4fe3c88bf740add99aa09a8df6de847ca64d839;hb=e5f426aa2e86d56357b8af2795e73cc0c9b17e8f;hp=537e917a837e334fcedf317e4c9127950fbee4e2;hpb=bf098bc53228f6b5016cb4a6126f4466bfba4e00;p=picodrive.git diff --git a/Pico/VideoPort.c b/Pico/VideoPort.c index 537e917..a4fe3c8 100644 --- a/Pico/VideoPort.c +++ b/Pico/VideoPort.c @@ -1,20 +1,26 @@ // This is part of Pico Library // (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006 notaz, All rights reserved. +// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas // Free for non-commercial use. // For commercial use, separate licencing terms must be obtained. #include "PicoInt.h" +#include "cd/gfx_cd.h" extern const unsigned char hcounts_32[]; extern const unsigned char hcounts_40[]; extern const unsigned short vcounts[]; extern int rendstatus; +#ifndef UTYPES_DEFINED +typedef unsigned char u8; typedef unsigned short u16; +typedef unsigned int u32; +#define UTYPES_DEFINED +#endif static __inline void AutoIncrement() @@ -87,34 +93,82 @@ static void DmaSlow(int len) if(Pico.m.scanline != -1) { Pico.m.dma_bytes += len; - SekSetCyclesLeft(SekCyclesLeft - CheckDMA()); + if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCyclesBurn(CheckDMA()); + else SekSetCyclesLeftNoMCD(SekCyclesLeftNoMCD - CheckDMA()); } else { // be approximate in non-accurate mode SekSetCyclesLeft(SekCyclesLeft - (len*(((488<<8)/167))>>8)); } - if ((source&0xe00000)==0xe00000) { pd=(u16 *)(Pico.ram+(source&0xfffe)); pdend=(u16 *)(Pico.ram+0x10000); } // Ram - else if(PicoMCD & 1) { - if(source<0x20000) { pd=(u16 *)(Pico_mcd->bios+(source&~1)); pdend=(u16 *)(Pico_mcd->bios+0x20000); } // Bios area - else { dprintf("unsupported src"); return; } // Invalid source address + if ((source&0xe00000)==0xe00000) { // Ram + pd=(u16 *)(Pico.ram+(source&0xfffe)); + pdend=(u16 *)(Pico.ram+0x10000); + } else if(PicoMCD & 1) { + dprintf("DmaSlow CD, r3=%02x", Pico_mcd->s68k_regs[3]); + if(source<0x20000) { // Bios area + pd=(u16 *)(Pico_mcd->bios+(source&~1)); + pdend=(u16 *)(Pico_mcd->bios+0x20000); + } else if ((source&0xfc0000)==0x200000) { // Word Ram + source -= 2; + if (!(Pico_mcd->s68k_regs[3]&4)) { // 2M mode + pd=(u16 *)(Pico_mcd->word_ram2M+(source&0x3fffe)); + pdend=(u16 *)(Pico_mcd->word_ram2M+0x40000); + } else { + if (source < 0x220000) { // 1M mode + int bank = Pico_mcd->s68k_regs[3]&1; + pd=(u16 *)(Pico_mcd->word_ram1M[bank]+(source&0x1fffe)); + pdend=(u16 *)(Pico_mcd->word_ram1M[bank]+0x20000); + } else { + DmaSlowCell(source, a, len, inc); + 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 FIXME: unsupported src"); + return; + } } else { - if(source pdend - pd) { + len = pdend - pd; + dprintf("DmaSlow overflow"); } switch (Pico.video.type) { case 1: // vram r = Pico.vram; - for(; len; len--) + if (inc == 2 && !(a&1) && a+len*2 < 0x10000) { - d=*pd++; - if(a&1) d=(d<<8)|(d>>8); - r[a>>1] = (u16)d; // will drop the upper bits - // AutoIncrement - a=(u16)(a+inc); - // didn't src overlap? - if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM + // most used DMA mode + memcpy16(r + (a>>1), pd, len); + a += len*2; + } + else + { + for(; len; len--) + { + d=*pd++; + if(a&1) d=(d<<8)|(d>>8); + r[a>>1] = (u16)d; // will drop the upper bits + // AutoIncrement + a=(u16)(a+inc); + // didn't src overlap? + //if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM + } } rendstatus|=0x10; break; @@ -124,11 +178,11 @@ static void DmaSlow(int len) r = Pico.cram; for(a2=a&0x7f; len; len--) { - r[a2>>1] = (u16)*pd++;; // bit 0 is ignored + r[a2>>1] = (u16)*pd++; // bit 0 is ignored // 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 } @@ -143,7 +197,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; } @@ -258,7 +312,7 @@ static void CommandChange() if (cmd&0x80) CommandDma(); } -void PicoVideoWrite(unsigned int a,unsigned short d) +PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) { struct PicoVideo *pvid=&Pico.video; @@ -340,7 +394,7 @@ void PicoVideoWrite(unsigned int a,unsigned short d) } } -unsigned int PicoVideoRead(unsigned int a) +PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) { unsigned int d=0;