# HG changeset patch # User Matti Hamalainen # Date 1506279651 -10800 # Node ID 979f550ead7748aab9c8baf9f810375669301ab8 # Parent 4f81528aa4f6a1958878c3e2f35059832a3e5fab Implement GunPaint support. Possibly not working correctly. diff -r 4f81528aa4f6 -r 979f550ead77 tools/lib64gfx.c --- a/tools/lib64gfx.c Sun Sep 24 21:45:35 2017 +0300 +++ b/tools/lib64gfx.c Sun Sep 24 22:00:51 2017 +0300 @@ -336,6 +336,17 @@ } +static int fmtProbeGunPaint(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) +{ + if (len > 0x400 && + dmCompareAddr16(buf, 0, fmt->addr) && + strncmp((const char *) (buf + 0x3ea), "GUNPAINT (JZ) ", 14) == 0) + return DM_PROBE_SCORE_MAX; + + return DM_PROBE_SCORE_FALSE; +} + + #define AMICA_DM_PROBE_SIZE 2048 static int fmtProbeAmicaPaintPacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) { @@ -344,7 +355,8 @@ return DM_PROBE_SCORE_FALSE; // Interpaint Hi-Res gives a false positive - if (len == 9002) + // as do some GunPaint images .. + if (len == 9002 || fmtProbeGunPaint(buf, len, fmt) > DM_PROBE_SCORE_GOOD) return DM_PROBE_SCORE_FALSE; for (n = 0, i = 2; i < len; i++) @@ -509,6 +521,33 @@ } +static Uint8 fmtGetPixelGunPaint( + const DMC64Image *img, const int bmoffs, const int scroffs, + const int vshift, const int vbitmap, const int raster) +{ + const int vbank = (raster & 7);// + (vbitmap * 8); + int vr, vb; + if (raster < 177) + { + vb = 0; + vr = raster; + } + else + { + vb = 0; + vr = raster - 177; + } + + switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3) + { + case 0: return img->extraData[vb][vr] & 15; break; + case 1: return img->screen[vbank][scroffs] >> 4; break; + case 2: return img->screen[vbank][scroffs] & 15; break; + default: return img->color[0][scroffs] & 15; break; + } +} + + static Uint8 fmtGetPixelBMFLI( const DMC64Image *img, const int bmoffs, const int scroffs, const int vshift, const int vbitmap, const int raster) @@ -844,6 +883,24 @@ } }, + { + D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, "gun", "GunPaint (unpacked)", 0x4000, 0, + C64_SCR_WIDTH, C64_SCR_HEIGHT, + C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, + fmtProbeGunPaint, NULL, + NULL, NULL, NULL, fmtGetPixelGunPaint, + { + DEF_SCREEN_RAMS_8(0x0000, 0) + { DT_BITMAP, 0x2000, 0, 0, NULL, NULL }, + { DT_EXTRA_DATA, 0x3f4f, 0, 177, NULL, NULL }, + { DT_COLOR_RAM, 0x4000, 0, 0, NULL, NULL }, + DEF_SCREEN_RAMS_8(0x4400, 8) + { DT_BITMAP, 0x6400, 1, 0, NULL, NULL }, + { DT_EXTRA_DATA, 0x47e8, 1, 20, NULL, NULL }, + { DT_LAST, 0, 0, 0, NULL, NULL }, + } + }, + }; const int ndmC64ImageFormats = sizeof(dmC64ImageFormats) / sizeof(dmC64ImageFormats[0]);