changeset 1594:afb49736615a

Implement packed Koala Painter probing.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 14 May 2018 06:38:58 +0300
parents a77876a07425
children 1eb8c1dc81fd
files tools/lib64fmts.c
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64fmts.c	Mon May 14 06:37:29 2018 +0300
+++ b/tools/lib64fmts.c	Mon May 14 06:38:58 2018 +0300
@@ -32,6 +32,19 @@
 
 
 
+static int fmtProbeKoalaPaintPacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
+{
+    // Attempt to prevent misprobes of unpacked Koala and Run Paint
+    if (len > 30 &&
+        len != 10006 &&
+        len != fmt->size &&
+        dmCompareAddr16(buf, 0, fmt->addr))
+        return DM_PROBE_SCORE_MAX;
+
+    return DM_PROBE_SCORE_FALSE;
+}
+
+
 static int fmtDecodeKoalaPaintPacked(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
 {
     int res;
@@ -715,7 +728,7 @@
         D64_FMT_MC, "klp", "Koala Paint (packed)", 0x6000, 0, DM_FMT_RDWR,
         C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
         C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
-        NULL,
+        fmtProbeKoalaPaintPacked,
         fmtDecodeKoalaPaintPacked, fmtEncodeKoalaPaintPacked,
         NULL, NULL,
         NULL,