X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fvideoport.c;h=9def819deb4a4b86bf7e251db61e403cf80a4afa;hb=eef77d7a8b0b0d47e9559e40d8cb6407ea39b0f2;hp=22b83850e3aaf201fdaa89130a991ca5f97f276c;hpb=22814963ccbcba3a08ca49656fd80dc40de64710;p=picodrive.git diff --git a/pico/videoport.c b/pico/videoport.c index 22b8385..9def819 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -100,7 +100,7 @@ static void DmaSlow(int len, unsigned int source) Pico.video.type, source, a, len, inc, (Pico.video.status&8)||!(Pico.video.reg[1]&0x40), SekCyclesDone(), SekPc); - Pico.m.dma_xfers += len; + Pico.m.dma_xfers = len; if (Pico.m.dma_xfers < len) // lame 16bit var Pico.m.dma_xfers = ~0; SekCyclesBurnRun(CheckDMA()); @@ -109,7 +109,7 @@ static void DmaSlow(int len, unsigned int source) base = (u16 *)PicoMem.ram; mask = 0xffff; } - else if (PicoAHW & PAHW_MCD) + else if (PicoIn.AHW & PAHW_MCD) { u8 r3 = Pico_mcd->s68k_regs[3]; elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", r3); @@ -225,10 +225,10 @@ static void DmaCopy(int len) int source; elprintf(EL_VDPDMA, "DmaCopy len %i [%u]", len, SekCyclesDone()); - Pico.m.dma_xfers += len; + Pico.m.dma_xfers = len; if (Pico.m.dma_xfers < len) Pico.m.dma_xfers = ~0; - Pico.video.status |= 2; // dma busy + Pico.video.status |= SR_DMA; source =Pico.video.reg[0x15]; source|=Pico.video.reg[0x16]<<8; @@ -256,10 +256,10 @@ static NOINLINE void DmaFill(int data) len = GetDmaLength(); elprintf(EL_VDPDMA, "DmaFill len %i inc %i [%u]", len, inc, SekCyclesDone()); - Pico.m.dma_xfers += len; + Pico.m.dma_xfers = len; if (Pico.m.dma_xfers < len) // lame 16bit var Pico.m.dma_xfers = ~0; - Pico.video.status |= 2; // dma busy + Pico.video.status |= SR_DMA; switch (Pico.video.type) { @@ -306,6 +306,10 @@ static NOINLINE void CommandDma(void) if ((pvid->reg[1]&0x10)==0) return; // DMA not enabled + if (Pico.m.dma_xfers) + elprintf(EL_VDPDMA|EL_ANOMALY, "Dma overlap, left=%d @ %06x", + Pico.m.dma_xfers, SekPc); + len = GetDmaLength(); source =Pico.video.reg[0x15]; source|=Pico.video.reg[0x16] << 8; @@ -346,8 +350,8 @@ static NOINLINE void CommandChange(void) static void DrawSync(int blank_on) { - if (Pico.m.scanline < 224 && !(PicoOpt & POPT_ALT_RENDERER) && - !PicoSkipFrame && Pico.est.DrawScanline <= Pico.m.scanline) { + if (Pico.m.scanline < 224 && !(PicoIn.opt & POPT_ALT_RENDERER) && + !PicoIn.skipFrame && Pico.est.DrawScanline <= Pico.m.scanline) { //elprintf(EL_ANOMALY, "sync"); PicoDrawSync(Pico.m.scanline, blank_on); } @@ -376,8 +380,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) pvid->pending=0; } - // preliminary FIFO emulation for Chaos Engine, The (E) - if (!(pvid->status & SR_VB) && (pvid->reg[1] & 0x40) && !(PicoOpt&POPT_DIS_VDP_FIFO)) // active display? + if (!(pvid->status & SR_VB) && !(PicoIn.opt&POPT_DIS_VDP_FIFO)) { int use = pvid->type == 1 ? 2 : 1; pvid->lwrite_cnt -= use; @@ -434,6 +437,9 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) case 0x01: elprintf(EL_INTSW, "vint_onoff: %i->%i [%u] pend=%i @ %06x", (dold&0x20)>>5, (d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc); + if (!(pvid->status & PVS_VB2)) + pvid->status &= ~SR_VB; + pvid->status |= ((d >> 3) ^ SR_VB) & SR_VB; // forced blanking goto update_irq; case 0x05: //elprintf(EL_STATUS, "spritep moved to %04x", (unsigned)(Pico.video.reg[5]&0x7f) << 9); @@ -503,25 +509,25 @@ update_irq: } } -PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) +static u32 SrLow(const struct PicoVideo *pv) { - a&=0x1c; - - if (a==0x04) // control port - { - struct PicoVideo *pv=&Pico.video; - unsigned int d; - d=pv->status; - //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast) - if (SekCyclesDone() - Pico.t.m68c_line_start >= 488-88) - d|=0x0004; // H-Blank (Sonic3 vs) + unsigned int c, d = pv->status; - d |= ((pv->reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled - d |= (pv->pending_ints&0x20)<<2; // V-int pending? - if (d&0x100) pv->status&=~0x100; // FIFO no longer full + c = SekCyclesDone() - Pico.t.m68c_line_start - 39; + if (c < 92) + d |= SR_HB; + return d; +} - pv->pending = 0; // ctrl port reads clear write-pending flag (Charles MacDonald) +PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) +{ + a &= 0x1c; + if (a == 0x04) // control port + { + struct PicoVideo *pv = &Pico.video; + unsigned int d = SrLow(pv); + pv->pending = 0; elprintf(EL_SR, "SR read: %04x [%u] @ %06x", d, SekCyclesDone(), SekPc); return d; } @@ -572,12 +578,9 @@ unsigned char PicoVideoRead8DataL(void) return VideoRead(); } -// FIXME: broken mess unsigned char PicoVideoRead8CtlH(void) { u8 d = (u8)(Pico.video.status >> 8); - if (d & 1) - Pico.video.status &= ~0x100; // FIFO no longer full Pico.video.pending = 0; elprintf(EL_SR, "SR read (h): %02x @ %06x", d, SekPc); return d; @@ -585,11 +588,7 @@ unsigned char PicoVideoRead8CtlH(void) unsigned char PicoVideoRead8CtlL(void) { - u8 d = (u8)Pico.video.status; - //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast) - d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled - d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending? - if (SekCyclesDone() - Pico.t.m68c_line_start >= 488-88) d |= 4; // H-Blank + u8 d = SrLow(&Pico.video); Pico.video.pending = 0; elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc); return d;