comparison tools/lib64fmts.c @ 1538:af729e29a6f6

Implement Amica Paint packed format encoding.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 12 May 2018 04:54:36 +0300
parents 2f7ff28ea56e
children 2acf4578d2e6
comparison
equal deleted inserted replaced
1537:776aa43b2c57 1538:af729e29a6f6
200 dmGrowBufFree(&mem); 200 dmGrowBufFree(&mem);
201 return res; 201 return res;
202 } 202 }
203 203
204 204
205 static int fmtEncodeAmicaPaintPacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt)
206 {
207 int res;
208 DMGrowBuf tmp;
209 DMCompParams cfg;
210
211 // Encode the data to temp buffer
212 if ((res = dmC64EncodeGenericBMP(TRUE, &tmp, img, fmt)) != DMERR_OK)
213 goto out;
214
215 // And now RLE compress the data to the existing buffer
216 cfg.type = DM_COMP_RLE_MARKER;
217 cfg.rleMarker = 0xC2;
218 cfg.rleMinCount = 3;
219 cfg.rleMaxCount = 255;
220 res = dmEncodeGenericRLE(buf, tmp.data, tmp.data + tmp.len, &cfg);
221
222 out:
223 dmGrowBufFree(&tmp);
224 return res;
225 }
226
227
205 static int fmtProbeFLIDesigner(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) 228 static int fmtProbeFLIDesigner(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
206 { 229 {
207 if (len == fmt->size && 230 if (len == fmt->size &&
208 (dmCompareAddr16(buf, 0, 0x3c00) || dmCompareAddr16(buf, 0, 0x3ff0))) 231 (dmCompareAddr16(buf, 0, 0x3c00) || dmCompareAddr16(buf, 0, 0x3ff0)))
209 return DM_PROBE_SCORE_MAX; 232 return DM_PROBE_SCORE_MAX;
620 { 643 {
621 D64_FMT_MC, "ami", "Amica Paint (packed)", 0x4000, 0, 644 D64_FMT_MC, "ami", "Amica Paint (packed)", 0x4000, 0,
622 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, 645 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
623 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, 646 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
624 fmtProbeAmicaPaintPacked, 647 fmtProbeAmicaPaintPacked,
625 fmtDecodeAmicaPaintPacked, fmtEncodeStub, 648 fmtDecodeAmicaPaintPacked, fmtEncodeAmicaPaintPacked,
626 NULL, NULL, 649 NULL, NULL,
627 NULL, 650 NULL,
628 { 651 {
629 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL }, 652 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL },
630 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, 653 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },