changeset 2299:ad019d930401

Add initial (broken) read support for Flinterlazer 1.0 images.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 04 Jul 2019 11:09:51 +0300
parents b5abfff07ca9
children a494e4a4b6bc
files tools/lib64fmts.c
diffstat 1 files changed, 115 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64fmts.c	Thu Jul 04 10:54:16 2019 +0300
+++ b/tools/lib64fmts.c	Thu Jul 04 11:09:51 2019 +0300
@@ -935,6 +935,91 @@
 }
 
 
+static int fmtGetPixelFlinterlazer(Uint8 *col,
+    const DMC64Image *img, const int rasterX, const int rasterY)
+{
+    DM_C64_GENERIC_MC_PIXEL_DEFS(img)
+    const int vbank = rasterY & 7;
+    int res;
+    Uint8 color1, color2;
+    Uint8 bgcol = img->bgcolor;
+    if ((res = dmC64GetGenericMCPixel(&color1, img, bmoffs, scroffs, vshift, vbank    , 0, 0, bgcol)) != DMERR_OK)
+        return res;
+    *col = color1 * 17;
+    return DMERR_OK;
+}
+
+
+enum
+{
+    I_BRK            = 0x00,
+    I_RTS            = 0x60,
+    I_LDA_IMD        = 0xa9,
+    I_STA_ABS        = 0x8d,
+};
+
+
+static int fmtDecode6502SpeedCode(const DMGrowBuf *buf, DMC64Image *img, const int cbank)
+{
+    size_t reg_pc = 0;
+    Uint8 reg_accu = 0;//, reg_x = 0, reg_y = 0;
+    Uint16 reg_ptr;
+
+    while (reg_pc < buf->size)
+    {
+        Uint8 instr = buf->data[reg_pc++];
+
+        switch (instr)
+        {
+            case I_LDA_IMD:
+                if (reg_pc >= buf->size)
+                    goto out;
+
+                reg_accu = buf->data[reg_pc++];
+                break;
+
+            case I_STA_ABS:
+                if (reg_pc >= buf->size)
+                    goto out;
+                reg_ptr = buf->data[reg_pc++];
+
+                if (reg_pc >= buf->size)
+                    goto out;
+                reg_ptr |= buf->data[reg_pc++] << 8;
+
+                if (reg_ptr >= 0xd800 && reg_ptr <= 0xdbff)
+                {
+                    img->color[cbank].data[reg_ptr - 0xd800] = reg_accu;
+                }
+                break;
+
+            case I_RTS:
+                return DMERR_OK;
+
+            default:
+                return DMERR_INVALID_DATA;
+        }
+    }
+
+out:
+    return DMERR_INVALID_DATA;
+}
+
+
+static int fmtDecodeFlinterlazer(const DMC64EncDecOp *op, DMC64Image *img,
+    const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt)
+{
+    DMGrowBuf tmp;
+    (void) op;
+    (void) fmt;
+
+    // Flinterlazer stores color RAMs as speedcode, so we need to
+    // decode some 6510 instructions to get the data.
+    return fmtDecode6502SpeedCode(
+        dmGrowBufConstCopyOffsSize(&tmp, buf, 0, 0x17b2), img, 0);
+}
+
+
 #define XX2_MIN_SIZE   4000
 #define XX2_WIDTH_CH   40
 #define XX2_HEIGHT_CH  10
@@ -2364,6 +2449,36 @@
     },
 
     {
+        "flnt", "Flinterlazer 1.0 (unpacked)", 0x284e, 38812, DM_FMT_RD | DM_FMT_BROKEN,
+        NULL,
+        NULL, NULL,
+        {
+            D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE,
+            D64_SCR_WIDTH / 2, D64_SCR_HEIGHT,
+            D64_SCR_CH_WIDTH , D64_SCR_CH_HEIGHT,
+            2, 1,
+            NULL, NULL,
+            fmtGetPixelFlinterlazer,
+            {
+                { DO_COPY       , DS_COLOR_RAM   , 0x0000         , 0,  0    ,   0, NULL, NULL, DF_NORMAL },
+                { DO_COPY       , DS_COLOR_RAM   , 0x0000         , 1,  0    ,   0, NULL, NULL, DF_NORMAL },
+
+                { DO_COPY       , DS_BITMAP_RAM  , 0x4000 - 0x284e, 0,  0    ,   0, NULL, NULL, DF_NORMAL },
+                DEF_REPEAT_BLOCK_8(DS_SCREEN_RAM , 0x6000 - 0x284e, 0,  0x400,   0, DF_NORMAL),
+
+                { DO_COPY       , DS_BITMAP_RAM  , 0x8000 - 0x284e, 1,  0    ,   0, NULL, NULL, DF_NORMAL },
+                DEF_REPEAT_BLOCK_8(DS_SCREEN_RAM , 0xA000 - 0x284e, 1,  0x400,   0, DF_NORMAL),
+
+                { DO_SET_OP     , DS_EXTRA_INFO  , D64_ILACE_COLOR, 0 , 0    ,   D64_EI_ILACE_TYPE, NULL, NULL, DF_DECODE },
+                { DO_SET_OP     , DS_EXTRA_INFO  , D64_FLI_8      , 0,  0    ,   D64_EI_FLI_TYPE, NULL, NULL, DF_DECODE },
+                { DO_FUNC       , 0              , 0     , 0,  0,   0, fmtDecodeFlinterlazer, NULL, DF_NORMAL },
+                { DO_LAST       , 0              , 0              , 0,  0    ,   0, NULL, NULL, DF_NORMAL },
+            }
+        },
+        NULL
+    },
+
+    {
         "eci", "ECI Graphic Editor 1.0 (unpacked)", 0x4000, 32770, DM_FMT_RDWR,
         NULL,
         NULL, NULL,