Procházet zdrojové kódy

32x renderer, fix for render buffers with pitch != line width, some speedup

kub před 3 roky
rodič
revize
aa97a0a01f
3 změnil soubory, kde provedl 14 přidání a 10 odebrání
  1. 4 1
      pico/32x/draw.c
  2. 9 8
      pico/draw.c
  3. 1 1
      pico/mode4.c

+ 4 - 1
pico/32x/draw.c

@@ -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);

+ 9 - 8
pico/draw.c

@@ -1635,6 +1635,9 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est)
   unsigned short *pal=est->HighPal;
   int len;
 
+  if (DrawLineDestIncrement == 0)
+    return;
+
   PicoDrawUpdateHighPal();
 
   if (Pico.video.reg[12]&1) {
@@ -1693,7 +1696,7 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
     len = 256;
   }
 
-  if (DrawLineDestBase == HighColBase) {
+  if (DrawLineDestIncrement == 0) {
     if (!sh && (est->rendstatus & PDRAW_SONIC_MODE))
       blockcpy_or(pd+8, est->HighCol+8, len, est->SonicPalCount*0x40);
   } else if (!sh && (est->rendstatus & PDRAW_SONIC_MODE)) {
@@ -1980,6 +1983,7 @@ void PicoDrawUpdateHighPal(void)
 void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode)
 {
   PicoDrawSetInternalBuf(NULL, 0);
+  PicoDrawSetOutBufMD(NULL, 0);
   PicoDraw2SetOutBuf(NULL);
   switch (which)
   {
@@ -2009,18 +2013,15 @@ void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode)
 void PicoDrawSetOutBufMD(void *dest, int increment)
 {
   if (FinalizeLine == FinalizeLine8bit && increment >= 328) {
-    // kludge for no-copy mode
+    // kludge for no-copy mode, using ALT_RENDERER layout
     PicoDrawSetInternalBuf(dest, increment);
-  }
-
-  if (FinalizeLine == NULL)
+  } else if (FinalizeLine == NULL) {
     PicoDraw2SetOutBuf(dest);
-  else if (dest != NULL) {
+  } else if (dest != NULL) {
     DrawLineDestBase = dest;
     DrawLineDestIncrement = increment;
     Pico.est.DrawLineDest = (char *)DrawLineDestBase + Pico.est.DrawScanline * increment;
-  }
-  else {
+  } else {
     DrawLineDestBase = DefOutBuff;
     DrawLineDestIncrement = 0;
     Pico.est.DrawLineDest = DefOutBuff;

+ 1 - 1
pico/mode4.c

@@ -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);
 }