# HG changeset patch # User Matti Hamalainen # Date 1589303184 -10800 # Node ID a40de347fcb0f9e8d3ee9191e7a3f30dd9fdc973 # Parent bf1d671fc9994da6651bfe5f65320305db159454 Make c64 formats listing (optionally) more verbose. Handle --help a bit differently in gfxconv. diff -r bf1d671fc999 -r a40de347fcb0 tools/64vw.c --- a/tools/64vw.c Sat May 02 08:25:12 2020 +0300 +++ b/tools/64vw.c Tue May 12 20:06:24 2020 +0300 @@ -147,7 +147,7 @@ break; case 16: - argShowC64Formats(stdout, FALSE); + argShowC64Formats(stdout, FALSE, TRUE); exit(0); break; diff -r bf1d671fc999 -r a40de347fcb0 tools/gfxconv.c --- a/tools/gfxconv.c Sat May 02 08:25:12 2020 +0300 +++ b/tools/gfxconv.c Tue May 12 20:06:24 2020 +0300 @@ -132,7 +132,9 @@ optOutFormat = -1, optItemCount = -1, optPlanedWidth = 1, - optForcedInSubFormat = -1; + optForcedInSubFormat = -1, + optShowHelp = 0; + unsigned int optInSkip = 0; BOOL optInSkipNeg = FALSE; @@ -233,8 +235,6 @@ "(Not all input->output combinations are actually supported.)\n" "\n" ); - - argShowC64Formats(stdout, TRUE); } @@ -763,22 +763,11 @@ switch (optN) { case 0: - argShowHelp(); - exit(0); + optShowHelp = 1; break; case 3: - argShowHelp(); - argShowFormats(); - argShowC64PaletteHelp(stdout); - - for (int n = 0; n < optListN; n++) - { - const char *str = argGetHelpTopic(optList[n].id); - if (str != NULL) - fprintf(stdout, "\n%s\n", str); - } - exit(0); + optShowHelp = 2; break; case 1: @@ -837,8 +826,7 @@ break; case 18: - argShowFormats(); - exit(0); + optShowHelp = 3; break; case 20: @@ -2635,6 +2623,35 @@ argHandleOpt, argHandleFile, OPTH_BAILOUT)) exit(1); + switch (optShowHelp) + { + case 1: + argShowHelp(); + exit(0); + break; + + case 2: + argShowHelp(); + argShowFormats(); + argShowC64Formats(stdout, TRUE, TRUE); + argShowC64PaletteHelp(stdout); + + for (int n = 0; n < optListN; n++) + { + const char *str = argGetHelpTopic(optList[n].id); + if (str != NULL) + fprintf(stdout, "\n%s\n", str); + } + exit(0); + break; + + case 3: + argShowFormats(); + argShowC64Formats(stdout, TRUE, dmVerbosity > 0); + exit(0); + break; + } + // Determine input format, if not specified if (optInType == FFMT_AUTO && optInFilename != NULL) { diff -r bf1d671fc999 -r a40de347fcb0 tools/lib64gfx.h --- a/tools/lib64gfx.h Sat May 02 08:25:12 2020 +0300 +++ b/tools/lib64gfx.h Tue May 12 20:06:24 2020 +0300 @@ -297,7 +297,7 @@ char *fext; // Filename extension char *name; // Format description/name - size_t addr; // Loading address (0 if no loading address) + ssize_t addr; // Loading address ( -2 if no loading address, -1 if loading address not known) size_t size; // Size, including loading address. Only used in probing and encoding. int flags; // DM_FMT_* flags (read/write/broken/etc.), see libgfx.h diff -r bf1d671fc999 -r a40de347fcb0 tools/lib64util.c --- a/tools/lib64util.c Sat May 02 08:25:12 2020 +0300 +++ b/tools/lib64util.c Tue May 12 20:06:24 2020 +0300 @@ -220,14 +220,16 @@ } -void argShowC64Formats(FILE *fh, const BOOL rw) +void argShowC64Formats(FILE *fh, const BOOL rw, const BOOL verbose) { fprintf(fh, "Available C64 bitmap formats (-f ):\n" - " frmt %s| Type | Description\n" - "------%s+-----------------+-------------------------------------\n", + " frmt %s| Type %s| Description\n" + "------%s+-----------------%s+-------------------------------------\n", rw ? "| RW " : "", - rw ? "+----" : "" + verbose ? "| Load | Size " : "", + rw ? "+----" : "", + verbose ? "+-------+-------" : "" ); for (int i = 0; i < ndmC64ImageFormats; i++) @@ -247,8 +249,28 @@ } fprintf(fh, - "| %-15s | %s%s\n", - dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->mode, FALSE), + "| %-15s ", + dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->mode, FALSE) + ); + + if (verbose) + { + fprintf(fh, "| $%04x ", + (uint32_t) fmt->addr); + + if (fmt->size > 0) + { + fprintf(fh, "| $%04" DM_PRIx_SIZE_T " ", + fmt->size); + } + else + { + fprintf(fh, "| "); + } + } + + fprintf(fh, + "| %s%s\n", fmt->name, fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : ""); } diff -r bf1d671fc999 -r a40de347fcb0 tools/lib64util.h --- a/tools/lib64util.h Sat May 02 08:25:12 2020 +0300 +++ b/tools/lib64util.h Tue May 12 20:06:24 2020 +0300 @@ -37,7 +37,7 @@ void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt, const char *indent); void argShowC64PaletteHelp(FILE *fh); -void argShowC64Formats(FILE *fh, const BOOL rw); +void argShowC64Formats(FILE *fh, const BOOL rw, const BOOL verbose); BOOL argHandleC64PaletteOption(char *optArg, DMC64Palette **ppal, char **palFile); int dmHandleExternalPalette(const char *filename, DMPalette **ppal);