diff tools/gfxconv.c @ 2265:48b48251610a

Refactor how the image "mode/type" is handled. It is still not perfect for our purposes, but better now.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 17 Jun 2019 02:03:35 +0300
parents fe974f670d1d
children 9269a32ba7f9
line wrap: on
line diff
--- a/tools/gfxconv.c	Mon Jun 17 01:44:54 2019 +0300
+++ b/tools/gfxconv.c	Mon Jun 17 02:03:35 2019 +0300
@@ -1272,19 +1272,20 @@
     dst->d024    = src->d024;
 
     // Try to do some simple fixups
-    if ((dst->fmt->type & D64_FMT_MODE_MASK) == D64_FMT_MC &&
-        (src->fmt->type & D64_FMT_MODE_MASK) == D64_FMT_HIRES)
+    if ((dst->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_MC &&
+        (src->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_HIRES)
     {
         dmC64MemBlockCopy(&dst->screen[0], &src->screen[0]);
     }
     else
-    if ((dst->fmt->type & D64_FMT_MODE_MASK) == D64_FMT_HIRES &&
-        (src->fmt->type & D64_FMT_MODE_MASK) == D64_FMT_MC)
+    if ((dst->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_HIRES &&
+        (src->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_MC)
     {
         // XXX TODO: Handle FLI mc->hires differently?
     }
 
-    if ((dst->fmt->type & D64_FMT_FLI) && (src->fmt->type & D64_FMT_FLI) == 0)
+    if ((dst->extraInfo[D64_EI_MODE] & D64_FMT_FLI) &&
+        (src->extraInfo[D64_EI_MODE] & D64_FMT_FLI) == 0)
     {
         dmMsg(1, "Upconverting multicolor to FLI.\n");
         for (int i = 0; i < dst->nblocks; i++)
@@ -1300,7 +1301,8 @@
         }
     }
     else
-    if ((src->fmt->type & D64_FMT_FLI) && (dst->fmt->type & D64_FMT_FLI) == 0)
+    if ((src->extraInfo[D64_EI_MODE] & D64_FMT_FLI) &&
+        (dst->extraInfo[D64_EI_MODE] & D64_FMT_FLI) == 0)
     {
         dmMsg(1, "Downconverting FLI to multicolor.\n");
     }
@@ -2102,7 +2104,7 @@
         {
             forced = &dmC64ImageFormats[optForcedInSubFormat];
             dmMsg(0, "Forced '%s' format image, type %d, %s\n",
-                forced->name, forced->format->type, forced->fext);
+                forced->name, forced->format->mode, forced->fext);
         }
 
         res = dmC64DecodeBMP(&inC64Image,
@@ -2112,7 +2114,7 @@
         if (forced == NULL && inC64Fmt != NULL && res == DMERR_OK)
         {
             dmMsg(1, "Probed '%s' format image, type %d, %s\n",
-                inC64Fmt->name, inC64Fmt->format->type, inC64Fmt->fext);
+                inC64Fmt->name, inC64Fmt->format->mode, inC64Fmt->fext);
 
             optInType = FFMT_BITMAP;
         }
@@ -2225,7 +2227,7 @@
                 case FFMT_CHAR:
                 case FFMT_SPRITE:
                     // Set character data if required
-                    if ((inC64Fmt->format->type & D64_FMT_CHAR) &&
+                    if ((inC64Image->extraInfo[D64_EI_MODE] & D64_FMT_CHAR) &&
                         inC64Image->charData[0].data == NULL)
                     {
                         // Check character ROM filename