Mercurial > hg > dmlib
annotate tools/lib64gfx.c @ 1494:3b220604ae3c
Add short format attribute names to dmC64GetImageTypeString().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 11 May 2018 06:26:42 +0300 |
parents | 5f9080d24f3c |
children | 5c46004dad15 |
rev | line source |
---|---|
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Functions for reading and converting various restricted |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * C64/etc and/or indexed/paletted graphics formats. |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * Programmed and designed by Matti 'ccr' Hamalainen |
1456 | 5 * (C) Copyright 2012-2018 Tecnic Software productions (TNSP) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 * Please read file 'COPYING' for information on license and distribution. |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 */ |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #include "lib64gfx.h" |
435 | 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 |
1426
4c7b456d7f0b
Rename global dmC64Palette to dmDefaultC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
1425
diff
changeset
|
16 DMColor dmDefaultC64Palette[C64_NCOLORS] = |
1381 | 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 | |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
36 #define DM_RLE_MARKER 1 |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
37 #define DM_RLE_MASK 2 |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
38 |
1381 | 39 |
1461 | 40 #define DM_GET_ADDR_LO(addr) ((addr) & 0xff) |
41 #define DM_GET_ADDR_HI(addr) (((addr) >> 8) & 0xff) | |
42 | |
43 | |
1488
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
44 void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt) |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
45 { |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
46 char typeStr[64]; |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
47 |
1494
3b220604ae3c
Add short format attribute names to dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents:
1492
diff
changeset
|
48 dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->type, TRUE); |
1488
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
49 |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
50 if (fmt != NULL) |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
51 { |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
52 fprintf(fh, |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
53 "Format : %s [%s]\n", |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
54 fmt->name, fmt->fext); |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
55 } |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
56 |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
57 fprintf(fh, |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
58 "Type : %s\n" |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
59 "Banks : %d\n", |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
60 typeStr, |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
61 img->nbanks); |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
62 |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
63 if (img->type & D64_FMT_ILACE) |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
64 { |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
65 char *tmps; |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
66 switch(img->laceType) |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
67 { |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
68 case D64_ILACE_COLOR: tmps = "color"; break; |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
69 case D64_ILACE_RES: tmps = "resolution"; break; |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
70 default: tmps = "ERROR"; break; |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
71 } |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
72 fprintf(fh, |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
73 "Interlace type : %s\n", |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
74 tmps); |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
75 } |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
76 |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
77 fprintf(fh, |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
78 "Width x Height : %d x %d\n" |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
79 "CHwidth x CHheight : %d x %d\n", |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
80 img->width, img->height, |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
81 img->chWidth, img->chHeight); |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
82 } |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
83 |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1487
diff
changeset
|
84 |
1457
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
85 void dmSetDefaultC64Palette(DMImage *img) |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
86 { |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
87 img->constpal = TRUE; |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
88 img->pal = dmDefaultC64Palette; |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
89 img->ncolors = C64_NCOLORS; |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
90 img->ctransp = 255; |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
91 } |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
92 |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
93 |
1494
3b220604ae3c
Add short format attribute names to dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents:
1492
diff
changeset
|
94 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng) |
1489
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
95 { |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
96 snprintf(buf, len, |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
97 "%s%s%s%s", |
1494
3b220604ae3c
Add short format attribute names to dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents:
1492
diff
changeset
|
98 (type & D64_FMT_MC) ? (lng ? "MultiColor " : "MC ") : "HiRes ", |
3b220604ae3c
Add short format attribute names to dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents:
1492
diff
changeset
|
99 (type & D64_FMT_ILACE) ? (lng ? "Interlaced " : "ILace ") : "", |
1489
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
100 (type & D64_FMT_FLI) ? "FLI " : "", |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
101 (type & D64_FMT_CHAR) ? "CHAR" : "" |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
102 ); |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
103 |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
104 return buf; |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
105 } |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
106 |
71e847ea9d22
Move one function to a better place in the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
107 |
1381 | 108 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr) |
109 { | |
110 return buf[offs ] == DM_GET_ADDR_LO(addr) && | |
111 buf[offs + 1] == DM_GET_ADDR_HI(addr); | |
112 } | |
113 | |
114 | |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
115 int dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
116 { |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
117 int nbanks = 0; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
118 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
|
119 { |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
120 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
121 if (op->type == DT_LAST) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
122 break; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
123 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
124 if (op->bank > nbanks) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
125 nbanks = op->bank; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
126 } |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
127 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
128 return nbanks + 1; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
129 } |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
130 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
131 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
132 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
|
133 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
134 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
|
135 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
136 if (img == NULL) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
137 return NULL; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
138 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
139 // Initialize image information |
1492
5f9080d24f3c
Set DMC64Image::type in dmC64ImageAlloc() from format type.
Matti Hamalainen <ccr@tnsp.org>
parents:
1491
diff
changeset
|
140 img->type = fmt->type; |
1491 | 141 img->width = fmt->width; |
142 img->height = fmt->height; | |
143 img->chWidth = fmt->chWidth; | |
144 img->chHeight = fmt->chHeight; | |
145 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
|
146 |
1491 | 147 img->screenSize = img->chWidth * img->chHeight; |
148 img->bitmapSize = img->screenSize * 8; | |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
149 img->charmemSize = C64_MAX_CHARS * C64_CHR_SIZE; |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
150 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
151 // Allocate banks |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
152 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
|
153 (img->bitmap = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL || |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
154 (img->screen = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL || |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
155 (img->charmem = dmCalloc(img->nbanks, sizeof(Uint8 *))) == NULL) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
156 goto err; |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
157 |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
158 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
|
159 { |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
160 if ((img->color[i] = dmMalloc0(img->screenSize)) == NULL) |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
161 goto err; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
162 |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
163 if ((img->bitmap[i] = dmMalloc0(img->bitmapSize)) == NULL) |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
164 goto err; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
165 |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
166 if ((img->screen[i] = dmMalloc0(img->screenSize)) == NULL) |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
167 goto err; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
168 |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
169 if ((img->charmem[i] = dmMalloc0(img->charmemSize)) == NULL) |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
170 goto err; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
171 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
172 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
173 return img; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
174 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
175 err: |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
176 dmC64ImageFree(img); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
177 return NULL; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
178 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
179 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
180 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
181 void dmC64ImageFree(DMC64Image *img) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
182 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
183 if (img != NULL) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
184 { |
1462
9cb6dd1046bf
Fix memory leaks by freeing more things in dmC64ImageFree().
Matti Hamalainen <ccr@tnsp.org>
parents:
1461
diff
changeset
|
185 // Free the allocated areas |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
186 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
|
187 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
188 dmFree(img->color[i]); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
189 dmFree(img->bitmap[i]); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
190 dmFree(img->screen[i]); |
932 | 191 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
|
192 } |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
193 |
1462
9cb6dd1046bf
Fix memory leaks by freeing more things in dmC64ImageFree().
Matti Hamalainen <ccr@tnsp.org>
parents:
1461
diff
changeset
|
194 // Free the pointers to the areas |
9cb6dd1046bf
Fix memory leaks by freeing more things in dmC64ImageFree().
Matti Hamalainen <ccr@tnsp.org>
parents:
1461
diff
changeset
|
195 dmFree(img->color); |
9cb6dd1046bf
Fix memory leaks by freeing more things in dmC64ImageFree().
Matti Hamalainen <ccr@tnsp.org>
parents:
1461
diff
changeset
|
196 dmFree(img->bitmap); |
9cb6dd1046bf
Fix memory leaks by freeing more things in dmC64ImageFree().
Matti Hamalainen <ccr@tnsp.org>
parents:
1461
diff
changeset
|
197 dmFree(img->screen); |
9cb6dd1046bf
Fix memory leaks by freeing more things in dmC64ImageFree().
Matti Hamalainen <ccr@tnsp.org>
parents:
1461
diff
changeset
|
198 dmFree(img->charmem); |
9cb6dd1046bf
Fix memory leaks by freeing more things in dmC64ImageFree().
Matti Hamalainen <ccr@tnsp.org>
parents:
1461
diff
changeset
|
199 |
9cb6dd1046bf
Fix memory leaks by freeing more things in dmC64ImageFree().
Matti Hamalainen <ccr@tnsp.org>
parents:
1461
diff
changeset
|
200 // Extra data .. |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
201 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
|
202 dmFree(img->extraData[i]); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
203 |
1167 | 204 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
|
205 dmFree(img); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
206 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
207 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
208 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
209 |
827 | 210 int dmC64ConvertCSDataToImage(DMImage *img, |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
211 int xoffs, int yoffs, const Uint8 *buf, |
915 | 212 int width, int height, BOOL multicolor, |
213 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
|
214 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
215 int yc, widthpx = width * 8; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
216 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
|
217 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
218 if (img == NULL) |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
219 return DMERR_NULLPTR; |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
220 |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
221 if (xoffs < 0 || yoffs < 0 || |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
222 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
|
223 yoffs > img->height - height) |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
224 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
|
225 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
226 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
|
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 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
|
229 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
230 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
|
231 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
232 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
|
233 int xc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
234 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
|
235 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
236 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
|
237 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
238 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
|
239 const int v = 6 - ((xc * 2) & 6); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
240 const Uint8 c = colors[(b >> v) & 3]; |
925 | 241 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
242 *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
|
243 *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
|
244 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
245 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
246 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
|
247 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
248 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
249 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
250 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
251 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
|
252 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
253 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
|
254 int xc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
255 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
|
256 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 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
|
258 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 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
|
260 const int v = 7 - (xc & 7); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
261 const Uint8 c = colors[(b >> v) & 1]; |
925 | 262 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
263 *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
|
264 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
265 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
266 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
|
267 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
268 } |
925 | 269 |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
270 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
|
271 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
272 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
273 |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
274 static int dmDecodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, |
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
275 const Uint8 rleMarker, const Uint8 rleMask1, const Uint8 rleMask2, const int rleType) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
276 { |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
277 int 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
|
278 |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
279 if ((res = dmGrowBufAlloc(dst, BUF_SIZE_INITIAL, BUF_SIZE_GROW)) != DMERR_OK) |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
280 goto err; |
925 | 281 |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
282 // Perform RLE decode |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
283 while (src < srcEnd) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
284 { |
1476 | 285 Uint8 data = *src++; |
286 int count = 1; | |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
287 |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
288 switch (rleType) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
289 { |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
290 case DM_RLE_MARKER: |
1476 | 291 // A simple marker byte RLE variant: [Marker] [count] [data] |
292 if (data == rleMarker) | |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
293 { |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
294 if (srcEnd - src < 2) |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
295 { |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
296 res = DMERR_INVALID_DATA; |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
297 goto err; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
298 } |
1476 | 299 count = *src++; |
300 data = *src++; | |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
301 } |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
302 break; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
303 |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
304 case DM_RLE_MASK: |
1476 | 305 // Mask marker RLE: usually high bit(s) of byte mark RLE sequence |
306 // and the lower bits contain the count: [Mask + count] [data] | |
307 if ((data & rleMask1) == rleMarker) | |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
308 { |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
309 if (srcEnd - src < 1) |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
310 { |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
311 res = DMERR_INVALID_DATA; |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
312 goto err; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
313 } |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
314 |
1476 | 315 count = data & rleMask2; |
316 data = *src++; | |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
317 } |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
318 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
|
319 } |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
320 |
1476 | 321 while (count--) |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
322 { |
1476 | 323 if (!dmGrowBufPutU8(dst, data)) |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
324 { |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
325 res = DMERR_MALLOC; |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
326 goto err; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
327 } |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
328 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
329 } |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
330 |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
331 res = 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
|
332 |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
333 err: |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
334 return res; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
335 } |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
336 |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
337 |
1478
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
338 static int dmDecodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
339 const Uint8 rleMarker, const Uint8 rleMask1, const Uint8 rleMask2, const int rleType) |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
340 { |
1478
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
341 int res; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
342 if ((res = dmGrowBufAlloc(dst, BUF_SIZE_INITIAL, BUF_SIZE_GROW)) != DMERR_OK) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
343 return res; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
344 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
345 return dmDecodeGenericRLE(dst, src, srcEnd, rleMarker, rleMask1, rleMask2, rleType); |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
346 } |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
347 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
348 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
349 static BOOL dmEncodeGenericRLESequence(DMGrowBuf *dst, const Uint8 data, const Uint8 count, const Uint8 rleMarker, const int rleType) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
350 { |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
351 switch (rleType) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
352 { |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
353 case DM_RLE_MARKER: |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
354 // A simple marker byte RLE variant: [Marker] [count] [data] |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
355 if (!dmGrowBufPutU8(dst, rleMarker) || |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
356 !dmGrowBufPutU8(dst, count) || |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
357 !dmGrowBufPutU8(dst, data)) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
358 return FALSE; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
359 break; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
360 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
361 case DM_RLE_MASK: |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
362 // Mask marker RLE: usually high bit(s) of byte mark RLE sequence |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
363 // and the lower bits contain the count: [Mask + count] [data] |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
364 if (!dmGrowBufPutU8(dst, rleMarker | count) || |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
365 !dmGrowBufPutU8(dst, data)) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
366 return FALSE; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
367 break; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
368 } |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
369 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
370 return TRUE; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
371 } |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
372 |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
373 |
1478
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
374 static int dmEncodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
375 const Uint8 rleMarker, const Uint8 rleMinCount, const Uint8 rleMaxCount, const int rleType) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
376 { |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
377 int res; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
378 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
379 // Perform RLE encoding |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
380 int count = 0, prev; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
381 while (src < srcEnd) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
382 { |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
383 Uint8 data = *src++; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
384 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
385 if ((count >= rleMinCount && data != prev) || count >= rleMaxCount) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
386 { |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
387 if (!dmEncodeGenericRLESequence(dst, prev, count + 1, rleMarker, rleType)) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
388 { |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
389 res = dmError(DMERR_MALLOC, |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
390 "Could reallocate memory for RLE encoding buffer.\n"); |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
391 goto err; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
392 } |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
393 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
394 count = 1; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
395 } |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
396 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
397 prev = data; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
398 } |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
399 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
400 res = DMERR_OK; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
401 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
402 err: |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
403 return res; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
404 } |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
405 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
406 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
407 static int dmEncodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
408 const Uint8 rleMarker, const Uint8 rleMinCount, const Uint8 rleMaxCount, const int rleType) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
409 { |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
410 int res; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
411 if ((res = dmGrowBufAlloc(dst, BUF_SIZE_INITIAL, BUF_SIZE_GROW)) != DMERR_OK) |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
412 return res; |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
413 |
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
414 return dmEncodeGenericRLE(dst, src, srcEnd, rleMarker, rleMinCount, rleMaxCount, rleType); |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
415 } |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
416 |
519 | 417 |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
418 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
|
419 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
|
420 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
|
421 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
422 (void) cbank; |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
423 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
|
424 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
|
425 else |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
426 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
|
427 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
428 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
429 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
430 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
|
431 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
|
432 const int vshift, const int vbank, const int vbitmap, const int cbank) |
1369 | 433 { |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
434 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
|
435 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
436 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
|
437 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
|
438 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
|
439 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
|
440 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
441 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
442 |
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 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
|
445 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
|
446 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
|
447 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
448 (void) raster; |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
449 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
|
450 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
451 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
452 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
453 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
|
454 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
|
455 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
|
456 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
457 (void) raster; |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
458 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0); |
1369 | 459 } |
460 | |
461 | |
462 static int fmtProbeDrazPaint20Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) | |
463 { | |
464 const char *ident = (const char *) buf + 2; | |
465 | |
466 if (len > 22 && | |
467 dmCompareAddr16(buf, 0, fmt->addr) && | |
468 strncmp(ident, "DRAZPAINT ", 10) == 0 && | |
469 ident[11] == '.' && ( | |
470 (ident[10] == '1' && ident[12] == '4') || | |
471 (ident[10] == '2' && ident[12] == '0') | |
472 )) | |
473 return DM_PROBE_SCORE_MAX; | |
474 | |
475 return DM_PROBE_SCORE_FALSE; | |
476 } | |
477 | |
478 | |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
479 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
|
480 { |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
481 int res; |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
482 DMGrowBuf mem; |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
483 |
1478
d883b4c1cf48
More work on RLE encoding/decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1476
diff
changeset
|
484 if ((res = dmDecodeGenericRLEAlloc(&mem, buf + 0x0e, buf + len, *(buf + 0x0d), 0, 0, DM_RLE_MARKER)) != 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
|
485 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
|
486 |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
487 res = dmC64DecodeGenericBMP(img, mem.data, mem.len, 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
|
488 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
489 out: |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
490 dmGrowBufFree(&mem); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
491 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
|
492 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
493 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
494 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
495 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
|
496 { |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
497 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
|
498 dmCompareAddr16(buf, 0, fmt->addr) && |
1382 | 499 strncmp((const char *) (buf + 2), "DRAZLACE! 1.0", 13) == 0) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
500 return DM_PROBE_SCORE_MAX; |
925 | 501 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
502 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
|
503 } |
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 |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
506 static BOOL fmtDrazLaceSetLaceType(DMC64Image *img, const DMC64EncDecOp *op, |
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
507 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
|
508 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
509 (void) len; |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
510 (void) fmt; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
511 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
|
512 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
|
513 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
514 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
515 |
1389
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
516 static int fmtProbeGunPaint(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
517 { |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
518 if (len > 0x400 && |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
519 dmCompareAddr16(buf, 0, fmt->addr) && |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
520 strncmp((const char *) (buf + 0x3ea), "GUNPAINT (JZ) ", 14) == 0) |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
521 return DM_PROBE_SCORE_MAX; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
522 |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
523 return DM_PROBE_SCORE_FALSE; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
524 } |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
525 |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
526 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
527 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
|
528 { |
541
7ca6abbbbb40
Use size_t instead of int here to avoid signedness issues.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
529 size_t i, n; |
1433 | 530 |
1392
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
531 if (len < 2048 || !dmCompareAddr16(buf, 0, fmt->addr)) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
532 return DM_PROBE_SCORE_FALSE; |
925 | 533 |
494
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
534 // Interpaint Hi-Res gives a false positive |
1389
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
535 // as do some GunPaint images .. |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
536 if (len == 9002 || fmtProbeGunPaint(buf, len, fmt) > DM_PROBE_SCORE_GOOD) |
494
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
537 return DM_PROBE_SCORE_FALSE; |
925 | 538 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
539 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
|
540 if (buf[i] == 0xC2) n++; |
925 | 541 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
542 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
|
543 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
|
544 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
|
545 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
|
546 if (n > 10) |
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
547 return DM_PROBE_SCORE_MAYBE; |
1369 | 548 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
549 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
|
550 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
551 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
552 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
553 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
|
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 int res; |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
556 DMGrowBuf mem, tmp; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
557 |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
558 // Amica Paint apparently is broken and stores one byte less than it should |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
559 // so we need to do some crappy buffer expansion here .. |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
560 if ((res = dmGrowBufAlloc(&tmp, len + 4, 4)) != DMERR_OK) |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
561 return 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
|
562 |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
563 tmp.len = len; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
564 memcpy(tmp.data, buf, len); |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
565 tmp.data[tmp.len++] = 0; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
566 |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
567 // Now do an RLE decode on the enlarged buffer |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
568 if ((res = dmDecodeGenericRLE(&mem, tmp.data, tmp.data + tmp.len, 0xC2, 0, 0, DM_RLE_MARKER)) != 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
|
569 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
|
570 |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
571 // And finally decode to bitmap struct |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
572 res = dmC64DecodeGenericBMP(img, mem.data, mem.len, fmt); |
925 | 573 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
574 out: |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
575 dmGrowBufFree(&tmp); |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
576 dmGrowBufFree(&mem); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
577 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
|
578 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
579 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
580 |
1392
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
581 static int fmtProbeFLIDesigner(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
582 { |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
583 if (len == fmt->size && |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
584 (dmCompareAddr16(buf, 0, 0x3c00) || dmCompareAddr16(buf, 0, 0x3ff0))) |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
585 return DM_PROBE_SCORE_MAX; |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
586 |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
587 return DM_PROBE_SCORE_FALSE; |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
588 } |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
589 |
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
590 |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
591 static BOOL fmtTruePaintSetLaceType(DMC64Image *img, const DMC64EncDecOp *op, |
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
592 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
|
593 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
594 (void) op; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
595 (void) buf; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
596 (void) len; |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
597 (void) fmt; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
598 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
|
599 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
|
600 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
601 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
602 |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
603 static Uint8 fmtGetPixelTruePaint( |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
604 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
|
605 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
|
606 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
607 (void) raster; |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
608 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
|
609 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
610 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
611 |
1369 | 612 #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
|
613 |
943
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
614 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
|
615 { |
1369 | 616 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
|
617 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
|
618 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
|
619 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
620 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
|
621 } |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
622 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
623 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
624 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
|
625 { |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
626 int res; |
1377 | 627 |
1369 | 628 // If there is only data for less than XX2_MIN_SIZE bytes, |
629 // allocate a buffer of that size and copy data there. | |
630 // Otherwise allocate len bytes. | |
631 size_t nlen = len < XX2_MIN_SIZE ? XX2_MIN_SIZE : len; | |
632 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
|
633 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
|
634 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
|
635 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
636 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
|
637 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
|
638 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
639 dmFree(mem); |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
640 return res; |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
641 } |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
642 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
643 |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
644 #define FUNPAINT2_HEADER_SIZE (0x10) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
645 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
646 static BOOL fmtProbeFunPaint2Header(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
647 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
648 return |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
649 len > 30 && |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
650 dmCompareAddr16(buf, 0, fmt->addr) && |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
651 strncmp((const char *) (buf + 2), "FUNPAINT (MT) ", 14) == 0; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
652 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
653 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
654 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
655 static int fmtProbeFunPaint2Unpacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
656 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
657 if (fmtProbeFunPaint2Header(buf, len, fmt) && |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
658 buf[2 + 14] == 0) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
659 return DM_PROBE_SCORE_MAX; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
660 else |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
661 return DM_PROBE_SCORE_FALSE; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
662 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
663 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
664 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
665 static int fmtProbeFunPaint2Packed(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
666 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
667 if (fmtProbeFunPaint2Header(buf, len, fmt) && |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
668 buf[2 + 14] != 0) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
669 return DM_PROBE_SCORE_MAX; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
670 else |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
671 return DM_PROBE_SCORE_FALSE; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
672 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
673 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
674 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
675 static int fmtDecodeFunPaint2Unpacked(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
676 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
677 return dmC64DecodeGenericBMP(img, buf + FUNPAINT2_HEADER_SIZE, len - FUNPAINT2_HEADER_SIZE, fmt); |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
678 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
679 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
680 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
681 static int fmtDecodeFunPaint2Packed(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
682 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
683 int res; |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
684 DMGrowBuf mem; |
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
685 dmGrowBufInit(&mem); |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
686 |
1466
bc75be0546fc
More work on RLE decoder/encoder changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
687 if ((res = dmDecodeGenericRLE(&mem, buf + FUNPAINT2_HEADER_SIZE, buf + len, *(buf + 15), 0, 0, DM_RLE_MARKER)) != DMERR_OK) |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
688 goto out; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
689 |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
690 res = dmC64DecodeGenericBMP(img, mem.data, mem.len, fmt); |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
691 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
692 out: |
1463
bde6a66bc2f6
Change dmDecodeGenericRLE() to use DMGrowBuf as output. Also add support
Matti Hamalainen <ccr@tnsp.org>
parents:
1462
diff
changeset
|
693 dmGrowBufFree(&mem); |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
694 return res; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
695 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
696 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
697 |
1471
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
698 static int fmtEncodeStub(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
699 { |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
700 (void) buf; |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
701 (void) img; |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
702 (void) fmt; |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
703 |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
704 return dmError(DMERR_NOT_SUPPORTED, |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
705 "Encoding of '%s' format not supported.\n", |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
706 fmt->name); |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
707 } |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
708 |
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
709 |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
710 static Uint8 fmtGetPixelFunPaint2( |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
711 const DMC64Image *img, const int bmoffs, const int scroffs, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
712 const int vshift, const int vbitmap, const int raster) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
713 { |
1390 | 714 const int vbank = (raster & 7) + (vbitmap * 8); |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
715 int vr, vb; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
716 if (raster < 100) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
717 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
718 vb = 0; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
719 vr = raster; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
720 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
721 else |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
722 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
723 vb = 0; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
724 vr = raster - 100; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
725 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
726 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
727 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3) |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
728 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
729 case 0: return img->extraData[vb][vr] & 15; break; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
730 case 1: return img->screen[vbank][scroffs] >> 4; break; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
731 case 2: return img->screen[vbank][scroffs] & 15; break; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
732 default: return img->color[0][scroffs] & 15; break; |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
733 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
734 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
735 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
736 |
1389
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
737 static Uint8 fmtGetPixelGunPaint( |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
738 const DMC64Image *img, const int bmoffs, const int scroffs, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
739 const int vshift, const int vbitmap, const int raster) |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
740 { |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
741 const int vbank = (raster & 7);// + (vbitmap * 8); |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
742 int vr, vb; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
743 if (raster < 177) |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
744 { |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
745 vb = 0; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
746 vr = raster; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
747 } |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
748 else |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
749 { |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
750 vb = 0; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
751 vr = raster - 177; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
752 } |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
753 |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
754 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3) |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
755 { |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
756 case 0: return img->extraData[vb][vr] & 15; break; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
757 case 1: return img->screen[vbank][scroffs] >> 4; break; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
758 case 2: return img->screen[vbank][scroffs] & 15; break; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
759 default: return img->color[0][scroffs] & 15; break; |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
760 } |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
761 } |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
762 |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
763 |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
764 static Uint8 fmtGetPixelBMFLI( |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
765 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
|
766 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
|
767 { |
1380 | 768 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
|
769 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
|
770 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
771 case 0: return img->extraData[0][raster]; break; |
1380 | 772 case 1: return img->screen[vbank][scroffs] >> 4; break; |
773 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
|
774 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
|
775 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
776 } |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
777 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
778 |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
779 static Uint8 fmtGetPixelFLIDesigner( |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
780 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
|
781 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
|
782 { |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
783 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
|
784 } |
943
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
785 |
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
786 |
1394
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
787 static Uint8 fmtGetPixelCHFLI( |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
788 const DMC64Image *img, const int bmoffs, const int scroffs, |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
789 const int vshift, const int vbitmap, const int raster) |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
790 { |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
791 const int vbank = raster & 7; |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
792 |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
793 if ((img->bitmap[vbitmap][bmoffs] >> vshift) & 1) |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
794 return img->screen[vbank][scroffs] >> 4; |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
795 else |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
796 return img->screen[vbank][scroffs] & 15; |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
797 } |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
798 |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
799 |
1369 | 800 // |
801 // Array with data for supported formats | |
802 // | |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
803 #define DEF_SCREEN_RAM(start, oindex, bindex, osize) { DT_SCREEN_RAM, (start) + ((osize) * (oindex)), (bindex), 0, NULL, NULL } |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
804 #define DEF_SCREEN_RAMS_8(start, sindex, osize) \ |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
805 DEF_SCREEN_RAM((start), 0, (sindex + 0), (osize)), \ |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
806 DEF_SCREEN_RAM((start), 1, (sindex + 1), (osize)), \ |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
807 DEF_SCREEN_RAM((start), 2, (sindex + 2), (osize)), \ |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
808 DEF_SCREEN_RAM((start), 3, (sindex + 3), (osize)), \ |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
809 DEF_SCREEN_RAM((start), 4, (sindex + 4), (osize)), \ |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
810 DEF_SCREEN_RAM((start), 5, (sindex + 5), (osize)), \ |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
811 DEF_SCREEN_RAM((start), 6, (sindex + 6), (osize)), \ |
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
812 DEF_SCREEN_RAM((start), 7, (sindex + 7), (osize)), |
1388
4f81528aa4f6
Simplify some image format definitions by using macro to define screen ram blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
1387
diff
changeset
|
813 |
4f81528aa4f6
Simplify some image format definitions by using macro to define screen ram blocks.
Matti Hamalainen <ccr@tnsp.org>
parents:
1387
diff
changeset
|
814 |
516 | 815 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
|
816 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
817 { |
1475 | 818 D64_FMT_MC, "d2p", "DrazPaint 1.4/2.0 (packed)", 0x5800, 0, |
939
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
819 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
820 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1443 | 821 fmtProbeDrazPaint20Packed, |
1471
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
822 fmtDecodeDrazPaintPacked, fmtEncodeStub, |
1443 | 823 NULL, NULL, |
824 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
|
825 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
826 { 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
|
827 { 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
|
828 { 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
|
829 { 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
|
830 { 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
|
831 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
832 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
833 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
834 { |
1475 | 835 D64_FMT_MC, "drp", "DrazPaint (unpacked)", 0x5800, 10051, |
836 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, | |
837 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, | |
838 NULL, | |
839 NULL, NULL, | |
840 NULL, NULL, | |
841 NULL, | |
842 { | |
843 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL }, | |
844 { DT_BITMAP, 0x0800, 0, 0, NULL, NULL }, | |
845 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL }, | |
846 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, NULL, NULL }, | |
847 { DT_LAST, 0, 0, 0, NULL, NULL }, | |
848 } | |
849 }, | |
850 | |
851 { | |
924
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
852 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
|
853 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
|
854 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
1443 | 855 fmtProbeDrazLace10Packed, |
1471
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
856 fmtDecodeDrazPaintPacked, fmtEncodeStub, |
1443 | 857 NULL, NULL, |
858 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
|
859 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
860 { 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
|
861 { 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
|
862 { 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
|
863 { 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
|
864 { 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
|
865 { 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
|
866 { 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
|
867 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
868 }, |
925 | 869 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
870 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
871 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
|
872 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
|
873 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
1442 | 874 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
|
875 NULL, NULL, |
1442 | 876 NULL, NULL, |
877 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
|
878 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
879 { 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
|
880 { 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
|
881 { 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
|
882 { 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
|
883 { 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
|
884 { 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
|
885 { 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
|
886 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
887 }, |
925 | 888 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
889 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
890 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
|
891 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
|
892 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
1442 | 893 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
|
894 NULL, NULL, |
1443 | 895 NULL, NULL, |
896 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
|
897 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
898 { 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
|
899 { 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
|
900 { 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
|
901 { 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
|
902 { 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
|
903 { 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
|
904 { 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
|
905 { 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
|
906 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
907 }, |
925 | 908 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
909 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
910 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
|
911 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
912 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 913 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
|
914 NULL, NULL, |
1442 | 915 NULL, NULL, |
916 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
|
917 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
918 { 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
|
919 { 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
|
920 { 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
|
921 { 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
|
922 { 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
|
923 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
924 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
925 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
926 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
927 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
|
928 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
929 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 930 NULL, |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
931 NULL, NULL, |
1442 | 932 NULL, NULL, |
933 NULL, | |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
934 { |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
935 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
936 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
937 { 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
|
938 { 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
|
939 { DT_LAST, 0, 0, 0, NULL, NULL }, |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
940 } |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
941 }, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
942 |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
943 { |
924
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
944 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
|
945 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
946 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 947 fmtProbeAmicaPaintPacked, |
1471
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
948 fmtDecodeAmicaPaintPacked, fmtEncodeStub, |
1442 | 949 NULL, NULL, |
950 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
|
951 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
952 { 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
|
953 { 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
|
954 { 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
|
955 { 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
|
956 { 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
|
957 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
958 }, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
959 |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
960 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
961 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
|
962 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
963 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 964 NULL, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
965 NULL, NULL, |
1442 | 966 NULL, NULL, |
967 NULL, | |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
968 { |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
969 { 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
|
970 { 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
|
971 { 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
|
972 { 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
|
973 { 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
|
974 } |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
975 }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
976 |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
977 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
978 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
|
979 C64_SCR_WIDTH , C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
980 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 981 NULL, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
982 NULL, NULL, |
1442 | 983 NULL, NULL, |
984 NULL, | |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
985 { |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
986 { 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
|
987 { 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
|
988 { 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
|
989 } |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
990 }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
991 |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
992 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
993 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
|
994 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
|
995 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
1442 | 996 NULL, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
997 NULL, NULL, |
1442 | 998 NULL, NULL, |
999 NULL, | |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1000 { |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1001 { 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
|
1002 { 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
|
1003 { 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
|
1004 } |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1005 }, |
1396 | 1006 |
1370
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1007 { |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1008 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
|
1009 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1010 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
1442 | 1011 NULL, |
1370
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1012 NULL, NULL, |
1442 | 1013 NULL, NULL, |
1014 NULL, | |
1370
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1015 { |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1016 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1017 { 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
|
1018 { 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
|
1019 { 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
|
1020 { DT_LAST, 0, 0, 0, NULL, NULL }, |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1021 } |
53358cc2f9ff
Add support for Interpaint Multicolor (unpacked) images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1369
diff
changeset
|
1022 }, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1023 |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1024 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
1025 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
|
1026 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
|
1027 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, |
1442 | 1028 NULL, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1029 NULL, NULL, |
1442 | 1030 NULL, NULL, |
1031 NULL, | |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1032 { |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1033 { 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
|
1034 { 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
|
1035 { 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
|
1036 } |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
1037 }, |
905 | 1038 |
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
|
1039 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
1040 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
|
1041 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
1042 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 1043 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
|
1044 NULL, NULL, |
1442 | 1045 NULL, NULL, |
1046 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
|
1047 { |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
1048 { 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
|
1049 { DT_COLOR_RAM, 0x0100, 0, 0, NULL, NULL }, |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
1050 DEF_SCREEN_RAMS_8( 0x0500, 0, 0x400) |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
1051 { 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
|
1052 { 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
|
1053 } |
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
|
1054 }, |
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
|
1055 |
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
|
1056 { |
1392
aad9d9e7e1d3
Cleanups, support another variant of FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1390
diff
changeset
|
1057 D64_FMT_MC | D64_FMT_FLI, "fli", "FLI Designer (unpacked)", 0, 17409, |
939
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
1058 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
1059 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 1060 fmtProbeFLIDesigner, |
1061 NULL, NULL, | |
1062 NULL, NULL, | |
1063 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
|
1064 { |
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
|
1065 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL }, |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
1066 DEF_SCREEN_RAMS_8( 0x0400, 0, 0x400) |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
1067 { 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
|
1068 { 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
|
1069 } |
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
|
1070 }, |
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
|
1071 |
906
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
1072 { |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
1073 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
|
1074 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, |
5e820addd035
Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents:
935
diff
changeset
|
1075 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 1076 NULL, |
906
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
1077 NULL, NULL, |
1442 | 1078 NULL, NULL, |
1079 NULL, | |
906
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
1080 { |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
1081 { 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
|
1082 { 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
|
1083 { 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
|
1084 { 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
|
1085 { 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
|
1086 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1087 }, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1088 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1089 #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
|
1090 #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
|
1091 #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
|
1092 #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
|
1093 |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1094 { |
943
8eacbc38b043
Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
1095 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
|
1096 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
|
1097 XX2_WIDTH_CH , XX2_HEIGHT_CH, |
1442 | 1098 fmtProbeFormatXX2, |
1099 fmtDecodeFormatXX2, NULL, | |
1100 NULL, NULL, | |
1101 NULL, | |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1102 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1103 { 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
|
1104 { 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
|
1105 { DT_SCREEN_RAM, XX2_BSIZE, 0, XX2_SIZE, NULL, NULL }, |
1382 | 1106 { 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
|
1107 { 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
|
1108 } |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
1109 }, |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1110 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1111 { |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1112 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, "fp2", "FunPaint II (unpacked)", 0x3ff0, 33694, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1113 C64_SCR_WIDTH, C64_SCR_HEIGHT, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1114 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 1115 fmtProbeFunPaint2Unpacked, |
1471
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
1116 fmtDecodeFunPaint2Unpacked, fmtEncodeStub, |
1442 | 1117 NULL, NULL, |
1118 fmtGetPixelFunPaint2, | |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1119 { |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
1120 DEF_SCREEN_RAMS_8( 0x0000, 0, 0x400) |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1121 { DT_BITMAP, 0x2000, 0, 0, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1122 { DT_EXTRA_DATA, 0x3f40, 0, 100, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1123 { DT_COLOR_RAM, 0x4000, 0, 0, NULL, NULL }, |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
1124 DEF_SCREEN_RAMS_8( 0x43e8, 8, 0x400) |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1125 { DT_BITMAP, 0x63e8, 1, 0, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1126 { DT_EXTRA_DATA, 0x8328, 1, 100, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1127 { DT_LAST, 0, 0, 0, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1128 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1129 }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1130 |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1131 { |
1396 | 1132 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, "fp2p", "FunPaint II (packed)", 0x3ff0, 0, |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1133 C64_SCR_WIDTH, C64_SCR_HEIGHT, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1134 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 1135 fmtProbeFunPaint2Packed, |
1471
a988baa5b21f
Add stub function to prevent attempts to encode formats that do not support encoding yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1469
diff
changeset
|
1136 fmtDecodeFunPaint2Packed, fmtEncodeStub, |
1442 | 1137 NULL, NULL, |
1138 fmtGetPixelFunPaint2, | |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1139 { |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
1140 DEF_SCREEN_RAMS_8( 0x0000, 0, 0x400) |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1141 { DT_BITMAP, 0x2000, 0, 0, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1142 { DT_EXTRA_DATA, 0x3f40, 0, 100, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1143 { DT_COLOR_RAM, 0x4000, 0, 0, NULL, NULL }, |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
1144 DEF_SCREEN_RAMS_8( 0x43e8, 8, 0x400) |
1384
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1145 { DT_BITMAP, 0x63e8, 1, 0, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1146 { DT_EXTRA_DATA, 0x8328, 1, 100, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1147 { DT_LAST, 0, 0, 0, NULL, NULL }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1148 } |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1149 }, |
ef20200d71d7
Implement (buggy) support for packed and unpacked FunPaint II images in
Matti Hamalainen <ccr@tnsp.org>
parents:
1382
diff
changeset
|
1150 |
1389
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1151 { |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1152 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, "gun", "GunPaint (unpacked)", 0x4000, 0, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1153 C64_SCR_WIDTH, C64_SCR_HEIGHT, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1154 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, |
1442 | 1155 fmtProbeGunPaint, |
1156 NULL, NULL, | |
1157 NULL, NULL, | |
1158 fmtGetPixelGunPaint, | |
1389
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1159 { |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
1160 DEF_SCREEN_RAMS_8( 0x0000, 0, 0x400) |
1389
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1161 { DT_BITMAP, 0x2000, 0, 0, NULL, NULL }, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1162 { DT_EXTRA_DATA, 0x3f4f, 0, 177, NULL, NULL }, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1163 { DT_COLOR_RAM, 0x4000, 0, 0, NULL, NULL }, |
1393
b5fc5a05033d
Make screen ram definition macros more flexible, for possible future use cases.
Matti Hamalainen <ccr@tnsp.org>
parents:
1392
diff
changeset
|
1164 DEF_SCREEN_RAMS_8( 0x4400, 8, 0x400) |
1389
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1165 { DT_BITMAP, 0x6400, 1, 0, NULL, NULL }, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1166 { DT_EXTRA_DATA, 0x47e8, 1, 20, NULL, NULL }, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1167 { DT_LAST, 0, 0, 0, NULL, NULL }, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1168 } |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1169 }, |
979f550ead77
Implement GunPaint support. Possibly not working correctly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1388
diff
changeset
|
1170 |
1394
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1171 { |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1172 D64_FMT_HIRES | D64_FMT_FLI, "chi", "Crest Hires FLI Designer (unpacked)", 0x4000, 16386, |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1173 C64_SCR_WIDTH, 14 * 8, |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1174 C64_SCR_CH_WIDTH , 14, |
1442 | 1175 NULL, |
1394
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1176 NULL, NULL, |
1442 | 1177 NULL, NULL, |
1178 fmtGetPixelCHFLI, | |
1394
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1179 { |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1180 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1181 DEF_SCREEN_RAMS_8( 0x2000, 0, 0x400) |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1182 { DT_LAST, 0, 0, 0, NULL, NULL }, |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1183 } |
054561dbcd57
Add support for Crest Hires FLI Designer format.
Matti Hamalainen <ccr@tnsp.org>
parents:
1393
diff
changeset
|
1184 }, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1185 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1186 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1187 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
|
1188 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1189 |
518 | 1190 // Perform probing of the given data buffer, trying to determine |
1191 // if it contains a supported "C64" image format. Returns the | |
1192 // "probe score", see libgfx.h for list of values. If a match | |
1193 // 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
|
1194 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
|
1195 { |
1380 | 1196 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
|
1197 |
1380 | 1198 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
|
1199 { |
516 | 1200 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
|
1201 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
|
1202 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
|
1203 { |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
1204 // 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
|
1205 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
|
1206 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
|
1207 } |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
1208 else |
1134
d0898867ec4c
Various fixes for issues reported by clang static analyzer.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
1209 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
|
1210 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
|
1211 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1212 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
|
1213 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1214 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
|
1215 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
|
1216 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1217 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1218 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1219 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
|
1220 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1221 *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
|
1222 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
|
1223 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1224 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1225 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
|
1226 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1227 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1228 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1229 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
|
1230 { |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1231 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
|
1232 { |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1233 case DT_COLOR_RAM: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1234 case DT_BITMAP: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1235 case DT_SCREEN_RAM: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1236 case DT_CHAR_DATA: |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1237 if (op->bank < 0 || op->bank > img->nbanks) |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1238 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1239 return dmError(DMERR_INTERNAL, |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1240 "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
|
1241 op->bank, img->nbanks, op->type, i); |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1242 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1243 break; |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1244 |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1245 case DT_EXTRA_DATA: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1246 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
|
1247 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1248 return dmError(DMERR_INTERNAL, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1249 "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
|
1250 op->bank, op->type, i); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1251 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1252 break; |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1253 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1254 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1255 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
|
1256 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1257 return dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1258 "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
|
1259 op->type, i); |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1260 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1261 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1262 return DMERR_OK; |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1263 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1264 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1265 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1266 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
|
1267 { |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1268 BOOL check; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1269 switch (op->type) |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1270 { |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1271 case DT_SCREEN_RAM: |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1272 case DT_COLOR_RAM: |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1273 *size = fmt->chHeight * fmt->chWidth; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1274 check = TRUE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1275 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1276 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1277 case DT_BITMAP: |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1278 *size = fmt->chHeight * fmt->chWidth * 8; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1279 check = TRUE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1280 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1281 |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1282 case DT_EXTRA_DATA: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1283 *size = op->size; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1284 check = TRUE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1285 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1286 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1287 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
|
1288 *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
|
1289 check = TRUE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1290 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1291 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1292 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
|
1293 *size = 1; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1294 check = FALSE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1295 break; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1296 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1297 default: |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1298 *size = 0; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1299 check = FALSE; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1300 } |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1301 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1302 if (op->size != 0) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1303 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1304 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
|
1305 return FALSE; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1306 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1307 *size = op->size; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1308 } |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1309 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1310 return TRUE; |
927
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1311 } |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1312 |
db495f421242
Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
925
diff
changeset
|
1313 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
1314 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
|
1315 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
|
1316 { |
1460 | 1317 int res = DMERR_OK; |
1318 | |
513 | 1319 if (buf == NULL || img == NULL || fmt == NULL) |
1320 return DMERR_NULLPTR; | |
1321 | |
925 | 1322 // 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
|
1323 img->type = fmt->type; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1324 img->width = fmt->width; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1325 img->height = fmt->height; |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1326 img->chWidth = fmt->chWidth; |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1327 img->chHeight = fmt->chHeight; |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1328 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
|
1329 |
518 | 1330 // Perform decoding |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1331 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
|
1332 { |
515 | 1333 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
1334 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
|
1335 size_t size; |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1336 |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1337 // Check for last operator |
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1338 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
|
1339 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
|
1340 |
811 | 1341 // Check operation validity |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1342 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
|
1343 return res; |
925 | 1344 |
811 | 1345 // Check size |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1346 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
|
1347 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1348 return dmError(DMERR_INVALID_DATA, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1349 "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
|
1350 "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
|
1351 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
|
1352 } |
811 | 1353 |
1354 // 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
|
1355 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
|
1356 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1357 return dmError(DMERR_INVALID_DATA, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1358 "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
|
1359 "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
|
1360 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
|
1361 } |
811 | 1362 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1363 src = buf + op->offs; |
811 | 1364 |
1365 // 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
|
1366 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
|
1367 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1368 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
|
1369 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
|
1370 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
|
1371 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
|
1372 case DT_EXTRA_DATA: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1373 if (img->extraData[op->bank] != NULL) |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1374 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1375 return dmError(DMERR_INTERNAL, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1376 "Extra data block already allocated and used! " |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1377 "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
|
1378 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
|
1379 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1380 if ((img->extraData[op->bank] = dmMalloc0(size)) == NULL) |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1381 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1382 return dmError(DMERR_MALLOC, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1383 "Could not allocate extradata block! " |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1384 "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
|
1385 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
|
1386 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1387 img->extraDataSizes[op->bank] = size; |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1388 memcpy(img->extraData[op->bank], src, size); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1389 break; |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1390 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1391 case DT_COLOR_REG: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1392 switch (op->size) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1393 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1394 case DC_D020: img->d020 = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1395 case DC_BGCOL: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1396 case DC_D021: img->bgcolor = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1397 case DC_D022: img->d022 = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1398 case DC_D023: img->d023 = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1399 case DC_D024: img->d024 = *src; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1400 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1401 return dmError(DMERR_INTERNAL, |
1371 | 1402 "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
|
1403 "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
|
1404 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
|
1405 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1406 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1407 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1408 case DT_COLOR_SET: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1409 switch (op->size) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1410 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1411 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
|
1412 case DC_BGCOL: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1413 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
|
1414 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
|
1415 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
|
1416 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
|
1417 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1418 return dmError(DMERR_INTERNAL, |
1371 | 1419 "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
|
1420 "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
|
1421 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
|
1422 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1423 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1424 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1425 case DT_CHAR_CONFIG: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1426 switch (op->offs) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1427 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1428 case D64_CHCFG_SCREEN: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1429 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1430 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1431 case D64_CHCFG_LINEAR: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1432 { |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1433 for (int bank = 0; bank < img->nbanks; bank++) |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1434 for (int offs = 0; offs < fmt->chHeight * fmt->chWidth; offs++) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1435 img->screen[bank][offs] = offs & 0xff; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1436 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1437 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1438 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1439 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1440 return dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1441 "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
|
1442 "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
|
1443 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
|
1444 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1445 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1446 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
1447 case DT_DEC_FUNCTION: |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1448 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
|
1449 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1450 return dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1451 "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
|
1452 "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
|
1453 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
|
1454 } |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
1455 if (!op->decFunction(img, op, buf, len, 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
|
1456 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1457 return dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1458 "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
|
1459 "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
|
1460 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
|
1461 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1462 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1463 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1464 } |
916 | 1465 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
1466 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
|
1467 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1468 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1469 |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1470 int dmC64EncodeGenericBMP(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1471 { |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1472 int res = DMERR_OK; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1473 |
1469
0046b4e1b35f
Various fixes in bmp encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
1474 if (img == NULL || fmt == NULL) |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1475 return DMERR_NULLPTR; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1476 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1477 // Allocate the output buffer |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1478 if ((res = dmGrowBufAlloc(buf, fmt->size, BUF_SIZE_GROW)) != DMERR_OK) |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1479 { |
1472
b9d3577d8290
Improve error handling and checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1471
diff
changeset
|
1480 dmError(res, |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1481 "Could not allocate %d bytes of memory for C64 image encoding buffer.\n", |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1482 fmt->size); |
1447 | 1483 goto err; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1484 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1485 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1486 // Perform encoding |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1487 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
|
1488 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1489 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
1364 | 1490 size_t size, chksize; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1491 |
1365
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1492 // Check for last operator |
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1493 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
|
1494 break; |
60d7240e1a63
Remove hardcoded encoding/decoding operator counts from the structures, use
Matti Hamalainen <ccr@tnsp.org>
parents:
1364
diff
changeset
|
1495 |
811 | 1496 // Check operation validity |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1497 if ((res = dmC64SanityCheckEncDecOp(i, op, img)) != DMERR_OK) |
1447 | 1498 goto err; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1499 |
811 | 1500 // Check size |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1501 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
|
1502 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1503 res = dmError(DMERR_INVALID_DATA, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1504 "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
|
1505 "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
|
1506 i, op->type, op->offs, op->offs, op->bank, size, size, op->size, op->size); |
1447 | 1507 goto err; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1508 } |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1509 |
811 | 1510 // Do we need to reallocate some more space? |
1448
50402c225ef4
Do not insert load address to the buffer beginning in dmC64EncodeGenericBMP().
Matti Hamalainen <ccr@tnsp.org>
parents:
1447
diff
changeset
|
1511 chksize = op->offs + size; |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1512 if (!dmGrowBufCheckGrow(buf, chksize)) |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1513 { |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1514 res = dmError(DMERR_MALLOC, |
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1515 "Could not re-allocate %d bytes of memory for C64 image encoding buffer.\n", |
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1516 chksize); |
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1517 goto err; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1518 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1519 |
1487
06df2bdf5dc4
Various fixes to dmC64EncodeGenericBMP().
Matti Hamalainen <ccr@tnsp.org>
parents:
1486
diff
changeset
|
1520 if (chksize > buf->len) |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1521 buf->len = chksize; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1522 |
811 | 1523 // Perform operation |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1524 Uint8 *dst = buf->data + op->offs; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1525 switch (op->type) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1526 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1527 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
|
1528 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
|
1529 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
|
1530 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
|
1531 case DT_EXTRA_DATA: |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1532 if (img->extraData[op->bank] == NULL) |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1533 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1534 res = dmError(DMERR_NULLPTR, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1535 "DT_EXTRA_DATA block is NULL in ", |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1536 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1537 i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
1447 | 1538 goto err; |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1539 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1540 if (size > img->extraDataSizes[op->bank]) |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1541 { |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1542 res = dmError(DMERR_INTERNAL, |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1543 "DT_EXTRA_DATA size mismatch %d <> %d in ", |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1544 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1545 op->size, img->extraDataSizes[op->bank], i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
1447 | 1546 goto err; |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1547 } |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1548 memcpy(dst, img->extraData[op->bank], size); |
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1372
diff
changeset
|
1549 break; |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1550 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1551 case DT_COLOR_REG: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1552 switch (op->size) |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1553 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1554 case DC_D020: *dst = img->d020; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1555 case DC_BGCOL: |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1556 case DC_D021: *dst = img->bgcolor; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1557 case DC_D022: *dst = img->d022; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1558 case DC_D023: *dst = img->d023; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1559 case DC_D024: *dst = img->d024; break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1560 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1561 res = dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1562 "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
|
1563 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1564 op->size, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
1447 | 1565 goto err; |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1566 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1567 break; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1568 |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1569 case DT_ENC_FUNCTION: |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1570 if (op->encFunction == NULL) |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1571 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1572 res = dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1573 "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
|
1574 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1463
diff
changeset
|
1575 i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
1447 | 1576 goto err; |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1577 } |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
1578 if (!op->encFunction(op, buf, img, fmt)) |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1579 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1580 res = dmError(DMERR_INTERNAL, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
946
diff
changeset
|
1581 "Encode op custom function failed: op #%d, " |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1582 "offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
1583 i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
1584 goto err; |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
1585 } |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1586 break; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1587 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1588 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1589 |
1448
50402c225ef4
Do not insert load address to the buffer beginning in dmC64EncodeGenericBMP().
Matti Hamalainen <ccr@tnsp.org>
parents:
1447
diff
changeset
|
1590 res = DMERR_OK; |
535
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
1591 |
1447 | 1592 err: |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1593 return res; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1594 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1595 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1596 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1597 // 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
|
1598 // 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
|
1599 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
|
1600 { |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1601 DMC64GetPixelFunc getPixel; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1602 |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1603 // Sanity check arguments |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1604 if (dst == NULL || src == NULL) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1605 return DMERR_NULLPTR; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1606 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1607 if (dst->width < src->width || dst->height < src->height) |
1460 | 1608 { |
1609 return dmError(DMERR_INVALID_DATA, | |
1610 "Invalid src vs. dst width/height %d x %d <-> %d x %d\n", | |
1611 src->width, src->height, dst->width, dst->height); | |
1612 } | |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1613 |
1167 | 1614 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
|
1615 |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1616 // Check pixel getter function |
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1617 if (fmt->getPixel != NULL) |
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1618 getPixel = fmt->getPixel; |
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1619 else |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
1620 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
|
1621 |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1622 // 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
|
1623 int rwidth = src->width; |
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1624 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
|
1625 rwidth /= 2; |
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1626 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1627 // Perform conversion |
1411 | 1628 Uint8 *dp = dst->data; |
1629 for (int yc = 0; yc < src->height; yc++) | |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1630 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1631 Uint8 *d = dp; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1632 const int y = yc / 8, yb = yc & 7; |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1633 const int scroffsy = y * src->chWidth; |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1634 int xc; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1635 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1636 if (src->type & D64_FMT_CHAR) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1637 { |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1638 // Charmode conversion |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1639 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
|
1640 // Hi-res charmap |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1641 for (xc = 0; xc < rwidth; xc++) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1642 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1643 const int x = xc / 8; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1644 const int scroffs = scroffsy + x; |
918 | 1645 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
|
1646 const int v = 7 - (xc & 7); |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1647 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1648 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
|
1649 *d++ = src->color[0][scroffs]; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1650 else |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1651 *d++ = src->bgcolor; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1652 } |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1653 else |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1654 // Multicolor variants |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1655 for (xc = 0; xc < rwidth; xc++) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1656 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1657 const int x = xc / 4; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1658 const int scroffs = scroffsy + x; |
918 | 1659 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
|
1660 const int col = src->color[0][scroffs] & 15; |
925 | 1661 |
944
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1662 if (col & 8) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1663 { |
944
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1664 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
|
1665 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
|
1666 { |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1667 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
|
1668 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
|
1669 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
|
1670 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
|
1671 } |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1672 } |
944
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1673 else |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1674 { |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1675 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
|
1676 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
|
1677 *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
|
1678 else |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1679 *d++ = src->bgcolor; |
c62bb4028cf0
Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
1680 } |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1681 } |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
1682 } |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1683 else |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1684 { |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1685 // Perform generic BITMAP conversion |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1478
diff
changeset
|
1686 const int bmoffsy = y * src->chWidth * 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
|
1687 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1688 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES) |
811 | 1689 // Hi-res bitmap |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1690 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
|
1691 { |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1692 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
|
1693 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
|
1694 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
|
1695 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
|
1696 |
1387
14d79e4d82cf
Oops, 100L. Had forgotten to change singlecolor mode handling pixel getter
Matti Hamalainen <ccr@tnsp.org>
parents:
1385
diff
changeset
|
1697 *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
|
1698 } |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1699 else |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1700 // Multicolor bitmap and variants |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1701 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
|
1702 { |
901
f532262f90b1
Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents:
857
diff
changeset
|
1703 const int x = xc / 4; |
f532262f90b1
Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents:
857
diff
changeset
|
1704 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
|
1705 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
|
1706 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
|
1707 |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1708 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
|
1709 { |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1710 switch (src->laceType) |
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1711 { |
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1712 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
|
1713 *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
|
1714 *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
|
1715 break; |
1366
d4387509a363
Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
1716 |
d4387509a363
Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
1717 default: |
d4387509a363
Return DMERR_NOT_SUPPORTED for decoding color-interlaced images, for now
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
1718 return DMERR_NOT_SUPPORTED; |
1362
7bc67ba68904
Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents:
1361
diff
changeset
|
1719 } |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1720 } |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1721 else |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1722 { |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
1723 *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
|
1724 } |
529
1bce06b5026f
Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents:
528
diff
changeset
|
1725 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1726 } |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
1727 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
|
1728 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1729 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
1730 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
|
1731 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1732 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1733 |
940
ff18d2511843
Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents:
939
diff
changeset
|
1734 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
|
1735 { |
940
ff18d2511843
Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents:
939
diff
changeset
|
1736 int res; |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1737 DMImage *dst; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1738 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1739 if (pdst == NULL || src == NULL) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1740 return DMERR_NULLPTR; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1741 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1742 // Allocate image structure |
1289 | 1743 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
|
1744 return DMERR_MALLOC; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1745 |
1426
4c7b456d7f0b
Rename global dmC64Palette to dmDefaultC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
1425
diff
changeset
|
1746 // Set partial palette information |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1747 dst->ncolors = C64_NCOLORS; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1748 dst->constpal = TRUE; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1749 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1750 // Convert |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1751 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
|
1752 res = fmt->convertFrom(dst, src, fmt); |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1753 else |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
1754 res = dmC64ConvertGenericBMP2Image(dst, src, fmt); |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1755 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1756 return res; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1757 } |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
1758 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1759 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1760 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
|
1761 const size_t probeOffs, const size_t loadOffs, |
516 | 1762 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
|
1763 { |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1764 if (img == NULL) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1765 return DMERR_NULLPTR; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1766 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1767 // Check for forced format |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1768 if (forced != NULL) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1769 *fmt = forced; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1770 else |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1771 { |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1772 // Nope, perform a generic probe |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1773 if (probeOffs >= len) |
1460 | 1774 return DMERR_OUT_OF_DATA; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1775 |
537
32d9e67da189
Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
536
diff
changeset
|
1776 if (dmC64ProbeBMP(buf + probeOffs, len - probeOffs, fmt) == DM_PROBE_SCORE_FALSE) |
1460 | 1777 return DMERR_NOT_SUPPORTED; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1778 } |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1779 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1780 if (loadOffs >= len) |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1781 return DMERR_INVALID_ARGS; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1782 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1783 if (*fmt == NULL) |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1784 return DMERR_INVALID_DATA; |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1785 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1786 // Allocate memory |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1377
diff
changeset
|
1787 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
|
1788 return DMERR_MALLOC; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1789 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
1790 // 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
|
1791 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
|
1792 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
|
1793 else |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
927
diff
changeset
|
1794 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
|
1795 } |
1467
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1796 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1797 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1798 // Convert a generic bitmap image to DMC64Image |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1799 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1800 { |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1801 if (dst == NULL || src == NULL || fmt == NULL) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1802 return DMERR_NULLPTR; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1803 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1804 return DMERR_OK; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1805 } |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1806 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1807 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1808 int dmC64ConvertImage2BMP(DMC64Image **pdst, const DMImage *src, const DMC64ImageFormat *fmt) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1809 { |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1810 int res; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1811 DMC64Image *dst; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1812 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1813 if (pdst == NULL || src == NULL) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1814 return DMERR_NULLPTR; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1815 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1816 // Allocate the basic C64 bitmap image structure |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1817 if ((*pdst = dst = dmC64ImageAlloc(fmt)) == NULL) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1818 return DMERR_MALLOC; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1819 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1820 // Convert |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1821 if (fmt->convertTo != NULL) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1822 res = fmt->convertTo(dst, src, fmt); |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1823 else |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1824 res = dmC64ConvertGenericImage2BMP(dst, src, fmt); |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1825 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1826 return res; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1827 } |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1828 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1829 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1830 int dmC64EncodeBMP(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1831 { |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1832 int res; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1833 |
1472
b9d3577d8290
Improve error handling and checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1471
diff
changeset
|
1834 if (img == NULL || fmt == NULL) |
1467
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1835 return DMERR_NULLPTR; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1836 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1837 // Attempt to encode the image to a buffer |
1472
b9d3577d8290
Improve error handling and checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1471
diff
changeset
|
1838 if ((res = dmGrowBufInit(buf)) != DMERR_OK) |
b9d3577d8290
Improve error handling and checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1471
diff
changeset
|
1839 return res; |
b9d3577d8290
Improve error handling and checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1471
diff
changeset
|
1840 |
1467
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1841 if (fmt->encode != NULL) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1842 res = fmt->encode(buf, img, fmt); |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1843 else |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1844 res = dmC64EncodeGenericBMP(buf, img, fmt); |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1845 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1846 if (res != DMERR_OK) |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1847 goto err; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1848 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1849 // Add the loading address |
1469
0046b4e1b35f
Various fixes in bmp encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
1850 if (!dmGrowBufGrow(buf, 2)) |
0046b4e1b35f
Various fixes in bmp encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
1851 { |
0046b4e1b35f
Various fixes in bmp encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
1852 res = DMERR_MALLOC; |
1467
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1853 goto err; |
1469
0046b4e1b35f
Various fixes in bmp encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
1854 } |
1467
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1855 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1856 memmove(buf->data + 2, buf->data, buf->len); |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1857 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1858 buf->data[0] = DM_GET_ADDR_LO(fmt->addr); |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1859 buf->data[1] = DM_GET_ADDR_HI(fmt->addr); |
1485
06a9c16601d6
Oops. Fix dmC64EncodeBMP() to add loading address to total data size.
Matti Hamalainen <ccr@tnsp.org>
parents:
1483
diff
changeset
|
1860 buf->len += 2; |
1467
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1861 |
1469
0046b4e1b35f
Various fixes in bmp encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
1862 return DMERR_OK; |
1467
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1863 |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1864 err: |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1865 dmGrowBufFree(buf); |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1866 return res; |
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1466
diff
changeset
|
1867 } |