changeset 810:cbe263ad963c

Some work on charset conversion.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 15 May 2014 02:05:53 +0300
parents eba3b87f3f84
children aebc2f8b2c2d
files lib64gfx.c tools/gfxconv.c
diffstat 2 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lib64gfx.c	Wed May 14 21:28:14 2014 +0300
+++ b/lib64gfx.c	Thu May 15 02:05:53 2014 +0300
@@ -703,9 +703,7 @@
 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const BOOL doubleMC)
 {
     Uint8 *dp = dst->data;
-    int divisor = doubleMC ? 4 : 8,
-        wdivisor = doubleMC ? 2 : 1,
-        yc;
+    int yc;
 
     // Sanity check arguments
     if (dst == NULL || src == NULL)
@@ -740,6 +738,10 @@
         }
         else
         {
+            const int
+                wdivisor = doubleMC ? 2 : 1,
+                divisor  = doubleMC ? 4 : 8;
+
             for (xc = 0; xc < dst->width / wdivisor; xc++)
             {
                 const int x = xc / divisor;
@@ -765,19 +767,22 @@
                     }
                     c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, vbank, scroffs);
                     *d++ = c;
-                    *d++ = c;
+                    if (doubleMC)
+                        *d++ = c;
                 }
                 else
                 if (src->type & D64_FMT_ILACE)
                 {
                     *d++ = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, src->laceBank1, scroffs);
-                    *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs);
+                    if (doubleMC)
+                        *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs);
                 }
                 else
                 {
                     c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, 0, scroffs);
                     *d++ = c;
-                    *d++ = c;
+                    if (doubleMC)
+                        *d++ = c;
                 }
             }
         }
--- a/tools/gfxconv.c	Wed May 14 21:28:14 2014 +0300
+++ b/tools/gfxconv.c	Thu May 15 02:05:53 2014 +0300
@@ -1618,14 +1618,14 @@
 
                 if (optOutFilename == NULL)
                 {
-                    dmError("Output filename not set, required for image formats.\n");
+                    dmError("Output filename not set, required for bitmap formats.\n");
                     goto error;
                 }
 
                 switch (optOutFormat)
                 {
                     case FFMT_IMAGE:
-                        res = dmC64ConvertBMP2Image(&outImage, &cimage, cfmt, TRUE);
+                        res = dmC64ConvertBMP2Image(&outImage, &cimage, cfmt, FALSE);
 
                         if (res != DMERR_OK || outImage == NULL)
                         {
@@ -1643,6 +1643,14 @@
 
                     case FFMT_CHAR:
                     case FFMT_SPRITE:
+                        res = dmC64ConvertBMP2Image(&outImage, &cimage, cfmt, TRUE);
+
+                        if (res != DMERR_OK || outImage == NULL)
+                        {
+                            dmError("Error in bitmap to template image conversion.\n");
+                            goto error;
+                        }
+
                         res = dmWriteSpritesAndChars(optOutFilename, outImage, optOutFormat, optInMulticolor);
                         break;