Mercurial > hg > dmlib
annotate tools/lib64gfx.c @ 1381:b6782b785457
Move things around a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 24 Sep 2017 19:51:23 +0300 |
parents | 959b34402b81 |
children | 558776ee9603 |
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 |
1308
8f71ca1900ea
Update header blurps and copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents:
1289
diff
changeset
|
5 * (C) Copyright 2012-2017 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 | 10 |
514 | 11 #define BUF_SIZE_INITIAL (16*1024) |
12 #define BUF_SIZE_GROW (4*1024) | |
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 | 15 // Based on Pepto's palette, stolen from VICE |
16 DMColor dmC64Palette[C64_NCOLORS] = | |
17 { | |
18 { 0x00, 0x00, 0x00, 0xff }, | |
19 { 0xFF, 0xFF, 0xFF, 0xff }, | |
20 { 0x68, 0x37, 0x2B, 0xff }, | |
21 { 0x70, 0xA4, 0xB2, 0xff }, | |
22 { 0x6F, 0x3D, 0x86, 0xff }, | |
23 { 0x58, 0x8D, 0x43, 0xff }, | |
24 { 0x35, 0x28, 0x79, 0xff }, | |
25 { 0xB8, 0xC7, 0x6F, 0xff }, | |
26 { 0x6F, 0x4F, 0x25, 0xff }, | |
27 { 0x43, 0x39, 0x00, 0xff }, | |
28 { 0x9A, 0x67, 0x59, 0xff }, | |
29 { 0x44, 0x44, 0x44, 0xff }, | |
30 { 0x6C, 0x6C, 0x6C, 0xff }, | |
31 { 0x9A, 0xD2, 0x84, 0xff }, | |
32 { 0x6C, 0x5E, 0xB5, 0xff }, | |
33 { 0x95, 0x95, 0x95, 0xff }, | |
34 }; | |
35 | |
36 | |
37 #define DM_GET_ADDR_LO(addr) ((addr) & 0xff) | |
38 #define DM_GET_ADDR_HI(addr) (((addr) >> 8) & 0xff) | |
39 | |
40 | |
41 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr) | |
42 { | |
43 return buf[offs ] == DM_GET_ADDR_LO(addr) && | |
44 buf[offs + 1] == DM_GET_ADDR_HI(addr); | |
45 } | |
46 | |
47 | |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
48 int dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
49 { |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
50 int nbanks = 0; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
51 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
|
52 { |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
53 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
54 if (op->type == DT_LAST) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
55 break; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
56 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
57 if (op->bank > nbanks) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
58 nbanks = op->bank; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
59 } |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
60 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
61 return nbanks + 1; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
62 } |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
63 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
64 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
65 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
|
66 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
67 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
|
68 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
69 if (img == NULL) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
70 return NULL; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
71 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
72 // Initialize image information |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
73 img->width = fmt->width; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
74 img->height = fmt->height; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
75 img->ch_width = fmt->ch_width; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
76 img->ch_height = fmt->ch_height; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
77 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
|
78 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
79 // Allocate banks |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
80 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
|
81 (img->bitmap = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL || |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
82 (img->screen = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL || |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
83 (img->charmem = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
84 goto err; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
85 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
86 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
|
87 { |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
88 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
|
89 goto err; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
90 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
91 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
|
92 goto err; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
93 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
94 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
|
95 goto err; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
96 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
97 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
|
98 goto err; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
99 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
100 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
101 return img; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
102 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
103 err: |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
104 dmC64ImageFree(img); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
105 return NULL; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
106 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
107 |
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 void dmC64ImageFree(DMC64Image *img) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
110 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
111 if (img != NULL) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
112 { |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
113 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
|
114 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
115 dmFree(img->color[i]); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
116 dmFree(img->bitmap[i]); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
117 dmFree(img->screen[i]); |
932 | 118 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
|
119 } |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
120 |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
121 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
|
122 dmFree(img->extraData[i]); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
123 |
1167 | 124 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
|
125 dmFree(img); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
126 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
127 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
128 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
129 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
130 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
|
131 { |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
132 *buf = 0; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
133 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
134 if (type & D64_FMT_FLI) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
135 strncat(buf, "FLI ", len - strlen(buf)); |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
136 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
137 strncat(buf, (type & D64_FMT_MC) ? "MCol " : "HiRes ", len - strlen(buf)); |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
138 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
139 if (type & D64_FMT_ILACE) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
140 strncat(buf, "Ilace ", len - strlen(buf)); |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
141 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
142 if (type & D64_FMT_CHAR) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
143 strncat(buf, "CharMap", len - strlen(buf)); |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
144 |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
145 return buf; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
146 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
147 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 |
827 | 149 int dmC64ConvertCSDataToImage(DMImage *img, |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
150 int xoffs, int yoffs, const Uint8 *buf, |
915 | 151 int width, int height, BOOL multicolor, |
152 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
|
153 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 int yc, widthpx = width * 8; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
155 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
|
156 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 if (img == NULL) |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
158 return DMERR_NULLPTR; |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
159 |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
160 if (xoffs < 0 || yoffs < 0 || |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
161 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
|
162 yoffs > img->height - height) |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
163 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
|
164 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 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
|
166 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 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
|
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 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
|
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 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
|
172 int xc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
173 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
|
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 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
|
176 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 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
|
178 const int v = 6 - ((xc * 2) & 6); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
179 const Uint8 c = colors[(b >> v) & 3]; |
925 | 180 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 *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
|
182 *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
|
183 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
184 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
185 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
|
186 } |
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 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
189 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 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
|
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 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
|
193 int xc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
194 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
|
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 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
|
197 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
198 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
|
199 const int v = 7 - (xc & 7); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
200 const Uint8 c = colors[(b >> v) & 1]; |
925 | 201 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
202 *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
|
203 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
205 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
|
206 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
207 } |
925 | 208 |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
209 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
|
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
212 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
213 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
|
214 { |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
215 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
|
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 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
|
218 return DMERR_MALLOC; |
925 | 219 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
220 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
|
221 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
|
222 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
223 while (src <= srcEnd && 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
|
224 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
225 int 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
|
226 if (c == rleMarker && src + 2 <= srcEnd) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
227 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 *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
|
232 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
233 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
234 *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
|
235 } |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
236 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
237 *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
|
238 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
239 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
|
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 |
519 | 242 |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
243 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
|
244 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
|
245 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
|
246 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
247 (void) cbank; |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
248 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
|
249 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
|
250 else |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
251 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
|
252 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
253 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
254 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
255 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
|
256 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
|
257 const int vshift, const int vbank, const int vbitmap, const int cbank) |
1369 | 258 { |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
259 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
|
260 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 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
|
265 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
266 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
267 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
268 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
269 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
|
270 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
|
271 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
|
272 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
273 (void) raster; |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
274 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
|
275 } |
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 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
278 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
|
279 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
|
280 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
|
281 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
282 (void) raster; |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
283 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0); |
1369 | 284 } |
285 | |
286 | |
287 static int fmtProbeDrazPaint20Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) | |
288 { | |
289 const char *ident = (const char *) buf + 2; | |
290 | |
291 if (len > 22 && | |
292 dmCompareAddr16(buf, 0, fmt->addr) && | |
293 strncmp(ident, "DRAZPAINT ", 10) == 0 && | |
294 ident[11] == '.' && ( | |
295 (ident[10] == '1' && ident[12] == '4') || | |
296 (ident[10] == '2' && ident[12] == '0') | |
297 )) | |
298 return DM_PROBE_SCORE_MAX; | |
299 | |
300 return DM_PROBE_SCORE_FALSE; | |
301 } | |
302 | |
303 | |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
304 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
|
305 { |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
306 int res; |
1372 | 307 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
|
308 |
1372 | 309 if ((res = dmDecodeGenericRLE(&mem, &end, buf + 0x0e, buf + len, *(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
|
310 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
|
311 |
1372 | 312 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
|
313 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
314 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
|
315 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
|
316 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
|
317 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
318 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
320 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
|
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 const char *ident = (const char *) buf + 2; |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
323 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
|
324 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
|
325 strncmp(ident, "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
|
326 return DM_PROBE_SCORE_MAX; |
925 | 327 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
328 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
|
329 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
330 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
331 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
332 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
|
333 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
334 (void) len; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
335 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
|
336 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
|
337 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
338 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
340 #define AMICA_DM_PROBE_SIZE 2048 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
341 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
|
342 { |
541
7ca6abbbbb40
Use size_t instead of int here to avoid signedness issues.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
343 size_t i, n; |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
344 if (len < AMICA_DM_PROBE_SIZE || !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
|
345 return DM_PROBE_SCORE_FALSE; |
925 | 346 |
494
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
347 // Interpaint Hi-Res gives a false positive |
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
348 if (len == 9002) |
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
349 return DM_PROBE_SCORE_FALSE; |
925 | 350 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
351 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
|
352 if (buf[i] == 0xC2) n++; |
925 | 353 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 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
|
358 if (n > 10) |
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
359 return DM_PROBE_SCORE_MAYBE; |
1369 | 360 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
361 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
|
362 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
363 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
364 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
365 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
|
366 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
367 int res; |
1372 | 368 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
|
369 |
1372 | 370 if ((res = dmDecodeGenericRLE(&mem, &end, buf, buf + len, 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
|
371 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
|
372 |
1372 | 373 res = dmC64DecodeGenericBMP(img, mem, end - mem + 1, fmt); |
925 | 374 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
375 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
|
376 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
|
377 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
|
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
380 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
381 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
|
382 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
383 (void) op; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
384 (void) buf; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
385 (void) len; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
386 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
|
387 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
|
388 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
389 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
390 |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
391 static Uint8 fmtGetPixelTruePaint( |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
392 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
|
393 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
|
394 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
395 (void) raster; |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
396 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
|
397 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
398 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
399 |
1369 | 400 #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
|
401 |
943
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
402 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
|
403 { |
1369 | 404 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
|
405 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
|
406 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
|
407 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
408 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
|
409 } |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
410 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
411 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
412 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
|
413 { |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
414 int res; |
1377 | 415 |
1369 | 416 // If there is only data for less than XX2_MIN_SIZE bytes, |
417 // allocate a buffer of that size and copy data there. | |
418 // Otherwise allocate len bytes. | |
419 size_t nlen = len < XX2_MIN_SIZE ? XX2_MIN_SIZE : len; | |
420 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
|
421 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
|
422 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
|
423 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
424 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
|
425 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
|
426 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
427 dmFree(mem); |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
428 return res; |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
429 } |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
430 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
431 |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
432 static Uint8 fmtGetPixelBMFLI( |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
433 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
|
434 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
|
435 { |
1380 | 436 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
|
437 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
|
438 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
439 case 0: return img->extraData[0][raster]; break; |
1380 | 440 case 1: return img->screen[vbank][scroffs] >> 4; break; |
441 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
|
442 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
|
443 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
444 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
445 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
446 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
447 static Uint8 fmtGetPixelFLIDesigner( |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
448 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
|
449 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
|
450 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
451 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
|
452 } |
943
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
453 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
454 |
1369 | 455 // |
456 // Array with data for supported formats | |
457 // | |
516 | 458 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
|
459 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
460 { |
924
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
461 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
|
462 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
463 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
464 fmtProbeDrazPaint20Packed, fmtDecodeDrazPaintPacked, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
465 NULL, NULL, 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
|
466 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
467 { 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
|
468 { 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
|
469 { 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
|
470 { 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
|
471 { 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
|
472 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
473 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
474 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
475 { |
924
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
476 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
|
477 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
|
478 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
479 fmtProbeDrazLace10Packed, fmtDecodeDrazPaintPacked, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
480 NULL, NULL, 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
|
481 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
482 { 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
|
483 { 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
|
484 { 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
|
485 { 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
|
486 { 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
|
487 { 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
|
488 { 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
|
489 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
490 }, |
925 | 491 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
492 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
493 D64_FMT_MC, "drp", "DrazPaint (unpacked)", 0x5800, 10051, |
939
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
494 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
495 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
496 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
497 NULL, NULL, 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
|
498 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
499 { 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
|
500 { 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
|
501 { 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
|
502 { 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
|
503 { 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
|
504 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
505 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
506 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
507 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
508 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
|
509 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
|
510 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
511 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
512 NULL, NULL, 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
|
513 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
514 { 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
|
515 { 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
|
516 { 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
|
517 { 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
|
518 { 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
|
519 { 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
|
520 { 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
|
521 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 }, |
925 | 523 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
524 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
525 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
|
526 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
|
527 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
528 NULL, NULL, |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
529 NULL, NULL, NULL, 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
|
530 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
531 { 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
|
532 { 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
|
533 { 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
|
534 { 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
|
535 { 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
|
536 { 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
|
537 { 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
|
538 { 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
|
539 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
540 }, |
925 | 541 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
542 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
543 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
|
544 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
545 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
546 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
547 NULL, NULL, 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
|
548 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
549 { 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
|
550 { 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
|
551 { 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
|
552 { 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
|
553 { 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
|
554 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
555 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
556 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
557 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
558 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
|
559 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
560 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
561 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
562 NULL, NULL, NULL, NULL, |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
563 { |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
564 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
565 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
566 { 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
|
567 { 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
|
568 { DT_LAST, 0, 0, 0, NULL, NULL }, |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
569 } |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
570 }, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
571 |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
572 { |
924
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
573 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
|
574 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
575 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
576 fmtProbeAmicaPaintPacked, fmtDecodeAmicaPaintPacked, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
577 NULL, NULL, 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
|
578 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
579 { 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
|
580 { 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
|
581 { 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
|
582 { 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
|
583 { 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
|
584 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
585 }, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
586 |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
587 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
588 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
|
589 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
590 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
591 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
592 NULL, NULL, NULL, NULL, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
593 { |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
594 { 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
|
595 { 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
|
596 { 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
|
597 { 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
|
598 { 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
|
599 } |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
600 }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
601 |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
602 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
603 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
|
604 C64_SCR_WIDTH , C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
605 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
606 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
607 NULL, NULL, NULL, NULL, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
608 { |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
609 { 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
|
610 { 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
|
611 { 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
|
612 } |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
613 }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
614 |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
615 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
616 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
|
617 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
|
618 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
619 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
620 NULL, NULL, NULL, NULL, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
621 { |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
622 { 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
|
623 { 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
|
624 { 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
|
625 } |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
626 }, |
1370
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
627 { |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
628 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
|
629 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
630 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
631 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
632 NULL, NULL, NULL, NULL, |
1370
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
633 { |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
634 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
635 { 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
|
636 { 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
|
637 { 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
|
638 { DT_LAST, 0, 0, 0, NULL, NULL }, |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
639 } |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
640 }, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
641 |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
642 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
643 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
|
644 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
|
645 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
646 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
647 NULL, NULL, NULL, NULL, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
648 { |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
649 { 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
|
650 { 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
|
651 { 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
|
652 } |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
653 }, |
905 | 654 |
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
|
655 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
656 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
|
657 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
658 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
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
|
659 NULL, NULL, |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
660 NULL, NULL, NULL, 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
|
661 { |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
662 { 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
|
663 { DT_COLOR_RAM, 0x0100, 0, 0, NULL, NULL }, |
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
|
664 |
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
|
665 { DT_SCREEN_RAM, 0x0500, 0, 0, NULL, NULL }, |
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
|
666 { DT_SCREEN_RAM, 0x0900, 1, 0, NULL, NULL }, |
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
|
667 { DT_SCREEN_RAM, 0x0d00, 2, 0, NULL, NULL }, |
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
|
668 { DT_SCREEN_RAM, 0x1100, 3, 0, NULL, NULL }, |
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
|
669 |
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
|
670 { DT_SCREEN_RAM, 0x1500, 4, 0, NULL, NULL }, |
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
|
671 { DT_SCREEN_RAM, 0x1900, 5, 0, NULL, NULL }, |
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
|
672 { DT_SCREEN_RAM, 0x1d00, 6, 0, NULL, NULL }, |
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
|
673 { DT_SCREEN_RAM, 0x2100, 7, 0, NULL, NULL }, |
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
|
674 |
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
|
675 { 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
|
676 { 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
|
677 } |
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
|
678 }, |
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
|
679 |
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
|
680 { |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
681 D64_FMT_MC | D64_FMT_FLI, "fli", "FLI Designer 1 (unpacked)", 0x3c00, 17409, |
939
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
682 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
683 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
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
|
684 NULL, NULL, |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
685 NULL, NULL, NULL, 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
|
686 { |
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
|
687 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL }, |
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
|
688 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL }, |
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
|
689 { DT_SCREEN_RAM, 0x0800, 1, 0, NULL, NULL }, |
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
|
690 { DT_SCREEN_RAM, 0x0c00, 2, 0, NULL, NULL }, |
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
|
691 { DT_SCREEN_RAM, 0x1000, 3, 0, NULL, NULL }, |
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
|
692 { DT_SCREEN_RAM, 0x1400, 4, 0, NULL, NULL }, |
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
|
693 { DT_SCREEN_RAM, 0x1800, 5, 0, NULL, NULL }, |
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
|
694 { DT_SCREEN_RAM, 0x1c00, 6, 0, NULL, NULL }, |
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
|
695 { DT_SCREEN_RAM, 0x2000, 7, 0, NULL, NULL }, |
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
|
696 { 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
|
697 { 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
|
698 } |
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
|
699 }, |
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
|
700 |
906
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
701 { |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
702 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
|
703 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
704 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
906
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
705 NULL, NULL, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
706 NULL, NULL, 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
|
707 { |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
708 { 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
|
709 { 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
|
710 { 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
|
711 { 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
|
712 { 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
|
713 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
714 }, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
715 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
716 #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
|
717 #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
|
718 #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
|
719 #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
|
720 |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
721 { |
943
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
722 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
|
723 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
|
724 XX2_WIDTH_CH , XX2_HEIGHT_CH, |
943
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
725 fmtProbeFormatXX2, fmtDecodeFormatXX2, |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
726 NULL, NULL, NULL, NULL, |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
727 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
728 { 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
|
729 { 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
|
730 { DT_SCREEN_RAM, XX2_BSIZE, 0, XX2_SIZE, NULL, NULL }, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
731 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
732 { 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
|
733 { 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
|
734 } |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
735 }, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
736 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
737 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
738 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
|
739 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
740 |
518 | 741 // Perform probing of the given data buffer, trying to determine |
742 // if it contains a supported "C64" image format. Returns the | |
743 // "probe score", see libgfx.h for list of values. If a match | |
744 // 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
|
745 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
|
746 { |
1380 | 747 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
|
748 |
1380 | 749 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
|
750 { |
516 | 751 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
|
752 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
|
753 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
|
754 { |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
755 // 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
|
756 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
|
757 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
|
758 } |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
759 else |
1134
d0898867ec4c
Various fixes for issues reported by clang static analyzer.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
760 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
|
761 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
|
762 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
763 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
|
764 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
765 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
|
766 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
|
767 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
768 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
769 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
770 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
|
771 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
772 *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
|
773 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
|
774 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
775 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
776 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
|
777 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
778 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
779 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
780 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
|
781 { |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
782 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
|
783 { |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
784 case DT_COLOR_RAM: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
785 case DT_BITMAP: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
786 case DT_SCREEN_RAM: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
787 case DT_CHAR_DATA: |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
788 if (op->bank < 0 || op->bank > img->nbanks) |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
789 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
790 return dmError(DMERR_INTERNAL, |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
791 "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
|
792 op->bank, img->nbanks, op->type, i); |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
793 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
794 break; |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
795 |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
796 case DT_EXTRA_DATA: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
797 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
|
798 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
799 return dmError(DMERR_INTERNAL, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
800 "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
|
801 op->bank, op->type, i); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
802 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
803 break; |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
804 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
805 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
806 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
|
807 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
808 return dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
809 "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
|
810 op->type, i); |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
811 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
812 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
813 return DMERR_OK; |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
814 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
815 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
816 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
817 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
|
818 { |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
819 BOOL check; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
820 switch (op->type) |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
821 { |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
822 case DT_SCREEN_RAM: |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
823 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
|
824 *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
|
825 check = TRUE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
826 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
827 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
828 case DT_BITMAP: |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
829 *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
|
830 check = TRUE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
831 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
832 |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
833 case DT_EXTRA_DATA: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
834 *size = op->size; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
835 check = TRUE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
836 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
837 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
838 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
|
839 *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
|
840 check = TRUE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
841 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
842 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
843 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
|
844 *size = 1; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
845 check = FALSE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
846 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
847 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
848 default: |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
849 *size = 0; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
850 check = FALSE; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
851 } |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
852 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
853 if (op->size != 0) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
854 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
855 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
|
856 return FALSE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
857 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
858 *size = op->size; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
859 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
860 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
861 return TRUE; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
862 } |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
863 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
864 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
865 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
|
866 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
|
867 { |
513 | 868 if (buf == NULL || img == NULL || fmt == NULL) |
869 return DMERR_NULLPTR; | |
870 | |
925 | 871 // 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
|
872 img->type = fmt->type; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
873 img->width = fmt->width; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
874 img->height = fmt->height; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
875 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
|
876 img->ch_height = fmt->ch_height; |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
877 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
|
878 |
518 | 879 // Perform decoding |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
880 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
|
881 { |
515 | 882 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
883 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
|
884 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
|
885 int res; |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
886 |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
887 // Check for last operator |
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
888 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
|
889 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
|
890 |
811 | 891 // Check operation validity |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
892 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
|
893 return res; |
925 | 894 |
811 | 895 // Check size |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
896 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
|
897 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
898 return dmError(DMERR_INVALID_DATA, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
899 "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
|
900 "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
|
901 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
|
902 } |
811 | 903 |
904 // 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
|
905 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
|
906 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
907 return dmError(DMERR_INVALID_DATA, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
908 "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
|
909 "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
|
910 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
|
911 } |
811 | 912 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
913 src = buf + op->offs; |
811 | 914 |
915 // 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
|
916 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
|
917 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
918 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
|
919 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
|
920 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
|
921 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
|
922 case DT_EXTRA_DATA: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
923 if (img->extraData[op->bank] != NULL) |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
924 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
925 return dmError(DMERR_INTERNAL, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
926 "Extra data block already allocated and used! " |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
927 "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
|
928 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
|
929 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
930 if ((img->extraData[op->bank] = dmMalloc0(size)) == NULL) |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
931 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
932 return dmError(DMERR_MALLOC, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
933 "Could not allocate extradata block! " |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
934 "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
|
935 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
|
936 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
937 img->extraDataSizes[op->bank] = size; |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
938 memcpy(img->extraData[op->bank], src, size); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
939 break; |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
940 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
941 case DT_COLOR_REG: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
942 switch (op->size) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
943 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
944 case DC_D020: img->d020 = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
945 case DC_BGCOL: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
946 case DC_D021: img->bgcolor = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
947 case DC_D022: img->d022 = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
948 case DC_D023: img->d023 = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
949 case DC_D024: img->d024 = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
950 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
951 return dmError(DMERR_INTERNAL, |
1371 | 952 "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
|
953 "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
|
954 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
|
955 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
956 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
957 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
958 case DT_COLOR_SET: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
959 switch (op->size) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
960 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
961 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
|
962 case DC_BGCOL: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
963 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
|
964 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
|
965 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
|
966 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
|
967 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
968 return dmError(DMERR_INTERNAL, |
1371 | 969 "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
|
970 "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
|
971 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
|
972 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
973 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
974 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
975 case DT_CHAR_CONFIG: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
976 switch (op->offs) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
977 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
978 case D64_CHCFG_SCREEN: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
979 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
980 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
981 case D64_CHCFG_LINEAR: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
982 { |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
983 for (int bank = 0; bank < img->nbanks; bank++) |
1371 | 984 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
|
985 img->screen[bank][offs] = offs & 0xff; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
986 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
987 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
988 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
989 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
990 return dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
991 "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
|
992 "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
|
993 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
|
994 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
995 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
996 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
997 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
|
998 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
|
999 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1000 return dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1001 "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
|
1002 "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
|
1003 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
|
1004 } |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1005 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
|
1006 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1007 return dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1008 "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
|
1009 "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
|
1010 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
|
1011 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1012 break; |
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 } |
916 | 1015 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
1016 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
|
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 |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1020 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
|
1021 { |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1022 int res = DMERR_OK; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1023 Uint8 *buf; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1024 size_t allocated; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1025 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1026 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
|
1027 return DMERR_NULLPTR; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1028 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1029 // Allocate the output buffer |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1030 *plen = 0; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1031 if (fmt->size > 0) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1032 *plen = allocated = fmt->size; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1033 else |
935
77c07853797b
Allocate somewhat larger initial encoding buffer for C64 image encoders.
Matti Hamalainen <ccr@tnsp.org>
parents:
934
diff
changeset
|
1034 allocated = 16 * 1024; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1035 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1036 if ((buf = dmMalloc(allocated)) == NULL) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1037 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1038 return dmError(DMERR_MALLOC, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1039 "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
|
1040 allocated); |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1041 goto error; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1042 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1043 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1044 // Perform encoding |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1045 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
|
1046 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1047 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
536
18fc2890ba4b
Take loading address into account while encoding, so start other data from offset +2.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
1048 Uint8 *dst = 2 + buf + op->offs; |
1364 | 1049 size_t size, chksize; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1050 |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1051 // Check for last operator |
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1052 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
|
1053 break; |
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1054 |
811 | 1055 // Check operation validity |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1056 if ((res = dmC64SanityCheckEncDecOp(i, op, img)) != DMERR_OK) |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1057 goto error; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1058 |
811 | 1059 // Check size |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1060 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
|
1061 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1062 res = dmError(DMERR_INVALID_DATA, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1063 "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
|
1064 "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
|
1065 i, op->type, op->offs, op->offs, op->bank, size, size, op->size, op->size); |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1066 goto error; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1067 } |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1068 |
811 | 1069 // Do we need to reallocate some more space? |
1364 | 1070 chksize = op->offs + size + 2; |
1071 if (chksize > allocated) | |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1072 { |
1364 | 1073 size_t diff = allocated - chksize, |
833 | 1074 grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW; |
934 | 1075 |
833 | 1076 allocated += grow; |
1077 | |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1078 if ((buf = dmRealloc(buf, allocated)) == NULL) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1079 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1080 res = dmError(DMERR_MALLOC, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1081 "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
|
1082 allocated); |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1083 goto error; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1084 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1085 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1086 |
1364 | 1087 if (fmt->size == 0 && chksize > *plen) |
1088 *plen = chksize; | |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1089 |
811 | 1090 // Perform operation |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1091 switch (op->type) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1092 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1093 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
|
1094 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
|
1095 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
|
1096 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
|
1097 case DT_EXTRA_DATA: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1098 if (img->extraData[op->bank] == NULL) |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1099 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1100 res = dmError(DMERR_NULLPTR, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1101 "DT_EXTRA_DATA block is NULL in ", |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1102 "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
|
1103 i, op->offs, op->offs, op->bank, size, size, *plen, *plen); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1104 goto error; |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1105 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1106 if (size > img->extraDataSizes[op->bank]) |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1107 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1108 res = dmError(DMERR_INTERNAL, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1109 "DT_EXTRA_DATA size mismatch %d <> %d in ", |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1110 "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
|
1111 op->size, img->extraDataSizes[op->bank], i, op->offs, op->offs, op->bank, size, size, *plen, *plen); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1112 goto error; |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1113 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1114 memcpy(dst, img->extraData[op->bank], size); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1115 break; |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1116 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1117 case DT_COLOR_REG: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1118 switch (op->size) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1119 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1120 case DC_D020: *dst = img->d020; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1121 case DC_BGCOL: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1122 case DC_D021: *dst = img->bgcolor; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1123 case DC_D022: *dst = img->d022; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1124 case DC_D023: *dst = img->d023; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1125 case DC_D024: *dst = img->d024; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1126 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1127 res = dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1128 "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
|
1129 "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
|
1130 op->size, i, op->offs, op->offs, op->bank, size, size, *plen, *plen); |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1131 goto error; |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1132 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1133 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1134 |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1135 case DT_ENC_FUNCTION: |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1136 if (op->encfunction == NULL) |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1137 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1138 res = dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1139 "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
|
1140 "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
|
1141 i, op->offs, op->offs, op->bank, size, size, *plen, *plen); |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1142 goto error; |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1143 } |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1144 /* |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1145 if (!op->encfunction(op, buf, len)) |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1146 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1147 res = dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1148 "Encode op custom function failed: op #%d, " |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1149 "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
|
1150 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
|
1151 goto out; |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1152 } |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1153 */ |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1154 break; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1155 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1156 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1157 |
535
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
1158 buf[0] = DM_GET_ADDR_LO(fmt->addr); |
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
1159 buf[1] = DM_GET_ADDR_HI(fmt->addr); |
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
1160 |
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
1161 *pbuf = buf; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1162 return DMERR_OK; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1163 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1164 error: |
538
45c46bfa03bd
Free the correct buffer pointer in error situations in the encoder function.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
1165 dmFree(buf); |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1166 *pbuf = NULL; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1167 *plen = 0; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1168 return res; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1169 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1170 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1171 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1172 // 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
|
1173 // 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
|
1174 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
|
1175 { |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1176 Uint8 *dp = dst->data; |
810
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
1177 int yc; |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1178 DMC64GetPixelFunc getPixel; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1179 |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1180 // Sanity check arguments |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1181 if (dst == NULL || src == NULL) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1182 return DMERR_NULLPTR; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1183 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1184 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
|
1185 return DMERR_INVALID_DATA; |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1186 |
1167 | 1187 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
|
1188 |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1189 // Check pixel getter function |
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1190 if (fmt->getPixel != NULL) |
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1191 getPixel = fmt->getPixel; |
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1192 else |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
1193 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
|
1194 |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1195 // 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
|
1196 int rwidth = src->width; |
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1197 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
|
1198 rwidth /= 2; |
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1199 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1200 // Perform conversion |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1201 for (yc = 0; yc < src->height; yc++) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1202 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1203 Uint8 *d = dp; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1204 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
|
1205 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
|
1206 int xc; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1207 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1208 if (src->type & D64_FMT_CHAR) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1209 { |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1210 // Charmode conversion |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1211 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
|
1212 // Hi-res charmap |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1213 for (xc = 0; xc < rwidth; xc++) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1214 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1215 const int x = xc / 8; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1216 const int scroffs = scroffsy + x; |
918 | 1217 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
|
1218 const int v = 7 - (xc & 7); |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1219 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1220 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
|
1221 *d++ = src->color[0][scroffs]; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1222 else |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1223 *d++ = src->bgcolor; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1224 } |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1225 else |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1226 // Multicolor variants |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1227 for (xc = 0; xc < rwidth; xc++) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1228 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1229 const int x = xc / 4; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1230 const int scroffs = scroffsy + x; |
918 | 1231 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
|
1232 const int col = src->color[0][scroffs] & 15; |
925 | 1233 |
944
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1234 if (col & 8) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1235 { |
944
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1236 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
|
1237 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
|
1238 { |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1239 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
|
1240 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
|
1241 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
|
1242 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
|
1243 } |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1244 } |
944
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1245 else |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1246 { |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1247 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
|
1248 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
|
1249 *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
|
1250 else |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1251 *d++ = src->bgcolor; |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1252 } |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1253 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1254 } |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1255 else |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1256 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1257 // 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
|
1258 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
|
1259 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1260 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES) |
811 | 1261 // Hi-res bitmap |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1262 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
|
1263 { |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1264 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
|
1265 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
|
1266 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
|
1267 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
|
1268 |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1269 *d++ = getPixel(src, bmoffs, vshift, 0, scroffs, yc); |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1270 } |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1271 else |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1272 // Multicolor bitmap and variants |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1273 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
|
1274 { |
901
f532262f90b1
Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents:
857
diff
changeset
|
1275 const int x = xc / 4; |
f532262f90b1
Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents:
857
diff
changeset
|
1276 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
|
1277 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
|
1278 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
|
1279 |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1280 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
|
1281 { |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1282 switch (src->laceType) |
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1283 { |
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1284 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
|
1285 *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
|
1286 *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
|
1287 break; |
1366
d4387509a363
Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
1288 |
d4387509a363
Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
1289 default: |
d4387509a363
Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
1290 return DMERR_NOT_SUPPORTED; |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1291 } |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1292 } |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1293 else |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1294 { |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
1295 *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
|
1296 } |
529
1bce06b5026f
Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents:
528
diff
changeset
|
1297 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1298 } |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1299 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
|
1300 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1301 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
1302 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
|
1303 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1304 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1305 |
940
ff18d2511843
Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents:
939
diff
changeset
|
1306 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
|
1307 { |
940
ff18d2511843
Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents:
939
diff
changeset
|
1308 int res; |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1309 DMImage *dst; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1310 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1311 if (pdst == NULL || src == NULL) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1312 return DMERR_NULLPTR; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1313 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1314 // Allocate image structure |
1289 | 1315 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
|
1316 return DMERR_MALLOC; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1317 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1318 // Set palette |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1319 dst->pal = (DMColor *) &dmC64Palette; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1320 dst->ncolors = C64_NCOLORS; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1321 dst->constpal = TRUE; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1322 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1323 // Convert |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1324 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
|
1325 res = fmt->convertFrom(dst, src, fmt); |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1326 else |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1327 res = dmC64ConvertGenericBMP2Image(dst, src, fmt); |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1328 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1329 return res; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1330 } |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1331 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1332 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1333 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
|
1334 const size_t probeOffs, const size_t loadOffs, |
516 | 1335 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
|
1336 { |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1337 if (img == NULL) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1338 return DMERR_NULLPTR; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1339 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1340 // Check for forced format |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1341 if (forced != NULL) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1342 *fmt = forced; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1343 else |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1344 { |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1345 // Nope, perform a generic probe |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1346 if (probeOffs >= len) |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1347 return DMERR_INVALID_DATA; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1348 |
537
32d9e67da189
Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
536
diff
changeset
|
1349 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
|
1350 return DMERR_INVALID_DATA; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1351 } |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1352 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1353 if (loadOffs >= len) |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1354 return DMERR_INVALID_ARGS; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1355 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1356 if (*fmt == NULL) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1357 return DMERR_INVALID_DATA; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1358 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1359 // Allocate memory |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1360 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
|
1361 return DMERR_MALLOC; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1362 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1363 // 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
|
1364 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
|
1365 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
|
1366 else |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1367 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
|
1368 } |