Mercurial > hg > dmlib
diff tools/gfxconv.c @ 2408:60e119262c67
Option index re-ordering cleanup work.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 13 Jan 2020 21:21:25 +0200 |
parents | b7cd5dd0b82e |
children | bc05bcfc4598 |
line wrap: on
line diff
--- a/tools/gfxconv.c Mon Jan 13 21:16:57 2020 +0200 +++ b/tools/gfxconv.c Mon Jan 13 21:21:25 2020 +0200 @@ -159,26 +159,27 @@ static const DMOptArg optList[] = { - { 0, '?', "help", "Show this help", OPT_NONE }, - { 15, 'v', "verbose", "Increase verbosity", OPT_NONE }, - { 3, 'o', "output", "Output filename", OPT_ARGREQ }, - { 4, 's', "skip", "Skip N bytes in input from start (negative value will be offset from input end)", OPT_ARGREQ }, - { 1, 'i', "informat", "Set input format (see --formats)", OPT_ARGREQ }, - { 5, 'f', "format", "Set output format (see --formats)", OPT_ARGREQ }, - { 17, 'F', "formats", "List supported input/output formats", OPT_NONE }, - { 8, 'q', "sequential", "Output sequential files (image output only)", OPT_NONE }, - { 6, 'm', "colormap", "Set color index mapping (see below for information)", OPT_ARGREQ }, - { 7, 'n', "numitems", "How many 'items' to output (default: all)", OPT_ARGREQ }, - { 11, 'w', "width", "Item width (number of items per row, min 1)", OPT_ARGREQ }, - { 9, 'S', "scale", "Scale output image by specified value(s) (see below)", OPT_ARGREQ }, - { 12, 'P', "paletted", "Use indexed/paletted output IF possible.", OPT_NONE }, - { 13, 'N', "nplanes", "# of bitplanes (some output formats)", OPT_ARGREQ }, - { 18, 'B', "bpp", "Bits per plane (some output formats)", OPT_ARGREQ }, - { 14, 'I', "interleave", "Interleaved/planar output (some output formats)", OPT_NONE }, - { 20, 'C', "compress", "Use compression -C <0-9>, 0 = disable, default is 9", OPT_ARGREQ }, - { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, - { 21, 0, "char-rom", "Set character ROM file to be used.", OPT_ARGREQ }, - { 22, 'p', "palette" , "Set C64 palette to be used (see list with -p help).", OPT_ARGREQ }, + { 0, '?', "help" , "Show this help", OPT_NONE }, + { 2, 'v', "verbose" , "Be more verbose", OPT_NONE }, + + { 10, 'o', "output" , "Output filename", OPT_ARGREQ }, + { 12, 's', "skip" , "Skip N bytes in input from start (negative value will be offset from input end)", OPT_ARGREQ }, + { 14, 'i', "informat" , "Set input format (see --formats)", OPT_ARGREQ }, + { 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 below for information)", 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 below)", OPT_ARGREQ }, + { 30, 'P', "paletted" , "Use indexed/paletted output IF possible.", OPT_NONE }, + { 32, 'N', "nplanes" , "# of bitplanes (some output formats)", OPT_ARGREQ }, + { 34, 'B', "bpp" , "Bits per plane (some output formats)", OPT_ARGREQ }, + { 36, 'I', "interleave" , "Interleaved/planar output (some output formats)", OPT_NONE }, + { 38, 'C', "compress" , "Use compression -C <0-9>, 0 = disable, default is 9", OPT_ARGREQ }, + { 40, 'R', "remap" , "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, + { 42, 0, "char-rom" , "Set character ROM file to be used.", OPT_ARGREQ }, + { 44, 'p', "palette" , "Set C64 palette to be used (see list with -p help).", OPT_ARGREQ }, }; static const int optListN = sizeof(optList) / sizeof(optList[0]); @@ -681,16 +682,23 @@ exit(0); break; - case 17: - argShowFormats(); - exit(0); - break; - - case 15: + case 2: dmVerbosity++; break; - case 1: + case 10: + optOutFilename = optArg; + break; + + case 12: + if (!dmGetIntVal(optArg, &optInSkip, &optInSkipNeg)) + { + dmErrorMsg("Invalid skip value argument '%s'.\n", optArg); + return FALSE; + } + break; + + case 14: { DMConvFormat fmt; @@ -707,19 +715,7 @@ } break; - case 3: - optOutFilename = optArg; - break; - - case 4: - if (!dmGetIntVal(optArg, &optInSkip, &optInSkipNeg)) - { - dmErrorMsg("Invalid skip value argument '%s'.\n", optArg); - return FALSE; - } - break; - - case 5: + case 16: { DMConvFormat fmt; @@ -736,15 +732,24 @@ } break; - case 6: + case 18: + argShowFormats(); + exit(0); + break; + + case 20: + optSequential = TRUE; + break; + + case 22: { - int index, ncolors; + int ncolors; if (!dmParseMapOptionString(optArg, optColorMap, &ncolors, D64_NCOLORS, FALSE, "color index option")) return FALSE; dmMsg(1, "Set color index mapping: "); - for (index = 0; index < ncolors; index++) + for (int index = 0; index < ncolors; index++) { dmPrint(1, "[%d:%d]%s", index, optColorMap[index], @@ -754,7 +759,7 @@ } break; - case 7: + case 24: if (!dmGetIntVal(optArg, &tmpUInt, NULL) || tmpUInt < 1) { @@ -765,11 +770,18 @@ optItemCount = tmpUInt; break; - case 8: - optSequential = TRUE; + case 26: + if (!dmGetIntVal(optArg, &tmpUInt, NULL) || + tmpUInt < 1 || tmpUInt > 512) + { + dmErrorMsg("Invalid planed width value '%s' [1 .. 512]\n", + optArg); + return FALSE; + } + optPlanedWidth = tmpUInt; break; - case 9: + case 28: { BOOL error = FALSE; unsigned int tmpUInt2; @@ -836,22 +848,11 @@ } break; - case 11: - if (!dmGetIntVal(optArg, &tmpUInt, NULL) || - tmpUInt < 1 || tmpUInt > 512) - { - dmErrorMsg("Invalid planed width value '%s' [1 .. 512]\n", - optArg); - return FALSE; - } - optPlanedWidth = tmpUInt; - break; - - case 12: + case 30: optUsePalette = TRUE; break; - case 13: + case 32: if (!dmGetIntVal(optArg, &tmpUInt, NULL) || tmpUInt < 1 || tmpUInt > 8) { @@ -862,7 +863,7 @@ optSpec.nplanes = tmpUInt; break; - case 18: + case 34: if (!dmGetIntVal(optArg, &tmpUInt, NULL) || tmpUInt < 1 || tmpUInt > 32) { @@ -873,43 +874,22 @@ optSpec.bpp = tmpUInt; break; - case 14: + case 36: optSpec.planar = TRUE; break; - case 16: - if ((tmpStr = dm_strrcasecmp(optArg, "+remove")) != NULL) - { - optRemapRemove = TRUE; - *tmpStr = 0; - } - - if (optArg[0] == '@') + case 38: + if (!dmGetIntVal(optArg, &tmpUInt, NULL) || + tmpUInt > FCMP_BEST) { - if (optArg[1] != 0) - { - int res; - if ((res = dmParseColorRemapFile(optArg + 1, - optRemapTable, &optNRemapTable, DM_MAX_COLORS)) != DMERR_OK) - return FALSE; - } - else - { - dmErrorMsg("No remap filename given.\n"); - return FALSE; - } + dmErrorMsg("Invalid compression setting '%s' [%d .. %d]\n", + optArg, FCMP_NONE, FCMP_BEST); + return FALSE; } - else - { - if (!dmParseMapOptionString(optArg, optRemapTable, - &optNRemapTable, DM_MAX_COLORS, TRUE, "color remap option")) - return FALSE; - } - - optRemapColors = TRUE; + optSpec.compression = tmpUInt; break; - case 19: + case 39: { int tx0, ty0, tx1, ty1; if (strcasecmp(optArg, "auto") == 0) @@ -942,22 +922,43 @@ } break; - case 20: - if (!dmGetIntVal(optArg, &tmpUInt, NULL) || - tmpUInt > FCMP_BEST) + case 40: + if ((tmpStr = dm_strrcasecmp(optArg, "+remove")) != NULL) + { + optRemapRemove = TRUE; + *tmpStr = 0; + } + + if (optArg[0] == '@') { - dmErrorMsg("Invalid compression setting '%s' [%d .. %d]\n", - optArg, FCMP_NONE, FCMP_BEST); - return FALSE; + if (optArg[1] != 0) + { + int res; + if ((res = dmParseColorRemapFile(optArg + 1, + optRemapTable, &optNRemapTable, DM_MAX_COLORS)) != DMERR_OK) + return FALSE; + } + else + { + dmErrorMsg("No remap filename given.\n"); + return FALSE; + } } - optSpec.compression = tmpUInt; + else + { + if (!dmParseMapOptionString(optArg, optRemapTable, + &optNRemapTable, DM_MAX_COLORS, TRUE, "color remap option")) + return FALSE; + } + + optRemapColors = TRUE; break; - case 21: + case 42: optCharROMFilename = optArg; break; - case 22: + case 44: return argHandleC64PaletteOption(optArg, &optC64Palette, &optPaletteFile); default: