changeset 2367:36226425aac1

Fix Petscii Coca editor format writing.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 07 Jan 2020 15:25:14 +0200
parents 1e6e018b6487
children 4cd67faadbd3
files tools/lib64fmts.c
diffstat 1 files changed, 46 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64fmts.c	Tue Jan 07 15:04:19 2020 +0200
+++ b/tools/lib64fmts.c	Tue Jan 07 15:25:14 2020 +0200
@@ -243,6 +243,48 @@
 }
 
 
+static const Uint8 fmtCocaPETSCII_ID1[] =
+{
+    0x01, 0x08, 0x0b, 0x08, 0x0a, 0x00, 0x9e, 0x32, 0x30, 0x36,
+    0x31, 0x00, 0x00, 0x00, 0x78, 0xa2, 0x00, 0xbd, 0x5a, 0x08,
+    0x9d, 0x00, 0x04, 0xbd, 0x5a, 0x09, 0x9d, 0x00, 0x05, 0xbd,
+    0x5a, 0x0a, 0x9d, 0x00, 0x06, 0xbd, 0x5a, 0x0b, 0x9d, 0x00,
+    0x07, 0xbd, 0x5a, 0x0c, 0x9d, 0x00, 0xd8, 0xbd, 0x5a, 0x0d,
+    0x9d, 0x00, 0xd9, 0xbd, 0x5a, 0x0e, 0x9d, 0x00, 0xda, 0xbd,
+    0x5a, 0x0f, 0x9d, 0x00, 0xdb, 0xe8, 0xd0, 0xcd, 0xad, 0x42,
+    0x0c, 0x8d, 0x20, 0xd0, 0xad, 0x43, 0x0c, 0x8d, 0x21, 0xd0,
+    0xad, 0x44, 0x0c, 0x8d, 0x18, 0xd0, 0x4c, 0x55, 0x08
+};
+
+static int fmtProbeCocaPETSCII(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
+{
+    (void) fmt;
+
+    if (buf->len == 2115 &&
+        DM_MEMCMP_SIZE(buf->data, fmtCocaPETSCII_ID1) == 0 &&
+        buf->data[0x0c44 - 0x0801 + 2] == 0x14)
+        return DM_PROBE_SCORE_MAX;
+
+    return DM_PROBE_SCORE_FALSE;
+}
+
+
+static int fmtEncodeCocaPETSCIIData(const DMC64EncDecOp *op, DMGrowBuf *buf,
+    const DMC64Image *img, const DMC64ImageCommonFormat *fmt)
+{
+    (void) op;
+    (void) img;
+    (void) fmt;
+
+    memcpy(buf->data,
+        fmtCocaPETSCII_ID1, sizeof(fmtCocaPETSCII_ID1));
+
+    buf->data[0x0c44 - 0x0801 + 2] = 0x14;
+
+    return DMERR_OK;
+}
+
+
 static int fmtProbeKoalaPainter(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
 {
     int score = DM_PROBE_SCORE_FALSE;
@@ -2780,8 +2822,8 @@
     },
 
     {
-        "poca", "Petscii Coca editor (unpacked)", 0x0801, 2115, DM_FMT_RDWR,
-        NULL,
+        "poca", "Petscii Coca editor (unpacked)", 0x0801, 0, DM_FMT_RDWR,
+        fmtProbeCocaPETSCII,
         NULL, NULL,
         {
             D64_FMT_HIRES | D64_FMT_CHAR,
@@ -2791,9 +2833,10 @@
             NULL, NULL,
             NULL,
             {
-                { DO_FUNC       , 0              , 0     , 0,  0,   0, NULL, fmtEncodeMarqPETSCIIData, DF_NORMAL },
+                { DO_FUNC       , 0              , 0     , 0,  0,   0, NULL, fmtEncodeCocaPETSCIIData, DF_NORMAL },
                 { DO_COPY       , DS_SCREEN_RAM  , 0x085a - 0x0801, 0,  0,   0, NULL, NULL, DF_NORMAL },
                 { DO_COPY       , DS_COLOR_RAM   , 0x0c5a - 0x0801, 0,  0,   0, NULL, NULL, DF_NORMAL },
+
                 { DO_SET_MEM_LO , DS_D020        , 0x0c42 - 0x0801, 0,  0,   0, NULL, NULL, DF_NORMAL },
                 { DO_SET_MEM_LO , DS_BGCOL       , 0x0c43 - 0x0801, 0,  0,   0, NULL, NULL, DF_NORMAL },