# HG changeset patch # User Matti Hamalainen # Date 1558827944 -10800 # Node ID b49d7cb20a734762e36484a2ffccc0b4c18b2f4b # Parent 51b8826bd4c134029605ec510f28d003639b9ce8 Implement initial ECM support in charmap decoding. diff -r 51b8826bd4c1 -r b49d7cb20a73 tools/lib64gfx.c --- a/tools/lib64gfx.c Sun May 26 02:44:34 2019 +0300 +++ b/tools/lib64gfx.c Sun May 26 02:45:44 2019 +0300 @@ -36,9 +36,11 @@ char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng) { + static const char *fmtModesShort[] = { "MC", "HiRes", "ECM" }; + static const char *fmtModesLong[] = { "MultiColor", "HiRes", "Extended Color Mode" }; snprintf(buf, len, - "%s%s%s%s", - (type & D64_FMT_MC) ? (lng ? "MultiColor " : "MC ") : "HiRes ", + "%s %s%s%s", + lng ? fmtModesLong[type & D64_FMT_MASK] : fmtModesShort[type & D64_FMT_MASK], (type & D64_FMT_ILACE) ? (lng ? "Interlaced " : "ILace ") : "", (type & D64_FMT_FLI) ? "FLI " : "", (type & D64_FMT_CHAR) ? "CHAR" : "" @@ -1299,7 +1301,7 @@ if (src->fmt->type & D64_FMT_CHAR) { // Charmode conversion - if ((src->fmt->type & D64_FMT_MC) == D64_FMT_HIRES) + if ((src->fmt->type & D64_FMT_MASK) == D64_FMT_HIRES) { // Hi-res charmap const int x = xc / 8; @@ -1313,6 +1315,27 @@ *dp++ = src->bgcolor; } else + if ((src->fmt->type & D64_FMT_MASK) == D64_FMT_ECM) + { + // Hi-res ECM charmap + const int x = xc / 8; + const int scroffs = scroffsy + x; + const int vshift = 7 - (xc & 7); + const int chr = src->screen[0].data[scroffs]; + + if ((src->charData[0].data[(chr & 0x3f) * C64_CHR_SIZE + yb] >> vshift) & 1) + *dp++ = src->color[0].data[scroffs] & 15; + else + switch ((chr >> 6) & 3) + { + case 0: *dp++ = src->bgcolor; break; + case 1: *dp++ = src->d022; break; + case 2: *dp++ = src->d023; break; + case 3: *dp++ = src->d024; break; + } + } + else + if ((src->fmt->type & D64_FMT_MASK) == D64_FMT_MC) { // Multicolor charmap const int x = xc / 4; @@ -1344,7 +1367,7 @@ else { // Perform generic BITMAP conversion - if ((src->fmt->type & D64_FMT_MC) == D64_FMT_HIRES) + if ((src->fmt->type & D64_FMT_MASK) == D64_FMT_HIRES) { // Hi-res bitmap const int x = xc / 8; diff -r 51b8826bd4c1 -r b49d7cb20a73 tools/lib64gfx.h --- a/tools/lib64gfx.h Sun May 26 02:44:34 2019 +0300 +++ b/tools/lib64gfx.h Sun May 26 02:45:44 2019 +0300 @@ -53,10 +53,13 @@ { D64_FMT_HIRES = 0x0000, // Hi-res D64_FMT_MC = 0x0001, // MultiColor - D64_FMT_ILACE = 0x0002, // Interlace - D64_FMT_FLI = 0x0004, // FLI - D64_FMT_CHAR = 0x0008, // Character mode - D64_FMT_BORDER = 0x0010, // Uses border area + D64_FMT_ECM = 0x0002, // ECM mode (applies only to character mode) + D64_FMT_MASK = 0x000f, + + D64_FMT_ILACE = 0x0010, // Interlace + D64_FMT_FLI = 0x0020, // FLI + D64_FMT_CHAR = 0x0040, // Character mode + D64_FMT_BORDER = 0x0080, // Uses border area };