# HG changeset patch # User Matti Hamalainen # Date 1526005387 -10800 # Node ID c71b6c5204afb02152439528d06ffb857224d7f9 # Parent 06df2bdf5dc4e61a5e923a4cd26fb905ea81a30f Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw. diff -r 06df2bdf5dc4 -r c71b6c5204af tools/64vw.c --- a/tools/64vw.c Fri May 11 04:55:28 2018 +0300 +++ b/tools/64vw.c Fri May 11 05:23:07 2018 +0300 @@ -164,44 +164,6 @@ } -void dmDumpC64Image(const char *filename, const DMC64Image *img, const DMC64ImageFormat *fmt) -{ - char typeStr[64]; - - dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->type); - - dmPrint(1, - "\n%s\n" - "Format : %s [%s]\n" - "Type : %s\n" - "Banks : %d\n", - filename, - fmt->name, fmt->fext, - typeStr, - img->nbanks); - - if (img->type & D64_FMT_ILACE) - { - char *tmps; - switch(img->laceType) - { - case D64_ILACE_COLOR: tmps = "color"; break; - case D64_ILACE_RES: tmps = "resolution"; break; - default: tmps = "ERROR"; break; - } - dmPrint(1, - "Interlace type : %s\n", - tmps); - } - - dmPrint(1, - "Width x Height : %d x %d\n" - "CHwidth x CHheight : %d x %d\n", - img->width, img->height, - img->chWidth, img->chHeight); -} - - int dmReadC64Image(const char *filename, const DMC64ImageFormat *forced, const DMC64ImageFormat **fmt, DMC64Image **cimage) { Uint8 *dataBuf = NULL; @@ -300,7 +262,8 @@ } else { - dmDumpC64Image(filename, cimage, fmt); + fprintf(stdout, "\n%s\n", filename); + dmC64ImageDump(stdout, cimage, fmt); } dmC64ImageFree(cimage); @@ -417,7 +380,11 @@ cimage->width, cimage->height, currIndex + 1, noptFilenames2); - dmDumpC64Image(filename, cimage, fmt); + if (dmVerbosity >= 1) + { + fprintf(stdout, "\n%s\n", filename); + dmC64ImageDump(stdout, cimage, fmt); + } } fail: diff -r 06df2bdf5dc4 -r c71b6c5204af tools/lib64gfx.c --- a/tools/lib64gfx.c Fri May 11 04:55:28 2018 +0300 +++ b/tools/lib64gfx.c Fri May 11 05:23:07 2018 +0300 @@ -41,6 +41,47 @@ #define DM_GET_ADDR_HI(addr) (((addr) >> 8) & 0xff) +void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt) +{ + char typeStr[64]; + + dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->type); + + if (fmt != NULL) + { + fprintf(fh, + "Format : %s [%s]\n", + fmt->name, fmt->fext); + } + + fprintf(fh, + "Type : %s\n" + "Banks : %d\n", + typeStr, + img->nbanks); + + if (img->type & D64_FMT_ILACE) + { + char *tmps; + switch(img->laceType) + { + case D64_ILACE_COLOR: tmps = "color"; break; + case D64_ILACE_RES: tmps = "resolution"; break; + default: tmps = "ERROR"; break; + } + fprintf(fh, + "Interlace type : %s\n", + tmps); + } + + fprintf(fh, + "Width x Height : %d x %d\n" + "CHwidth x CHheight : %d x %d\n", + img->width, img->height, + img->chWidth, img->chHeight); +} + + void dmSetDefaultC64Palette(DMImage *img) { img->constpal = TRUE; diff -r 06df2bdf5dc4 -r c71b6c5204af tools/lib64gfx.h --- a/tools/lib64gfx.h Fri May 11 04:55:28 2018 +0300 +++ b/tools/lib64gfx.h Fri May 11 05:23:07 2018 +0300 @@ -194,6 +194,8 @@ extern const DMC64ImageFormat dmC64ImageFormats[]; extern const int ndmC64ImageFormats; + +void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt); void dmSetDefaultC64Palette(DMImage *img);