X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fvideoport.c;h=b5e3f86ceaa791da564c35e6398c6dec8dd6750e;hb=0e4bde9b2d981c264343aa66809f2f26ce7843c8;hp=072a941b0a8b8a168e6f116ef5972185f9afc990;hpb=88fd63ad10faa746ef9d7ad7d98a72e51fe2aa86;p=picodrive.git diff --git a/pico/videoport.c b/pico/videoport.c index 072a941..b5e3f86 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -357,10 +357,10 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) { struct PicoVideo *pvid=&Pico.video; - //if (Pico.m.scanline < 224) - // elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x", a, d); - a&=0x1c; + //elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x [%u] @ %06x", + // a, d, SekCyclesDone(), SekPc); + a &= 0x1c; switch (a) { case 0x00: // Data port 0 or 2 @@ -376,15 +376,14 @@ 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) && !(PicoOpt&POPT_DIS_VDP_FIFO)) { int use = pvid->type == 1 ? 2 : 1; pvid->lwrite_cnt -= use; if (pvid->lwrite_cnt < 0) SekCyclesLeft = 0; - elprintf(EL_ASVDP, "VDP data write: %04x [%06x] {%i} #%i @ %06x", d, Pico.video.addr, - Pico.video.type, pvid->lwrite_cnt, SekPc); + elprintf(EL_ASVDP, "VDP data write: [%04x] %04x [%u] {%i} #%i @ %06x", + Pico.video.addr, d, SekCyclesDone(), Pico.video.type, pvid->lwrite_cnt, SekPc); } VideoWrite(d); @@ -434,6 +433,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); @@ -451,14 +453,15 @@ update_irq: // update IRQ level if (!SekShouldInterrupt()) // hack { - int lines, pints, irq=0; + int lines, pints, irq = 0; lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10); - pints = (pvid->pending_ints&lines); + pints = pvid->pending_ints & lines; if (pints & 0x20) irq = 6; else if (pints & 0x10) irq = 4; SekInterrupt(irq); // update line - if (irq) SekEndRun(24); // make it delayed + // this is broken because cost of current insn isn't known here + if (irq) SekEndRun(21); // make it delayed } #endif } @@ -502,26 +505,26 @@ update_irq: } } -PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) +static u32 SrLow(const struct PicoVideo *pv) { - a&=0x1c; + unsigned int c, d = pv->status; - 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) - - 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; - elprintf(EL_SR, "SR read: %04x @ %06x", d, SekPc); + 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; } @@ -571,12 +574,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; @@ -584,11 +584,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;