changeset 1777:a7f9e12bcd9b

Improve probing of FunPaint 2 packed vs. unpacked format variants.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 12 Jun 2018 18:20:00 +0300
parents aa427e68e114
children e8041923767d
files tools/lib64fmts.c
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64fmts.c	Tue Jun 12 17:56:35 2018 +0300
+++ b/tools/lib64fmts.c	Tue Jun 12 18:20:00 2018 +0300
@@ -576,9 +576,17 @@
     if (len > 30 &&
         dmCompareAddr16(buf, 0, fmt->addr) &&
         memcmp(buf + 2, fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) == 0)
-        return DM_PROBE_SCORE_MAX;
-    else
-        return DM_PROBE_SCORE_FALSE;
+    {
+        // Unpacked variant
+        if (fmt->size != 0 && buf[14 + 2] == 0)
+            return DM_PROBE_SCORE_MAX;
+
+        // Packed variant
+        if (fmt->size == 0 && buf[14 + 2] != 0)
+            return DM_PROBE_SCORE_MAX;
+    }
+
+    return DM_PROBE_SCORE_FALSE;
 }
 
 
@@ -1510,7 +1518,7 @@
 
     {
         "fp2p", "FunPaint II (packed)", 0x3ff0, 0, DM_FMT_RDWR,
-        NULL,
+        fmtProbeFunPaint2,
         fmtDecodeFunPaint2, fmtEncodeFunPaint2Packed,
         { }, &dmC64CommonFormats[3]
     },