changeset 2345:fe025c461760

Move pixel helper functions from being inline in lib64gfx.h to lib64gfx.c
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 08 Oct 2019 14:49:00 +0300
parents 13e54305e5fc
children 32893335efc0
files tools/lib64gfx.c tools/lib64gfx.h
diffstat 2 files changed, 133 insertions(+), 103 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Wed Sep 25 12:13:28 2019 +0300
+++ b/tools/lib64gfx.c	Tue Oct 08 14:49:00 2019 +0300
@@ -1330,6 +1330,128 @@
 }
 
 
+//
+// Helper functions for pixel format decoding
+//
+int dmC64GetGenericSCPixel(Uint8 *col,
+    const DMC64Image *img, const int bmoffs, const int scroffs,
+    const int vshift, const int vbank, const int bitmap)
+{
+    if ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 1)
+        *col = img->screen[vbank].data[scroffs] >> 4;
+    else
+        *col = img->screen[vbank].data[scroffs] & 15;
+
+    return DMERR_OK;
+}
+
+
+int dmC64GetGenericMCPixel(Uint8 *col,
+    const DMC64Image *img, const int bmoffs, const int scroffs,
+    const int vshift, const int vbank, const int bitmap,
+    const int cbank, const int bgcolor)
+{
+    switch ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 3)
+    {
+        case  0: *col = bgcolor & 15; break;
+        case  1: *col = img->screen[vbank].data[scroffs] >> 4; break;
+        case  2: *col = img->screen[vbank].data[scroffs] & 15; break;
+        default: *col = img->color[cbank].data[scroffs] & 15; break;
+    }
+
+    return DMERR_OK;
+}
+
+
+int dmC64GetGenericCharSCPixel(Uint8 *col,
+    const DMC64Image *img, const int scroffs, const int rasterX,
+    const int chrbank, const size_t chroffs, const int chr,
+    const int cbank, const int bgcolor)
+{
+    if (chroffs >= img->charData[chrbank].size)
+    {
+        return dmError(DMERR_INVALID_DATA,
+            "Character map index #%d out of bounds for char ROM data.\n",
+            chr);
+    }
+
+    const int vshift = 7 - (rasterX & 7);
+    if ((img->charData[chrbank].data[chroffs] >> vshift) & 1)
+        *col = img->color[cbank].data[scroffs] & 15;
+    else
+        *col = bgcolor & 15;
+
+    return DMERR_OK;
+}
+
+
+int dmC64GetGenericCharMCPixel(Uint8 *col,
+    const DMC64Image *img, const int scroffs, const int rasterX,
+    const int chrbank, const size_t chroffs, const int chr,
+    const int cbank, const int bgcolor,
+    const int bgd022, const int bgd023)
+{
+    if (chroffs >= img->charData[chrbank].size)
+    {
+        return dmError(DMERR_INVALID_DATA,
+            "Character map index #%d out of bounds for char ROM data.\n",
+            chr);
+    }
+
+    const int ccol = img->color[cbank].data[scroffs];
+    if (ccol & 8)
+    {
+        const int vshift = 6 - (rasterX & 6);
+        switch ((img->charData[chrbank].data[chroffs] >> vshift) & 3)
+        {
+            case 0: *col = bgcolor & 15; break;
+            case 1: *col = bgd022 & 15; break;
+            case 2: *col = bgd023 & 15; break;
+            case 3: *col = ccol & 7;
+        }
+    }
+    else
+    {
+        const int vshift = 7 - (rasterX & 7);
+        if ((img->charData[chrbank].data[chroffs] >> vshift) & 1)
+            *col = ccol & 7;
+        else
+            *col = bgcolor & 15;
+    }
+
+    return DMERR_OK;
+}
+
+
+int dmC64GetGenericCharECMPixel(Uint8 *col,
+    const DMC64Image *img, const int scroffs, const int rasterX,
+    const int chrbank, const size_t chroffs, const int chr,
+    const int cbank, const int bgcolor,
+    const int bgd022, const int bgd023, const int bgd024)
+{
+    if (chroffs >= img->charData[0].size)
+    {
+        return dmError(DMERR_INVALID_DATA,
+            "Character map index #%d out of bounds for char ROM data.\n",
+            chr);
+    }
+
+    const int vshift = 7 - (rasterX & 7);
+    if ((img->charData[chrbank].data[chroffs] >> vshift) & 1)
+        *col = img->color[cbank].data[scroffs] & 15;
+    else
+    switch ((chr >> 6) & 3)
+    {
+        case 0: *col = bgcolor & 15; break;
+        case 1: *col = bgd022 & 15; break;
+        case 2: *col = bgd023 & 15; break;
+        case 3: *col = bgd024 & 15; break;
+    }
+
+    return DMERR_OK;
+}
+
+
 static int fmtGetGenericSCPixel(DMC64ScanLine *scan,
     const DMC64Image *img, const int rasterX, const int rasterY)
 {
--- a/tools/lib64gfx.h	Wed Sep 25 12:13:28 2019 +0300
+++ b/tools/lib64gfx.h	Tue Oct 08 14:49:00 2019 +0300
@@ -484,125 +484,33 @@
 
 
 //
-// Inline helper functions for pixel format decoding
+// Pixel format helpers
 //
-static inline int dmC64GetGenericSCPixel(Uint8 *col,
+int dmC64GetGenericSCPixel(Uint8 *col,
     const DMC64Image *img, const int bmoffs, const int scroffs,
-    const int vshift, const int vbank, const int bitmap)
-{
-    if ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 1)
-        *col = img->screen[vbank].data[scroffs] >> 4;
-    else
-        *col = img->screen[vbank].data[scroffs] & 15;
+    const int vshift, const int vbank, const int bitmap);
 
-    return DMERR_OK;
-}
-
-
-static inline int dmC64GetGenericMCPixel(Uint8 *col,
+int dmC64GetGenericMCPixel(Uint8 *col,
     const DMC64Image *img, const int bmoffs, const int scroffs,
     const int vshift, const int vbank, const int bitmap,
-    const int cbank, const int bgcolor)
-{
-    switch ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 3)
-    {
-        case  0: *col = bgcolor & 15; break;
-        case  1: *col = img->screen[vbank].data[scroffs] >> 4; break;
-        case  2: *col = img->screen[vbank].data[scroffs] & 15; break;
-        default: *col = img->color[cbank].data[scroffs] & 15; break;
-    }
+    const int cbank, const int bgcolor);
 
