vdp, add handling of external buffers for fast renderer
authorkub <derkub@gmail.com>
Sat, 12 Dec 2020 13:36:54 +0000 (14:36 +0100)
committerkub <derkub@gmail.com>
Sat, 12 Dec 2020 13:36:54 +0000 (14:36 +0100)
pico/draw.c
pico/draw2.c
pico/pico_int.h

index e8a4723..6318713 100644 (file)
@@ -1855,9 +1855,6 @@ PICO_INTERNAL void PicoFrameStart(void)
     Pico.m.dirtyPal = (dirty ? 2 : 0); // mark as dirty but already copied\r
     blockcpy(Pico.est.SonicPal, PicoMem.cram, 0x40*2);\r
   }\r
-\r
-  if (PicoIn.opt & POPT_ALT_RENDERER)\r
-    return;\r
 }\r
 \r
 static void DrawBlankedLine(int line, int offs, int sh, int bgc)\r
@@ -1974,10 +1971,12 @@ void PicoDrawUpdateHighPal(void)
 void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode)\r
 {\r
   PicoDrawSetInternalBuf(NULL, 0);\r
+  PicoDraw2SetOutBuf(NULL);\r
   switch (which)\r
   {\r
     case PDF_8BIT:\r
       FinalizeLine = FinalizeLine8bit;\r
+      PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328);\r
       break;\r
 \r
     case PDF_RGB555:\r
@@ -1989,13 +1988,13 @@ void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode)
 \r
     default:\r
       FinalizeLine = NULL;\r
-      PicoDrawSetOutBufMD(Pico.est.Draw2FB+8, 328);\r
       break;\r
   }\r
   if (PicoIn.AHW & PAHW_32X)\r
     PicoDrawSetOutFormat32x(which, use_32x_line_mode);\r
   PicoDrawSetOutputMode4(which);\r
   rendstatus_old = -1;\r
+  Pico.m.dirtyPal = 1;\r
 }\r
 \r
 void PicoDrawSetOutBufMD(void *dest, int increment)\r
@@ -2004,7 +2003,10 @@ void PicoDrawSetOutBufMD(void *dest, int increment)
     // kludge for no-copy mode\r
     PicoDrawSetInternalBuf(dest, increment);\r
   }\r
-  if (dest != NULL) {\r
+\r
+  if (FinalizeLine == NULL)\r
+    PicoDraw2SetOutBuf(dest);\r
+  else if (dest != NULL) {\r
     DrawLineDestBase = dest;\r
     DrawLineDestIncrement = increment;\r
     Pico.est.DrawLineDest = (char *)DrawLineDestBase + Pico.est.DrawScanline * increment;\r
index e254952..ec1a12c 100644 (file)
@@ -692,7 +692,15 @@ PICO_INTERNAL void PicoFrameFull()
        pprof_end(draw);\r
 }\r
 \r
+void PicoDraw2SetOutBuf(void *dest)\r
+{\r
+       if (dest)\r
+               Pico.est.Draw2FB = dest;\r
+       else\r
+               Pico.est.Draw2FB = PicoDraw2FB_;\r
+}\r
+\r
 void PicoDraw2Init(void)\r
 {\r
-       Pico.est.Draw2FB = PicoDraw2FB_;\r
+       PicoDraw2SetOutBuf(NULL);\r
 }\r
index 1a2e408..ae9f2e1 100644 (file)
@@ -674,6 +674,7 @@ extern int DrawLineDestIncrement;
 extern unsigned int VdpSATCache[128];\r
 \r
 // draw2.c\r
+void PicoDraw2SetOutBuf(void *dest);\r
 void PicoDraw2Init(void);\r
 PICO_INTERNAL void PicoFrameFull();\r
 \r