Mercurial > hg > dmlib
comparison tools/gfxconv.c @ 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 |
comparison
equal
deleted
inserted
replaced
2494:fcaf2db0cd05 | 2495:88c68a03c493 |
---|---|
182 { 12, 's', "skip" , "Skip N bytes in input from start (negative value will be offset from input end)", OPT_ARGREQ }, | 182 { 12, 's', "skip" , "Skip N bytes in input from start (negative value will be offset from input end)", OPT_ARGREQ }, |
183 { 14, 'i', "informat" , "Set input format (see --formats)", OPT_ARGREQ }, | 183 { 14, 'i', "informat" , "Set input format (see --formats)", OPT_ARGREQ }, |
184 { 16, 'f', "format" , "Set output format (see --formats)", OPT_ARGREQ }, | 184 { 16, 'f', "format" , "Set output format (see --formats)", OPT_ARGREQ }, |
185 { 18, 'F', "formats" , "List supported input/output formats", OPT_NONE }, | 185 { 18, 'F', "formats" , "List supported input/output formats", OPT_NONE }, |
186 { 20, 'q', "sequential" , "Output sequential files (image output only)", OPT_NONE }, | 186 { 20, 'q', "sequential" , "Output sequential files (image output only)", OPT_NONE }, |
187 { 22, 'm', "colormap" , "Set color index mapping (see '-m help')", OPT_ARGREQ }, | 187 { 22, 'm', "colormap" , "Set color map definitions (see '-m help')", OPT_ARGREQ }, |
188 { 24, 'n', "numitems" , "How many 'items' to output (default: all)", OPT_ARGREQ }, | 188 { 24, 'n', "numitems" , "How many 'items' to output (default: all)", OPT_ARGREQ }, |
189 { 26, 'w', "width" , "Item width (number of items per row, min 1)", OPT_ARGREQ }, | 189 { 26, 'w', "width" , "Item width (number of items per row, min 1)", OPT_ARGREQ }, |
190 { 28, 'S', "scale" , "Scale output image by specified value(s) (see '-S help')", OPT_ARGREQ }, | 190 { 28, 'S', "scale" , "Scale output image by specified value(s) (see '-S help')", OPT_ARGREQ }, |
191 { 30, 'P', "paletted" , "Use indexed/paletted output IF possible.", OPT_NONE }, | 191 { 30, 'P', "paletted" , "Use indexed/paletted output IF possible.", OPT_NONE }, |
192 { 32, 'N', "nplanes" , "# of bitplanes (some output formats)", OPT_ARGREQ }, | 192 { 32, 'N', "nplanes" , "# of bitplanes (some output formats)", OPT_ARGREQ }, |
250 | 250 |
251 const char * argGetHelpTopic(const int opt) | 251 const char * argGetHelpTopic(const int opt) |
252 { | 252 { |
253 switch (opt) | 253 switch (opt) |
254 { | 254 { |
255 case 22: | |
256 return | |
257 "Color map definitions (-m)\n" | |
258 "--------------------------\n" | |
259 "Color map definitions are used for sprite/char data input (and ANSI text\n" | |
260 "output), to set what colors of the C64 palette are used for each single\n" | |
261 "color/multi color bit-combination.\n" | |
262 "\n" | |
263 "For example, if the input is multi color sprite or char, you can define\n" | |
264 "colors like: -m 0,8,3,15 .. for hires/single color: -m 0,1\n" | |
265 "\n" | |
266 "The numbers are palette indexes, and the order is for bit(pair)-values\n" | |
267 "00, 01, 10, 11 (multi color) and 0, 1 (single color).\n" | |
268 "\n" | |
269 "NOTICE! 255 is a special transparency color index; -m 255,2 would use\n" | |
270 "transparency for '0' bits and and C64 color 2 for '1' bits.\n"; | |
271 | |
255 case 28: | 272 case 28: |
256 return | 273 return |
257 "Output image scaling (-S)\n" | 274 "Output image scaling (-S)\n" |
258 "-------------------------\n" | 275 "-------------------------\n" |
259 "Scaling option '-S <n>', '-S <x>:<y>', '-S <x>:<y>*<n>' can be used to set\n" | 276 "Scaling can be done in direct or relative mode with integer scale factors.\n" |
260 "the direct or relative scale integer factor(s). '-S <n>' sets both height\n" | 277 "\n" |
261 "and width scale factor to <n>. '-S <x>:<y>*<n>' scales width by X*n and\n" | 278 "'-S [*]<n>' sets both height and width scale factor to <n> directly or\n" |
262 "height Y*n. Certain input formats set their default aspect/scale factors.\n" | 279 " relative to the certain input format's default aspect/scale factors.\n" |
263 "By prepending -S parameters with asterisk ('*') you can scale relative to\n" | 280 "\n" |
264 "those values. (e.g. '-S *2' for example.) NOTE! Only integer scale factors\n" | 281 "'-S <W>:<H>[*<n>]' scales width by W*n and height H*n.\n" |
265 "can be used at the moment.\n"; | 282 " If <n> is not specified, it defaults to 1.\n"; |
266 | |
267 case 22: | |
268 return | |
269 "Color index mapping (-m)\n" | |
270 "------------------------\n" | |
271 "Color index map definitions are used for sprite/char data input (and ANSI\n" | |
272 "output), to set what colors of the C64 palette are used for each single\n" | |
273 "color/multi color bit-combination.\n" | |
274 "For example, if the input is multi color sprite or char, you can define\n" | |
275 "colors like: -m 0,8,3,15 .. for hires/single color: -m 0,1\n" | |
276 "The numbers are palette indexes, and the order is for bit(pair)-values\n" | |
277 "00, 01, 10, 11 (multi color) and 0, 1 (single color). NOTICE! 255 is the\n" | |
278 "special transparency color index; -m 255,2 would use transparency for\n" | |
279 "'0' bits and and C64 color 2 for '1' bits.\n"; | |
280 | 283 |
281 case 42: | 284 case 42: |
282 return | 285 return |
283 "Palette remapping (-R)\n" | 286 "Palette remapping (-R)\n" |
284 "----------------------\n" | 287 "----------------------\n" |
838 case 20: | 841 case 20: |
839 optSequential = TRUE; | 842 optSequential = TRUE; |
840 break; | 843 break; |
841 | 844 |
842 case 22: | 845 case 22: |
846 if (strcasecmp(optArg, "help") == 0) | |
847 { | |
848 fprintf(stdout, "\n%s\n", argGetHelpTopic(optN)); | |
849 exit(0); | |
850 } | |
851 else | |
843 { | 852 { |
844 int ncolors; | 853 int ncolors; |
845 if (!dmParseMapOptionString(optArg, optColorMap, | 854 if (!dmParseMapOptionString(optArg, optColorMap, |
846 &ncolors, D64_NCOLORS, FALSE, "color index option")) | 855 &ncolors, D64_NCOLORS, FALSE, "color index option")) |
847 return FALSE; | 856 return FALSE; |
878 } | 887 } |
879 optPlanedWidth = tmpUInt; | 888 optPlanedWidth = tmpUInt; |
880 break; | 889 break; |
881 | 890 |
882 case 28: | 891 case 28: |
892 if (strcasecmp(optArg, "help") == 0) | |
893 { | |
894 fprintf(stdout, "\n%s\n", argGetHelpTopic(optN)); | |
895 exit(0); | |
896 } | |
897 else | |
883 { | 898 { |
884 BOOL error = FALSE; | 899 BOOL error = FALSE; |
885 unsigned int tmpUInt2; | 900 unsigned int tmpUInt2; |
886 char *tmpStr = dm_strdup(optArg), | 901 char *tmpStr = dm_strdup(optArg), |
887 *tmpOpt = tmpStr, sep; | 902 *tmpOpt = tmpStr, sep; |
1047 } | 1062 } |
1048 } | 1063 } |
1049 break; | 1064 break; |
1050 | 1065 |
1051 case 42: | 1066 case 42: |
1067 if (strcasecmp(optArg, "help") == 0) | |
1068 { | |
1069 fprintf(stdout, "\n%s\n", argGetHelpTopic(optN)); | |
1070 exit(0); | |
1071 } | |
1072 | |
1052 // Check if any flags/sub-options are specified | 1073 // Check if any flags/sub-options are specified |
1053 if ((tmpStr = strchr(optArg, '+')) != NULL) | 1074 if ((tmpStr = strchr(optArg, '+')) != NULL) |
1054 { | 1075 { |
1055 *tmpStr++ = 0; | 1076 *tmpStr++ = 0; |
1056 do | 1077 do |