changeset 2495:88c68a03c493

Add 'help' support to -m, -S and -R options.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 28 Apr 2020 20:55:10 +0300
parents fcaf2db0cd05
children 6a6ed3eeded5
files tools/gfxconv.c
diffstat 1 files changed, 43 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/tools/gfxconv.c	Tue Apr 28 20:34:49 2020 +0300
+++ b/tools/gfxconv.c	Tue Apr 28 20:55:10 2020 +0300
@@ -184,7 +184,7 @@
     { 16, 'f', "format"          , "Set output format (see --formats)", OPT_ARGREQ },
     { 18, 'F', "formats"         , "List supported input/output formats", OPT_NONE },
     { 20, 'q', "sequential"      , "Output sequential files (image output only)", OPT_NONE },
-    { 22, 'm', "colormap"        , "Set color index mapping (see '-m help')", OPT_ARGREQ },
+    { 22, 'm', "colormap"        , "Set color map definitions (see '-m help')", OPT_ARGREQ },
     { 24, 'n', "numitems"        , "How many 'items' to output (default: all)", OPT_ARGREQ },
     { 26, 'w', "width"           , "Item width (number of items per row, min 1)", OPT_ARGREQ },
     { 28, 'S', "scale"           , "Scale output image by specified value(s) (see '-S help')", OPT_ARGREQ },
@@ -252,31 +252,34 @@
 {
     switch (opt)
     {
+        case 22:
+            return
+            "Color map definitions (-m)\n"
+            "--------------------------\n"
+            "Color map definitions are used for sprite/char data input (and ANSI text\n"
+            "output), to set what colors of the C64 palette are used for each single\n"
+            "color/multi color bit-combination.\n"
+            "\n"
+            "For example, if the input is multi color sprite or char, you can define\n"
+            "colors like: -m 0,8,3,15 .. for hires/single color: -m 0,1\n"
+            "\n"
+            "The numbers are palette indexes, and the order is for bit(pair)-values\n"
+            "00, 01, 10, 11 (multi color) and 0, 1 (single color).\n"
+            "\n"
+            "NOTICE! 255 is a special transparency color index; -m 255,2 would use\n"
+            "transparency for '0' bits and and C64 color 2 for '1' bits.\n";
+
         case 28:
             return
             "Output image scaling (-S)\n"
             "-------------------------\n"
-            "Scaling option '-S <n>', '-S <x>:<y>', '-S <x>:<y>*<n>' can be used to set\n"
-            "the direct or relative scale integer factor(s). '-S <n>' sets both height\n"
-            "and width scale factor to <n>. '-S <x>:<y>*<n>' scales width by X*n and\n"
-            "height Y*n. Certain input formats set their default aspect/scale factors.\n"
-            "By prepending -S parameters with asterisk ('*') you can scale relative to\n"
-            "those values. (e.g. '-S *2' for example.) NOTE! Only integer scale factors\n"
-            "can be used at the moment.\n";
-
-        case 22:
-            return
-            "Color index mapping (-m)\n"
-            "------------------------\n"
-            "Color index map definitions are used for sprite/char data input (and ANSI\n"
-            "output), to set what colors of the C64 palette are used for each single\n"
-            "color/multi color bit-combination.\n"
-            "For example, if the input is multi color sprite or char, you can define\n"
-            "colors like: -m 0,8,3,15 .. for hires/single color: -m 0,1\n"
-            "The numbers are palette indexes, and the order is for bit(pair)-values\n"
-            "00, 01, 10, 11 (multi color) and 0, 1 (single color). NOTICE! 255 is the\n"
-            "special transparency color index; -m 255,2 would use transparency for\n"
-            "'0' bits and and C64 color 2 for '1' bits.\n";
+            "Scaling can be done in direct or relative mode with integer scale factors.\n"
+            "\n"
+            "'-S [*]<n>' sets both height and width scale factor to <n> directly or\n"
+            "    relative to the certain input format's default aspect/scale factors.\n"
+            "\n"
+            "'-S <W>:<H>[*<n>]' scales width by W*n and height H*n.\n"
+            "    If <n> is not specified, it defaults to 1.\n";
 
         case 42:
             return
@@ -840,6 +843,12 @@
             break;
 
         case 22:
+            if (strcasecmp(optArg, "help") == 0)
+            {
+                fprintf(stdout, "\n%s\n", argGetHelpTopic(optN));
+                exit(0);
+            }
+            else
             {
                 int ncolors;
                 if (!dmParseMapOptionString(optArg, optColorMap,
@@ -880,6 +889,12 @@
             break;
 
         case 28:
+            if (strcasecmp(optArg, "help") == 0)
+            {
+                fprintf(stdout, "\n%s\n", argGetHelpTopic(optN));
+                exit(0);
+            }
+            else
             {
                 BOOL error = FALSE;
                 unsigned int tmpUInt2;
@@ -1049,6 +1064,12 @@
             break;
 
         case 42:
+            if (strcasecmp(optArg, "help") == 0)
+            {
+                fprintf(stdout, "\n%s\n", argGetHelpTopic(optN));
+                exit(0);
+            }
+
             // Check if any flags/sub-options are specified
             if ((tmpStr = strchr(optArg, '+')) != NULL)
             {