# HG changeset patch # User Matti Hamalainen # Date 1559029850 -10800 # Node ID 5daed72fd2114ac3d98c9444620140804f51c797 # Parent 898c1edadbc67584bd5654b4d1d5017d7260b42e Improve Marq's PETSCII prg export support. diff -r 898c1edadbc6 -r 5daed72fd211 tools/lib64fmts.c --- 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