changeset 1774:88354355b8e1

Move dmC64ProbeBMP() to more logical place in the source.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 12 Jun 2018 15:36:00 +0300
parents 9336bfb5b6d1
children 4e4d54135baf
files tools/lib64gfx.c tools/lib64gfx.h
diffstat 2 files changed, 41 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Tue Jun 12 14:31:09 2018 +0300
+++ b/tools/lib64gfx.c	Tue Jun 12 15:36:00 2018 +0300
@@ -676,45 +676,6 @@
 }
 
 
-// Perform probing of the given data buffer, trying to determine
-// if it contains a supported "C64" image format. Returns the
-// "probe score", see libgfx.h for list of values. If a match
-// is found, pointer to format description is set to *pfmt.
-int dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **pfmt)
-{
-    int scoreMax = DM_PROBE_SCORE_FALSE, scoreIndex = -1;
-
-    for (int i = 0; i < ndmC64ImageFormats; i++)
-    {
-        const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
-        int score = DM_PROBE_SCORE_FALSE;
-        if (fmt->probe == NULL && fmt->size > 0 && fmt->addr > 0)
-        {
-            // Generic probe just checks matching size and load address
-            if (len == fmt->size && dmCompareAddr16(buf, 0, fmt->addr))
-                score = DM_PROBE_SCORE_GOOD;
-        }
-        else
-        if (fmt->probe != NULL)
-            score = fmt->probe(buf, len, fmt);
-
-        if (score > scoreMax)
-        {
-            scoreMax = score;
-            scoreIndex = i;
-        }
-    }
-
-    if (scoreIndex >= 0)
-    {
-        *pfmt = &dmC64ImageFormats[scoreIndex];
-        return scoreMax;
-    }
-    else
-        return DM_PROBE_SCORE_FALSE;
-}
-
-
 int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img)
 {
     switch (op->type)
@@ -1474,3 +1435,42 @@
     dmGrowBufFree(buf);
     return res;
 }
+
+
+// Perform probing of the given data buffer, trying to determine
+// if it contains a supported "C64" image format. Returns the
+// "probe score", see libgfx.h for list of values. If a match
+// is found, pointer to format description is set to *pfmt.
+int dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **pfmt)
+{
+    int scoreMax = DM_PROBE_SCORE_FALSE, scoreIndex = -1;
+
+    for (int i = 0; i < ndmC64ImageFormats; i++)
+    {
+        const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
+        int score = DM_PROBE_SCORE_FALSE;
+        if (fmt->probe == NULL && fmt->size > 0 && fmt->addr > 0)
+        {
+            // Generic probe just checks matching size and load address
+            if (len == fmt->size && dmCompareAddr16(buf, 0, fmt->addr))
+                score = DM_PROBE_SCORE_GOOD;
+        }
+        else
+        if (fmt->probe != NULL)
+            score = fmt->probe(buf, len, fmt);
+
+        if (score > scoreMax)
+        {
+            scoreMax = score;
+            scoreIndex = i;
+        }
+    }
+
+    if (scoreIndex >= 0)
+    {
+        *pfmt = &dmC64ImageFormats[scoreIndex];
+        return scoreMax;
+    }
+    else
+        return DM_PROBE_SCORE_FALSE;
+}
--- a/tools/lib64gfx.h	Tue Jun 12 14:31:09 2018 +0300
+++ b/tools/lib64gfx.h	Tue Jun 12 15:36:00 2018 +0300
@@ -280,6 +280,8 @@
 //
 // Miscellaneous functions
 //
+int       dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **fmt);
+
 char *    dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng);
 void      dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt);
 
@@ -304,7 +306,6 @@
 int       dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img);
 BOOL      dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size);
 
-int       dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **fmt);
 
 int       dmC64DecodeGenericBMP(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt);
 int       dmC64EncodeGenericBMP(const BOOL allocate, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt);