# HG changeset patch # User Matti Hamalainen # Date 1559118698 -10800 # Node ID fdd0fd7dc0e63b5242ee2d79890fcadfb1ada964 # Parent 903effcd616bf404d3bd2b3098230f1420e200c2 Some more work on charmap and PETSCII support. diff -r 903effcd616b -r fdd0fd7dc0e6 tools/lib64fmts.c --- a/tools/lib64fmts.c Wed May 29 10:24:53 2019 +0300 +++ b/tools/lib64fmts.c Wed May 29 11:31:38 2019 +0300 @@ -89,19 +89,45 @@ } -static int fmtGetPixelMarqPETSCII(Uint8 *col, +static int fmtGetPixelPETSCII(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]) + if (img->extraData[0].data != NULL) + { + // Marq's PETSCII editor + // 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; + } + } + else + if (img->extraData[1].data != NULL) { - case 23: chr += 256; break; // lower case, so add 256 to char ROM offset - case 20: break; // upper case - default: - return DMERR_INVALID_DATA; + // petscii.krissz.hu editor + if (img->extraData[1].data[0x0028 - 2] == 0xd8) + { + return dmC64GetGenericCharMCPixel( + col, img, + scroffs, rasterX, + 0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr, + 0, img->bgcolor, img->d022, img->d023); + } + else + if (img->extraData[1].data[0x0028 - 2] == 0x01) + { + return dmC64GetGenericCharECMPixel( + col, img, + scroffs, rasterX, + 0, ((chr & 0x3f) * D64_CHR_SIZE) + (rasterY & 7), chr, + 0, img->bgcolor, img->d022, img->d023, img->d024); + } } return dmC64GetGenericCharSCPixel( @@ -115,8 +141,12 @@ static const Uint8 fmtPetsciiKrisszHu_ID1[] = { 0x01, 0x08, 0x0b, 0x08, 0x0A, 0x00, 0x9E, 0x32, 0x30, 0x36, - 0x31, 0x00, 0x00, 0x00, 0xA9, 0x1B, 0x8D, 0x11, 0xD0, 0xA9, - 0x80, 0x8D, 0x91, 0x02, 0xA9, + 0x31, 0x00, 0x00, 0x00, 0xA9, +}; + +static const Uint8 fmtPetsciiKrisszHu_ID2[] = +{ + 0x8d, 0x11, 0xd0, 0xa9, 0x80, 0x8d, 0x91, 0x02, 0xa9, 0x18, }; @@ -125,7 +155,8 @@ (void) fmt; if (buf->len == 10193 && - DM_MEMCMP_SIZE(buf->data, fmtPetsciiKrisszHu_ID1) == 0 + DM_MEMCMP_SIZE(buf->data, fmtPetsciiKrisszHu_ID1) == 0 && + DM_MEMCMP_SIZE(buf->data + 0x10, fmtPetsciiKrisszHu_ID2) == 0 ) return DM_PROBE_SCORE_MAX; @@ -2091,8 +2122,9 @@ NULL, NULL, { }, &dmC64CommonFormats[8] }, + { - "pet", "Marq's PETSCII (unpacked)", 0x0801, 0, DM_FMT_RD, + "mrqp", "Marq's PETSCII editor (unpacked)", 0x0801, 0, DM_FMT_RD, fmtProbeMarqPETSCII, NULL, NULL, { @@ -2101,7 +2133,7 @@ D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT, 1, 1, NULL, NULL, - fmtGetPixelMarqPETSCII, + fmtGetPixelPETSCII, { { DO_COPY , DS_SCREEN_RAM , 0x60, 0, 0, 0, NULL, NULL }, { DO_COPY , DS_COLOR_RAM , 0x60 + 1000, 0, 0, 0, NULL, NULL }, @@ -2118,7 +2150,7 @@ }, { - "pkhu", "petscii.krissz.hu (unpacked)", 0x0801, 0, DM_FMT_RD, + "pkhu", "petscii.krissz.hu editor (unpacked)", 0x0801, 0, DM_FMT_RD, fmtProbePetsciiKrisszHu, NULL, NULL, { @@ -2127,15 +2159,23 @@ D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT, 1, 1, NULL, NULL, - NULL, + fmtGetPixelPETSCII, { { DO_COPY , DS_SCREEN_RAM , 0x2001 - 2, 0, 0, 0, NULL, NULL }, { DO_COPY , DS_COLOR_RAM , 0x23e9 - 2, 0, 0, 0, NULL, NULL }, - { DO_SET_MEM_LO , DS_D020 , 0x001e - 2, 0, 0, 0, NULL, NULL }, - { DO_SET_MEM_LO , DS_BGCOL , 0x0023 - 2, 0, 0, 0, NULL, NULL }, + { DO_SET_MEM_LO , DS_D020 , 0x001e - 2, 0, 0, 0, NULL, NULL }, + { DO_SET_MEM_LO , DS_BGCOL , 0x0023 - 2, 0, 0, 0, NULL, NULL }, - { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL }, + { DO_SET_MEM_LO , DS_D022 , 0x0028 - 2, 0, 0, 0, NULL, NULL }, + { DO_SET_MEM_LO , DS_D023 , 0x002d - 2, 0, 0, 0, NULL, NULL }, + { DO_SET_MEM_LO , DS_D024 , 0x0032 - 2, 0, 0, 0, NULL, NULL }, + + { DO_COPY , DS_EXTRA_DATA , 0x0000 , 1, 0x0100, 0, NULL, NULL }, + + { DO_COPY , DS_CHAR_DATA , 0x1801 - 2, 0, 0x0800, 0, NULL, NULL }, + + { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL }, } }, NULL