-    return DMERR_OK;
-}
-
-
-static inline int dmC64GetGenericCharSCPixel(Uint8 *col,
+int dmC64GetGenericCharSCPixel(Uint8 *col,
     const DMC64Image *img, const int scroffs, const int rasterX,
     const int chrbank, const size_t chroffs, const int chr,
-    const int cbank, const int bgcolor)
-{
-    if (chroffs >= img->charData[chrbank].size)
-    {
-        return dmError(DMERR_INVALID_DATA,
-            "Character map index #%d out of bounds for char ROM data.\n",
-            chr);
-    }
+    const int cbank, const int bgcolor);
 
-    const int vshift = 7 - (rasterX & 7);
-    if ((img->charData[chrbank].data[chroffs] >> vshift) & 1)
-        *col = img->color[cbank].data[scroffs] & 15;
-    else
-        *col = bgcolor & 15;
-
-    return DMERR_OK;
-}
-
-
-static inline int dmC64GetGenericCharMCPixel(Uint8 *col,
+int dmC64GetGenericCharMCPixel(Uint8 *col,
     const DMC64Image *img, const int scroffs, const int rasterX,
     const int chrbank, const size_t chroffs, const int chr,
     const int cbank, const int bgcolor,
-    const int bgd022, const int bgd023)
-{
-    if (chroffs >= img->charData[chrbank].size)
-    {
-        return dmError(DMERR_INVALID_DATA,
-            "Character map index #%d out of bounds for char ROM data.\n",
-            chr);
-    }
+    const int bgd022, const int bgd023);
 
-    const int ccol = img->color[cbank].data[scroffs];
-    if (ccol & 8)
-    {
-        const int vshift = 6 - (rasterX & 6);
-        switch ((img->charData[chrbank].data[chroffs] >> vshift) & 3)
-        {
-            case 0: *col = bgcolor & 15; break;
-            case 1: *col = bgd022 & 15; break;
-            case 2: *col = bgd023 & 15; break;
-            case 3: *col = ccol & 7;
-        }
-    }
-    else
-    {
-        const int vshift = 7 - (rasterX & 7);
-        if ((img->charData[chrbank].data[chroffs] >> vshift) & 1)
-            *col = ccol & 7;
-        else
-            *col = bgcolor & 15;
-    }
-
-    return DMERR_OK;
-}
-
-
-static inline int dmC64GetGenericCharECMPixel(Uint8 *col,
+int dmC64GetGenericCharECMPixel(Uint8 *col,
     const DMC64Image *img, const int scroffs, const int rasterX,
     const int chrbank, const size_t chroffs, const int chr,
     const int cbank, const int bgcolor,
-    const int bgd022, const int bgd023, const int bgd024)
-{
-    if (chroffs >= img->charData[0].size)
-    {
-        return dmError(DMERR_INVALID_DATA,
-            "Character map index #%d out of bounds for char ROM data.\n",
-            chr);
-    }
-
-    const int vshift = 7 - (rasterX & 7);
-    if ((img->charData[chrbank].data[chroffs] >> vshift) & 1)
-        *col = img->color[cbank].data[scroffs] & 15;
-    else
-    switch ((chr >> 6) & 3)
-    {
-        case 0: *col = bgcolor & 15; break;
-        case 1: *col = bgd022 & 15; break;
-        case 2: *col = bgd023 & 15; break;
-        case 3: *col = bgd024 & 15; break;
-    }
-
-    return DMERR_OK;
-}
+    const int bgd022, const int bgd023, const int bgd024);
 
 
 static inline const DMC64EncDecOp * fmtGetEncDecOp(const DMC64ImageFormat *fmt, const int index)