handle 'bad' dma better
authornotaz <notasas@gmail.com>
Fri, 20 Oct 2017 21:02:38 +0000 (00:02 +0300)
committernotaz <notasas@gmail.com>
Fri, 20 Oct 2017 21:02:38 +0000 (00:02 +0300)
pico/pico.c
pico/videoport.c

index 2e561c6..76c5fe9 100644 (file)
@@ -253,10 +253,9 @@ PICO_INTERNAL int CheckDMA(void)
   xfers_can = dma_timings[dma_op];\r
   if(xfers <= xfers_can)\r
   {\r
   xfers_can = dma_timings[dma_op];\r
   if(xfers <= xfers_can)\r
   {\r
-    if(dma_op&2) Pico.video.status&=~2; // dma no longer busy\r
-    else {\r
+    Pico.video.status &= ~SR_DMA;\r
+    if (!(dma_op & 2))\r
       burn = xfers * dma_bsycles[dma_op] >> 8; // have to be approximate because can't afford division..\r
       burn = xfers * dma_bsycles[dma_op] >> 8; // have to be approximate because can't afford division..\r
-    }\r
     Pico.m.dma_xfers = 0;\r
   } else {\r
     if(!(dma_op&2)) burn = 488;\r
     Pico.m.dma_xfers = 0;\r
   } else {\r
     if(!(dma_op&2)) burn = 488;\r
index 355489e..9def819 100644 (file)
@@ -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),\r
     SekCyclesDone(), SekPc);\r
 \r
     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
   if (Pico.m.dma_xfers < len) // lame 16bit var\r
     Pico.m.dma_xfers = ~0;\r
   SekCyclesBurnRun(CheckDMA());\r
@@ -225,10 +225,10 @@ static void DmaCopy(int len)
   int source;\r
   elprintf(EL_VDPDMA, "DmaCopy len %i [%u]", len, SekCyclesDone());\r
 \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
   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
 \r
   source =Pico.video.reg[0x15];\r
   source|=Pico.video.reg[0x16]<<8;\r
@@ -256,10 +256,10 @@ static NOINLINE void DmaFill(int data)
   len = GetDmaLength();\r
   elprintf(EL_VDPDMA, "DmaFill len %i inc %i [%u]", len, inc, SekCyclesDone());\r
 \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
   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
   switch (Pico.video.type)\r
   {\r
@@ -306,6 +306,10 @@ static NOINLINE void CommandDma(void)
 \r
   if ((pvid->reg[1]&0x10)==0) return; // DMA not enabled\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
   len = GetDmaLength();\r
   source =Pico.video.reg[0x15];\r
   source|=Pico.video.reg[0x16] << 8;\r