changeset 529:1bce06b5026f

Combine conversion of interlaced and normal multicolor images to one function.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 22 Nov 2012 03:23:05 +0200
parents 0961b6983b8e
children 5b37a2e427b7
files lib64gfx.c
diffstat 1 files changed, 15 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/lib64gfx.c	Thu Nov 22 02:38:12 2012 +0200
+++ b/lib64gfx.c	Thu Nov 22 03:23:05 2012 +0200
@@ -612,41 +612,22 @@
         {
             const int x = xc / 4;
             const int scroffs = scroffsy + x;
-            const int b = img->bitmap[0][bmoffsy + (x * 8) + yb];
-            const int v = 6 - ((xc * 2) & 6);
-            const Uint8 c = dmC64GetMCColor(img, (b >> v) & 3, 0, scroffs);
-            *d++ = c;
-            *d++ = c;
-        }
-
-        dp += screen->pitch;
-    }
-
-    return DMERR_OK;
-}
-
-
-static int dmC64ConvertLaceMultiColorBMP(DMImage *screen, const DMC64Image *img)
-{
-    int yc;
-    Uint8 *dp = screen->data;
-    
-    for (yc = 0; yc < C64_SCR_HEIGHT; yc++)
-    {
-        Uint8 *d = dp;
-        const int y = yc / 8, yb = yc & 7;
-        const int scroffsy = y * C64_SCR_CH_WIDTH;
-        const int bmoffsy = y * C64_SCR_WIDTH;
-        int xc;
-
-        for (xc = 0; xc < C64_SCR_WIDTH / 2; xc++)
-        {
-            const int x = xc / 4;
-            const int scroffs = scroffsy + x;
             const int bmoffs = bmoffsy + (x * 8) + yb;
             const int v = 6 - ((xc * 2) & 6);
-            *d++ = dmC64GetMCColor(img, (img->bitmap[0][bmoffs] >> v) & 3, 0, scroffs);
-            *d++ = dmC64GetMCColor(img, (img->bitmap[1][bmoffs] >> v) & 3, img->laceBank2, scroffs);
+            switch (img->type)
+            {
+                case DM_C64IFMT_MC:
+                    {
+                    const Uint8 c = dmC64GetMCColor(img, (img->bitmap[0][bmoffs] >> v) & 3, 0, scroffs);
+                    *d++ = c;
+                    *d++ = c;
+                    }
+                    break;
+                case DM_C64IFMT_MC_ILACE:
+                    *d++ = dmC64GetMCColor(img, (img->bitmap[0][bmoffs] >> v) & 3, 0, scroffs);
+                    *d++ = dmC64GetMCColor(img, (img->bitmap[1][bmoffs] >> v) & 3, img->laceBank2, scroffs);
+                    break;
+            }
         }
 
         dp += screen->pitch;
@@ -666,11 +647,9 @@
             return dmC64ConvertHiResBMP(dst, src);
         
         case DM_C64IFMT_MC:
+        case DM_C64IFMT_MC_ILACE:
             return dmC64ConvertMultiColorBMP(dst, src);
 
-        case DM_C64IFMT_MC_ILACE:
-            return dmC64ConvertLaceMultiColorBMP(dst, src);
-
         default:
             return DMERR_NOT_SUPPORTED;
     }