32x renderer, fix for render buffers with pitch != line width, some speedup
authorkub <derkub@gmail.com>
Wed, 13 Jan 2021 22:27:11 +0000 (23:27 +0100)
committerkub <derkub@gmail.com>
Wed, 13 Jan 2021 22:27:11 +0000 (23:27 +0100)
pico/32x/draw.c
pico/draw.c
pico/mode4.c

index 3ca858d..915748c 100644 (file)
@@ -179,6 +179,7 @@ static void do_loop_dc##name(unsigned short *dst,               \
     p32x = dram + dram[l];                                      \
     do_line_dc(dst, p32x, pmd, inv_bit, md_code);               \
     post_code;                                                  \
+    dst += DrawLineDestIncrement32x/2 - 320;                    \
   }                                                             \
 }                                                               \
                                                                 \
@@ -200,6 +201,7 @@ static void do_loop_pp##name(unsigned short *dst,               \
     p32x += (lines_sft_offs >> 8) & 1;                          \
     do_line_pp(dst, p32x, pmd, md_code);                        \
     post_code;                                                  \
+    dst += DrawLineDestIncrement32x/2 - 320;                    \
   }                                                             \
 }                                                               \
                                                                 \
@@ -220,6 +222,7 @@ static void do_loop_rl##name(unsigned short *dst,               \
     p32x = dram + dram[l];                                      \
     do_line_rl(dst, p32x, pmd, md_code);                        \
     post_code;                                                  \
+    dst += DrawLineDestIncrement32x/2 - 320;                    \
   }                                                             \
 }
 
@@ -337,7 +340,7 @@ void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode)
   if (which == PDF_RGB555) {
     // need CLUT pixels in PicoDraw2FB for layer transparency
     PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328);
-    PicoDrawSetOutBufMD(DrawLineDestBase32x, DrawLineDestIncrement32x);
+    PicoDrawSetOutBufMD(NULL, 0);
   } else {
     // use the same layout as alt renderer
     PicoDrawSetInternalBuf(NULL, 0);
index 3f39796..deb23f9 100644 (file)
@@ -1635,6 +1635,9 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est)
   unsigned short *pal=est->HighPal;\r
   int len;\r
 \r
+  if (DrawLineDestIncrement == 0)\r
+    return;\r
+\r
   PicoDrawUpdateHighPal();\r
 \r
   if (Pico.video.reg[12]&1) {\r
@@ -1693,7 +1696,7 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
     len = 256;\r
   }\r
 \r
-  if (DrawLineDestBase == HighColBase) {\r
+  if (DrawLineDestIncrement == 0) {\r
     if (!sh && (est->rendstatus & PDRAW_SONIC_MODE))\r
       blockcpy_or(pd+8, est->HighCol+8, len, est->SonicPalCount*0x40);\r
   } else if (!sh && (est->rendstatus & PDRAW_SONIC_MODE)) {\r
@@ -1980,6 +1983,7 @@ void PicoDrawUpdateHighPal(void)
 void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode)\r
 {\r
   PicoDrawSetInternalBuf(NULL, 0);\r
+  PicoDrawSetOutBufMD(NULL, 0);\r
   PicoDraw2SetOutBuf(NULL);\r
   switch (which)\r
   {\r
@@ -2009,18 +2013,15 @@ void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode)
 void PicoDrawSetOutBufMD(void *dest, int increment)\r
 {\r
   if (FinalizeLine == FinalizeLine8bit && increment >= 328) {\r
-    // kludge for no-copy mode\r
+    // kludge for no-copy mode, using ALT_RENDERER layout\r
     PicoDrawSetInternalBuf(dest, increment);\r
-  }\r
-\r
-  if (FinalizeLine == NULL)\r
+  } else if (FinalizeLine == NULL) {\r
     PicoDraw2SetOutBuf(dest);\r
-  else if (dest != NULL) {\r
+  else if (dest != NULL) {\r
     DrawLineDestBase = dest;\r
     DrawLineDestIncrement = increment;\r
     Pico.est.DrawLineDest = (char *)DrawLineDestBase + Pico.est.DrawScanline * increment;\r
-  }\r
-  else {\r
+  } else {\r
     DrawLineDestBase = DefOutBuff;\r
     DrawLineDestIncrement = 0;\r
     Pico.est.DrawLineDest = DefOutBuff;\r
index 9e853d4..9cbc1d4 100644 (file)
@@ -366,7 +366,7 @@ static void FinalizeLine8bitM4(int line)
 {
   unsigned char *pd = Pico.est.DrawLineDest;
 
-  if (HighColBase != DrawLineDestBase)
+  if (DrawLineDestIncrement)
     memcpy(pd + line_offset, Pico.est.HighCol + line_offset + 8, 256);
 }