diff tools/gfxconv.c @ 1545:3b613fcbf3ff

Improve how format read/write capabilities are marked and shown.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 12 May 2018 21:01:46 +0300
parents 416d7b3ba3b2
children 228e71d66089
line wrap: on
line diff
--- a/tools/gfxconv.c	Sat May 12 21:00:22 2018 +0300
+++ b/tools/gfxconv.c	Sat May 12 21:01:46 2018 +0300
@@ -49,7 +49,7 @@
 {
     char *name;       // Descriptive name of the format
     char *fext;       // File extension
-    BOOL in, out;     // Can read/write?
+    int flags;        // DM_FMT_* flags, see libgfx.h
     int format;       // Format identifier
     int subformat;    // Subformat identifier
 } DMConvFormat;
@@ -57,52 +57,17 @@
 
 static DMConvFormat convFormatList[] =
 {
-    {
-        "ASCII text", "asc", FALSE, TRUE,
-        FFMT_ASCII  , 0,
-    },
-    {
-        "ANSI colored text", "ansi", FALSE, TRUE,
-        FFMT_ANSI   , 0,
-    },
-    {
-        "PNG image file", "png", TRUE, TRUE,
-        FFMT_IMAGE  , DM_IMGFMT_PNG,
-    },
-    {
-        "PPM image file", "ppm", FALSE, TRUE,
-        FFMT_IMAGE  , DM_IMGFMT_PPM,
-    },
-    {
-        "PCX image file", "pcx", TRUE, TRUE,
-        FFMT_IMAGE  , DM_IMGFMT_PCX,
-    },
-    {
-        "IFF ILBM file", "lbm", TRUE, FALSE,
-        FFMT_IMAGE  , DM_IMGFMT_ILBM,
-    },
-    {
-        "Bitplaned RAW (intl/non-intl) image file", "raw", FALSE, TRUE,
-        FFMT_IMAGE  , DM_IMGFMT_RAW,
-    },
-    {
-        "IFFMaster RAW image file", "araw", FALSE, TRUE,
-        FFMT_IMAGE  , DM_IMGFMT_ARAW,
-    },
-
-    {
-        "C64 bitmap image file", NULL, TRUE, TRUE,
-        FFMT_BITMAP , -1,
-    },
-
-    {
-        "C64 character/font data", "chr", TRUE, TRUE,
-        FFMT_CHAR   , 0
-    },
-    {
-        "C64 sprite data", "spr", TRUE, TRUE,
-        FFMT_SPRITE , 0
-    },
+    { "ASCII text"                           , "asc"   , DM_FMT_WR   , FFMT_ASCII  , 0 },
+    { "ANSI colored text"                    , "ansi"  , DM_FMT_WR   , FFMT_ANSI   , 0 },
+    { "PNG image"                            , "png"   , DM_FMT_RDWR , FFMT_IMAGE  , DM_IMGFMT_PNG },
+    { "PPM image"                            , "ppm"   , DM_FMT_WR   , FFMT_IMAGE  , DM_IMGFMT_PPM },
+    { "PCX image"                            , "pcx"   , DM_FMT_RDWR , FFMT_IMAGE  , DM_IMGFMT_PCX },
+    { "IFF ILBM"                             , "lbm"   , DM_FMT_RD   , FFMT_IMAGE  , DM_IMGFMT_ILBM },
+    { "Bitplaned RAW (intl/non-intl) image"  , "raw"   , DM_FMT_WR   , FFMT_IMAGE  , DM_IMGFMT_RAW },
+    { "IFFMaster RAW image"                  , "araw"  , DM_FMT_WR   , FFMT_IMAGE  , DM_IMGFMT_ARAW },
+    { "C64 bitmap image"                     , NULL    , DM_FMT_RDWR , FFMT_BITMAP , -1  },
+    { "C64 character/font data"              , "chr"   , DM_FMT_RDWR , FFMT_CHAR   , 0 },
+    { "C64 sprite data"                      , "spr"   , DM_FMT_RDWR , FFMT_SPRITE , 0 },
 };
 
 static const int nconvFormatList = sizeof(convFormatList) / sizeof(convFormatList[0]);
@@ -180,20 +145,19 @@
 
 void argShowFormats()
 {
-
     printf(
-    "Available input/output formats:\n"
-    "  Ext | I | O | Description\n"
-    "------+---+---+-----------------------------------------------\n"
+    "Available input/output formats (-f <frmt>):\n"
+    " frmt | RW | Description\n"
+    "------+----+-------------------------------------------------------\n"
     );
 
     for (int i = 0; i < nconvFormatList; i++)
     {
-        DMConvFormat *fmt = &convFormatList[i];
-        printf("%-5s | %c | %c | %s\n",
+        const DMConvFormat *fmt = &convFormatList[i];
+        printf("%-5s | %c%c | %s\n",
             fmt->fext ? fmt->fext : "",
-            fmt->in ? 'X' : ' ',
-            fmt->out ? 'X' : ' ',
+            (fmt->flags & DM_FMT_RD) ? 'R' : ' ',
+            (fmt->flags & DM_FMT_WR) ? 'W' : ' ',
             fmt->name);
     }
 
@@ -201,17 +165,19 @@
     "\n"
     "(Not all input->output combinations are actually supported.)\n"
     "\n"
-    "Available bitmap formats (-f <bfrm>):\n"
-    " bfrm | Type            | Description\n"
-    "------+-----------------+-------------------------------------\n"
+    "Available C64 bitmap formats (-f <bfrm>):\n"
+    " frmt | RW | Type            | Description\n"
+    "------+----+-----------------+-------------------------------------\n"
     );
 
     for (int i = 0; i < ndmC64ImageFormats; i++)
     {
         const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
         char buf[64];
-        printf("%-5s | %-15s | %s\n",
+        printf("%-5s | %c%c | %-15s | %s\n",
             fmt->fext,
+            (fmt->flags & DM_FMT_RD) ? 'R' : ' ',
+            (fmt->flags & DM_FMT_WR) ? 'W' : ' ',
             dmC64GetImageTypeString(buf, sizeof(buf), fmt->type, FALSE),
             fmt->name);
     }