annotate tools/lib64gfx.c @ 1457:dcff9ac95d3f

Add function to set DMImage's palette to default C64 palette and use it.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 10 May 2018 19:58:52 +0300
parents 42fb39da7dde
children 361cad3b8445
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Functions for reading and converting various restricted
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * C64/etc and/or indexed/paletted graphics formats.
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * Programmed and designed by Matti 'ccr' Hamalainen
1456
42fb39da7dde Bump copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 1448
diff changeset
5 * (C) Copyright 2012-2018 Tecnic Software productions (TNSP)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 *
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 * Please read file 'COPYING' for information on license and distribution.
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 */
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #include "lib64gfx.h"
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 433
diff changeset
10
514
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
11 #define BUF_SIZE_INITIAL (16*1024)
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
12 #define BUF_SIZE_GROW (4*1024)
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
13
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
1381
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
15 // Based on Pepto's palette, stolen from VICE
1426
4c7b456d7f0b Rename global dmC64Palette to dmDefaultC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents: 1425
diff changeset
16 DMColor dmDefaultC64Palette[C64_NCOLORS] =
1381
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
17 {
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
18 { 0x00, 0x00, 0x00, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
19 { 0xFF, 0xFF, 0xFF, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
20 { 0x68, 0x37, 0x2B, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
21 { 0x70, 0xA4, 0xB2, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
22 { 0x6F, 0x3D, 0x86, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
23 { 0x58, 0x8D, 0x43, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
24 { 0x35, 0x28, 0x79, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
25 { 0xB8, 0xC7, 0x6F, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
26 { 0x6F, 0x4F, 0x25, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
27 { 0x43, 0x39, 0x00, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
28 { 0x9A, 0x67, 0x59, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
29 { 0x44, 0x44, 0x44, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
30 { 0x6C, 0x6C, 0x6C, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
31 { 0x9A, 0xD2, 0x84, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
32 { 0x6C, 0x5E, 0xB5, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
33 { 0x95, 0x95, 0x95, 0xff },
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
34 };
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
35
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
36
1457
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
37 void dmSetDefaultC64Palette(DMImage *img)
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
38 {
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
39 img->constpal = TRUE;
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
40 img->pal = dmDefaultC64Palette;
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
41 img->ncolors = C64_NCOLORS;
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
42 img->ctransp = 255;
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
43 }
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
44
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
45
1381
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
46 #define DM_GET_ADDR_LO(addr) ((addr) & 0xff)
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
47 #define DM_GET_ADDR_HI(addr) (((addr) >> 8) & 0xff)
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
48
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
49
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
50 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr)
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
51 {
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
52 return buf[offs ] == DM_GET_ADDR_LO(addr) &&
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
53 buf[offs + 1] == DM_GET_ADDR_HI(addr);
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
54 }
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
55
b6782b785457 Move things around a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
56
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
57 int dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt)
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
58 {
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
59 int nbanks = 0;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
60 for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++)
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
61 {
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
62 const DMC64EncDecOp *op = &fmt->encdecOps[i];
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
63 if (op->type == DT_LAST)
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
64 break;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
65
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
66 if (op->bank > nbanks)
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
67 nbanks = op->bank;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
68 }
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
69
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
70 return nbanks + 1;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
71 }
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
72
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
73
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
74 DMC64Image *dmC64ImageAlloc(const DMC64ImageFormat *fmt)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
75 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
76 DMC64Image *img = dmMalloc0(sizeof(DMC64Image));
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
77
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
78 if (img == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
79 return NULL;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
80
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
81 // Initialize image information
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
82 img->width = fmt->width;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
83 img->height = fmt->height;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
84 img->ch_width = fmt->ch_width;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
85 img->ch_height = fmt->ch_height;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
86 img->nbanks = dmC64ImageGetNumBanks(fmt);
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
87
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
88 // Allocate banks
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
89 if ((img->color = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL ||
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
90 (img->bitmap = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL ||
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
91 (img->screen = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL ||
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
92 (img->charmem = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL)
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
93 goto err;
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
94
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
95 for (int i = 0; i < img->nbanks; i++)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
96 {
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
97 if ((img->color[i] = dmMalloc0(img->ch_width * img->ch_height)) == NULL)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
98 goto err;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
99
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
100 if ((img->bitmap[i] = dmMalloc0(img->ch_width * img->ch_height * 8)) == NULL)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
101 goto err;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
102
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
103 if ((img->screen[i] = dmMalloc0(img->ch_width * img->ch_height)) == NULL)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
104 goto err;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
105
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
106 if ((img->charmem[i] = dmMalloc0(C64_MAX_CHARS * C64_CHR_SIZE)) == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
107 goto err;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
108 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
109
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
110 return img;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
111
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
112 err:
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
113 dmC64ImageFree(img);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
114 return NULL;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
115 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
116
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
117
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
118 void dmC64ImageFree(DMC64Image *img)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
119 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
120 if (img != NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
121 {
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
122 for (int i = 0; i < img->nbanks; i++)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
123 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
124 dmFree(img->color[i]);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
125 dmFree(img->bitmap[i]);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
126 dmFree(img->screen[i]);
932
6320bf08e302 Oops, plug a memory leak.
Matti Hamalainen <ccr@tnsp.org>
parents: 931
diff changeset
127 dmFree(img->charmem[i]);
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
128 }
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
129
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
130 for (int i = 0; i < C64_MAX_EXTRA_DATA; i++)
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
131 dmFree(img->extraData[i]);
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
132
1167
848a88ce7a57 Use dmMemset().
Matti Hamalainen <ccr@tnsp.org>
parents: 1134
diff changeset
133 dmMemset(img, 0, sizeof(DMC64Image));
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
134 dmFree(img);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
135 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
136 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
137
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
138
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
139 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 {
1425
f08c4ace528d Simplify dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents: 1419
diff changeset
141 snprintf(buf, len,
f08c4ace528d Simplify dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents: 1419
diff changeset
142 "%s%s%s%s",
f08c4ace528d Simplify dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents: 1419
diff changeset
143 (type & D64_FMT_FLI) ? "FLI " : "",
f08c4ace528d Simplify dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents: 1419
diff changeset
144 (type & D64_FMT_MC) ? "MCol " : "HiRes ",
f08c4ace528d Simplify dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents: 1419
diff changeset
145 (type & D64_FMT_ILACE) ? "Ilace " : "",
f08c4ace528d Simplify dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents: 1419
diff changeset
146 (type & D64_FMT_CHAR) ? "CharMap" : ""
f08c4ace528d Simplify dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents: 1419
diff changeset
147 );
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
148
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
149 return buf;
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
150 }
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
827
c8beac5313c3 Rename a function.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
153 int dmC64ConvertCSDataToImage(DMImage *img,
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
154 int xoffs, int yoffs, const Uint8 *buf,
915
ba6b210c9bf4 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
155 int width, int height, BOOL multicolor,
ba6b210c9bf4 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
156 int *colors)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 int yc, widthpx = width * 8;
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
159 Uint8 *dp;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 if (img == NULL)
517
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
162 return DMERR_NULLPTR;
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
163
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
164 if (xoffs < 0 || yoffs < 0 ||
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
165 xoffs > img->width - widthpx ||
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 yoffs > img->height - height)
517
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
167 return DMERR_INVALID_ARGS;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 dp = img->data + (yoffs * img->pitch) + xoffs;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 if (multicolor)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 for (yc = 0; yc < height; yc++)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 const int offs = yc * width;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 int xc;
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
177 Uint8 *d = dp;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 for (xc = 0; xc < widthpx / 2; xc++)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 const int b = buf[offs + (xc / 4)];
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 const int v = 6 - ((xc * 2) & 6);
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
183 const Uint8 c = colors[(b >> v) & 3];
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
184
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 *d++ = c;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 *d++ = c;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 dp += img->pitch;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 else
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 for (yc = 0; yc < height; yc++)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 const int offs = yc * width;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 int xc;
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
198 Uint8 *d = dp;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 for (xc = 0; xc < widthpx; xc++)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 const int b = buf[offs + (xc / 8)];
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 const int v = 7 - (xc & 7);
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
204 const Uint8 c = colors[(b >> v) & 1];
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
205
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 *d++ = c;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 dp += img->pitch;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 }
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
212
517
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
213 return DMERR_OK;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
217 static int dmDecodeGenericRLE(Uint8 **mem, Uint8 **pdstEnd, const Uint8 *src, const Uint8 *srcEnd, const Uint8 rleMarker)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 {
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
219 Uint8 *dst, *dstEnd;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
221 if ((*mem = dmMalloc(C64_RAM_SIZE)) == NULL)
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
222 return DMERR_MALLOC;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
223
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
224 dst = *mem;
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
225 dstEnd = *mem + C64_RAM_SIZE;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226
1418
d8a509d72449 Backed out changeset 3baed76155a1
Matti Hamalainen <ccr@tnsp.org>
parents: 1416
diff changeset
227 while (src <= srcEnd && dst <= dstEnd)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 {
1412
c386d287fa1e Use Uint8 instead of int in the rle decoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1411
diff changeset
229 Uint8 c = *src++;
1418
d8a509d72449 Backed out changeset 3baed76155a1
Matti Hamalainen <ccr@tnsp.org>
parents: 1416
diff changeset
230 if (c == rleMarker && src + 2 <= srcEnd)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 int cnt = *src++;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 c = *src++;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 while (cnt-- && dst <= dstEnd)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 *dst++ = c;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 else
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 *dst++ = c;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 }
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
240
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
241 *pdstEnd = dst;
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
242
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
243 return DMERR_OK;
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
244 }
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
245
519
feaaf0e2ecbe Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
246
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
247 static inline Uint8 dmC64GetGenericSCPixel(
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
248 const DMC64Image *img, const int bmoffs, const int scroffs,
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
249 const int vshift, const int vbank, const int vbitmap, const int cbank)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
250 {
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
251 (void) cbank;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
252 if ((img->bitmap[vbitmap][bmoffs] >> vshift) & 1)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
253 return img->screen[vbank][scroffs] >> 4;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
254 else
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
255 return img->screen[vbank][scroffs] & 15;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
256 }
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
257
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
258
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
259 static inline Uint8 dmC64GetGenericMCPixel(
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
260 const DMC64Image *img, const int bmoffs, const int scroffs,
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
261 const int vshift, const int vbank, const int vbitmap, const int cbank)
1369
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
262 {
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
263 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
264 {
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
265 case 0: return img->bgcolor; break;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
266 case 1: return img->screen[vbank][scroffs] >> 4; break;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
267 case 2: return img->screen[vbank][scroffs] & 15; break;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
268 default: return img->color[cbank][scroffs] & 15; break;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
269 }
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
270 }
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
271
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
272
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
273 static inline Uint8 fmtGetGenericSCPixel(
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
274 const DMC64Image *img, const int bmoffs, const int scroffs,
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
275 const int vshift, const int vbitmap, const int raster)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
276 {
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
277 (void) raster;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
278 return dmC64GetGenericSCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0);
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
279 }
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
280
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
281
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
282 static inline Uint8 fmtGetGenericMCPixel(
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
283 const DMC64Image *img, const int bmoffs, const int scroffs,
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
284 const int vshift, const int vbitmap, const int raster)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
285 {
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
286 (void) raster;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
287 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0);
1369
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
288 }
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
289
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
290
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
291 static int fmtProbeDrazPaint20Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
292 {
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
293 const char *ident = (const char *) buf + 2;
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
294
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
295 if (len > 22 &&
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
296 dmCompareAddr16(buf, 0, fmt->addr) &&
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
297 strncmp(ident, "DRAZPAINT ", 10) == 0 &&
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
298 ident[11] == '.' && (
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
299 (ident[10] == '1' && ident[12] == '4') ||
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
300 (ident[10] == '2' && ident[12] == '0')
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
301 ))
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
302 return DM_PROBE_SCORE_MAX;
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
303
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
304 return DM_PROBE_SCORE_FALSE;
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
305 }
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
306
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
307
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
308 static int fmtDecodeDrazPaintPacked(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
309 {
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
310 int res;
1372
b3e561e2209a Variable name cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1371
diff changeset
311 Uint8 *mem = NULL, *end;
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
312
1419
56f643d647b7 Better fix for the RLE decoding bounds issue, not changing
Matti Hamalainen <ccr@tnsp.org>
parents: 1418
diff changeset
313 if ((res = dmDecodeGenericRLE(&mem, &end, buf + 0x0e, buf + len - 1, *(buf + 0x0d))) != DMERR_OK)
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
314 goto out;
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
315
1372
b3e561e2209a Variable name cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1371
diff changeset
316 res = dmC64DecodeGenericBMP(img, mem, end - mem + 1, fmt);
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
317
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
318 out:
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 dmFree(mem);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 return res;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
324 static int fmtProbeDrazLace10Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 {
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
326 if (len > 22 &&
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
327 dmCompareAddr16(buf, 0, fmt->addr) &&
1382
558776ee9603 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1381
diff changeset
328 strncmp((const char *) (buf + 2), "DRAZLACE! 1.0", 13) == 0)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 return DM_PROBE_SCORE_MAX;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
330
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 return DM_PROBE_SCORE_FALSE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
335 static BOOL fmtDrazLaceSetLaceType(DMC64Image *img, const struct _DMC64EncDecOp *op, const Uint8 *buf, const size_t len)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 {
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
337 (void) len;
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
338 img->laceType = buf[op->offs] ? D64_ILACE_RES : D64_ILACE_COLOR;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 return TRUE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342
1389
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
343 static int fmtProbeGunPaint(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
344 {
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
345 if (len > 0x400 &&
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
346 dmCompareAddr16(buf, 0, fmt->addr) &&
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
347 strncmp((const char *) (buf + 0x3ea), "GUNPAINT (JZ) ", 14) == 0)
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
348 return DM_PROBE_SCORE_MAX;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
349
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
350 return DM_PROBE_SCORE_FALSE;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
351 }
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
352
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
353
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
354 static int fmtProbeAmicaPaintPacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 {
541
7ca6abbbbb40 Use size_t instead of int here to avoid signedness issues.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
356 size_t i, n;
1433
d8a83582f78f Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1426
diff changeset
357
1392
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
358 if (len < 2048 || !dmCompareAddr16(buf, 0, fmt->addr))
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 return DM_PROBE_SCORE_FALSE;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
360
494
abb112ac9916 Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents: 468
diff changeset
361 // Interpaint Hi-Res gives a false positive
1389
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
362 // as do some GunPaint images ..
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
363 if (len == 9002 || fmtProbeGunPaint(buf, len, fmt) > DM_PROBE_SCORE_GOOD)
494
abb112ac9916 Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents: 468
diff changeset
364 return DM_PROBE_SCORE_FALSE;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
365
533
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
366 for (n = 0, i = 2; i < len; i++)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 if (buf[i] == 0xC2) n++;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
368
533
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
369 if (n > 50)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 return DM_PROBE_SCORE_GOOD;
533
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
371 if (n > 25)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 return DM_PROBE_SCORE_AVG;
533
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
373 if (n > 10)
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
374 return DM_PROBE_SCORE_MAYBE;
1369
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
375
533
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
376 return DM_PROBE_SCORE_FALSE;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
380 static int fmtDecodeAmicaPaintPacked(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 int res;
1372
b3e561e2209a Variable name cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1371
diff changeset
383 Uint8 *mem = NULL, *end;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384
1419
56f643d647b7 Better fix for the RLE decoding bounds issue, not changing
Matti Hamalainen <ccr@tnsp.org>
parents: 1418
diff changeset
385 if ((res = dmDecodeGenericRLE(&mem, &end, buf, buf + len - 1, 0xC2)) != DMERR_OK)
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
386 goto out;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387
1372
b3e561e2209a Variable name cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1371
diff changeset
388 res = dmC64DecodeGenericBMP(img, mem, end - mem + 1, fmt);
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
389
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
390 out:
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 dmFree(mem);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 return res;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395
1392
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
396 static int fmtProbeFLIDesigner(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
397 {
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
398 if (len == fmt->size &&
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
399 (dmCompareAddr16(buf, 0, 0x3c00) || dmCompareAddr16(buf, 0, 0x3ff0)))
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
400 return DM_PROBE_SCORE_MAX;
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
401
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
402 return DM_PROBE_SCORE_FALSE;
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
403 }
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
404
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
405
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
406 static BOOL fmtTruePaintSetLaceType(DMC64Image *img, const struct _DMC64EncDecOp *op, const Uint8 *buf, const size_t len)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 {
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
408 (void) op;
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
409 (void) buf;
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
410 (void) len;
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
411 img->laceType = D64_ILACE_RES;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 return TRUE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
416 static Uint8 fmtGetPixelTruePaint(
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
417 const DMC64Image *img, const int bmoffs, const int scroffs,
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
418 const int vshift, const int vbitmap, const int raster)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
419 {
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
420 (void) raster;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
421 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0);
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
422 }
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
423
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
424
1369
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
425 #define XX2_MIN_SIZE 4000
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
426
943
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
427 static int fmtProbeFormatXX2(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
428 {
1369
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
429 if (len >= XX2_MIN_SIZE && len <= XX2_MIN_SIZE + 8 &&
943
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
430 dmCompareAddr16(buf, 0, fmt->addr))
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
431 return DM_PROBE_SCORE_MAYBE;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
432
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
433 return DM_PROBE_SCORE_FALSE;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
434 }
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
435
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
436
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
437 static int fmtDecodeFormatXX2(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
438 {
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
439 int res;
1377
e274a7e6dff9 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1376
diff changeset
440
1369
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
441 // If there is only data for less than XX2_MIN_SIZE bytes,
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
442 // allocate a buffer of that size and copy data there.
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
443 // Otherwise allocate len bytes.
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
444 size_t nlen = len < XX2_MIN_SIZE ? XX2_MIN_SIZE : len;
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
445 Uint8 *mem = dmMalloc0(nlen);
943
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
446 if (mem == NULL)
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
447 return DMERR_MALLOC;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
448
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
449 memcpy(mem, buf, len);
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
450 res = dmC64DecodeGenericBMP(img, mem, nlen, fmt);
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
451
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
452 dmFree(mem);
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
453 return res;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
454 }
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
455
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
456
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
457 #define FUNPAINT2_HEADER_SIZE (0x10)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
458
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
459 static BOOL fmtProbeFunPaint2Header(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
460 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
461 return
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
462 len > 30 &&
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
463 dmCompareAddr16(buf, 0, fmt->addr) &&
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
464 strncmp((const char *) (buf + 2), "FUNPAINT (MT) ", 14) == 0;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
465 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
466
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
467
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
468 static int fmtProbeFunPaint2Unpacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
469 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
470 if (fmtProbeFunPaint2Header(buf, len, fmt) &&
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
471 buf[2 + 14] == 0)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
472 return DM_PROBE_SCORE_MAX;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
473 else
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
474 return DM_PROBE_SCORE_FALSE;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
475 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
476
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
477
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
478 static int fmtProbeFunPaint2Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
479 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
480 if (fmtProbeFunPaint2Header(buf, len, fmt) &&
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
481 buf[2 + 14] != 0)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
482 return DM_PROBE_SCORE_MAX;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
483 else
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
484 return DM_PROBE_SCORE_FALSE;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
485 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
486
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
487
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
488 static int fmtDecodeFunPaint2Unpacked(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
489 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
490 return dmC64DecodeGenericBMP(img, buf + FUNPAINT2_HEADER_SIZE, len - FUNPAINT2_HEADER_SIZE, fmt);
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
491 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
492
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
493
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
494 static int fmtDecodeFunPaint2Packed(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
495 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
496 int res;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
497 Uint8 *mem = NULL, *end;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
498
1419
56f643d647b7 Better fix for the RLE decoding bounds issue, not changing
Matti Hamalainen <ccr@tnsp.org>
parents: 1418
diff changeset
499 if ((res = dmDecodeGenericRLE(&mem, &end, buf + FUNPAINT2_HEADER_SIZE, buf + len - 1, *(buf + 15))) != DMERR_OK)
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
500 goto out;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
501
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
502 res = dmC64DecodeGenericBMP(img, mem, end - mem + 1, fmt);
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
503
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
504 out:
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
505 dmFree(mem);
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
506 return res;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
507 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
508
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
509
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
510 static Uint8 fmtGetPixelFunPaint2(
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
511 const DMC64Image *img, const int bmoffs, const int scroffs,
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
512 const int vshift, const int vbitmap, const int raster)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
513 {
1390
e3794fb2df83 FunPaint2 decoding fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1389
diff changeset
514 const int vbank = (raster & 7) + (vbitmap * 8);
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
515 int vr, vb;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
516 if (raster < 100)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
517 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
518 vb = 0;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
519 vr = raster;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
520 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
521 else
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
522 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
523 vb = 0;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
524 vr = raster - 100;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
525 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
526
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
527 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3)
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
528 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
529 case 0: return img->extraData[vb][vr] & 15; break;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
530 case 1: return img->screen[vbank][scroffs] >> 4; break;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
531 case 2: return img->screen[vbank][scroffs] & 15; break;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
532 default: return img->color[0][scroffs] & 15; break;
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
533 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
534 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
535
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
536
1389
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
537 static Uint8 fmtGetPixelGunPaint(
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
538 const DMC64Image *img, const int bmoffs, const int scroffs,
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
539 const int vshift, const int vbitmap, const int raster)
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
540 {
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
541 const int vbank = (raster & 7);// + (vbitmap * 8);
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
542 int vr, vb;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
543 if (raster < 177)
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
544 {
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
545 vb = 0;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
546 vr = raster;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
547 }
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
548 else
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
549 {
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
550 vb = 0;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
551 vr = raster - 177;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
552 }
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
553
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
554 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3)
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
555 {
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
556 case 0: return img->extraData[vb][vr] & 15; break;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
557 case 1: return img->screen[vbank][scroffs] >> 4; break;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
558 case 2: return img->screen[vbank][scroffs] & 15; break;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
559 default: return img->color[0][scroffs] & 15; break;
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
560 }
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
561 }
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
562
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
563
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
564 static Uint8 fmtGetPixelBMFLI(
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
565 const DMC64Image *img, const int bmoffs, const int scroffs,
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
566 const int vshift, const int vbitmap, const int raster)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
567 {
1380
959b34402b81 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1378
diff changeset
568 const int vbank = raster & 7;
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
569 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
570 {
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
571 case 0: return img->extraData[0][raster]; break;
1380
959b34402b81 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1378
diff changeset
572 case 1: return img->screen[vbank][scroffs] >> 4; break;
959b34402b81 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1378
diff changeset
573 case 2: return img->screen[vbank][scroffs] & 15; break;
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
574 default: return img->color[0][scroffs] & 15; break;
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
575 }
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
576 }
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
577
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
578
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
579 static Uint8 fmtGetPixelFLIDesigner(
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
580 const DMC64Image *img, const int bmoffs, const int scroffs,
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
581 const int vshift, const int vbitmap, const int raster)
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
582 {
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
583 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, raster & 7, vbitmap, 0);
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
584 }
943
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
585
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
586
1394
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
587 static Uint8 fmtGetPixelCHFLI(
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
588 const DMC64Image *img, const int bmoffs, const int scroffs,
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
589 const int vshift, const int vbitmap, const int raster)
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
590 {
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
591 const int vbank = raster & 7;
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
592
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
593 if ((img->bitmap[vbitmap][bmoffs] >> vshift) & 1)
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
594 return img->screen[vbank][scroffs] >> 4;
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
595 else
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
596 return img->screen[vbank][scroffs] & 15;
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
597 }
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
598
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
599
1369
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
600 //
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
601 // Array with data for supported formats
3a94c0e8297f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1366
diff changeset
602 //
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
603 #define DEF_SCREEN_RAM(start, oindex, bindex, osize) { DT_SCREEN_RAM, (start) + ((osize) * (oindex)), (bindex), 0, NULL, NULL }
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
604 #define DEF_SCREEN_RAMS_8(start, sindex, osize) \
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
605 DEF_SCREEN_RAM((start), 0, (sindex + 0), (osize)), \
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
606 DEF_SCREEN_RAM((start), 1, (sindex + 1), (osize)), \
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
607 DEF_SCREEN_RAM((start), 2, (sindex + 2), (osize)), \
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
608 DEF_SCREEN_RAM((start), 3, (sindex + 3), (osize)), \
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
609 DEF_SCREEN_RAM((start), 4, (sindex + 4), (osize)), \
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
610 DEF_SCREEN_RAM((start), 5, (sindex + 5), (osize)), \
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
611 DEF_SCREEN_RAM((start), 6, (sindex + 6), (osize)), \
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
612 DEF_SCREEN_RAM((start), 7, (sindex + 7), (osize)),
1388
4f81528aa4f6 Simplify some image format definitions by using macro to define screen ram blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 1387
diff changeset
613
4f81528aa4f6 Simplify some image format definitions by using macro to define screen ram blocks.
Matti Hamalainen <ccr@tnsp.org>
parents: 1387
diff changeset
614
516
6f141f760c54 Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
615 const DMC64ImageFormat dmC64ImageFormats[] =
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
616 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
617 {
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
618 D64_FMT_MC, "d2p", "DrazPaint 2.0 (packed)", 0x5800, 0,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
619 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
620 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1443
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
621 fmtProbeDrazPaint20Packed,
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
622 fmtDecodeDrazPaintPacked, NULL,
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
623 NULL, NULL,
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
624 NULL,
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
625 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
626 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
627 { DT_BITMAP, 0x0800, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
628 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
629 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
630 { DT_LAST, 0, 0, 0, NULL, NULL },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
631 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
632 },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
634 {
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
635 D64_FMT_MC | D64_FMT_ILACE, "dlp", "DrazLace 1.0 (packed)", 0x5800, 0,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
636 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
637 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
1443
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
638 fmtProbeDrazLace10Packed,
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
639 fmtDecodeDrazPaintPacked, NULL,
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
640 NULL, NULL,
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
641 NULL,
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
642 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
643 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
644 { DT_BITMAP, 0x0800, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
645 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
646 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, NULL, NULL },
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
647 { DT_BITMAP, 0x2800, 1, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
648 { DT_DEC_FUNCTION, 0x2742, 0, 1, fmtDrazLaceSetLaceType, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
649 { DT_LAST, 0, 0, 0, NULL, NULL },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
650 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
651 },
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
652
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
653 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
654 D64_FMT_MC, "drp", "DrazPaint (unpacked)", 0x5800, 10051,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
655 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
656 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
657 NULL,
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
658 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
659 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
660 NULL,
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
661 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
662 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
663 { DT_BITMAP, 0x0800, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
664 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
665 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
666 { DT_LAST, 0, 0, 0, NULL, NULL },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
667 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
668 },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
669
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
670 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
671 D64_FMT_MC | D64_FMT_ILACE, "drl", "DrazLace 1.0 (unpacked)", 0x5800, 18242,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
672 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
673 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
674 NULL,
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
675 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
676 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
677 NULL,
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
678 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
679 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
680 { DT_BITMAP, 0x0800, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
681 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
682 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, NULL, NULL },
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
683 { DT_BITMAP, 0x2800, 1, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
684 { DT_DEC_FUNCTION, 0x2742, 0, 1, fmtDrazLaceSetLaceType, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
685 { DT_LAST, 0, 0, 0, NULL, NULL },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
686 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
687 },
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
688
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
689 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
690 D64_FMT_MC | D64_FMT_ILACE, "mci", "Truepaint (unpacked)", 0x9c00, 19434,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
691 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
692 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
693 NULL,
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
694 NULL, NULL,
1443
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
695 NULL, NULL,
57e97e58cbf3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
696 fmtGetPixelTruePaint,
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
697 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
698 { DT_SCREEN_RAM, 0x0000, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
699 { DT_COLOR_REG, 0x03e8, 0, DC_BGCOL, NULL, NULL },
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
700 { DT_BITMAP, 0x0400, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
701 { DT_BITMAP, 0x2400, 1, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
702 { DT_SCREEN_RAM, 0x4400, 1, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
703 { DT_COLOR_RAM, 0x4800, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
704 { DT_DEC_FUNCTION, 0x0000, 0, 0, fmtTruePaintSetLaceType, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
705 { DT_LAST, 0, 0, 0, NULL, NULL },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
706 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
707 },
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
708
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
709 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
710 D64_FMT_MC, "kla", "Koala Paint (unpacked)", 0x6000, 10003,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
711 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
712 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
713 NULL,
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
714 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
715 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
716 NULL,
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
717 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
718 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
719 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
720 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
721 { DT_COLOR_REG, 0x2710, 0, DC_BGCOL, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
722 { DT_LAST, 0, 0, 0, NULL, NULL },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
723 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
724 },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
725
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
726 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
727 D64_FMT_MC, "ocp", "Advanced Art Studio (unpacked)", 0x2000, 10018,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
728 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
729 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
730 NULL,
524
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
731 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
732 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
733 NULL,
524
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
734 {
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
735 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
736 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
737 { DT_COLOR_RAM, 0x2338, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
738 { DT_COLOR_REG, 0x2329, 0, DC_BGCOL, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
739 { DT_LAST, 0, 0, 0, NULL, NULL },
524
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
740 }
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
741 },
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
742
524
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
743 {
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
744 D64_FMT_MC, "ami", "Amica Paint (packed)", 0x4000, 0,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
745 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
746 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
747 fmtProbeAmicaPaintPacked,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
748 fmtDecodeAmicaPaintPacked, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
749 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
750 NULL,
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
751 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
752 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
753 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
754 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
755 { DT_COLOR_REG, 0x2710, 0, DC_BGCOL, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
756 { DT_LAST, 0, 0, 0, NULL, NULL },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
757 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
758 },
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
759
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
760 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
761 D64_FMT_MC, "rpm", "Run Paint (unpacked)", 0x6000, 10006,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
762 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
763 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
764 NULL,
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
765 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
766 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
767 NULL,
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
768 {
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
769 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL },
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
770 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
771 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
772 { DT_COLOR_REG, 0x2710, 0, DC_BGCOL, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
773 { DT_LAST, 0, 0, 0, NULL, NULL },
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
774 }
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
775 },
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
776
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
777 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
778 D64_FMT_HIRES, "art", "Art Studio (unpacked)", 0x2000, 9009,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
779 C64_SCR_WIDTH , C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
780 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
781 NULL,
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
782 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
783 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
784 NULL,
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
785 {
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
786 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
787 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
788 { DT_LAST, 0, 0, 0, NULL, NULL },
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
789 }
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
790 },
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
791
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
792 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
793 D64_FMT_HIRES, "iph", "Interpaint (unpacked)", 0x4000, 9002,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
794 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
795 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
796 NULL,
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
797 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
798 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
799 NULL,
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
800 {
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
801 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
802 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
803 { DT_LAST, 0, 0, 0, NULL, NULL },
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
804 }
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
805 },
1396
7acadc08bc72 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1394
diff changeset
806
1370
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
807 {
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
808 D64_FMT_MC, "ipc", "Interpaint MC (unpacked)", 0x4000, 10003,
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
809 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
810 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
811 NULL,
1370
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
812 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
813 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
814 NULL,
1370
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
815 {
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
816 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
817 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
818 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL },
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
819 { DT_COLOR_REG, 0x2710, 0, DC_BGCOL, NULL, NULL },
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
820 { DT_LAST, 0, 0, 0, NULL, NULL },
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
821 }
53358cc2f9ff Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1369
diff changeset
822 },
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
823
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
824 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
825 D64_FMT_HIRES, "dd", "Doodle (unpacked)", 0x1c00, 9218,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
826 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
827 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
828 NULL,
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
829 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
830 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
831 NULL,
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
832 {
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
833 { DT_SCREEN_RAM, 0x0000, 0, 0, NULL, NULL },
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
834 { DT_BITMAP, 0x0400, 0, 0, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
835 { DT_LAST, 0, 0, 0, NULL, NULL },
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
836 }
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
837 },
905
b83868a23ca5 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 904
diff changeset
838
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
839 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
840 D64_FMT_MC | D64_FMT_FLI, "bml", "Blackmail FLI (unpacked)", 0x3b00, 17474,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
841 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
842 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
843 NULL,
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
844 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
845 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
846 fmtGetPixelBMFLI,
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
847 {
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
848 { DT_EXTRA_DATA, 0x0000, 0, 200, NULL, NULL },
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
849 { DT_COLOR_RAM, 0x0100, 0, 0, NULL, NULL },
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
850 DEF_SCREEN_RAMS_8( 0x0500, 0, 0x400)
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
851 { DT_BITMAP, 0x2500, 0, 0, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
852 { DT_LAST, 0, 0, 0, NULL, NULL },
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
853 }
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
854 },
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
855
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
856 {
1392
aad9d9e7e1d3 Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1390
diff changeset
857 D64_FMT_MC | D64_FMT_FLI, "fli", "FLI Designer (unpacked)", 0, 17409,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
858 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
859 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
860 fmtProbeFLIDesigner,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
861 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
862 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
863 fmtGetPixelFLIDesigner,
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
864 {
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
865 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL },
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
866 DEF_SCREEN_RAMS_8( 0x0400, 0, 0x400)
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
867 { DT_BITMAP, 0x2400, 0, 0, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
868 { DT_LAST, 0, 0, 0, NULL, NULL },
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
869 }
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
870 },
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
871
906
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
872 {
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
873 D64_FMT_MC, "xx1", "Unknown $2000 format (unpacked)", 0x2000, 10242,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
874 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
875 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
876 NULL,
906
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
877 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
878 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
879 NULL,
906
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
880 {
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
881 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
882 { DT_SCREEN_RAM, 0x2000, 0, 0, NULL, NULL },
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
883 { DT_COLOR_RAM, 0x2400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
884 { DT_COLOR_SET, 0x00 , 0, DC_BGCOL, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
885 { DT_LAST, 0, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
886 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
887 },
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
888
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
889 #define XX2_WIDTH_CH 40
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
890 #define XX2_HEIGHT_CH 10
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
891 #define XX2_SIZE (XX2_WIDTH_CH * XX2_HEIGHT_CH)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
892 #define XX2_BSIZE (XX2_SIZE * 8)
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
893
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
894 {
943
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
895 D64_FMT_MC, "xx2", "Unknown $2000 format (unpacked)", 0x2000, 0,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
896 XX2_WIDTH_CH * 4, XX2_HEIGHT_CH * 8,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
897 XX2_WIDTH_CH , XX2_HEIGHT_CH,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
898 fmtProbeFormatXX2,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
899 fmtDecodeFormatXX2, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
900 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
901 NULL,
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
902 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
903 { DT_BITMAP, 0x0000, 0, XX2_BSIZE, NULL, NULL },
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
904 { DT_COLOR_RAM, XX2_BSIZE + XX2_SIZE, 0, XX2_SIZE, NULL, NULL },
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
905 { DT_SCREEN_RAM, XX2_BSIZE, 0, XX2_SIZE, NULL, NULL },
1382
558776ee9603 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1381
diff changeset
906 { DT_COLOR_SET, 11, 0, DC_BGCOL, NULL, NULL },
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
907 { DT_LAST, 0, 0, 0, NULL, NULL },
906
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
908 }
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
909 },
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
910
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
911 {
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
912 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, "fp2", "FunPaint II (unpacked)", 0x3ff0, 33694,
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
913 C64_SCR_WIDTH, C64_SCR_HEIGHT,
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
914 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
915 fmtProbeFunPaint2Unpacked,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
916 fmtDecodeFunPaint2Unpacked, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
917 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
918 fmtGetPixelFunPaint2,
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
919 {
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
920 DEF_SCREEN_RAMS_8( 0x0000, 0, 0x400)
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
921 { DT_BITMAP, 0x2000, 0, 0, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
922 { DT_EXTRA_DATA, 0x3f40, 0, 100, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
923 { DT_COLOR_RAM, 0x4000, 0, 0, NULL, NULL },
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
924 DEF_SCREEN_RAMS_8( 0x43e8, 8, 0x400)
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
925 { DT_BITMAP, 0x63e8, 1, 0, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
926 { DT_EXTRA_DATA, 0x8328, 1, 100, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
927 { DT_LAST, 0, 0, 0, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
928 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
929 },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
930
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
931 {
1396
7acadc08bc72 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1394
diff changeset
932 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, "fp2p", "FunPaint II (packed)", 0x3ff0, 0,
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
933 C64_SCR_WIDTH, C64_SCR_HEIGHT,
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
934 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
935 fmtProbeFunPaint2Packed,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
936 fmtDecodeFunPaint2Packed, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
937 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
938 fmtGetPixelFunPaint2,
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
939 {
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
940 DEF_SCREEN_RAMS_8( 0x0000, 0, 0x400)
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
941 { DT_BITMAP, 0x2000, 0, 0, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
942 { DT_EXTRA_DATA, 0x3f40, 0, 100, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
943 { DT_COLOR_RAM, 0x4000, 0, 0, NULL, NULL },
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
944 DEF_SCREEN_RAMS_8( 0x43e8, 8, 0x400)
1384
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
945 { DT_BITMAP, 0x63e8, 1, 0, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
946 { DT_EXTRA_DATA, 0x8328, 1, 100, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
947 { DT_LAST, 0, 0, 0, NULL, NULL },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
948 }
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
949 },
ef20200d71d7 Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents: 1382
diff changeset
950
1389
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
951 {
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
952 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, "gun", "GunPaint (unpacked)", 0x4000, 0,
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
953 C64_SCR_WIDTH, C64_SCR_HEIGHT,
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
954 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
955 fmtProbeGunPaint,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
956 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
957 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
958 fmtGetPixelGunPaint,
1389
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
959 {
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
960 DEF_SCREEN_RAMS_8( 0x0000, 0, 0x400)
1389
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
961 { DT_BITMAP, 0x2000, 0, 0, NULL, NULL },
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
962 { DT_EXTRA_DATA, 0x3f4f, 0, 177, NULL, NULL },
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
963 { DT_COLOR_RAM, 0x4000, 0, 0, NULL, NULL },
1393
b5fc5a05033d Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents: 1392
diff changeset
964 DEF_SCREEN_RAMS_8( 0x4400, 8, 0x400)
1389
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
965 { DT_BITMAP, 0x6400, 1, 0, NULL, NULL },
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
966 { DT_EXTRA_DATA, 0x47e8, 1, 20, NULL, NULL },
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
967 { DT_LAST, 0, 0, 0, NULL, NULL },
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
968 }
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
969 },
979f550ead77 Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents: 1388
diff changeset
970
1394
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
971 {
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
972 D64_FMT_HIRES | D64_FMT_FLI, "chi", "Crest Hires FLI Designer (unpacked)", 0x4000, 16386,
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
973 C64_SCR_WIDTH, 14 * 8,
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
974 C64_SCR_CH_WIDTH , 14,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
975 NULL,
1394
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
976 NULL, NULL,
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
977 NULL, NULL,
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1433
diff changeset
978 fmtGetPixelCHFLI,
1394
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
979 {
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
980 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
981 DEF_SCREEN_RAMS_8( 0x2000, 0, 0x400)
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
982 { DT_LAST, 0, 0, 0, NULL, NULL },
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
983 }
054561dbcd57 Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents: 1393
diff changeset
984 },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
985 };
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
986
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
987 const int ndmC64ImageFormats = sizeof(dmC64ImageFormats) / sizeof(dmC64ImageFormats[0]);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
988
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
989
518
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
990 // Perform probing of the given data buffer, trying to determine
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
991 // if it contains a supported "C64" image format. Returns the
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
992 // "probe score", see libgfx.h for list of values. If a match
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
993 // is found, pointer to format description is set to *pfmt.
537
32d9e67da189 Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 536
diff changeset
994 int dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **pfmt)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
995 {
1380
959b34402b81 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1378
diff changeset
996 int scoreMax = DM_PROBE_SCORE_FALSE, scoreIndex = -1;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
997
1380
959b34402b81 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1378
diff changeset
998 for (int i = 0; i < ndmC64ImageFormats; i++)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
999 {
516
6f141f760c54 Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
1000 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1001 int score = DM_PROBE_SCORE_FALSE;
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1002 if (fmt->probe == NULL && fmt->size > 0 && fmt->addr > 0)
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1003 {
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1004 // Generic probe just checks matching size and load address
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1005 if (len == fmt->size && dmCompareAddr16(buf, 0, fmt->addr))
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1006 score = DM_PROBE_SCORE_GOOD;
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1007 }
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1008 else
1134
d0898867ec4c Various fixes for issues reported by clang static analyzer.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
1009 if (fmt->probe != NULL)
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1010 score = fmt->probe(buf, len, fmt);
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
1011
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1012 if (score > scoreMax)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1013 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1014 scoreMax = score;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1015 scoreIndex = i;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1016 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1017 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1018
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1019 if (scoreIndex >= 0)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1020 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1021 *pfmt = &dmC64ImageFormats[scoreIndex];
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1022 return scoreMax;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1023 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1024 else
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1025 return DM_PROBE_SCORE_FALSE;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1026 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1027
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1028
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1029 static int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img)
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1030 {
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1031 switch (op->type)
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1032 {
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1033 case DT_COLOR_RAM:
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1034 case DT_BITMAP:
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1035 case DT_SCREEN_RAM:
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1036 case DT_CHAR_DATA:
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1037 if (op->bank < 0 || op->bank > img->nbanks)
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1038 {
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1039 return dmError(DMERR_INTERNAL,
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1040 "Invalid bank %d / %d definition in generic encode/decode operator %d @ #%d.\n",
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1041 op->bank, img->nbanks, op->type, i);
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1042 }
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1043 break;
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1044
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1045 case DT_EXTRA_DATA:
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1046 if (op->bank < 0 || op->bank >= C64_MAX_EXTRA_DATA)
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1047 {
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1048 return dmError(DMERR_INTERNAL,
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1049 "Invalid bank %d definition in generic encode/decode operator %d @ #%d.\n",
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1050 op->bank, op->type, i);
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1051 }
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1052 break;
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1053 }
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1054
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1055 if (op->type < 0 || op->type >= DT_LAST)
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1056 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1057 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1058 "Invalid encode/decode operator type %d @ #%d.\n",
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1059 op->type, i);
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1060 }
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1061
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1062 return DMERR_OK;
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1063 }
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1064
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1065
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1066 static BOOL dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size)
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1067 {
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1068 BOOL check;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1069 switch (op->type)
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1070 {
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1071 case DT_SCREEN_RAM:
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1072 case DT_COLOR_RAM:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1073 *size = fmt->ch_height * fmt->ch_width;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1074 check = TRUE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1075 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1076
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1077 case DT_BITMAP:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1078 *size = fmt->ch_height * fmt->ch_width * 8;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1079 check = TRUE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1080 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1081
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1082 case DT_EXTRA_DATA:
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1083 *size = op->size;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1084 check = TRUE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1085 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1086
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1087 case DT_CHAR_DATA:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1088 *size = C64_MAX_CHARS * C64_CHR_SIZE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1089 check = TRUE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1090 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1091
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1092 case DT_COLOR_REG:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1093 *size = 1;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1094 check = FALSE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1095 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1096
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1097 default:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1098 *size = 0;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1099 check = FALSE;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1100 }
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1101
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1102 if (op->size != 0)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1103 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1104 if (check && op->size > *size)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1105 return FALSE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1106
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1107 *size = op->size;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1108 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1109
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1110 return TRUE;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1111 }
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1112
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
1113
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
1114 int dmC64DecodeGenericBMP(DMC64Image *img, const Uint8 *buf,
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1115 const size_t len, const DMC64ImageFormat *fmt)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1116 {
513
486067f39bc1 Add sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
1117 if (buf == NULL || img == NULL || fmt == NULL)
486067f39bc1 Add sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
1118 return DMERR_NULLPTR;
486067f39bc1 Add sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
1119
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
1120 // Clear the image structure, set basics
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1121 img->type = fmt->type;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1122 img->width = fmt->width;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1123 img->height = fmt->height;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1124 img->ch_width = fmt->ch_width;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1125 img->ch_height = fmt->ch_height;
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1126 img->nbanks = dmC64ImageGetNumBanks(fmt);
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1127
518
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
1128 // Perform decoding
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1129 for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1130 {
515
a896c1153e4e s/decenc/encdec/g
Matti Hamalainen <ccr@tnsp.org>
parents: 514
diff changeset
1131 const DMC64EncDecOp *op = &fmt->encdecOps[i];
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
1132 const Uint8 *src;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1133 size_t size;
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1134 int res;
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1135
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1136 // Check for last operator
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1137 if (op->type == DT_LAST)
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1138 break;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1139
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1140 // Check operation validity
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1141 if ((res = dmC64SanityCheckEncDecOp(i, op, img)) != DMERR_OK)
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1142 return res;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
1143
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1144 // Check size
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1145 if (!dmC64GetOpSize(op, fmt, &size))
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1146 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1147 return dmError(DMERR_INVALID_DATA,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1148 "Decode op SIZE out of bounds, op #%d type=%d, offs=%d ($%04x), "
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1149 "bank=%d, size=%d ($%04x) vs. allocated %d ($%04x)\n",
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1150 i, op->type, op->offs, op->offs, op->bank, size, size, op->size, op->size);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1151 }
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1152
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1153 // Do we need to reallocate some more space?
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1154 if (op->offs + size > len)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1155 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1156 return dmError(DMERR_INVALID_DATA,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1157 "Decode out of bounds, op #%d type=%d, offs=%d ($%04x), "
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1158 "bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1159 i, op->type, op->offs, op->offs, op->bank, size, size, len, len);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1160 }
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1161
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1162 src = buf + op->offs;
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1163
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1164 // Perform operation
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1165 switch (op->type)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1166 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1167 case DT_COLOR_RAM: memcpy(img->color[op->bank], src, size); break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1168 case DT_BITMAP: memcpy(img->bitmap[op->bank], src, size); break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1169 case DT_SCREEN_RAM: memcpy(img->screen[op->bank], src, size); break;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1170 case DT_CHAR_DATA: memcpy(img->charmem[op->bank], src, size); break;
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1171 case DT_EXTRA_DATA:
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1172 if (img->extraData[op->bank] != NULL)
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1173 {
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1174 return dmError(DMERR_INTERNAL,
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1175 "Extra data block already allocated and used! "
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1176 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1177 i, op->offs, op->offs, op->bank, size, size, len, len);
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1178 }
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1179 if ((img->extraData[op->bank] = dmMalloc0(size)) == NULL)
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1180 {
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1181 return dmError(DMERR_MALLOC,
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1182 "Could not allocate extradata block! "
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1183 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1184 i, op->offs, op->offs, op->bank, size, size, len, len);
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1185 }
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1186 img->extraDataSizes[op->bank] = size;
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1187 memcpy(img->extraData[op->bank], src, size);
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1188 break;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1189
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1190 case DT_COLOR_REG:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1191 switch (op->size)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1192 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1193 case DC_D020: img->d020 = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1194 case DC_BGCOL:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1195 case DC_D021: img->bgcolor = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1196 case DC_D022: img->d022 = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1197 case DC_D023: img->d023 = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1198 case DC_D024: img->d024 = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1199 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1200 return dmError(DMERR_INTERNAL,
1371
e6b13426b50a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1370
diff changeset
1201 "Unhandled DT_COLOR_REG mode %d in "
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1202 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1203 op->size, i, op->offs, op->offs, op->bank, size, size, len, len);
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1204 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1205 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1206
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1207 case DT_COLOR_SET:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1208 switch (op->size)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1209 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1210 case DC_D020: img->d020 = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1211 case DC_BGCOL:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1212 case DC_D021: img->bgcolor = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1213 case DC_D022: img->d022 = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1214 case DC_D023: img->d023 = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1215 case DC_D024: img->d024 = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1216 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1217 return dmError(DMERR_INTERNAL,
1371
e6b13426b50a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1370
diff changeset
1218 "Unhandled DT_COLOR_SET mode %d in "
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1219 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1220 op->size, i, op->offs, op->offs, op->bank, size, size, len, len);
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1221 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1222 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1223
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1224 case DT_CHAR_CONFIG:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1225 switch (op->offs)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1226 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1227 case D64_CHCFG_SCREEN:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1228 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1229
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1230 case D64_CHCFG_LINEAR:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1231 {
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1232 for (int bank = 0; bank < img->nbanks; bank++)
1371
e6b13426b50a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1370
diff changeset
1233 for (int offs = 0; offs < fmt->ch_height * fmt->ch_width; offs++)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1234 img->screen[bank][offs] = offs & 0xff;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1235 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1236 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1237
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1238 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1239 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1240 "Unhandled DT_CHAR_CONFIG mode %d in ",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1241 "op #%d, bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1242 op->offs, i, op->bank, size, size, len, len);
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1243 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1244 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1245
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1246 case DT_DEC_FUNCTION:
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1247 if (op->decfunction == NULL)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1248 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1249 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1250 "Decode op is a function, but function ptr is NULL: "
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1251 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1252 i, op->offs, op->offs, op->bank, size, size, len, len);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1253 }
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1254 if (!op->decfunction(img, op, buf, len))
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1255 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1256 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1257 "Decode op custom function failed: op #%d, "
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
1258 "offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1259 i, op->offs, op->offs, op->bank, size, size, len, len);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1260 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1261 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1262 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1263 }
916
3985f596ece5 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 915
diff changeset
1264
508
1ed5025c2538 Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents: 507
diff changeset
1265 return DMERR_OK;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1266 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1267
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1268
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1269 int dmC64EncodeGenericBMP(Uint8 **pbuf, size_t *plen, const DMC64Image *img, const DMC64ImageFormat *fmt)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1270 {
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1271 int res = DMERR_OK;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1272 Uint8 *buf;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1273 size_t allocated;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1274
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1275 if (pbuf == NULL || plen == NULL || img == NULL || fmt == NULL)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1276 return DMERR_NULLPTR;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1277
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1278 // Allocate the output buffer
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1279 *plen = 0;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1280 if (fmt->size > 0)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1281 *plen = allocated = fmt->size;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1282 else
935
77c07853797b Allocate somewhat larger initial encoding buffer for C64 image encoders.
Matti Hamalainen <ccr@tnsp.org>
parents: 934
diff changeset
1283 allocated = 16 * 1024;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1284
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1285 if ((buf = dmMalloc(allocated)) == NULL)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1286 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1287 return dmError(DMERR_MALLOC,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1288 "Could not allocate %d bytes of memory for C64 image encoding buffer.\n",
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1289 allocated);
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1290 goto err;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1291 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1292
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1293 // Perform encoding
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1294 for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++)
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1295 {
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1296 const DMC64EncDecOp *op = &fmt->encdecOps[i];
1448
50402c225ef4 Do not insert load address to the buffer beginning in dmC64EncodeGenericBMP().
Matti Hamalainen <ccr@tnsp.org>
parents: 1447
diff changeset
1297 Uint8 *dst = buf + op->offs;
1364
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
1298 size_t size, chksize;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1299
1365
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1300 // Check for last operator
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1301 if (op->type == DT_LAST)
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1302 break;
60d7240e1a63 Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents: 1364
diff changeset
1303
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1304 // Check operation validity
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1305 if ((res = dmC64SanityCheckEncDecOp(i, op, img)) != DMERR_OK)
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1306 goto err;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1307
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1308 // Check size
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1309 if (!dmC64GetOpSize(op, fmt, &size))
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1310 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1311 res = dmError(DMERR_INVALID_DATA,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1312 "Decode op SIZE out of bounds, op #%d type=%d, offs=%d ($%04x), "
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1313 "bank=%d, size=%d ($%04x) vs. allocated %d ($%04x)\n",
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1314 i, op->type, op->offs, op->offs, op->bank, size, size, op->size, op->size);
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1315 goto err;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1316 }
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1317
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1318 // Do we need to reallocate some more space?
1448
50402c225ef4 Do not insert load address to the buffer beginning in dmC64EncodeGenericBMP().
Matti Hamalainen <ccr@tnsp.org>
parents: 1447
diff changeset
1319 chksize = op->offs + size;
1364
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
1320 if (chksize > allocated)
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1321 {
1364
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
1322 size_t diff = allocated - chksize,
833
4f3828914890 Fix a 100L :S
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
1323 grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW;
934
fa15335238cf Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 932
diff changeset
1324
833
4f3828914890 Fix a 100L :S
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
1325 allocated += grow;
4f3828914890 Fix a 100L :S
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
1326
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1327 if ((buf = dmRealloc(buf, allocated)) == NULL)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1328 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1329 res = dmError(DMERR_MALLOC,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1330 "Could not re-allocate %d bytes of memory for C64 image encoding buffer.\n",
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1331 allocated);
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1332 goto err;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1333 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1334 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1335
1364
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
1336 if (fmt->size == 0 && chksize > *plen)
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
1337 *plen = chksize;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1338
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1339 // Perform operation
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1340 switch (op->type)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1341 {
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1342 case DT_COLOR_RAM: memcpy(dst, img->color[op->bank], size); break;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1343 case DT_BITMAP: memcpy(dst, img->bitmap[op->bank], size); break;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1344 case DT_SCREEN_RAM: memcpy(dst, img->screen[op->bank], size); break;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1345 case DT_CHAR_DATA: memcpy(dst, img->charmem[op->bank], size); break;
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1346 case DT_EXTRA_DATA:
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1347 if (img->extraData[op->bank] == NULL)
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1348 {
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1349 res = dmError(DMERR_NULLPTR,
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1350 "DT_EXTRA_DATA block is NULL in ",
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1351 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1352 i, op->offs, op->offs, op->bank, size, size, *plen, *plen);
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1353 goto err;
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1354 }
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1355 if (size > img->extraDataSizes[op->bank])
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1356 {
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1357 res = dmError(DMERR_INTERNAL,
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1358 "DT_EXTRA_DATA size mismatch %d <> %d in ",
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1359 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1360 op->size, img->extraDataSizes[op->bank], i, op->offs, op->offs, op->bank, size, size, *plen, *plen);
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1361 goto err;
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1362 }
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1363 memcpy(dst, img->extraData[op->bank], size);
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1372
diff changeset
1364 break;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1365
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1366 case DT_COLOR_REG:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1367 switch (op->size)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1368 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1369 case DC_D020: *dst = img->d020; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1370 case DC_BGCOL:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1371 case DC_D021: *dst = img->bgcolor; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1372 case DC_D022: *dst = img->d022; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1373 case DC_D023: *dst = img->d023; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1374 case DC_D024: *dst = img->d024; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1375 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1376 res = dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1377 "Unhandled DT_COLOR_REG mode %d in ",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1378 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1379 op->size, i, op->offs, op->offs, op->bank, size, size, *plen, *plen);
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1380 goto err;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1381 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1382 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1383
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1384 case DT_ENC_FUNCTION:
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1385 if (op->encfunction == NULL)
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1386 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1387 res = dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1388 "Encode op is a function, but function ptr is NULL: "
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1389 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1390 i, op->offs, op->offs, op->bank, size, size, *plen, *plen);
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1391 goto err;
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1392 }
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1393 /*
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1394 if (!op->encfunction(op, buf, len))
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1395 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1396 res = dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1397 "Encode op custom function failed: op #%d, "
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1398 "offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1399 i, op->offs, op->offs, op->bank, size, size, len, len);
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
1400 goto out;
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1401 }
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
1402 */
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1403 break;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1404 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1405 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1406
1448
50402c225ef4 Do not insert load address to the buffer beginning in dmC64EncodeGenericBMP().
Matti Hamalainen <ccr@tnsp.org>
parents: 1447
diff changeset
1407 res = DMERR_OK;
535
ab8d9696225c Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 534
diff changeset
1408
1447
de5f7e31a8bf Rename labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 1443
diff changeset
1409 err:
535
ab8d9696225c Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 534
diff changeset
1410 *pbuf = buf;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1411 return res;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1412 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1413
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1414
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1415 // Convert a generic "C64" format bitmap in DMC64Image struct to
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1416 // a indexed/paletted bitmap image.
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1417 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1418 {
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1419 DMC64GetPixelFunc getPixel;
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1420
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1421 // Sanity check arguments
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1422 if (dst == NULL || src == NULL)
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1423 return DMERR_NULLPTR;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1424
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1425 if (dst->width < src->width || dst->height < src->height)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1426 return DMERR_INVALID_DATA;
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1427
1167
848a88ce7a57 Use dmMemset().
Matti Hamalainen <ccr@tnsp.org>
parents: 1134
diff changeset
1428 dmMemset(dst->data, 0, dst->size);
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1429
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1430 // Check pixel getter function
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1431 if (fmt->getPixel != NULL)
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1432 getPixel = fmt->getPixel;
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1433 else
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
1434 getPixel = (fmt->type & D64_FMT_MC) ? fmtGetGenericMCPixel : fmtGetGenericSCPixel;
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1435
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1436 // Resolution interlaced pics need to halve the source width
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1437 int rwidth = src->width;
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1438 if ((src->type & D64_FMT_ILACE) && src->laceType == D64_ILACE_RES)
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1439 rwidth /= 2;
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1440
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1441 // Perform conversion
1411
a9afb2ad39cb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1396
diff changeset
1442 Uint8 *dp = dst->data;
a9afb2ad39cb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1396
diff changeset
1443 for (int yc = 0; yc < src->height; yc++)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1444 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1445 Uint8 *d = dp;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1446 const int y = yc / 8, yb = yc & 7;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1447 const int scroffsy = y * src->ch_width;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1448 int xc;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1449
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1450 if (src->type & D64_FMT_CHAR)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1451 {
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1452 // Charmode conversion
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1453 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1454 // Hi-res charmap
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1455 for (xc = 0; xc < rwidth; xc++)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1456 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1457 const int x = xc / 8;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1458 const int scroffs = scroffsy + x;
918
59615f9c2ca9 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 917
diff changeset
1459 const int chr = src->screen[0][scroffs];
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1460 const int v = 7 - (xc & 7);
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1461
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1462 if ((src->charmem[0][chr * C64_CHR_SIZE + yb] >> v) & 1)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1463 *d++ = src->color[0][scroffs];
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1464 else
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1465 *d++ = src->bgcolor;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1466 }
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1467 else
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1468 // Multicolor variants
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1469 for (xc = 0; xc < rwidth; xc++)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1470 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1471 const int x = xc / 4;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1472 const int scroffs = scroffsy + x;
918
59615f9c2ca9 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 917
diff changeset
1473 const int chr = src->screen[0][scroffs];
944
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1474 const int col = src->color[0][scroffs] & 15;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
1475
944
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1476 if (col & 8)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1477 {
944
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1478 const int v = 6 - ((xc * 2) & 6);
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1479 switch ((src->charmem[0][chr * C64_CHR_SIZE + yb] >> v) & 3)
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1480 {
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1481 case 0: *d++ = src->bgcolor; break;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1482 case 1: *d++ = src->d022; break;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1483 case 2: *d++ = src->d023; break;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1484 case 3: *d++ = col;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1485 }
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1486 }
944
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1487 else
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1488 {
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1489 const int v = 7 - (xc & 7);
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1490 if ((src->charmem[0][chr * C64_CHR_SIZE + yb] >> v) & 1)
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1491 *d++ = src->color[0][scroffs];
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1492 else
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1493 *d++ = src->bgcolor;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1494 }
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1495 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1496 }
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1497 else
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1498 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1499 // Perform generic BITMAP conversion
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1500 const int bmoffsy = y * src->ch_width * 8 + yb;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1501
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1502 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1503 // Hi-res bitmap
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1504 for (xc = 0; xc < rwidth; xc++)
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1505 {
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1506 const int x = xc / 8;
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1507 const int scroffs = scroffsy + x;
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1508 const int bmoffs = bmoffsy + (x * 8);
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1509 const int vshift = 7 - (xc & 7);
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1510
1387
14d79e4d82cf Oops, 100L. Had forgotten to change singlecolor mode handling pixel getter
Matti Hamalainen <ccr@tnsp.org>
parents: 1385
diff changeset
1511 *d++ = getPixel(src, bmoffs, scroffs, vshift, 0, yc);
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1512 }
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1513 else
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1514 // Multicolor bitmap and variants
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1515 for (xc = 0; xc < rwidth; xc++)
529
1bce06b5026f Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
1516 {
901
f532262f90b1 Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents: 857
diff changeset
1517 const int x = xc / 4;
f532262f90b1 Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents: 857
diff changeset
1518 const int scroffs = scroffsy + x;
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1519 const int bmoffs = bmoffsy + (x * 8);
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1520 const int vshift = 6 - ((xc * 2) & 6);
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1521
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1522 if (src->type & D64_FMT_ILACE)
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1523 {
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1524 switch (src->laceType)
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1525 {
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1526 case D64_ILACE_RES:
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
1527 *d++ = getPixel(src, bmoffs, scroffs, vshift, 0, yc);
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
1528 *d++ = getPixel(src, bmoffs, scroffs, vshift, 1, yc);
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1529 break;
1366
d4387509a363 Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents: 1365
diff changeset
1530
d4387509a363 Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents: 1365
diff changeset
1531 default:
d4387509a363 Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents: 1365
diff changeset
1532 return DMERR_NOT_SUPPORTED;
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1533 }
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1534 }
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1535 else
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1536 {
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
1537 *d++ = getPixel(src, bmoffs, scroffs, vshift, 0, yc);
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1538 }
529
1bce06b5026f Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
1539 }
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1540 }
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1541 dp += dst->pitch;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1542 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1543
508
1ed5025c2538 Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents: 507
diff changeset
1544 return DMERR_OK;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1545 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1546
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1547
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1548 int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt)
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1549 {
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1550 int res;
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1551 DMImage *dst;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1552
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1553 if (pdst == NULL || src == NULL)
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1554 return DMERR_NULLPTR;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1555
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1556 // Allocate image structure
1289
Matti Hamalainen <ccr@tnsp.org>
parents: 1235
diff changeset
1557 if ((*pdst = dst = dmImageAlloc(src->width, src->height, DM_IFMT_PALETTE, -1)) == NULL)
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1558 return DMERR_MALLOC;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1559
1426
4c7b456d7f0b Rename global dmC64Palette to dmDefaultC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents: 1425
diff changeset
1560 // Set partial palette information
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1561 dst->ncolors = C64_NCOLORS;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1562 dst->constpal = TRUE;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1563
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1564 // Convert
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1565 if (fmt->convertFrom != NULL)
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1566 res = fmt->convertFrom(dst, src, fmt);
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1567 else
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
1568 res = dmC64ConvertGenericBMP2Image(dst, src, fmt);
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1569
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1570 return res;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1571 }
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1572
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1573
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1574 int dmC64DecodeBMP(DMC64Image **img, const Uint8 *buf, const size_t len,
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1575 const size_t probeOffs, const size_t loadOffs,
516
6f141f760c54 Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
1576 const DMC64ImageFormat **fmt, const DMC64ImageFormat *forced)
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1577 {
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1578 if (img == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1579 return DMERR_NULLPTR;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1580
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1581 // Check for forced format
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1582 if (forced != NULL)
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1583 *fmt = forced;
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1584 else
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1585 {
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1586 // Nope, perform a generic probe
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1587 if (probeOffs >= len)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1588 return DMERR_INVALID_DATA;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1589
537
32d9e67da189 Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 536
diff changeset
1590 if (dmC64ProbeBMP(buf + probeOffs, len - probeOffs, fmt) == DM_PROBE_SCORE_FALSE)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1591 return DMERR_INVALID_DATA;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1592 }
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1593
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1594 if (loadOffs >= len)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1595 return DMERR_INVALID_ARGS;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1596
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1597 if (*fmt == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1598 return DMERR_INVALID_DATA;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1599
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1600 // Allocate memory
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1377
diff changeset
1601 if ((*img = dmC64ImageAlloc(*fmt)) == NULL)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1602 return DMERR_MALLOC;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1603
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1604 // Decode the bitmap to memory layout
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1605 if ((*fmt)->decode != NULL)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1606 return (*fmt)->decode(*img, buf + loadOffs, len - loadOffs, *fmt);
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1607 else
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1608 return dmC64DecodeGenericBMP(*img, buf + loadOffs, len - loadOffs, *fmt);
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1609 }