Pico.video.type, source, a, len, inc, (Pico.video.status&8)||!(Pico.video.reg[1]&0x40),\r
SekCyclesDone(), SekPc);\r
\r
- Pico.m.dma_xfers += len;\r
+ Pico.m.dma_xfers = len;\r
if (Pico.m.dma_xfers < len) // lame 16bit var\r
Pico.m.dma_xfers = ~0;\r
SekCyclesBurnRun(CheckDMA());\r
base = (u16 *)PicoMem.ram;\r
mask = 0xffff;\r
}\r
- else if (PicoAHW & PAHW_MCD)\r
+ else if (PicoIn.AHW & PAHW_MCD)\r
{\r
u8 r3 = Pico_mcd->s68k_regs[3];\r
elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", r3);\r
int source;\r
elprintf(EL_VDPDMA, "DmaCopy len %i [%u]", len, SekCyclesDone());\r
\r
- Pico.m.dma_xfers += len;\r
+ Pico.m.dma_xfers = len;\r
if (Pico.m.dma_xfers < len)\r
Pico.m.dma_xfers = ~0;\r
- Pico.video.status |= 2; // dma busy\r
+ Pico.video.status |= SR_DMA;\r
\r
source =Pico.video.reg[0x15];\r
source|=Pico.video.reg[0x16]<<8;\r
len = GetDmaLength();\r
elprintf(EL_VDPDMA, "DmaFill len %i inc %i [%u]", len, inc, SekCyclesDone());\r
\r
- Pico.m.dma_xfers += len;\r
+ Pico.m.dma_xfers = len;\r
if (Pico.m.dma_xfers < len) // lame 16bit var\r
Pico.m.dma_xfers = ~0;\r
- Pico.video.status |= 2; // dma busy\r
+ Pico.video.status |= SR_DMA;\r
\r
switch (Pico.video.type)\r
{\r
\r
if ((pvid->reg[1]&0x10)==0) return; // DMA not enabled\r
\r
+ if (Pico.m.dma_xfers)\r
+ elprintf(EL_VDPDMA|EL_ANOMALY, "Dma overlap, left=%d @ %06x",\r
+ Pico.m.dma_xfers, SekPc);\r
+\r
len = GetDmaLength();\r
source =Pico.video.reg[0x15];\r
source|=Pico.video.reg[0x16] << 8;\r
\r
static void DrawSync(int blank_on)\r
{\r
- if (Pico.m.scanline < 224 && !(PicoOpt & POPT_ALT_RENDERER) &&\r
- !PicoSkipFrame && Pico.est.DrawScanline <= Pico.m.scanline) {\r
+ if (Pico.m.scanline < 224 && !(PicoIn.opt & POPT_ALT_RENDERER) &&\r
+ !PicoIn.skipFrame && Pico.est.DrawScanline <= Pico.m.scanline) {\r
//elprintf(EL_ANOMALY, "sync");\r
PicoDrawSync(Pico.m.scanline, blank_on);\r
}\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
\r
- //if (Pico.m.scanline < 224)\r
- // elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x", a, d);\r
- a&=0x1c;\r
+ //elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x [%u] @ %06x",\r
+ // a, d, SekCyclesDone(), SekPc);\r
\r
+ a &= 0x1c;\r
switch (a)\r
{\r
case 0x00: // Data port 0 or 2\r
pvid->pending=0;\r
}\r
\r
- // preliminary FIFO emulation for Chaos Engine, The (E)\r
- if (!(pvid->status & SR_VB) && (pvid->reg[1] & 0x40) && !(PicoOpt&POPT_DIS_VDP_FIFO)) // active display?\r
+ if (!(pvid->status & SR_VB) && !(PicoIn.opt&POPT_DIS_VDP_FIFO))\r
{\r
int use = pvid->type == 1 ? 2 : 1;\r
pvid->lwrite_cnt -= use;\r
if (pvid->lwrite_cnt < 0)\r
SekCyclesLeft = 0;\r
- elprintf(EL_ASVDP, "VDP data write: %04x [%06x] {%i} #%i @ %06x", d, Pico.video.addr,\r
- Pico.video.type, pvid->lwrite_cnt, SekPc);\r
+ elprintf(EL_ASVDP, "VDP data write: [%04x] %04x [%u] {%i} #%i @ %06x",\r
+ Pico.video.addr, d, SekCyclesDone(), Pico.video.type, pvid->lwrite_cnt, SekPc);\r
}\r
VideoWrite(d);\r
\r
case 0x01:\r
elprintf(EL_INTSW, "vint_onoff: %i->%i [%u] pend=%i @ %06x", (dold&0x20)>>5,\r
(d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc);\r
+ if (!(pvid->status & PVS_VB2))\r
+ pvid->status &= ~SR_VB;\r
+ pvid->status |= ((d >> 3) ^ SR_VB) & SR_VB; // forced blanking\r
goto update_irq;\r
case 0x05:\r
//elprintf(EL_STATUS, "spritep moved to %04x", (unsigned)(Pico.video.reg[5]&0x7f) << 9);\r
// update IRQ level\r
if (!SekShouldInterrupt()) // hack\r
{\r
- int lines, pints, irq=0;\r
+ int lines, pints, irq = 0;\r
lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10);\r
- pints = (pvid->pending_ints&lines);\r
+ pints = pvid->pending_ints & lines;\r
if (pints & 0x20) irq = 6;\r
else if (pints & 0x10) irq = 4;\r
SekInterrupt(irq); // update line\r
\r
- if (irq) SekEndRun(24); // make it delayed\r
+ // this is broken because cost of current insn isn't known here\r
+ if (irq) SekEndRun(21); // make it delayed\r
}\r
#endif\r
}\r
}\r
}\r
\r
-PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)\r
+static u32 SrLow(const struct PicoVideo *pv)\r
{\r
- a&=0x1c;\r
-\r
- if (a==0x04) // control port\r
- {\r
- struct PicoVideo *pv=&Pico.video;\r
- unsigned int d;\r
- d=pv->status;\r
- //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)\r
- if (SekCyclesDone() - Pico.t.m68c_line_start >= 488-88)\r
- d|=0x0004; // H-Blank (Sonic3 vs)\r
+ unsigned int c, d = pv->status;\r
\r
- d |= ((pv->reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled\r
- d |= (pv->pending_ints&0x20)<<2; // V-int pending?\r
- if (d&0x100) pv->status&=~0x100; // FIFO no longer full\r
+ c = SekCyclesDone() - Pico.t.m68c_line_start - 39;\r
+ if (c < 92)\r
+ d |= SR_HB;\r
+ return d;\r
+}\r
\r
- pv->pending = 0; // ctrl port reads clear write-pending flag (Charles MacDonald)\r
+PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)\r
+{\r
+ a &= 0x1c;\r
\r
- elprintf(EL_SR, "SR read: %04x @ %06x", d, SekPc);\r
+ if (a == 0x04) // control port\r
+ {\r
+ struct PicoVideo *pv = &Pico.video;\r
+ unsigned int d = SrLow(pv);\r
+ pv->pending = 0;\r
+ elprintf(EL_SR, "SR read: %04x [%u] @ %06x", d, SekCyclesDone(), SekPc);\r
return d;\r
}\r
\r
return VideoRead();\r
}\r
\r
-// FIXME: broken mess\r
unsigned char PicoVideoRead8CtlH(void)\r
{\r
u8 d = (u8)(Pico.video.status >> 8);\r
- if (d & 1)\r
- Pico.video.status &= ~0x100; // FIFO no longer full\r
Pico.video.pending = 0;\r
elprintf(EL_SR, "SR read (h): %02x @ %06x", d, SekPc);\r
return d;\r
\r
unsigned char PicoVideoRead8CtlL(void)\r
{\r
- u8 d = (u8)Pico.video.status;\r
- //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)\r
- d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled\r
- d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending?\r
- if (SekCyclesDone() - Pico.t.m68c_line_start >= 488-88) d |= 4; // H-Blank\r
+ u8 d = SrLow(&Pico.video);\r
Pico.video.pending = 0;\r
elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc);\r
return d;\r