changeset 1651:6dd191d04ea8

Implement support for Boogie Down Paint 5 (packed) format.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 30 May 2018 03:26:13 +0300
parents 9233da9de92c
children 70fde5e03c2e
files tools/lib64fmts.c
diffstat 1 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64fmts.c	Wed May 30 03:25:34 2018 +0300
+++ b/tools/lib64fmts.c	Wed May 30 03:26:13 2018 +0300
@@ -192,6 +192,41 @@
 }
 
 
+static int fmtProbeBDP5Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
+{
+    const char *ident = (const char *) buf + 2;
+
+    if (len > 20 &&
+        dmCompareAddr16(buf, 0, fmt->addr) &&
+        strncmp(ident, "BDP 5.00", 8) == 0)
+        return DM_PROBE_SCORE_MAX;
+
+    return DM_PROBE_SCORE_FALSE;
+}
+
+
+static int fmtDecodeBDP5Packed(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
+{
+    int res;
+    DMGrowBuf mem;
+    DMCompParams cfg;
+
+    cfg.type        = DM_COMP_RLE_MARKER;
+    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_16BIT_RUNS | DM_RLE_ORDER_1;
+    cfg.rleMarker1  = buf[8];
+    cfg.rleMarker2  = buf[9];
+
+    if ((res = dmDecodeGenericRLEAlloc(&mem, buf + 10, buf + len, &cfg)) != DMERR_OK)
+        goto out;
+
+    res = dmC64DecodeGenericBMP(img, mem.data, mem.len, fmt);
+
+out:
+    dmGrowBufFree(&mem);
+    return res;
+}
+
+
 static int fmtProbeGunPaint(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
 {
     if (len > 0x400 &&
@@ -816,6 +851,24 @@
     },
 
     {
+        D64_FMT_MC, "bdp5", "Boogie Down Paint 5 (packed)", 0x5000, 0, DM_FMT_RD,
+        C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
+        C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
+        fmtProbeBDP5Packed,
+        fmtDecodeBDP5Packed, NULL,
+        NULL, NULL,
+        NULL,
+        {
+            { DT_BITMAP_RAM,   0x0000, 0,  0, NULL, NULL },
+            { DT_SCREEN_RAM,   0x1f40, 0,  0, NULL, NULL },
+            { DT_COLOR_RAM,    0x2328, 0,  0, NULL, NULL },
+            { DT_COLOR_REG,    0x2710, 0,  DC_BGCOL, NULL, NULL },
+            { DT_LAST,         0,      0,  0, NULL, NULL },
+        },
+        NULL
+    },
+
+    {
         D64_FMT_MC, "vid", "Vidcom 64 (unpacked)", 0x5800, 10050, DM_FMT_RDWR,
         C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
         C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,