handle 'bad' dma better
[picodrive.git] / pico / videoport.c
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.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
@@ -225,10 +225,10 @@ static void DmaCopy(int len)
   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
@@ -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
-  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
@@ -306,6 +306,10 @@ static NOINLINE void CommandDma(void)
 \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