changeset 2134:5daed72fd211

Improve Marq's PETSCII prg export support.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 28 May 2019 10:50:50 +0300
parents 898c1edadbc6
children cb4689d9ceed
files tools/lib64fmts.c
diffstat 1 files changed, 42 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64fmts.c	Tue May 28 10:35:26 2019 +0300
+++ b/tools/lib64fmts.c	Tue May 28 10:50:50 2019 +0300
@@ -61,24 +61,27 @@
 }
 
 
-static const Uint8 fmtMarqPETSCII_ID[] =
+static const Uint8 fmtMarqPETSCII_ID1[] =
 {
-    0x0b, 0x08, 0xef, 0x00, 0x9e, 0x32, 0x30, 0x36, 0x31, 0x00, 0x00, 0x00,
-    0xa9, 0x0b, 0x8d, 0x11, 0xd0, 0xa9, 0x17, 0x8d, 0x18, 0xd0, 0xa9, 0x0f,
-    0x8d, 0x20, 0xd0, 0xa9, 0x0e, 0x8d, 0x21, 0xd0, 0xa2, 0x00, 0xa0, 0xfa,
-    0xbd, 0x61, 0x08, 0x9d, 0x00, 0x04, 0xbd, 0x5b, 0x09, 0x9d, 0xfa, 0x04,
-    0xbd, 0x55, 0x0a, 0x9d, 0xf4, 0x05, 0xbd, 0x4f, 0x0b, 0x9d, 0xee, 0x06,
-    0xbd, 0x49, 0x0c, 0x9d, 0x00, 0xd8, 0xbd, 0x43, 0x0d, 0x9d, 0xfa, 0xd8,
-    0xbd, 0x3d, 0x0e, 0x9d, 0xf4, 0xd9, 0xbd, 0x37, 0x0f, 0x9d, 0xee, 0xda,
-    0xe8, 0x88, 0xd0, 0xcc, 0xa9, 0x1b, 0x8d, 0x11, 0xd0, 0x4c, 0x5e, 0x08,
+    0x01, 0x08, 0x0b, 0x08, 0xef, 0x00, 0x9e, 0x32, 0x30, 0x36,
+    0x31, 0x00, 0x00, 0x00, 0xa9, 0x0b, 0x8d, 0x11, 0xd0, 0xa9,
 };
 
+static const Uint8 fmtMarqPETSCII_ID2[] =
+{
+    0x8d, 0x21, 0xd0, 0xa2, 0x00, 0xa0, 0xfa, 0xbd, 0x61, 0x08,
+    0x9d, 0x00, 0x04, 0xbd, 0x5b, 0x09, 0x9d, 0xfa, 0x04, 0xbd,
+    0x55, 0x0a, 0x9d, 0xf4,
+};
+
+
 static int fmtProbeMarqPETSCII(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
 {
     (void) fmt;
 
     if (buf->len == 2098 &&
-        DM_MEMCMP_SIZE(buf->data + 2, fmtMarqPETSCII_ID) == 0
+        DM_MEMCMP_SIZE(buf->data, fmtMarqPETSCII_ID1) == 0 &&
+        DM_MEMCMP_SIZE(buf->data + 0x1f, fmtMarqPETSCII_ID2) == 0
         )
         return DM_PROBE_SCORE_MAX;
 
@@ -86,6 +89,29 @@
 }
 
 
+static int fmtGetPixelMarqPETSCII(Uint8 *col,
+    const DMC64Image *img, const int rasterX, const int rasterY)
+{
+    DM_C64_GENERIC_CHAR_PIXEL(img)
+    int chr = img->screen[0].data[scroffs];
+
+    // d018 has been copied to extraData[0].data[0]
+    switch (img->extraData[0].data[0])
+    {
+        case 23: chr += 256; break; // lower case, so add 256 to char ROM offset
+        case 20: break; // upper case
+        default:
+            return DMERR_INVALID_DATA;
+    }
+
+    return dmC64GetGenericCharSCPixel(
+        col, img,
+        scroffs, rasterX,
+        0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr,
+        0, img->bgcolor);
+}
+
+
 static int fmtProbeKoalaPainter(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
 {
     int score = DM_PROBE_SCORE_FALSE;
@@ -2054,15 +2080,17 @@
             D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT,
             1, 1,
             NULL, NULL,
-            NULL,
+            fmtGetPixelMarqPETSCII,
             {
                 { DO_COPY       , DS_SCREEN_RAM  , 0x60, 0, 0,   0, NULL, NULL },
                 { DO_COPY       , DS_COLOR_RAM   , 0x60 + 1000, 0, 0,   0, NULL, NULL },
 
-                { DO_SET_MEM_LO , DS_D020        , 0x17, 0,  0,   0, NULL, NULL },
-                { DO_SET_MEM_LO , DS_BGCOL       , 0x1c, 0,  0,   0, NULL, NULL },
+                // For offset values see petscii/m_c64.pde :: save_prg()
+                { DO_SET_MEM_LO , DS_D020        , 25 - 2, 0,  0,   0, NULL, NULL },
+                { DO_SET_MEM_LO , DS_BGCOL       , 30 - 2, 0,  0,   0, NULL, NULL },
+                { DO_COPY       , DS_EXTRA_DATA  , 20 - 2, 0,  1,   0, NULL, NULL }, // upper/lower
 
-                { DO_LAST       , 0              , 0             , 0, 0,   0, NULL, NULL },
+                { DO_LAST       , 0              , 0     , 0,  0,   0, NULL, NULL },
             }
         },
         NULL