Mercurial > hg > dmlib
annotate lib64gfx.c @ 525:b41f20507fe3
Fix hires bitmap conversion to DMImage, the screen colors per bit state were
reversed.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 22 Nov 2012 01:07:20 +0200 |
parents | 78edb9710ab7 |
children | f7df57cafdd9 |
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * (C) Copyright 2012 Tecnic Software productions (TNSP) |
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 const char *dmC64ImageTypeNames[DM_C64IFMT_LAST_TYPE] = |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 "hires", |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 "multicolor", |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 "hires interlace", |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 "mc interlace", |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 "hires fli", |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 "mc fli", |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 // Based on Pepto's palette, stolen from VICE |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 DMColor dmC64Palette[C64_NCOLORS] = |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 { |
468
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
29 { 0x00, 0x00, 0x00, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
30 { 0xFF, 0xFF, 0xFF, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
31 { 0x68, 0x37, 0x2B, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
32 { 0x70, 0xA4, 0xB2, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
33 { 0x6F, 0x3D, 0x86, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
34 { 0x58, 0x8D, 0x43, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
35 { 0x35, 0x28, 0x79, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
36 { 0xB8, 0xC7, 0x6F, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
37 { 0x6F, 0x4F, 0x25, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
38 { 0x43, 0x39, 0x00, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
39 { 0x9A, 0x67, 0x59, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
40 { 0x44, 0x44, 0x44, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
41 { 0x6C, 0x6C, 0x6C, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
42 { 0x9A, 0xD2, 0x84, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
43 { 0x6C, 0x5E, 0xB5, 0xff }, |
afa7f8dd4a8f
Change c64 palette's alpha values to 0xff to prevent RGBA output from being transparent.
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
44 { 0x95, 0x95, 0x95, 0xff }, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 const size_t dmC64DefaultSizes[DT_LAST] = |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 C64_SCR_COLOR_SIZE, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 C64_SCR_BITMAP_SIZE, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 C64_SCR_SCREEN_SIZE, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 1, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 C64_SCR_EXTRADATA, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 |
514 | 59 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr) |
60 { | |
61 return (buf[offs] == (addr & 0xff)) && (buf[offs + 1] == ((addr >> 8) & 0xff)); | |
62 } | |
63 | |
64 | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 int dmC64ConvertCSData(DMImage *img, |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
66 int xoffs, int yoffs, 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
|
67 int width, int height, BOOL multicolor, int *colors) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 int yc, widthpx = width * 8; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
70 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
|
71 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 if (img == NULL) |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
73 return DMERR_NULLPTR; |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
74 |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
75 if (xoffs < 0 || yoffs < 0 || |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
76 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
|
77 yoffs > img->height - height) |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
78 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
|
79 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 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
|
81 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 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
|
83 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 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
|
85 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 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
|
87 int xc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
88 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
|
89 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 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
|
91 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 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
|
93 const int v = 6 - ((xc * 2) & 6); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
94 const Uint8 c = colors[(b >> v) & 3]; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 *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
|
97 *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
|
98 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 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
|
101 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 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
|
106 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 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
|
108 int xc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
109 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
|
110 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 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
|
112 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 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
|
114 const int v = 7 - (xc & 7); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
115 const Uint8 c = colors[(b >> v) & 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
|
116 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 *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
|
118 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 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
|
121 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
124 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
|
125 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
128 static int fmtProbeDrazPaint20Packed(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
|
129 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 const char *ident = (const char *) buf + 2; |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
131 |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
132 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
|
133 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
|
134 strncmp(ident, "DRAZPAINT ", 10) == 0 && |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
135 ident[11] == '.' && ( |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
136 (ident[10] == '1' && ident[12] == '4') || |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
137 (ident[10] == '2' && ident[12] == '0') |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
138 )) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 return DM_PROBE_SCORE_MAX; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
141 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
|
142 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
145 static int dmDecodeGenericRLE(Uint8 **mem, Uint8 **pdstEnd, const Uint8 *src, const Uint8 *srcEnd, const Uint8 rleMarker) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 { |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
147 Uint8 *dst, *dstEnd; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
149 if ((*mem = dmMalloc(C64_RAM_SIZE)) == NULL) |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
150 return DMERR_MALLOC; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
151 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
152 dst = *mem; |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
153 dstEnd = *mem + C64_RAM_SIZE; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 while (src <= srcEnd && dst <= dstEnd) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 int c = *src++; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 if (c == rleMarker && src + 2 <= srcEnd) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 int cnt = *src++; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 c = *src++; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 while (cnt-- && dst <= dstEnd) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 *dst++ = c; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 *dst++ = c; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 } |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
168 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
169 *pdstEnd = dst; |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
170 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
171 return DMERR_OK; |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
172 } |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
173 |
519 | 174 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
175 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
|
176 { |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
177 int res; |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
178 Uint8 *mem = NULL, *dstEnd; |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
179 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
180 if ((res = dmDecodeGenericRLE(&mem, &dstEnd, buf + 0x0e, buf + len, *(buf + 0x0d))) != DMERR_OK) |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
181 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
|
182 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
183 res = dmC64DecodeGenericBMP(img, mem, dstEnd - mem + 1, fmt); |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
184 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
185 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
|
186 dmFree(mem); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 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
|
188 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
189 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
191 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
|
192 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 const char *ident = (const char *) buf + 2; |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
194 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
|
195 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
|
196 strncmp(ident, "DRAZLACE! 1.0", 13) == 0) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
197 return DM_PROBE_SCORE_MAX; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
198 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
199 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
|
200 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
201 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
202 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
203 static BOOL fmtDrazLaceSetLaceType(DMC64Image *img, const struct _DMC64EncDecOp *op, const Uint8 *buf, const size_t len) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
205 (void) len; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
206 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
207 img->laceType = buf[op->offs] ? DM_C64ILACE_RES : DM_C64ILACE_COLOR; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
208 img->laceBank2 = 0; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
209 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
|
210 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
211 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
212 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
213 #define AMICA_DM_PROBE_SIZE 1024 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
214 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
|
215 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
216 int i, n; |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
217 if (len < AMICA_DM_PROBE_SIZE || !dmCompareAddr16(buf, 0, fmt->addr)) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
218 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
|
219 |
494
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
220 // Interpaint Hi-Res gives a false positive |
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
221 if (len == 9002) |
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
222 return DM_PROBE_SCORE_FALSE; |
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
223 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
224 for (n = 0, i = 2; i < AMICA_DM_PROBE_SIZE; i++) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
225 if (buf[i] == 0xC2) n++; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
226 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
227 if (n > 5) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
228 return DM_PROBE_SCORE_GOOD; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
229 if (n > 3) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
230 return DM_PROBE_SCORE_AVG; |
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 return DM_PROBE_SCORE_MAYBE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
233 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
234 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
236 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
|
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 int res; |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
239 Uint8 *mem = NULL, *dstEnd; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
240 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
241 if ((res = dmDecodeGenericRLE(&mem, &dstEnd, buf, buf + len, 0xC2)) != DMERR_OK) |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
242 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
|
243 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
244 res = dmC64DecodeGenericBMP(img, mem, dstEnd - mem + 1, 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
|
245 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
246 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
|
247 dmFree(mem); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
248 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
|
249 } |
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 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
252 static BOOL fmtTruePaintSetLaceType(DMC64Image *img, const struct _DMC64EncDecOp *op, const Uint8 *buf, const size_t len) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
253 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
254 (void) op; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
255 (void) buf; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
256 (void) len; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 img->laceType = DM_C64ILACE_RES; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 img->laceBank2 = 1; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 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
|
260 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
261 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
262 |
516 | 263 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
|
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 { |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
266 DM_C64IFMT_MC, ".drp", "DrazPaint 2.0 (packed)", 0x5800, -1, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
267 fmtProbeDrazPaint20Packed, fmtDecodeDrazPaintPacked, |
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
268 NULL, NULL, NULL, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
269 4, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
270 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
271 { 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
|
272 { 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
|
273 { DT_SCREEN_RAM, 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
|
274 { DT_BGCOLOR, 0x2740, 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
|
275 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
276 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
277 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
278 { |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
279 DM_C64IFMT_MC_ILACE, ".dlp", "DrazLace 1.0 (packed)", 0x5800, -1, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
280 fmtProbeDrazLace10Packed, fmtDecodeDrazPaintPacked, |
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
281 NULL, NULL, NULL, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
282 6, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
283 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
284 { 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
|
285 { 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
|
286 { DT_SCREEN_RAM, 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
|
287 { DT_BGCOLOR, 0x2740, 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
|
288 { 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
|
289 { DT_DEC_FUNCTION, 0x2742, 0, 1, fmtDrazLaceSetLaceType, 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
|
290 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
291 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
292 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
293 { |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
294 DM_C64IFMT_MC, ".drp", "DrazPaint (unpacked)", 0x5800, 10051, |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
295 NULL, NULL, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
296 NULL, NULL, NULL, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
297 4, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
298 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
299 { 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
|
300 { 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
|
301 { DT_SCREEN_RAM, 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
|
302 { DT_BGCOLOR, 0x2740, 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
|
303 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
304 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
305 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
306 { |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
307 DM_C64IFMT_MC_ILACE, ".drl", "DrazLace 1.0 (unpacked)", 0x5800, 18242, |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
308 NULL, NULL, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
309 NULL, NULL, NULL, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
310 6, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
311 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
312 { 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
|
313 { 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
|
314 { DT_SCREEN_RAM, 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
|
315 { DT_BGCOLOR, 0x2740, 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
|
316 { 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
|
317 { DT_DEC_FUNCTION, 0x2742, 0, 1, fmtDrazLaceSetLaceType, 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
|
318 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
320 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
321 { |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
322 DM_C64IFMT_MC_ILACE, ".mci", "Truepaint (unpacked)", 0x9c00, 19434, |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
323 NULL, NULL, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
324 NULL, NULL, NULL, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
325 6, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
326 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
327 { DT_SCREEN_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
|
328 { DT_BGCOLOR, 0x03e8, 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
|
329 { 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
|
330 { 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
|
331 { 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
|
332 { 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
|
333 { DT_DEC_FUNCTION, 0x0000, 0, 0, fmtTruePaintSetLaceType, 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
|
334 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
335 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
336 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
337 { |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
338 DM_C64IFMT_MC, ".kla", "Koala Paint (unpacked)", 0x6000, 10003, |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
339 NULL, NULL, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
340 NULL, NULL, NULL, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
341 4, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
342 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
343 { 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
|
344 { 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
|
345 { DT_SCREEN_RAM, 0x1f40, 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
|
346 { DT_BGCOLOR, 0x2710, 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
|
347 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
348 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
349 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
350 { |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
351 DM_C64IFMT_MC, ".ocp", "Advanced Art Studio (unpacked)", 0x2000, 10018, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
352 NULL, NULL, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
353 NULL, NULL, NULL, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
354 4, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
355 { |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
356 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
357 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
358 { DT_COLOR_RAM, 0x2338, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
359 { DT_BGCOLOR, 0x2329, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
360 } |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
361 }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
362 { |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
363 DM_C64IFMT_MC, ".ami", "Amica Paint (packed)", 0x4000, -1, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
364 fmtProbeAmicaPaintPacked, fmtDecodeAmicaPaintPacked, |
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
365 NULL, NULL, NULL, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 4, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
367 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
368 { 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
|
369 { 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
|
370 { DT_SCREEN_RAM, 0x1f40, 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
|
371 { DT_BGCOLOR, 0x2710, 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
|
372 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
373 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
374 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
375 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
376 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
377 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
|
378 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
379 |
518 | 380 // Perform probing of the given data buffer, trying to determine |
381 // if it contains a supported "C64" image format. Returns the | |
382 // "probe score", see libgfx.h for list of values. If a match | |
383 // is found, pointer to format description is set to *pfmt. | |
516 | 384 int dmC64ProbeGeneric(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
|
385 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
386 int i, 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
|
387 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
388 for (i = 0; i < ndmC64ImageFormats; i++) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
389 { |
516 | 390 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
|
391 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
|
392 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
|
393 { |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
394 // 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
|
395 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
|
396 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
|
397 } |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
398 else |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
399 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
|
400 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
401 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
|
402 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
403 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
|
404 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
|
405 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
406 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
407 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
408 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
|
409 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
410 *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
|
411 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
|
412 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
413 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
414 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
|
415 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
416 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
417 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
418 static int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op) |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
419 { |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
420 if (op->bank < 0 || op->bank >= C64_SCR_MAX_BANK) |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
421 { |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
422 dmError("Invalid bank %d definition in generic encode/decode operator %d @ #%d.\n", |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
423 op->bank, op->type, i); |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
424 return DMERR_INTERNAL; |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
425 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
426 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
427 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
|
428 { |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
429 dmError("Invalid encode/decode operator type %d @ #%d.\n", |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
430 op->type, i); |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
431 return DMERR_INTERNAL; |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
432 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
433 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
434 return DMERR_OK; |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
435 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
436 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
437 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
438 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
|
439 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
|
440 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
441 int i; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
442 |
513 | 443 if (buf == NULL || img == NULL || fmt == NULL) |
444 return DMERR_NULLPTR; | |
445 | |
518 | 446 // Clear the image structure |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
447 memset(img, 0, sizeof(*img)); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
448 img->type = fmt->type; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
449 |
518 | 450 // Perform decoding |
515 | 451 for (i = 0; i < fmt->nencdecOps; 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
|
452 { |
515 | 453 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
454 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
|
455 size_t size; |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
456 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
|
457 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
458 if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK) |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
459 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
|
460 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
461 size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
462 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
463 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
|
464 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
465 dmError("Decode out of bounds, op #%d type=%d, offs=%d ($%04x), " |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
466 "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
|
467 i, op->type, op->offs, op->offs, op->bank, size, size, len, len); |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
468 return DMERR_INVALID_DATA; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
469 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
470 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
471 src = buf + op->offs; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
472 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
473 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
|
474 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
475 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
|
476 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
|
477 case DT_SCREEN_RAM: memcpy(img->screen[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
|
478 case DT_BGCOLOR: img->bgcolor = *src; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
479 case DT_EXTRADATA: memcpy(img->extradata, src, size); break; |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
480 case DT_DEC_FUNCTION: |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
481 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
|
482 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
483 dmError("Decode op is a function, but function ptr is NULL: " |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
484 "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
|
485 i, op->offs, op->offs, op->bank, size, size, len, len); |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
486 return DMERR_INTERNAL; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
487 } |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
488 if (!op->decfunction(img, op, buf, len)) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
489 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
490 dmError("Decode op custom function failed: op #%d, " |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
491 "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
|
492 i, op->offs, op->offs, op->bank, size, size, len, len); |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
493 return DMERR_INTERNAL; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
494 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
495 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
496 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
497 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
498 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
499 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
|
500 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
501 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
502 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
503 static int dmC64ConvertHiResBMP(DMImage *screen, const DMC64Image *img) |
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 int yc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
506 Uint8 *dp = screen->data; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
507 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
508 for (yc = 0; yc < C64_SCR_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
|
509 { |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
510 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
|
511 const int y = yc / 8, yb = yc & 7; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
512 const int scroffsy = y * C64_SCR_CH_WIDTH; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
513 const int bmoffsy = y * C64_SCR_WIDTH; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
514 int xc; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
515 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
516 for (xc = 0; xc < C64_SCR_WIDTH; xc++) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
517 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
518 const int x = 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
|
519 const int scroffs = scroffsy + x; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
520 const int b = img->bitmap[0][bmoffsy + (x * 8) + yb]; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
521 const int v = 7 - (xc & 7); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
522 Uint8 c; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
523 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
524 if ((b >> v) & 1) |
525
b41f20507fe3
Fix hires bitmap conversion to DMImage, the screen colors per bit state were
Matti Hamalainen <ccr@tnsp.org>
parents:
524
diff
changeset
|
525 c = img->screen[0][scroffs] >> 4; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
526 else |
525
b41f20507fe3
Fix hires bitmap conversion to DMImage, the screen colors per bit state were
Matti Hamalainen <ccr@tnsp.org>
parents:
524
diff
changeset
|
527 c = img->screen[0][scroffs] & 15; |
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
529 *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
|
530 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
531 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
532 dp += screen->pitch; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
533 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
534 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
535 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
|
536 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
537 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
538 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
539 static int dmC64ConvertMultiColorBMP(DMImage *screen, const DMC64Image *img) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
540 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
541 int yc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
542 Uint8 *dp = screen->data; |
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
544 for (yc = 0; yc < C64_SCR_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
|
545 { |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
546 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
|
547 const int y = yc / 8, yb = yc & 7; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
548 const int scroffsy = y * C64_SCR_CH_WIDTH; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
549 const int bmoffsy = y * C64_SCR_WIDTH; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
550 int xc; |
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 for (xc = 0; xc < C64_SCR_WIDTH / 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
|
553 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
554 const int x = 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
|
555 const int scroffs = scroffsy + x; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
556 const int b = img->bitmap[0][bmoffsy + (x * 8) + yb]; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
557 const int v = 6 - ((xc * 2) & 6); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
558 Uint8 c; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
559 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
560 switch ((b >> v) & 3) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
561 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
562 case 0: c = img->bgcolor; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
563 case 1: c = img->screen[0][scroffs] >> 4; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
564 case 2: c = img->screen[0][scroffs] & 15; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
565 case 3: c = img->color[0][scroffs] & 15; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
566 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
567 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
568 *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
|
569 *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
|
570 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
571 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
572 dp += screen->pitch; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
573 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
574 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
575 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
|
576 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
577 |
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 static int dmC64ConvertLaceMultiColorBMP(DMImage *screen, const DMC64Image *img) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
580 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
581 int yc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
582 Uint8 *dp = screen->data; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
583 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
584 for (yc = 0; yc < C64_SCR_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
|
585 { |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
586 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
|
587 const int y = yc / 8, yb = yc & 7; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
588 const int scroffsy = y * C64_SCR_CH_WIDTH; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
589 const int bmoffsy = y * C64_SCR_WIDTH; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
590 int xc; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
591 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
592 for (xc = 0; xc < C64_SCR_WIDTH / 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
|
593 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
594 const int x = 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
|
595 const int scroffs = scroffsy + x; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
596 const int bmoffs = bmoffsy + (x * 8) + yb; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
597 const int v = 6 - ((xc * 2) & 6); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
598 const int b1 = (img->bitmap[0][bmoffs] >> v) & 3; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
599 const int b2 = (img->bitmap[1][bmoffs] >> v) & 3; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
600 Uint8 c1, c2; |
407
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 switch (b1) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
603 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
604 case 0: c1 = img->bgcolor; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
605 case 1: c1 = img->screen[0][scroffs] >> 4; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
606 case 2: c1 = img->screen[0][scroffs] & 15; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
607 case 3: c1 = img->color[0][scroffs] & 15; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
608 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
609 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
610 switch (b2) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
611 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
612 case 0: c2 = img->bgcolor; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
613 case 1: c2 = img->screen[img->laceBank2][scroffs] >> 4; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
614 case 2: c2 = img->screen[img->laceBank2][scroffs] & 15; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
615 case 3: c2 = img->color[img->laceBank2][scroffs] & 15; break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
616 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
617 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
618 *d++ = c1; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
619 *d++ = c2; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
620 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
621 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
622 dp += screen->pitch; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
623 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
624 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
625 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
|
626 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
627 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
628 |
518 | 629 // Convert a generic "C64" format bitmap in DMC64Image struct to |
630 // a indexed/paletted bitmap image. | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
631 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
632 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
633 switch (src->type) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
634 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
635 case DM_C64IFMT_HIRES: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
636 return dmC64ConvertHiResBMP(dst, src); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
637 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
638 case DM_C64IFMT_MC: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
639 return dmC64ConvertMultiColorBMP(dst, src); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
640 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
641 case DM_C64IFMT_MC_ILACE: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
642 return dmC64ConvertLaceMultiColorBMP(dst, src); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
643 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
644 default: |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
645 return DMERR_NOT_SUPPORTED; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
646 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
647 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
648 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
649 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
650 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
651 int dmReadDataFile(FILE *inFile, const char *filename, Uint8 **pbuf, size_t *pbufSize) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
652 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
653 FILE *f; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
654 int res = DMERR_OK; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
655 Uint8 *dataBuf = NULL, *dataPtr; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
656 size_t readSize, dataSize, dataRead; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
657 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
658 if (inFile != NULL) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
659 f = inFile; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
660 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
661 if (filename != 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
|
662 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
663 if ((f = fopen(filename, "rb")) == NULL) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
664 { |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
665 dmError("Could not open '%s' for reading.\n", filename); |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
666 return DMERR_FOPEN; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
667 } |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
668 } |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
669 else |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
670 { |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
671 dmError("NULL filename and stream pointers.\n"); |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
672 return DMERR_NULLPTR; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
673 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
674 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
675 // Allocate initial data buffer |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
676 readSize = dataSize = BUF_SIZE_INITIAL; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
677 if ((dataBuf = dmMalloc(dataSize)) == NULL) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
678 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
679 dmError("Error allocating memory for data, %d bytes.\n", dataSize); |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
680 res = DMERR_MALLOC; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
681 goto error; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
682 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
683 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
684 dataPtr = dataBuf; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
685 dataRead = 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
|
686 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
687 while (!feof(f) && !ferror(f)) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
688 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
689 size_t read = fread(dataPtr, 1, readSize, f); |
420
8d15443ce209
Fix lingering issue with data reading helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
419
diff
changeset
|
690 dataPtr += read; |
8d15443ce209
Fix lingering issue with data reading helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
419
diff
changeset
|
691 dataRead += read; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
692 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
693 if (dataRead >= dataSize) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
694 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
695 readSize = BUF_SIZE_GROW; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
696 dataSize += BUF_SIZE_GROW; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
697 if ((dataBuf = dmRealloc(dataBuf, dataSize)) == 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
|
698 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
699 dmError("Error reallocating memory for data, %d bytes.\n", dataSize); |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
700 res = DMERR_MALLOC; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
701 goto error; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
702 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
703 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
704 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
705 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
706 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
707 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
708 *pbufSize = dataRead; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
709 *pbuf = dataBuf; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
710 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
711 error: |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
712 if (f != inFile) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
713 fclose(f); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
714 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
715 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
|
716 } |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
717 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
718 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
719 int dmC64DecodeBMP(DMC64Image *img, const Uint8 *buf, const size_t len, |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
720 const size_t probeOffs, const size_t loadOffs, |
516 | 721 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
|
722 { |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
723 // Check for forced format |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
724 if (forced != NULL) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
725 *fmt = forced; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
726 else |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
727 { |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
728 // Nope, perform a generic probe |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
729 if (probeOffs >= len) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
730 return -200; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
731 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
732 if (dmC64ProbeGeneric(buf + probeOffs, len - probeOffs, fmt) == DM_PROBE_SCORE_FALSE) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
733 return -201; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
734 } |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
735 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
736 if (loadOffs >= len) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
737 return -203; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
738 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
739 // 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
|
740 if ((*fmt)->decode != NULL) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
741 return (*fmt)->decode(img, buf + loadOffs, len - loadOffs, *fmt); |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
742 else |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
743 return dmC64DecodeGenericBMP(img, buf + loadOffs, len - loadOffs, *fmt); |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
744 } |