# HG changeset patch # User Matti Hamalainen # Date 1424894483 -7200 # Node ID ff18d2511843e548da9e117c5111b8bb067f6224 # Parent 5e820addd035e024cce8b1acef928e9348783469 Remove the doubleMC madness completely. Should be replaced with x/y aspect ratio information for display purposes. diff -r 5e820addd035 -r ff18d2511843 tools/gfxconv.c --- a/tools/gfxconv.c Wed Feb 25 21:26:26 2015 +0200 +++ b/tools/gfxconv.c Wed Feb 25 22:01:23 2015 +0200 @@ -1709,7 +1709,7 @@ switch (optOutFormat) { case FFMT_IMAGE: - res = dmC64ConvertBMP2Image(&outImage, cimage, cfmt, FALSE); + res = dmC64ConvertBMP2Image(&outImage, cimage, cfmt); if (res != DMERR_OK || outImage == NULL) { @@ -1727,7 +1727,7 @@ case FFMT_CHAR: case FFMT_SPRITE: - res = dmC64ConvertBMP2Image(&outImage, cimage, cfmt, TRUE); + res = dmC64ConvertBMP2Image(&outImage, cimage, cfmt); if (res != DMERR_OK || outImage == NULL) { diff -r 5e820addd035 -r ff18d2511843 tools/lib64gfx.c --- a/tools/lib64gfx.c Wed Feb 25 21:26:26 2015 +0200 +++ b/tools/lib64gfx.c Wed Feb 25 22:01:23 2015 +0200 @@ -1012,10 +1012,9 @@ // Convert a generic "C64" format bitmap in DMC64Image struct to // a indexed/paletted bitmap image. -int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const BOOL doubleMC) +int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src) { Uint8 *dp = dst->data; - const int wdivisor = doubleMC ? 2 : 1; int yc; // Sanity check arguments @@ -1054,7 +1053,7 @@ } else // Multicolor variants - for (xc = 0; xc < src->width / wdivisor; xc++) + for (xc = 0; xc < src->width; xc++) { const int x = xc / 4; const int scroffs = scroffsy + x; @@ -1071,14 +1070,12 @@ } *d++ = c; - if (doubleMC) - *d++ = c; } } else { // Perform generic BITMAP conversion - const int bmoffsy = y * src->width; + const int bmoffsy = y * src->ch_width * 8 + yb; if ((src->type & D64_FMT_MC) == D64_FMT_HIRES) // Hi-res bitmap @@ -1086,7 +1083,7 @@ { const int x = xc / 8; const int scroffs = scroffsy + x; - const int bmoffs = bmoffsy + (x * 8) + yb; + const int bmoffs = bmoffsy + (x * 8); const int v = 7 - (xc & 7); if ((src->bitmap[0][bmoffs] >> v) & 1) @@ -1096,11 +1093,11 @@ } else // Multicolor bitmap and variants - for (xc = 0; xc < src->width / wdivisor; xc++) + for (xc = 0; xc < src->width; xc++) { const int x = xc / 4; const int scroffs = scroffsy + x; - const int bmoffs = bmoffsy + (x * 8) + yb; + const int bmoffs = bmoffsy + (x * 8); const int v = 6 - ((xc * 2) & 6); Uint8 c; @@ -1121,22 +1118,17 @@ } c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, vbank, scroffs); *d++ = c; - if (doubleMC) - *d++ = c; } else if (src->type & D64_FMT_ILACE) { *d++ = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, src->laceBank1, scroffs); - if (doubleMC) - *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs); + *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs); } else { c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, 0, scroffs); *d++ = c; - if (doubleMC) - *d++ = c; } } } @@ -1147,22 +1139,16 @@ } -int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt, const BOOL doubleMC) +int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt) { - int width, res; + int res; DMImage *dst; if (pdst == NULL || src == NULL) return DMERR_NULLPTR; - // Calculate output image width - if ((src->type & D64_FMT_MC) && !doubleMC) - width = C64_SCR_WIDTH / 2; - else - width = C64_SCR_WIDTH; - // Allocate image structure - if ((*pdst = dst = dmImageAlloc(width, C64_SCR_HEIGHT)) == NULL) + if ((*pdst = dst = dmImageAlloc(src->width, src->height)) == NULL) return DMERR_MALLOC; // Set palette @@ -1172,9 +1158,9 @@ // Convert if (fmt->convertFrom != NULL) - res = fmt->convertFrom(dst, src, doubleMC); + res = fmt->convertFrom(dst, src); else - res = dmC64ConvertGenericBMP2Image(dst, src, doubleMC); + res = dmC64ConvertGenericBMP2Image(dst, src); return res; } diff -r 5e820addd035 -r ff18d2511843 tools/lib64gfx.h --- a/tools/lib64gfx.h Wed Feb 25 21:26:26 2015 +0200 +++ b/tools/lib64gfx.h Wed Feb 25 22:01:23 2015 +0200 @@ -177,7 +177,7 @@ int (*probe)(const Uint8 *buf, const size_t len, const struct _DMC64ImageFormat *fmt); int (*decode)(DMC64Image *img, const Uint8 *buf, const size_t len, const struct _DMC64ImageFormat *fmt); int (*encode)(DMC64Image *img, Uint8 **buf, size_t *len, const struct _DMC64ImageFormat *fmt); - int (*convertFrom)(DMImage *, const DMC64Image *, const BOOL doubleMC); + int (*convertFrom)(DMImage *, const DMC64Image *); int (*convertTo)(DMImage *, DMC64Image *); int nencdecOps; @@ -199,9 +199,9 @@ int dmC64DecodeGenericBMP(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt); int dmC64EncodeGenericBMP(Uint8 **pbuf, size_t *plen, const DMC64Image *img, const DMC64ImageFormat *fmt); -int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const BOOL doubleMC); +int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src); -int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt, const BOOL doubleMC); +int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt); int dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **fmt); int dmC64DecodeBMP(DMC64Image **img, const Uint8 *buf, const size_t len, const size_t probeOffs, const size_t loadOffs, const DMC64ImageFormat **fmt, const DMC64ImageFormat *forced); diff -r 5e820addd035 -r ff18d2511843 tools/view64.c --- a/tools/view64.c Wed Feb 25 21:26:26 2015 +0200 +++ b/tools/view64.c Wed Feb 25 22:01:23 2015 +0200 @@ -232,7 +232,7 @@ } // Create surface (we are lazy and ugly) - surf = SDL_CreateRGBSurface(SDL_SWSURFACE, C64_SCR_WIDTH, C64_SCR_HEIGHT, 8, 0, 0, 0, 0); + surf = SDL_CreateRGBSurface(SDL_SWSURFACE, cimage->width, cimage->height, 8, 0, 0, 0, 0); SDL_SetColors(surf, (SDL_Color *)dmC64Palette, 0, C64_NCOLORS); SDL_SetColors(screen, (SDL_Color *)dmC64Palette, 0, C64_NCOLORS); @@ -245,9 +245,9 @@ bmap.constpal = TRUE; if (fmt->convertFrom != NULL) - ret = fmt->convertFrom(&bmap, cimage, TRUE); + ret = fmt->convertFrom(&bmap, cimage); else - ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, TRUE); + ret = dmC64ConvertGenericBMP2Image(&bmap, cimage); // Set window title and caption