Mercurial > hg > dmlib
diff tools/lib64gfx.c @ 940:ff18d2511843
Remove the doubleMC madness completely. Should be replaced with x/y aspect
ratio information for display purposes.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 25 Feb 2015 22:01:23 +0200 |
parents | 5e820addd035 |
children | 8eacbc38b043 |
line wrap: on
line diff
--- 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; }