changeset 2118:05a6e00b09d0

Change D64_FMT_* MASK constants and how they are used.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 26 May 2019 17:51:24 +0300
parents 91d5caf0ff82
children 3c7c45715a49
files tools/lib64gfx.c tools/lib64gfx.h
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Sun May 26 05:20:47 2019 +0300
+++ b/tools/lib64gfx.c	Sun May 26 17:51:24 2019 +0300
@@ -36,8 +36,9 @@
 
 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng)
 {
-    static const char *fmtModesShort[] = { "HiRes", "MC", "ECM" };
-    static const char *fmtModesLong[] = { "HiRes", "MultiColor", "Extended Color Mode" };
+    static const char *fmtModesShort[] = { "ERROR", "HiR", "MC", "ECM" };
+    static const char *fmtModesLong[] = { "ERROR", "HiRes", "MultiColor", "Extended Color Mode" };
+
     snprintf(buf, len,
         "%s %s%s%s",
         lng ? fmtModesLong[type & D64_FMT_MASK] : fmtModesShort[type & D64_FMT_MASK],
@@ -1281,7 +1282,15 @@
     if (src->fmt->getPixel != NULL)
         getPixel = src->fmt->getPixel;
     else
-        getPixel = (src->fmt->type & D64_FMT_MC) ? fmtGetGenericMCPixel : fmtGetGenericSCPixel;
+    switch (src->fmt->type & D64_FMT_MASK)
+    {
+        case D64_FMT_MC: getPixel = fmtGetGenericMCPixel; break;
+        case D64_FMT_HIRES: getPixel = fmtGetGenericSCPixel; break;
+        default:
+            return dmError(DMERR_INVALID_DATA,
+                "Invalid bitmap image type/fmt=%d.\n",
+                src->fmt->type);
+    }
 
     // Resolution interlaced pics need to halve the source width
     int rwidth = dst->width, rheight = dst->height;
--- a/tools/lib64gfx.h	Sun May 26 05:20:47 2019 +0300
+++ b/tools/lib64gfx.h	Sun May 26 17:51:24 2019 +0300
@@ -51,9 +51,9 @@
 // Different supported flags/modes
 enum
 {
-    D64_FMT_HIRES        = 0x0000, // Hi-res
-    D64_FMT_MC           = 0x0001, // MultiColor
-    D64_FMT_ECM          = 0x0002, // ECM mode (applies only to character mode)
+    D64_FMT_HIRES        = 0x0001, // Hi-res
+    D64_FMT_MC           = 0x0002, // MultiColor
+    D64_FMT_ECM          = 0x0003, // ECM mode (applies only to character mode)
     D64_FMT_MASK         = 0x000f,
 
     D64_FMT_ILACE        = 0x0010, // Interlace