comparison tools/lib64fmts.c @ 1578:fb60abb09a65

Add support for packed Koala Painter files, though without probing now.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 13 May 2018 09:51:13 +0300
parents 632f1dbc83eb
children 4288b21e97b9
comparison
equal deleted inserted replaced
1577:632f1dbc83eb 1578:fb60abb09a65
29 { 0x6C, 0x5E, 0xB5, 0xff }, 29 { 0x6C, 0x5E, 0xB5, 0xff },
30 { 0x95, 0x95, 0x95, 0xff }, 30 { 0x95, 0x95, 0x95, 0xff },
31 }; 31 };
32 32
33 33
34
35 static int fmtDecodeKoalaPaintPacked(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
36 {
37 int res;
38 DMGrowBuf mem;
39 DMCompParams cfg;
40
41 cfg.type = DM_COMP_RLE_MARKER2;
42 cfg.rleMarker = 0xfe;
43 if ((res = dmDecodeGenericRLEAlloc(&mem, buf, buf + len, &cfg)) != DMERR_OK)
44 goto out;
45
46 res = dmC64DecodeGenericBMP(img, mem.data, mem.len, fmt);
47
48 out:
49 dmGrowBufFree(&mem);
50 return res;
51 }
52
53
54 static int fmtEncodeKoalaPaintPacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt)
55 {
56 int res;
57 DMGrowBuf tmp;
58 DMCompParams cfg;
59
60 // Encode the data to temp buffer
61 if ((res = dmC64EncodeGenericBMP(TRUE, &tmp, img, fmt)) != DMERR_OK)
62 goto out;
63
64 // And now RLE compress the data to the existing buffer
65 cfg.type = DM_COMP_RLE_MARKER2;
66 cfg.rleMarker = 0xfe;
67 cfg.rleMinCount = 3;
68 cfg.rleMaxCount = 255;
69 res = dmEncodeGenericRLE(buf, tmp.data, tmp.data + tmp.len, &cfg);
70
71 out:
72 dmGrowBufFree(&tmp);
73 return res;
74 }
75
76
34 static int fmtProbeDrazPaint20Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) 77 static int fmtProbeDrazPaint20Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
35 { 78 {
36 const char *ident = (const char *) buf + 2; 79 const char *ident = (const char *) buf + 2;
37 80
38 if (len > 22 && 81 if (len > 22 &&
630 { DT_LAST, 0, 0, 0, NULL, NULL }, 673 { DT_LAST, 0, 0, 0, NULL, NULL },
631 } 674 }
632 }, 675 },
633 676
634 { 677 {
678 D64_FMT_MC, "klp", "Koala Paint (packed)", 0x6000, 0, DM_FMT_RDWR,
679 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
680 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
681 NULL,
682 fmtDecodeKoalaPaintPacked, fmtEncodeKoalaPaintPacked,
683 NULL, NULL,
684 NULL,
685 {
686 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
687 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
688 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL },
689 { DT_COLOR_REG, 0x270f, 0, DC_BGCOL, NULL, NULL },
690 { DT_LAST, 0, 0, 0, NULL, NULL },
691 }
692 },
693
694 {
635 D64_FMT_MC, "aas", "Advanced Art Studio (unpacked)", 0x2000, 10018, DM_FMT_RDWR, 695 D64_FMT_MC, "aas", "Advanced Art Studio (unpacked)", 0x2000, 10018, DM_FMT_RDWR,
636 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, 696 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
637 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, 697 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
638 NULL, 698 NULL,
639 NULL, NULL, 699 NULL, NULL,