eliminate texrels (wip)
[picodrive.git] / pico / 32x / draw.c
index 66814ab..9500e08 100644 (file)
@@ -43,7 +43,7 @@ static void convert_pal555(int invert_prio)
                                                                   \
   for (i = 320; i > 0; i--, pd++, p32x++, pmd++) {                \
     unsigned short t = *p32x;                                     \
-    if (*pmd != mdbg && !((t ^ inv) & 0x8000)) {                  \
+    if ((*pmd & 0x3f) != mdbg && !((t ^ inv) & 0x8000)) {         \
       pmd_draw_code;                                              \
       continue;                                                   \
     }                                                             \
@@ -59,7 +59,7 @@ static void convert_pal555(int invert_prio)
   int i;                                                          \
   for (i = 320; i > 0; i--, pd++, p32x++, pmd++) {                \
     t = pal[*(unsigned char *)((long)p32x ^ 1)];                  \
-    if ((t & 0x20) || *pmd == mdbg)                               \
+    if ((t & 0x20) || (*pmd & 0x3f) == mdbg)                      \
       *pd = t;                                                    \
     else                                                          \
       pmd_draw_code;                                              \
@@ -74,7 +74,7 @@ static void convert_pal555(int invert_prio)
   for (i = 320; i > 0; p32x++) {                                  \
     t = pal[*p32x & 0xff];                                        \
     for (len = (*p32x >> 8) + 1; len > 0 && i > 0; len--, i--, pd++, pmd++) { \
-      if (*pmd == mdbg || (t & 0x20))                             \
+      if ((*pmd & 0x3f) == mdbg || (t & 0x20))                    \
         *pd = t;                                                  \
       else                                                        \
         pmd_draw_code;                                            \
@@ -82,7 +82,8 @@ static void convert_pal555(int invert_prio)
   }                                                               \
 }
 
-void FinalizeLine32xRGB555(int sh, int line)
+// this is almost never used (Wiz and menu bg gen only)
+void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est)
 {
   unsigned short *pd = DrawLineDest;
   unsigned short *pal = Pico32xMem->pal_native;
@@ -90,7 +91,7 @@ void FinalizeLine32xRGB555(int sh, int line)
   unsigned short *dram, *p32x;
   unsigned char   mdbg;
 
-  FinalizeLine555(sh, line);
+  FinalizeLine555(sh, line, est);
 
   if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0 || // 32x blanking
       // XXX: how is 32col mode hadled by real hardware?
@@ -306,20 +307,23 @@ void PicoDraw32xLayerMdOnly(int offs, int lines)
   }
 }
 
-void PicoDraw32xSetFrameMode(int is_on, int only_32x)
+void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode)
 {
 #ifdef _ASM_32X_DRAW
   extern void *Pico32xNativePal;
   Pico32xNativePal = Pico32xMem->pal_native;
 #endif
 
-  if (is_on) {
-    // use the same layout as alt renderer
-    PicoDrawSetInternalBuf(PicoDraw2FB, 328);
-    Pico32xDrawMode = only_32x ? PDM32X_32X_ONLY : PDM32X_BOTH;
-  } else {
+  if (which == PDF_RGB555 && use_32x_line_mode) {
+    // we'll draw via FinalizeLine32xRGB555 (rare)
     PicoDrawSetInternalBuf(NULL, 0);
     Pico32xDrawMode = PDM32X_OFF;
+    return;
   }
+
+  // use the same layout as alt renderer
+  PicoDrawSetInternalBuf(PicoDraw2FB, 328);
+  Pico32xDrawMode = (which == PDF_RGB555) ? PDM32X_32X_ONLY : PDM32X_BOTH;
 }
 
+// vim:shiftwidth=2:ts=2:expandtab