# HG changeset patch # User Matti Hamalainen # Date 1506281182 -10800 # Node ID f3c5f80511aecce2a341f4e2ccbc7586bb6e0ef8 # Parent e3794fb2df83e79ad04d3707386bd840bd5588c4 Add "probe only" mode to view64. diff -r e3794fb2df83 -r f3c5f80511ae tools/view64.c --- a/tools/view64.c Sun Sep 24 22:02:54 2017 +0300 +++ b/tools/view64.c Sun Sep 24 22:26:22 2017 +0300 @@ -16,6 +16,7 @@ int optVFlags = SDL_SWSURFACE | SDL_HWPALETTE; int optScrWidth, optScrHeight; int optForcedFormat = -1; +BOOL optProbeOnly = FALSE; static const DMOptArg optList[] = @@ -25,6 +26,7 @@ { 2, 0, "fs", "Fullscreen", OPT_NONE }, { 3, 'S', "scale", "Scale image by factor (1-10)", OPT_ARGREQ }, { 4, 'f', "format", "Force input format (see list below)", OPT_ARGREQ }, + { 5, 'p', "probe", "Probe only (no display)", OPT_NONE }, }; const int optListN = sizeof(optList) / sizeof(optList[0]); @@ -113,6 +115,10 @@ } break; + case 5: + optProbeOnly = TRUE; + break; + default: dmErrorMsg("Unknown option '%s'.\n", currArg); return FALSE; @@ -149,7 +155,7 @@ } -void dmDumpC64Image(const DMC64Image *img) +void dmDumpC64Image(const size_t size, const DMC64Image *img, const DMC64ImageFormat *fmt) { char typeStr[64]; @@ -161,10 +167,15 @@ ((img->type & D64_FMT_CHAR) ? " CHAR" : "") ); - dmPrint(0, + dmPrint(1, + "Format : %s [%s]\n" + "Data size : %" DM_PRIu_SIZE_T "\n" "Type : %s\n" "Banks : %d\n", - typeStr, img->nbanks); + fmt->name, fmt->fext, + size, + typeStr, + img->nbanks); if (img->type & D64_FMT_ILACE) { @@ -175,12 +186,12 @@ case D64_ILACE_RES: tmps = "resolution"; break; default: tmps = "ERROR"; break; } - dmPrint(0, + dmPrint(1, "Interlace type : %s\n", tmps); } - dmPrint(0, + dmPrint(1, "Width x Height : %d x %d\n" "CHwidth x CHheight : %d x %d\n", img->width, img->height, @@ -216,16 +227,16 @@ goto error; } + dmPrint(1, "\n%s\n", optFilename); if ((ret = dmReadDataFile(NULL, optFilename, &dataBuf, &dataSize)) != DMERR_OK) goto error; - dmMsg(1, "Read %d bytes of input.\n", dataSize); // Probe for format if (optForcedFormat >= 0) { forced = &dmC64ImageFormats[optForcedFormat]; - dmMsg(0,"Forced %s format image, type %d, %s\n", + dmMsg(0, "Forced %s format image, type %d, %s\n", forced->name, forced->type, forced->fext); } else @@ -239,19 +250,16 @@ goto error; } - if (forced == NULL && fmt != NULL) - { - dmPrint(0, "Probed %s format image, type %d, %s\n", - fmt->name, fmt->type, fmt->fext); - } - if (fmt == NULL) { dmErrorMsg("Probing could not find any matching image format. Perhaps try forcing a format via -f.\n"); goto error; } - dmDumpC64Image(cimage); + dmDumpC64Image(dataSize, cimage, fmt); + + if (optProbeOnly) + goto error; // Initialize libSDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0)