comparison tools/lib64fmts.c @ 2138:fdd0fd7dc0e6

Some more work on charmap and PETSCII support.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 29 May 2019 11:31:38 +0300
parents cb4689d9ceed
children 84780a9d8d17
comparison
equal deleted inserted replaced
2137:903effcd616b 2138:fdd0fd7dc0e6
87 87
88 return DM_PROBE_SCORE_FALSE; 88 return DM_PROBE_SCORE_FALSE;
89 } 89 }
90 90
91 91
92 static int fmtGetPixelMarqPETSCII(Uint8 *col, 92 static int fmtGetPixelPETSCII(Uint8 *col,
93 const DMC64Image *img, const int rasterX, const int rasterY) 93 const DMC64Image *img, const int rasterX, const int rasterY)
94 { 94 {
95 DM_C64_GENERIC_CHAR_PIXEL(img) 95 DM_C64_GENERIC_CHAR_PIXEL(img)
96 int chr = img->screen[0].data[scroffs]; 96 int chr = img->screen[0].data[scroffs];
97 97
98 // d018 has been copied to extraData[0].data[0] 98 if (img->extraData[0].data != NULL)
99 switch (img->extraData[0].data[0]) 99 {
100 { 100 // Marq's PETSCII editor
101 case 23: chr += 256; break; // lower case, so add 256 to char ROM offset 101 // d018 has been copied to extraData[0].data[0]
102 case 20: break; // upper case 102 switch (img->extraData[0].data[0])
103 default: 103 {
104 return DMERR_INVALID_DATA; 104 case 23: chr += 256; break; // lower case, so add 256 to char ROM offset
105 case 20: break; // upper case
106 default:
107 return DMERR_INVALID_DATA;
108 }
109 }
110 else
111 if (img->extraData[1].data != NULL)
112 {
113 // petscii.krissz.hu editor
114 if (img->extraData[1].data[0x0028 - 2] == 0xd8)
115 {
116 return dmC64GetGenericCharMCPixel(
117 col, img,
118 scroffs, rasterX,
119 0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr,
120 0, img->bgcolor, img->d022, img->d023);
121 }
122 else
123 if (img->extraData[1].data[0x0028 - 2] == 0x01)
124 {
125 return dmC64GetGenericCharECMPixel(
126 col, img,
127 scroffs, rasterX,
128 0, ((chr & 0x3f) * D64_CHR_SIZE) + (rasterY & 7), chr,
129 0, img->bgcolor, img->d022, img->d023, img->d024);
130 }
105 } 131 }
106 132
107 return dmC64GetGenericCharSCPixel( 133 return dmC64GetGenericCharSCPixel(
108 col, img, 134 col, img,
109 scroffs, rasterX, 135 scroffs, rasterX,
113 139
114 140
115 static const Uint8 fmtPetsciiKrisszHu_ID1[] = 141 static const Uint8 fmtPetsciiKrisszHu_ID1[] =
116 { 142 {
117 0x01, 0x08, 0x0b, 0x08, 0x0A, 0x00, 0x9E, 0x32, 0x30, 0x36, 143 0x01, 0x08, 0x0b, 0x08, 0x0A, 0x00, 0x9E, 0x32, 0x30, 0x36,
118 0x31, 0x00, 0x00, 0x00, 0xA9, 0x1B, 0x8D, 0x11, 0xD0, 0xA9, 144 0x31, 0x00, 0x00, 0x00, 0xA9,
119 0x80, 0x8D, 0x91, 0x02, 0xA9,
120 }; 145 };
121 146
147 static const Uint8 fmtPetsciiKrisszHu_ID2[] =
148 {
149 0x8d, 0x11, 0xd0, 0xa9, 0x80, 0x8d, 0x91, 0x02, 0xa9, 0x18,
150 };
151
122 152
123 static int fmtProbePetsciiKrisszHu(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) 153 static int fmtProbePetsciiKrisszHu(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
124 { 154 {
125 (void) fmt; 155 (void) fmt;
126 156
127 if (buf->len == 10193 && 157 if (buf->len == 10193 &&
128 DM_MEMCMP_SIZE(buf->data, fmtPetsciiKrisszHu_ID1) == 0 158 DM_MEMCMP_SIZE(buf->data, fmtPetsciiKrisszHu_ID1) == 0 &&
159 DM_MEMCMP_SIZE(buf->data + 0x10, fmtPetsciiKrisszHu_ID2) == 0
129 ) 160 )
130 return DM_PROBE_SCORE_MAX; 161 return DM_PROBE_SCORE_MAX;
131 162
132 return DM_PROBE_SCORE_FALSE; 163 return DM_PROBE_SCORE_FALSE;
133 } 164 }
2089 "cdhm", "Cosmos Designs Hires Manager (unpacked)", 0x4000, 16385, DM_FMT_RDWR, 2120 "cdhm", "Cosmos Designs Hires Manager (unpacked)", 0x4000, 16385, DM_FMT_RDWR,
2090 fmtProbeCosmosDesignsHiresManager, 2121 fmtProbeCosmosDesignsHiresManager,
2091 NULL, NULL, 2122 NULL, NULL,
2092 { }, &dmC64CommonFormats[8] 2123 { }, &dmC64CommonFormats[8]
2093 }, 2124 },
2094 { 2125
2095 "pet", "Marq's PETSCII (unpacked)", 0x0801, 0, DM_FMT_RD, 2126 {
2127 "mrqp", "Marq's PETSCII editor (unpacked)", 0x0801, 0, DM_FMT_RD,
2096 fmtProbeMarqPETSCII, 2128 fmtProbeMarqPETSCII,
2097 NULL, NULL, 2129 NULL, NULL,
2098 { 2130 {
2099 D64_FMT_HIRES | D64_FMT_CHAR, 2131 D64_FMT_HIRES | D64_FMT_CHAR,
2100 D64_SCR_WIDTH , D64_SCR_HEIGHT, 2132 D64_SCR_WIDTH , D64_SCR_HEIGHT,
2101 D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT, 2133 D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT,
2102 1, 1, 2134 1, 1,
2103 NULL, NULL, 2135 NULL, NULL,
2104 fmtGetPixelMarqPETSCII, 2136 fmtGetPixelPETSCII,
2105 { 2137 {
2106 { DO_COPY , DS_SCREEN_RAM , 0x60, 0, 0, 0, NULL, NULL }, 2138 { DO_COPY , DS_SCREEN_RAM , 0x60, 0, 0, 0, NULL, NULL },
2107 { DO_COPY , DS_COLOR_RAM , 0x60 + 1000, 0, 0, 0, NULL, NULL }, 2139 { DO_COPY , DS_COLOR_RAM , 0x60 + 1000, 0, 0, 0, NULL, NULL },
2108 2140
2109 // For offset values see petscii/m_c64.pde :: save_prg() 2141 // For offset values see petscii/m_c64.pde :: save_prg()
2116 }, 2148 },
2117 NULL 2149 NULL
2118 }, 2150 },
2119 2151
2120 { 2152 {
2121 "pkhu", "petscii.krissz.hu (unpacked)", 0x0801, 0, DM_FMT_RD, 2153 "pkhu", "petscii.krissz.hu editor (unpacked)", 0x0801, 0, DM_FMT_RD,
2122 fmtProbePetsciiKrisszHu, 2154 fmtProbePetsciiKrisszHu,
2123 NULL, NULL, 2155 NULL, NULL,
2124 { 2156 {
2125 D64_FMT_HIRES | D64_FMT_CHAR, 2157 D64_FMT_HIRES | D64_FMT_CHAR,
2126 D64_SCR_WIDTH , D64_SCR_HEIGHT, 2158 D64_SCR_WIDTH , D64_SCR_HEIGHT,
2127 D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT, 2159 D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT,
2128 1, 1, 2160 1, 1,
2129 NULL, NULL, 2161 NULL, NULL,
2130 NULL, 2162 fmtGetPixelPETSCII,
2131 { 2163 {
2132 { DO_COPY , DS_SCREEN_RAM , 0x2001 - 2, 0, 0, 0, NULL, NULL }, 2164 { DO_COPY , DS_SCREEN_RAM , 0x2001 - 2, 0, 0, 0, NULL, NULL },
2133 { DO_COPY , DS_COLOR_RAM , 0x23e9 - 2, 0, 0, 0, NULL, NULL }, 2165 { DO_COPY , DS_COLOR_RAM , 0x23e9 - 2, 0, 0, 0, NULL, NULL },
2134 2166
2135 { DO_SET_MEM_LO , DS_D020 , 0x001e - 2, 0, 0, 0, NULL, NULL }, 2167 { DO_SET_MEM_LO , DS_D020 , 0x001e - 2, 0, 0, 0, NULL, NULL },
2136 { DO_SET_MEM_LO , DS_BGCOL , 0x0023 - 2, 0, 0, 0, NULL, NULL }, 2168 { DO_SET_MEM_LO , DS_BGCOL , 0x0023 - 2, 0, 0, 0, NULL, NULL },
2137 2169
2138 { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL }, 2170 { DO_SET_MEM_LO , DS_D022 , 0x0028 - 2, 0, 0, 0, NULL, NULL },
2171 { DO_SET_MEM_LO , DS_D023 , 0x002d - 2, 0, 0, 0, NULL, NULL },
2172 { DO_SET_MEM_LO , DS_D024 , 0x0032 - 2, 0, 0, 0, NULL, NULL },
2173
2174 { DO_COPY , DS_EXTRA_DATA , 0x0000 , 1, 0x0100, 0, NULL, NULL },
2175
2176 { DO_COPY , DS_CHAR_DATA , 0x1801 - 2, 0, 0x0800, 0, NULL, NULL },
2177
2178 { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL },
2139 } 2179 }
2140 }, 2180 },
2141 NULL 2181 NULL
2142 }, 2182 },
2143 }; 2183 };