Mercurial > hg > dmlib
annotate tools/lib64gfx.c @ 915:ba6b210c9bf4
Cosmetic.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 25 Feb 2015 02:50:57 +0200 |
parents | 70cbbd5b7aea |
children | 3985f596ece5 |
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 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
15 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 { |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
17 snprintf(buf, len, |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
18 "%s%s%s", |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
19 (type & D64_FMT_FLI) ? "FLI " : "", |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
20 (type & D64_FMT_MC) ? "MCol" : "HiRes", |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
21 (type & D64_FMT_ILACE) ? " Ilace" : "" |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
22 ); |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
23 |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
24 return buf; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
25 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 // 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
|
29 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
|
30 { |
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
|
31 { 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
|
32 { 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
|
33 { 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
|
34 { 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
|
35 { 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
|
36 { 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
|
37 { 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
|
38 { 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
|
39 { 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
|
40 { 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
|
41 { 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
|
42 { 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
|
43 { 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
|
44 { 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
|
45 { 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
|
46 { 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
|
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 |
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 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
|
51 { |
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_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
|
53 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
|
54 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
|
55 1, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 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
|
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
803
5d158c4321bb
Add some parenthesis to the macros.
Matti Hamalainen <ccr@tnsp.org>
parents:
567
diff
changeset
|
60 #define DM_GET_ADDR_LO(addr) ((addr) & 0xff) |
5d158c4321bb
Add some parenthesis to the macros.
Matti Hamalainen <ccr@tnsp.org>
parents:
567
diff
changeset
|
61 #define DM_GET_ADDR_HI(addr) (((addr) >> 8) & 0xff) |
535
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
62 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 |
514 | 64 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr) |
65 { | |
827 | 66 return buf[offs ] == DM_GET_ADDR_LO(addr) && |
535
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
67 buf[offs + 1] == DM_GET_ADDR_HI(addr); |
514 | 68 } |
69 | |
70 | |
827 | 71 int dmC64ConvertCSDataToImage(DMImage *img, |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
72 int xoffs, int yoffs, const Uint8 *buf, |
915 | 73 int width, int height, BOOL multicolor, |
74 int *colors) | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 int yc, widthpx = width * 8; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
77 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
|
78 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 if (img == NULL) |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
80 return DMERR_NULLPTR; |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
81 |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
82 if (xoffs < 0 || yoffs < 0 || |
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
83 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
|
84 yoffs > img->height - height) |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
85 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
|
86 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 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
|
88 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 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
|
90 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 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
|
92 { |
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 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
|
94 int xc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
95 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
|
96 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 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
|
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 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
|
100 const int v = 6 - ((xc * 2) & 6); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
101 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
|
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 *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
|
104 *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
|
105 } |
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 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
|
108 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 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
|
113 { |
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 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
|
115 int xc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
116 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
|
117 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 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
|
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 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
|
121 const int v = 7 - (xc & 7); |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
122 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
|
123 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 *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
|
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 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
|
128 } |
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 |
517
e2a76bb59888
Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
131 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
|
132 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
135 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
|
136 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 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
|
138 |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 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
|
143 (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
|
144 (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
|
145 )) |
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 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
|
147 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 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
|
149 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 |
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 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
|
153 { |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
154 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
|
155 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
156 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
|
157 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
|
158 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
159 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
|
160 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
|
161 |
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 (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
|
163 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 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
|
165 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
|
166 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 *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
|
171 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
173 *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
|
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 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
176 *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
|
177 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
178 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
|
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 |
519 | 181 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
182 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
|
183 { |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
184 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
|
185 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
|
186 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
187 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
|
188 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
|
189 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
190 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
|
191 |
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
192 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
|
193 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
|
194 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
|
195 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
196 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
197 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
198 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
|
199 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
206 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
|
207 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
208 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
209 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
210 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
|
211 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
212 (void) len; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
213 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
214 img->laceType = buf[op->offs] ? D64_ILACE_RES : D64_ILACE_COLOR; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
215 img->laceBank1 = img->laceBank2 = 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
|
216 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
|
217 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
218 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
219 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
220 #define AMICA_DM_PROBE_SIZE 2048 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
221 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
|
222 { |
541
7ca6abbbbb40
Use size_t instead of int here to avoid signedness issues.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
223 size_t i, n; |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
224 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
|
225 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
|
226 |
494
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
227 // 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
|
228 if (len == 9002) |
abb112ac9916
Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents:
468
diff
changeset
|
229 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
|
230 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
231 for (n = 0, i = 2; i < len; i++) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
232 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
|
233 |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
234 if (n > 50) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 return DM_PROBE_SCORE_GOOD; |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
236 if (n > 25) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
237 return DM_PROBE_SCORE_AVG; |
533
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
238 if (n > 10) |
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
239 return DM_PROBE_SCORE_MAYBE; |
91e2d0d74e2f
Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents:
532
diff
changeset
|
240 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
|
241 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
242 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
243 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
244 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
|
245 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
246 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
|
247 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
|
248 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
249 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
|
250 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
|
251 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
252 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
|
253 |
523
d0c0c6baeb57
Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
254 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
|
255 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
|
256 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
|
257 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
260 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
|
261 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
262 (void) op; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
263 (void) buf; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
264 (void) len; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
265 img->laceType = D64_ILACE_RES; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
266 img->laceBank1 = 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
|
267 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
|
268 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
|
269 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
270 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
271 |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
272 static BOOL fmtSetFLIType(DMC64Image *img, const struct _DMC64EncDecOp *op, const Uint8 *buf, const size_t len) |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
273 { |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
274 (void) buf; |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
275 (void) len; |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
276 img->fliType = op->bank; |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
277 return TRUE; |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
278 } |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
279 |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
280 |
516 | 281 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
|
282 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
283 { |
539
8d7b6fecbb24
Change filename extension of DrazPaint 2.0 packed format to avoid conflict with the unpacked format while allowing the user to selecto output format via extension.
Matti Hamalainen <ccr@tnsp.org>
parents:
538
diff
changeset
|
284 D64_FMT_MC, "d2p", "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
|
285 fmtProbeDrazPaint20Packed, fmtDecodeDrazPaintPacked, |
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
286 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
|
287 4, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
288 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
289 { 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
|
290 { 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
|
291 { 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
|
292 { 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
|
293 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
294 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
295 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
296 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
297 D64_FMT_MC | D64_FMT_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
|
298 fmtProbeDrazLace10Packed, fmtDecodeDrazPaintPacked, |
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
299 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
|
300 6, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
301 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
302 { 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
|
303 { 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
|
304 { 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
|
305 { 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
|
306 { 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
|
307 { 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
|
308 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
309 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
310 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
311 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
312 D64_FMT_MC, "drp", "DrazPaint (unpacked)", 0x5800, 10051, |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
313 NULL, NULL, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
314 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
|
315 4, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
316 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
317 { 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
|
318 { 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
|
319 { 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
|
320 { 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
|
321 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
322 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
323 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
324 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
325 D64_FMT_MC | D64_FMT_ILACE, "drl", "DrazLace 1.0 (unpacked)", 0x5800, 18242, |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
326 NULL, NULL, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
327 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
|
328 6, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
329 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
330 { 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
|
331 { 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
|
332 { 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
|
333 { 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
|
334 { 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
|
335 { 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
|
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 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
338 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
340 D64_FMT_MC | D64_FMT_ILACE, "mci", "Truepaint (unpacked)", 0x9c00, 19434, |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
341 NULL, NULL, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
342 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
|
343 6, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
344 { |
510
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, 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
|
346 { 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
|
347 { 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
|
348 { 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
|
349 { 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
|
350 { 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
|
351 { 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
|
352 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
353 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
354 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
355 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
356 D64_FMT_MC, "kla", "Koala Paint (unpacked)", 0x6000, 10003, |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
357 NULL, NULL, |
507
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
358 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
|
359 4, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
360 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
361 { 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
|
362 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL }, |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
363 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL }, |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
364 { 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
|
365 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
367 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
368 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
369 D64_FMT_MC, "ocp", "Advanced Art Studio (unpacked)", 0x2000, 10018, |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
370 NULL, NULL, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
371 NULL, NULL, NULL, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
372 4, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
373 { |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
374 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
375 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
376 { DT_COLOR_RAM, 0x2338, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
377 { DT_BGCOLOR, 0x2329, 0, 0, NULL, NULL }, |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
378 } |
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
379 }, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
380 |
524
78edb9710ab7
Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents:
523
diff
changeset
|
381 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
382 D64_FMT_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
|
383 fmtProbeAmicaPaintPacked, fmtDecodeAmicaPaintPacked, |
272e64259fde
Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents:
494
diff
changeset
|
384 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
|
385 4, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
386 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
387 { 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
|
388 { 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
|
389 { 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
|
390 { 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
|
391 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
392 }, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
393 |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
394 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
395 D64_FMT_MC, "rpm", "Run Paint (unpacked)", 0x6000, 10006, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
396 NULL, NULL, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
397 NULL, NULL, NULL, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
398 4, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
399 { |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
400 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
401 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
402 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
403 { DT_BGCOLOR, 0x2710, 0, 0, NULL, NULL }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
404 } |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
405 }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
406 |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
407 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
408 D64_FMT_HIRES, "art", "Art Studio (unpacked)", 0x2000, 9009, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
409 NULL, NULL, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
410 NULL, NULL, NULL, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
411 2, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
412 { |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
413 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
414 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
415 } |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
416 }, |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
417 |
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
418 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
419 D64_FMT_HIRES, "iph", "Interpaint (unpacked)", 0x4000, 9002, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
420 NULL, NULL, |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
421 NULL, NULL, NULL, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
422 2, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
423 { |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
424 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
425 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL }, |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
426 } |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
427 }, |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
428 |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
429 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
430 D64_FMT_HIRES, "dd", "Doodle (unpacked)", 0x1c00, 9218, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
431 NULL, NULL, |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
432 NULL, NULL, NULL, |
527
49666bb544b9
Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents:
526
diff
changeset
|
433 2, |
526
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
434 { |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
435 { DT_SCREEN_RAM, 0x0000, 0, 0, NULL, NULL }, |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
436 { DT_BITMAP, 0x0400, 0, 0, NULL, NULL }, |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
437 } |
f7df57cafdd9
Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
525
diff
changeset
|
438 }, |
905 | 439 |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
440 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
441 D64_FMT_MC | D64_FMT_FLI, "bml", "Blackmail FLI (unpacked)", 0x3b00, 17474, |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
442 NULL, NULL, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
443 NULL, NULL, NULL, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
444 11, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
445 { |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
446 { DT_COLOR_RAM, 0x0100, 0, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
447 |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
448 { DT_SCREEN_RAM, 0x0500, 0, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
449 { DT_SCREEN_RAM, 0x0900, 1, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
450 { DT_SCREEN_RAM, 0x0d00, 2, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
451 { DT_SCREEN_RAM, 0x1100, 3, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
452 |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
453 { DT_SCREEN_RAM, 0x1500, 4, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
454 { DT_SCREEN_RAM, 0x1900, 5, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
455 { DT_SCREEN_RAM, 0x1d00, 6, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
456 { DT_SCREEN_RAM, 0x2100, 7, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
457 |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
458 { DT_BITMAP, 0x2500, 0, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
459 { DT_DEC_FUNCTION, 0x0000, D64_FLI_8BANK, 0, fmtSetFLIType, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
460 } |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
461 }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
462 |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
463 { |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
464 D64_FMT_MC | D64_FMT_FLI, "fli", "FLI Designer (unpacked)", 0x3c00, 17409, |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
465 NULL, NULL, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
466 NULL, NULL, NULL, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
467 11, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
468 { |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
469 { DT_COLOR_RAM, 0x0000, 0, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
470 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
471 { DT_SCREEN_RAM, 0x0800, 1, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
472 { DT_SCREEN_RAM, 0x0c00, 2, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
473 { DT_SCREEN_RAM, 0x1000, 3, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
474 { DT_SCREEN_RAM, 0x1400, 4, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
475 { DT_SCREEN_RAM, 0x1800, 5, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
476 { DT_SCREEN_RAM, 0x1c00, 6, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
477 { DT_SCREEN_RAM, 0x2000, 7, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
478 { DT_BITMAP, 0x2400, 0, 0, NULL, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
479 { DT_DEC_FUNCTION, 0x0000, D64_FLI_8BANK, 0, fmtSetFLIType, NULL }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
480 } |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
481 }, |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
482 |
906
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
483 { |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
484 D64_FMT_MC, "xx1", "Unknown $2000 format (unpacked)", 0x2000, 10242, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
485 NULL, NULL, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
486 NULL, NULL, NULL, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
487 4, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
488 { |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
489 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL }, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
490 { DT_SCREEN_RAM, 0x2000, 0, 0, NULL, NULL }, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
491 { DT_COLOR_RAM, 0x2400, 0, 0, NULL, NULL }, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
492 { DT_BGCOLOR_SET, 0x00 , 0, 0, NULL, NULL }, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
493 } |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
494 }, |
e591ce9b3526
Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents:
905
diff
changeset
|
495 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
496 }; |
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 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
|
499 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
500 |
518 | 501 // Perform probing of the given data buffer, trying to determine |
502 // if it contains a supported "C64" image format. Returns the | |
503 // "probe score", see libgfx.h for list of values. If a match | |
504 // is found, pointer to format description is set to *pfmt. | |
537
32d9e67da189
Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
536
diff
changeset
|
505 int dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **pfmt) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
506 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
507 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
|
508 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
509 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
|
510 { |
516 | 511 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
|
512 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
|
513 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
|
514 { |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
515 // 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
|
516 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
|
517 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
|
518 } |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
519 else |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
520 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
|
521 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 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
|
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 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
|
525 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
|
526 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
527 } |
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 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
|
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 *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
|
532 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
|
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 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
535 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
|
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 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
539 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
|
540 { |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
541 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
|
542 { |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
543 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
|
544 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
|
545 return DMERR_INTERNAL; |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
546 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
547 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
548 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
|
549 { |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
550 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
|
551 op->type, i); |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
552 return DMERR_INTERNAL; |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
553 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
554 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
555 return DMERR_OK; |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
556 } |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
557 |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
558 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
559 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
|
560 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
|
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 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
|
563 |
513 | 564 if (buf == NULL || img == NULL || fmt == NULL) |
565 return DMERR_NULLPTR; | |
566 | |
518 | 567 // 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
|
568 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
|
569 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
|
570 |
518 | 571 // Perform decoding |
515 | 572 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
|
573 { |
515 | 574 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
575 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
|
576 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
|
577 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
|
578 |
811 | 579 // Check operation validity |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
580 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
|
581 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
|
582 |
811 | 583 // Check 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
|
584 size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size; |
811 | 585 |
586 // Do we need to reallocate some more space? | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
587 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
|
588 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
589 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
|
590 "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
|
591 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
|
592 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
|
593 } |
811 | 594 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
595 src = buf + op->offs; |
811 | 596 |
597 // Perform operation | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
598 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
|
599 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
600 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
|
601 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
|
602 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
|
603 case DT_BGCOLOR: img->bgcolor = *src; break; |
903
f29a6164ec80
Implement DT_BGCOLOR_SET decode op.
Matti Hamalainen <ccr@tnsp.org>
parents:
901
diff
changeset
|
604 case DT_BGCOLOR_SET: img->bgcolor = op->offs; break; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
605 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
|
606 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
|
607 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
|
608 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
609 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
|
610 "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
|
611 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
|
612 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
|
613 } |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
614 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
|
615 { |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
616 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
|
617 "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
|
618 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
|
619 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
|
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 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
622 } |
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 |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
629 int dmC64EncodeGenericBMP(Uint8 **pbuf, size_t *plen, const DMC64Image *img, const DMC64ImageFormat *fmt) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
630 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
631 int i, res = DMERR_OK; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
632 Uint8 *buf; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
633 size_t allocated; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
634 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
635 if (pbuf == NULL || plen == NULL || img == NULL || fmt == NULL) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
636 return DMERR_NULLPTR; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
637 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
638 // Allocate the output buffer |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
639 *plen = 0; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
640 if (fmt->size > 0) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
641 *plen = allocated = fmt->size; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
642 else |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
643 allocated = 8 * 1024; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
644 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
645 if ((buf = dmMalloc(allocated)) == NULL) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
646 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
647 dmError("Could not allocate %d bytes of memory for C64 image encoding buffer.\n", |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
648 allocated); |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
649 res = DMERR_MALLOC; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
650 goto error; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
651 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
652 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
653 // Perform encoding |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
654 for (i = 0; i < fmt->nencdecOps; i++) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
655 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
656 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
536
18fc2890ba4b
Take loading address into account while encoding, so start other data from offset +2.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
657 Uint8 *dst = 2 + buf + op->offs; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
658 size_t size; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
659 |
811 | 660 // Check operation validity |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
661 if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
662 goto error; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
663 |
811 | 664 // Check size |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
665 size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
666 |
811 | 667 // Do we need to reallocate some more space? |
536
18fc2890ba4b
Take loading address into account while encoding, so start other data from offset +2.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
668 if (2 + op->offs + size > allocated) |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
669 { |
833 | 670 size_t diff = allocated - (op->offs + size + 2), |
671 grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW; | |
672 allocated += grow; | |
673 | |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
674 if ((buf = dmRealloc(buf, allocated)) == NULL) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
675 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
676 dmError("Could not re-allocate %d bytes of memory for C64 image encoding buffer.\n", |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
677 allocated); |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
678 res = DMERR_MALLOC; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
679 goto error; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
680 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
681 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
682 |
536
18fc2890ba4b
Take loading address into account while encoding, so start other data from offset +2.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
683 if (fmt->size == 0 && op->offs + size + 2 > *plen) |
18fc2890ba4b
Take loading address into account while encoding, so start other data from offset +2.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
684 *plen = op->offs + size + 2; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
685 |
811 | 686 // Perform operation |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
687 switch (op->type) |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
688 { |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
689 case DT_COLOR_RAM: memcpy(dst, img->color[op->bank], size); break; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
690 case DT_BITMAP: memcpy(dst, img->bitmap[op->bank], size); break; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
691 case DT_SCREEN_RAM: memcpy(dst, img->screen[op->bank], size); break; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
692 case DT_BGCOLOR: *dst = img->bgcolor; break; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
693 case DT_EXTRADATA: memcpy(dst, img->extradata, size); break; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
694 case DT_ENC_FUNCTION: |
904
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
695 if (op->encfunction == NULL) |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
696 { |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
697 dmError("Encode op is a function, but function ptr is NULL: " |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
698 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
699 i, op->offs, op->offs, op->bank, size, size, *plen, *plen); |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
700 return DMERR_INTERNAL; |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
701 } |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
702 /* |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
703 if (!op->encfunction(op, buf, len)) |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
704 { |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
705 dmError("Encode op custom function failed: op #%d, " |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
706 "offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
707 i, op->offs, op->offs, op->bank, size, size, len, len); |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
708 return DMERR_INTERNAL; |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
709 } |
d3cd9f2a8ef1
Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents:
903
diff
changeset
|
710 */ |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
711 break; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
712 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
713 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
714 |
535
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
715 buf[0] = DM_GET_ADDR_LO(fmt->addr); |
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
716 buf[1] = DM_GET_ADDR_HI(fmt->addr); |
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
717 |
ab8d9696225c
Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
718 *pbuf = buf; |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
719 return DMERR_OK; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
720 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
721 error: |
538
45c46bfa03bd
Free the correct buffer pointer in error situations in the encoder function.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
722 dmFree(buf); |
532
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
723 *pbuf = NULL; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
724 *plen = 0; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
725 return res; |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
726 } |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
727 |
128a50feff07
Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
728 |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
729 static inline Uint8 dmC64GetMCColor(const DMC64Image *img, const int bits, const int cbank, const int vbank, const int scroffs) |
528
0961b6983b8e
Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
527
diff
changeset
|
730 { |
0961b6983b8e
Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
527
diff
changeset
|
731 switch (bits) |
0961b6983b8e
Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
527
diff
changeset
|
732 { |
0961b6983b8e
Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
527
diff
changeset
|
733 case 0: return img->bgcolor; break; |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
734 case 1: return img->screen[vbank][scroffs] >> 4; break; |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
735 case 2: return img->screen[vbank][scroffs] & 15; break; |
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
736 default: return img->color[cbank][scroffs] & 15; break; |
528
0961b6983b8e
Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
527
diff
changeset
|
737 } |
0961b6983b8e
Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
527
diff
changeset
|
738 } |
0961b6983b8e
Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
527
diff
changeset
|
739 |
0961b6983b8e
Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
527
diff
changeset
|
740 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
741 // Convert a generic "C64" format bitmap in DMC64Image struct to |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
742 // a indexed/paletted bitmap image. |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
743 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const BOOL doubleMC) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
744 { |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
745 Uint8 *dp = dst->data; |
810
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
746 int yc; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
747 |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
748 // Sanity check arguments |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
749 if (dst == NULL || src == NULL) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
750 return DMERR_NULLPTR; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
751 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
752 if (dst->width < 8) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
753 return DMERR_INVALID_ARGS; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
754 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
755 // Perform generic conversion |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
756 for (yc = 0; yc < dst->height; yc++) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
757 { |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
758 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
|
759 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
|
760 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
|
761 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
|
762 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
|
763 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
764 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES) |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
765 { |
811 | 766 // Hi-res bitmap |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
767 for (xc = 0; xc < dst->width; xc++) |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
768 { |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
769 const int x = xc / 8; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
770 const int scroffs = scroffsy + x; |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
771 const int bmoffs = bmoffsy + (x * 8) + yb; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
772 const int v = 7 - (xc & 7); |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
773 |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
774 if ((src->bitmap[0][bmoffs] >> v) & 1) |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
775 *d++ = src->screen[0][scroffs] >> 4; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
776 else |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
777 *d++ = src->screen[0][scroffs] & 15; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
778 } |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
779 } |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
780 else |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
781 { |
811 | 782 // Multicolor variants |
857
16aa5955dfb5
Fix c64 multicolor bitmap conversion for !doubleMC case.
Matti Hamalainen <ccr@tnsp.org>
parents:
833
diff
changeset
|
783 const int wdivisor = doubleMC ? 2 : 1; |
810
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
784 |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
785 for (xc = 0; xc < dst->width / wdivisor; xc++) |
529
1bce06b5026f
Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents:
528
diff
changeset
|
786 { |
901
f532262f90b1
Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents:
857
diff
changeset
|
787 const int x = xc / 4; |
f532262f90b1
Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents:
857
diff
changeset
|
788 const int scroffs = scroffsy + x; |
f532262f90b1
Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents:
857
diff
changeset
|
789 const int bmoffs = bmoffsy + (x * 8) + yb; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
790 const int v = 6 - ((xc * 2) & 6); |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
791 Uint8 c; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
792 |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
793 if (src->type & D64_FMT_FLI) |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
794 { |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
795 int vbank = 0; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
796 switch (src->fliType) |
529
1bce06b5026f
Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents:
528
diff
changeset
|
797 { |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
798 case D64_FLI_2BANK: |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
799 vbank = yb / 4; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
800 break; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
801 case D64_FLI_4BANK: |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
802 vbank = yb / 2; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
803 break; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
804 case D64_FLI_8BANK: |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
805 vbank = yb; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
806 break; |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
807 } |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
808 c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, vbank, scroffs); |
529
1bce06b5026f
Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents:
528
diff
changeset
|
809 *d++ = c; |
810
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
810 if (doubleMC) |
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
811 *d++ = c; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
812 } |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
813 else |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
814 if (src->type & D64_FMT_ILACE) |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
815 { |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
816 *d++ = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, src->laceBank1, scroffs); |
810
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
817 if (doubleMC) |
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
818 *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs); |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
819 } |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
820 else |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
821 { |
531
2ac364d0ace9
Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
822 c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, 0, scroffs); |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
823 *d++ = c; |
810
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
824 if (doubleMC) |
cbe263ad963c
Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
803
diff
changeset
|
825 *d++ = c; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
826 } |
529
1bce06b5026f
Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents:
528
diff
changeset
|
827 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
828 } |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
529
diff
changeset
|
829 dp += dst->pitch; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
830 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
831 |
508
1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
832 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
|
833 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
834 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
835 |
556
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
836 int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt, const BOOL doubleMC) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
837 { |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
838 int width, res; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
839 DMImage *dst; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
840 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
841 if (pdst == NULL || src == NULL) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
842 return DMERR_NULLPTR; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
843 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
844 // Calculate output image width |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
845 if ((src->type & D64_FMT_MC) && !doubleMC) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
846 width = C64_SCR_WIDTH / 2; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
847 else |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
848 width = C64_SCR_WIDTH; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
849 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
850 // Allocate image structure |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
851 if ((*pdst = dst = dmImageAlloc(width, C64_SCR_HEIGHT)) == NULL) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
852 return DMERR_MALLOC; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
853 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
854 // Set palette |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
855 dst->pal = (DMColor *) &dmC64Palette; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
856 dst->ncolors = C64_NCOLORS; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
857 dst->constpal = TRUE; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
858 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
859 // Convert |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
860 if (fmt->convertFrom != NULL) |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
861 res = fmt->convertFrom(dst, src, doubleMC); |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
862 else |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
863 res = dmC64ConvertGenericBMP2Image(dst, src, doubleMC); |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
864 |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
865 return res; |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
866 } |
44d1e0d4acf3
Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
548
diff
changeset
|
867 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
868 |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
869 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
|
870 const size_t probeOffs, const size_t loadOffs, |
516 | 871 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
|
872 { |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
873 // Check for forced format |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
874 if (forced != NULL) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
875 *fmt = forced; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
876 else |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
877 { |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
878 // Nope, perform a generic probe |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
879 if (probeOffs >= len) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
880 return -200; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
881 |
537
32d9e67da189
Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
536
diff
changeset
|
882 if (dmC64ProbeBMP(buf + probeOffs, len - probeOffs, fmt) == DM_PROBE_SCORE_FALSE) |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
883 return -201; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
884 } |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
885 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
886 if (loadOffs >= len) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
887 return -203; |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
888 |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
889 // 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
|
890 if ((*fmt)->decode != NULL) |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
891 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
|
892 else |
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
410
diff
changeset
|
893 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
|
894 } |