annotate tools/lib64gfx.c @ 1364:0d61895e1763

Cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 22 Sep 2017 23:00:32 +0300
parents 7bc67ba68904
children 60d7240e1a63
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Functions for reading and converting various restricted
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * C64/etc and/or indexed/paletted graphics formats.
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * Programmed and designed by Matti 'ccr' Hamalainen
1308
8f71ca1900ea Update header blurps and copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 1289
diff changeset
5 * (C) Copyright 2012-2017 Tecnic Software productions (TNSP)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 *
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 * Please read file 'COPYING' for information on license and distribution.
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 */
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #include "lib64gfx.h"
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 433
diff changeset
10
514
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
11 #define BUF_SIZE_INITIAL (16*1024)
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
12 #define BUF_SIZE_GROW (4*1024)
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
13
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
15 DMC64Image * dmC64ImageAlloc(int width, int height, int ch_width, int ch_height)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
16 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
17 DMC64Image *img = dmMalloc0(sizeof(DMC64Image));
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
18
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
19 if (img == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
20 return NULL;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
21
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
22 img->width = width;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
23 img->height = height;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
24 img->ch_width = ch_width;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
25 img->ch_height = ch_height;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
26
1361
00f47a678482 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1308
diff changeset
27 for (int i = 0; i < C64_SCR_MAX_BANK; i++)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
28 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
29 if ((img->color[i] = dmMalloc0(ch_width * ch_height)) == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
30 goto err;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
31
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
32 if ((img->bitmap[i] = dmMalloc0(ch_width * ch_height * 8)) == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
33 goto err;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
34
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
35 if ((img->screen[i] = dmMalloc0(ch_width * ch_height)) == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
36 goto err;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
37
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
38 if ((img->charmem[i] = dmMalloc0(C64_MAX_CHARS * C64_CHR_SIZE)) == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
39 goto err;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
40 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
41
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
42 return img;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
43
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
44 err:
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
45 dmC64ImageFree(img);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
46 return NULL;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
47 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
48
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
49
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
50 void dmC64ImageFree(DMC64Image *img)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
51 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
52 if (img != NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
53 {
1361
00f47a678482 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1308
diff changeset
54 for (int i = 0; i < C64_SCR_MAX_BANK; i++)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
55 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
56 dmFree(img->color[i]);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
57 dmFree(img->bitmap[i]);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
58 dmFree(img->screen[i]);
932
6320bf08e302 Oops, plug a memory leak.
Matti Hamalainen <ccr@tnsp.org>
parents: 931
diff changeset
59 dmFree(img->charmem[i]);
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
60 }
1167
848a88ce7a57 Use dmMemset().
Matti Hamalainen <ccr@tnsp.org>
parents: 1134
diff changeset
61 dmMemset(img, 0, sizeof(DMC64Image));
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
62 dmFree(img);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
63 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
64 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
65
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
66
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
67 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
68 {
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
69 *buf = 0;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
70
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
71 if (type & D64_FMT_FLI)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
72 strncat(buf, "FLI ", len - strlen(buf));
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
73
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
74 strncat(buf, (type & D64_FMT_MC) ? "MCol " : "HiRes ", len - strlen(buf));
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
75
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
76 if (type & D64_FMT_ILACE)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
77 strncat(buf, "Ilace ", len - strlen(buf));
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
78
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
79 if (type & D64_FMT_CHAR)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
80 strncat(buf, "CharMap", len - strlen(buf));
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
81
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
82 return buf;
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
83 }
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
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 // 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
87 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
88 {
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
89 { 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
90 { 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
91 { 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
92 { 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
93 { 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
94 { 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
95 { 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
96 { 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
97 { 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
98 { 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
99 { 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
100 { 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
101 { 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
102 { 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
103 { 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
104 { 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
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
803
5d158c4321bb Add some parenthesis to the macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 567
diff changeset
108 #define DM_GET_ADDR_LO(addr) ((addr) & 0xff)
5d158c4321bb Add some parenthesis to the macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 567
diff changeset
109 #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
110
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
514
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
112 static BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr)
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
113 {
827
c8beac5313c3 Rename a function.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
114 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
115 buf[offs + 1] == DM_GET_ADDR_HI(addr);
514
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
116 }
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
117
c9b9f912acfb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 513
diff changeset
118
827
c8beac5313c3 Rename a function.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
119 int dmC64ConvertCSDataToImage(DMImage *img,
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
120 int xoffs, int yoffs, const Uint8 *buf,
915
ba6b210c9bf4 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
121 int width, int height, BOOL multicolor,
ba6b210c9bf4 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
122 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
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 int yc, widthpx = width * 8;
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
125 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
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 if (img == NULL)
517
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
128 return DMERR_NULLPTR;
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
129
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
130 if (xoffs < 0 || yoffs < 0 ||
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
131 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
132 yoffs > img->height - height)
517
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
133 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
134
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 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
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 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
138 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 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
140 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 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
142 int xc;
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
143 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
144
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 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
146 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 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
148 const int v = 6 - ((xc * 2) & 6);
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
149 const Uint8 c = colors[(b >> v) & 3];
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
150
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 *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
152 *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
153 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 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
156 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 else
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 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
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 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
163 int xc;
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
164 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
165
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 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
167 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 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
169 const int v = 7 - (xc & 7);
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
170 const Uint8 c = colors[(b >> v) & 1];
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
171
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 *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
173 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 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
176 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 }
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
178
517
e2a76bb59888 Return better error values, using DMERR_* enums.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
179 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
180 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
183 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
184 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 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
186
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
187 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
188 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
189 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
190 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
191 (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
192 (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
193 ))
407
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 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
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 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
197 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
200 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
201 {
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
202 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
203
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
204 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
205 return DMERR_MALLOC;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
206
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
207 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
208 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
209
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 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
211 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 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
213 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
214 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 int 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
216 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
217 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
218 *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
219 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 else
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 *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
222 }
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
223
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
224 *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
225
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
226 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
227 }
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
228
519
feaaf0e2ecbe Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
229
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
230 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
231 {
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
232 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
233 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
234
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
235 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
236 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
237
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
238 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
239
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
240 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
241 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
242 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
243 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
246 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
247 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 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
249 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
250 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
251 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
252 return DM_PROBE_SCORE_MAX;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
253
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 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
255 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
258 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
259 {
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
260 (void) len;
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
261
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
262 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
263 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
264 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
265 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267
533
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
268 #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
269 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
270 {
541
7ca6abbbbb40 Use size_t instead of int here to avoid signedness issues.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
271 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
272 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
273 return DM_PROBE_SCORE_FALSE;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
274
494
abb112ac9916 Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents: 468
diff changeset
275 // 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
276 if (len == 9002)
abb112ac9916 Prevent false positive probes of certain Interpaint files as Amica Paint
Matti Hamalainen <ccr@tnsp.org>
parents: 468
diff changeset
277 return DM_PROBE_SCORE_FALSE;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
278
533
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
279 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
280 if (buf[i] == 0xC2) n++;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
281
533
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
282 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
283 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
284 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
285 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
286 if (n > 10)
91e2d0d74e2f Adjust packed Amica paint format probe function to return less false
Matti Hamalainen <ccr@tnsp.org>
parents: 532
diff changeset
287 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
288 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
289 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
292 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
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 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
295 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
296
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
297 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
298 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
299
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
300 res = dmC64DecodeGenericBMP(img, mem, dstEnd - mem + 1, fmt);
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
301
523
d0c0c6baeb57 Split the RLE decoding from DrazPaint/Lace and Amica paint decoders to a
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
302 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
303 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
304 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
305 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
308 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
309 {
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
310 (void) op;
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
311 (void) buf;
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
312 (void) len;
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
313 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
314 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
315 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
316 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
317 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319
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
320 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
321 {
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
322 (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
323 (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
324 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
325 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
326 }
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
327
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
328
943
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
329 static int fmtProbeFormatXX2(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
330 {
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
331 if (len >= 4000 && len <= 4008 &&
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
332 dmCompareAddr16(buf, 0, fmt->addr))
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
333 return DM_PROBE_SCORE_MAYBE;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
334
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
335 return DM_PROBE_SCORE_FALSE;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
336 }
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
337
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
338
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
339 static int fmtDecodeFormatXX2(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
340 {
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
341 int res;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
342 size_t nlen = len < 4000 ? 4000 : len;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
343 Uint8 *mem = dmMalloc(nlen);
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
344 if (mem == NULL)
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
345 return DMERR_MALLOC;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
346
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
347 memcpy(mem, buf, len);
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
348 res = dmC64DecodeGenericBMP(img, mem, nlen, fmt);
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
349
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
350 dmFree(mem);
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
351 return res;
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
352 }
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
353
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
354
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
355
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
356
516
6f141f760c54 Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
357 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
358 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 {
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
360 D64_FMT_MC, "d2p", "DrazPaint 2.0 (packed)", 0x5800, 0,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
361 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
362 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
507
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
363 fmtProbeDrazPaint20Packed, fmtDecodeDrazPaintPacked,
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
364 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
365 4,
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
367 { 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
368 { 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
369 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
370 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, 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
371 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 {
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
375 D64_FMT_MC | D64_FMT_ILACE, "dlp", "DrazLace 1.0 (packed)", 0x5800, 0,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
376 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
377 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
507
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
378 fmtProbeDrazLace10Packed, fmtDecodeDrazPaintPacked,
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
379 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
380 6,
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
382 { 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
383 { 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
384 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
385 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, NULL, NULL },
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
386 { 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
387 { 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
388 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 },
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
390
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 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
392 D64_FMT_MC, "drp", "DrazPaint (unpacked)", 0x5800, 10051,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
393 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
394 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
395 NULL, NULL,
507
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
396 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
397 4,
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
399 { 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
400 { 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
401 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
402 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, 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
403 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
407 D64_FMT_MC | D64_FMT_ILACE, "drl", "DrazLace 1.0 (unpacked)", 0x5800, 18242,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
408 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
409 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
410 NULL, NULL,
507
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
411 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
412 6,
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
414 { 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
415 { 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
416 { DT_SCREEN_RAM, 0x0400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
417 { DT_COLOR_REG, 0x2740, 0, DC_BGCOL, NULL, NULL },
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
418 { 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
419 { 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
420 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 },
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
422
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
424 D64_FMT_MC | D64_FMT_ILACE, "mci", "Truepaint (unpacked)", 0x9c00, 19434,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
425 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
426 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
427 NULL, NULL,
507
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
428 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
429 6,
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
430 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
431 { DT_SCREEN_RAM, 0x0000, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
432 { DT_COLOR_REG, 0x03e8, 0, DC_BGCOL, NULL, NULL },
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
433 { 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
434 { 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
435 { 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
436 { 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
437 { 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
438 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 },
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
440
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
442 D64_FMT_MC, "kla", "Koala Paint (unpacked)", 0x6000, 10003,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
443 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
444 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
445 NULL, NULL,
507
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
446 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
447 4,
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
449 { 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
450 { 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
451 { DT_COLOR_RAM, 0x2328, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
452 { DT_COLOR_REG, 0x2710, 0, DC_BGCOL, 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
453 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454 },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
456 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
457 D64_FMT_MC, "ocp", "Advanced Art Studio (unpacked)", 0x2000, 10018,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
458 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
459 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
524
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
460 NULL, NULL,
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
461 NULL, NULL, NULL,
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
462 4,
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
463 {
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
464 { DT_BITMAP, 0x0000, 0, 0, NULL, NULL },
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
465 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
466 { DT_COLOR_RAM, 0x2338, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
467 { DT_COLOR_REG, 0x2329, 0, DC_BGCOL, NULL, NULL },
524
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
468 }
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
469 },
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
470
524
78edb9710ab7 Add Advanced Art Studio format support.
Matti Hamalainen <ccr@tnsp.org>
parents: 523
diff changeset
471 {
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
472 D64_FMT_MC, "ami", "Amica Paint (packed)", 0x4000, 0,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
473 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
474 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
507
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
475 fmtProbeAmicaPaintPacked, fmtDecodeAmicaPaintPacked,
272e64259fde Add function pointers for encoding and convertTo/convertFrom to the
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
476 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
477 4,
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478 {
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
479 { 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
480 { 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
481 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
482 { DT_COLOR_REG, 0x2710, 0, DC_BGCOL, 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
483 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 },
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
485
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
486 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
487 D64_FMT_MC, "rpm", "Run Paint (unpacked)", 0x6000, 10006,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
488 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
489 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
490 NULL, NULL,
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
491 NULL, NULL, NULL,
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
492 4,
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
493 {
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
494 { 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
495 { 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
496 { DT_SCREEN_RAM, 0x1f40, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
497 { DT_COLOR_REG, 0x2710, 0, DC_BGCOL, NULL, NULL },
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
498 }
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
499 },
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
500
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
501 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
502 D64_FMT_HIRES, "art", "Art Studio (unpacked)", 0x2000, 9009,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
503 C64_SCR_WIDTH , C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
504 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
527
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
505 NULL, NULL,
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
506 NULL, NULL, NULL,
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
507 2,
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
508 {
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
509 { 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
510 { 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
511 }
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
512 },
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
513
49666bb544b9 Add Run Paint MC unpacked format and Art Studio hires format.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
514 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
515 D64_FMT_HIRES, "iph", "Interpaint (unpacked)", 0x4000, 9002,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
516 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
517 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
518 NULL, NULL,
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
519 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
520 2,
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
521 {
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
522 { 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
523 { 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
524 }
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
525 },
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
527 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
528 D64_FMT_HIRES, "dd", "Doodle (unpacked)", 0x1c00, 9218,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
529 C64_SCR_WIDTH , C64_SCR_HEIGHT,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
530 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
531 NULL, NULL,
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
532 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
533 2,
526
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
534 {
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
535 { 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
536 { 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
537 }
f7df57cafdd9 Add support for Interpaint (unpacked) and Doodle (unpacked) hires formats.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
538 },
905
b83868a23ca5 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 904
diff changeset
539
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
540 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
541 D64_FMT_MC | D64_FMT_FLI, "bml", "Blackmail FLI (unpacked)", 0x3b00, 17474,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
542 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
543 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
544 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
545 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
546 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
547 {
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
548 { 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
549
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
550 { 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
551 { 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
552 { 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
553 { 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
554
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
555 { 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
556 { 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
557 { 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
558 { 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
559
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
560 { 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
561 { 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
562 }
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
563 },
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
564
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
565 {
534
fbfdc9e4fe2b Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
566 D64_FMT_MC | D64_FMT_FLI, "fli", "FLI Designer (unpacked)", 0x3c00, 17409,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
567 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
568 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
531
2ac364d0ace9 Add support for converting some FLI formats, such as Blackmail FLI and FLI Designer FLI.
Matti Hamalainen <ccr@tnsp.org>
parents: 530
diff changeset
569 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
570 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
571 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
572 {
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
573 { 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
574 { 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
575 { 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
576 { 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
577 { 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
578 { 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
579 { 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
580 { 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
581 { 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
582 { 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
583 { 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
584 }
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
585 },
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
586
906
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
587 {
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
588 D64_FMT_MC, "xx1", "Unknown $2000 format (unpacked)", 0x2000, 10242,
939
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
589 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
5e820addd035 Fix the multicolor bitmap widths.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
590 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
906
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
591 NULL, NULL,
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
592 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
593 4,
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
594 {
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
595 { 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
596 { 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
597 { DT_COLOR_RAM, 0x2400, 0, 0, NULL, NULL },
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
598 { DT_COLOR_SET, 0x00 , 0, DC_BGCOL, NULL, NULL },
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
599 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
600 },
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
601
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
602 #define XX2_WIDTH_CH 40
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
603 #define XX2_HEIGHT_CH 10
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
604 #define XX2_SIZE (XX2_WIDTH_CH * XX2_HEIGHT_CH)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
605 #define XX2_BSIZE (XX2_SIZE * 8)
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
606
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
607 {
943
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
608 D64_FMT_MC, "xx2", "Unknown $2000 format (unpacked)", 0x2000, 0,
924
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
609 XX2_WIDTH_CH * 4, XX2_HEIGHT_CH * 8,
732787cccca8 Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 923
diff changeset
610 XX2_WIDTH_CH , XX2_HEIGHT_CH,
943
8eacbc38b043 Add kludge to allow more lax handling of the "unknown" $2000 format.
Matti Hamalainen <ccr@tnsp.org>
parents: 940
diff changeset
611 fmtProbeFormatXX2, fmtDecodeFormatXX2,
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
612 NULL, NULL, NULL,
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
613 4,
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
614 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
615 { DT_BITMAP, 0x0000, 0, XX2_BSIZE, NULL, NULL },
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
616 { DT_COLOR_RAM, XX2_BSIZE + XX2_SIZE, 0, XX2_SIZE, NULL, NULL },
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
617 { DT_SCREEN_RAM, XX2_BSIZE, 0, XX2_SIZE, NULL, NULL },
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
618
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
619 { DT_COLOR_SET, 11 , 0, DC_BGCOL, NULL, NULL },
906
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
620 }
e591ce9b3526 Added support to gfxconv/view64 for unknown(?) bitmap format found on some
Matti Hamalainen <ccr@tnsp.org>
parents: 905
diff changeset
621 },
407
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 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
625
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
626
518
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
627 // Perform probing of the given data buffer, trying to determine
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
628 // if it contains a supported "C64" image format. Returns the
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
629 // "probe score", see libgfx.h for list of values. If a match
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
630 // 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
631 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
632 {
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
633 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
634
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
635 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
636 {
516
6f141f760c54 Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
637 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
638 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
639 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
640 {
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
641 // 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
642 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
643 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
644 }
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
645 else
1134
d0898867ec4c Various fixes for issues reported by clang static analyzer.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
646 if (fmt->probe != NULL)
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
647 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
648
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
649 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
650 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
651 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
652 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
653 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
654 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
655
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
656 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
657 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
658 *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
659 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
660 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
661 else
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
662 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
663 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
664
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
665
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
666 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
667 {
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
668 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
669 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
670 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
671 "Invalid bank %d definition in generic encode/decode operator %d @ #%d.\n",
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
672 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
673 }
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
674
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
675 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
676 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
677 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
678 "Invalid encode/decode operator type %d @ #%d.\n",
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
679 op->type, i);
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
680 }
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
681
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
682 return DMERR_OK;
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
683 }
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
684
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
685
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
686 static BOOL dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size)
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
687 {
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
688 BOOL check;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
689 switch (op->type)
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
690 {
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
691 case DT_SCREEN_RAM:
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
692 case DT_COLOR_RAM:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
693 *size = fmt->ch_height * fmt->ch_width;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
694 check = TRUE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
695 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
696
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
697 case DT_BITMAP:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
698 *size = fmt->ch_height * fmt->ch_width * 8;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
699 check = TRUE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
700 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
701
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
702 case DT_EXTRADATA:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
703 *size = C64_SCR_EXTRADATA;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
704 check = TRUE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
705 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
706
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
707 case DT_CHAR_DATA:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
708 *size = C64_MAX_CHARS * C64_CHR_SIZE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
709 check = TRUE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
710 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
711
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
712 case DT_COLOR_REG:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
713 *size = 1;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
714 check = FALSE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
715 break;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
716
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
717 default:
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
718 *size = 0;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
719 check = FALSE;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
720 }
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
721
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
722 if (op->size != 0)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
723 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
724 if (check && op->size > *size)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
725 return FALSE;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
726
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
727 *size = op->size;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
728 }
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
729
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
730 return TRUE;
927
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
731 }
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
732
db495f421242 Change dmC64DefaultSizes[] array into a function instead.
Matti Hamalainen <ccr@tnsp.org>
parents: 925
diff changeset
733
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
734 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
735 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
736 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
737 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
738
513
486067f39bc1 Add sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
739 if (buf == NULL || img == NULL || fmt == NULL)
486067f39bc1 Add sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
740 return DMERR_NULLPTR;
486067f39bc1 Add sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
741
921
2454ddb7363f Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents: 920
diff changeset
742 if (fmt->nencdecOps < 0 || fmt->nencdecOps >= D64_MAX_ENCDEC_OPS)
2454ddb7363f Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents: 920
diff changeset
743 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
744 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
745 "Invalid number of enc/dec ops in format. Internal error.\n");
921
2454ddb7363f Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents: 920
diff changeset
746 }
2454ddb7363f Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents: 920
diff changeset
747
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
748 // Clear the image structure, set basics
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
749 img->type = fmt->type;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
750 img->width = fmt->width;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
751 img->height = fmt->height;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
752 img->ch_width = fmt->ch_width;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
753 img->ch_height = fmt->ch_height;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
754
518
63849f85db57 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
755 // Perform decoding
515
a896c1153e4e s/decenc/encdec/g
Matti Hamalainen <ccr@tnsp.org>
parents: 514
diff changeset
756 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
757 {
515
a896c1153e4e s/decenc/encdec/g
Matti Hamalainen <ccr@tnsp.org>
parents: 514
diff changeset
758 const DMC64EncDecOp *op = &fmt->encdecOps[i];
410
e4b2f689aff6 Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
759 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
760 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
761 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
762
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
763 // 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
764 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
765 return res;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
766
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
767 // Check size
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
768 if (!dmC64GetOpSize(op, fmt, &size))
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
769 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
770 return dmError(DMERR_INVALID_DATA,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
771 "Decode op SIZE out of bounds, op #%d type=%d, offs=%d ($%04x), "
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
772 "bank=%d, size=%d ($%04x) vs. allocated %d ($%04x)\n",
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
773 i, op->type, op->offs, op->offs, op->bank, size, size, op->size, op->size);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
774 }
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
775
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
776 // 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
777 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
778 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
779 return dmError(DMERR_INVALID_DATA,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
780 "Decode out of bounds, op #%d type=%d, offs=%d ($%04x), "
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
781 "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
782 i, op->type, op->offs, op->offs, op->bank, size, size, len, len);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
783 }
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
784
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
785 src = buf + op->offs;
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
786
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
787 // 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
788 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
789 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
790 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
791 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
792 case DT_SCREEN_RAM: memcpy(img->screen[op->bank], src, size); break;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
793 case DT_CHAR_DATA: memcpy(img->charmem[op->bank], src, size); 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
794 case DT_EXTRADATA: memcpy(img->extradata, src, size); break;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
795
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
796 case DT_COLOR_REG:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
797 switch (op->size)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
798 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
799 case DC_D020: img->d020 = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
800 case DC_BGCOL:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
801 case DC_D021: img->bgcolor = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
802 case DC_D022: img->d022 = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
803 case DC_D023: img->d023 = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
804 case DC_D024: img->d024 = *src; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
805 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
806 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
807 "Unhandled DT_COLOR_REG mode %d in ",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
808 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
809 op->size, i, op->offs, op->offs, op->bank, size, size, len, len);
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
810 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
811 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
812
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
813 case DT_COLOR_SET:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
814 switch (op->size)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
815 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
816 case DC_D020: img->d020 = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
817 case DC_BGCOL:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
818 case DC_D021: img->bgcolor = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
819 case DC_D022: img->d022 = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
820 case DC_D023: img->d023 = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
821 case DC_D024: img->d024 = op->offs; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
822 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
823 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
824 "Unhandled DT_COLOR_SET mode %d in ",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
825 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
826 op->size, i, op->offs, op->offs, op->bank, size, size, len, len);
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
827 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
828 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
829
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
830 case DT_CHAR_CONFIG:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
831 switch (op->offs)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
832 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
833 case D64_CHCFG_SCREEN:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
834 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
835
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
836 case D64_CHCFG_LINEAR:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
837 {
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
838 int bank, offs;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
839 for (bank = 0; bank < C64_SCR_MAX_BANK; bank++)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
840 for (offs = 0; offs < fmt->ch_height * fmt->ch_width; offs++)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
841 img->screen[bank][offs] = offs & 0xff;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
842 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
843 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
844
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
845 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
846 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
847 "Unhandled DT_CHAR_CONFIG mode %d in ",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
848 "op #%d, bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
849 op->offs, i, op->bank, size, size, len, len);
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
850 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
851 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
852
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
853 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
854 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
855 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
856 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
857 "Decode op is a function, but function ptr is NULL: "
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
858 "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
859 i, op->offs, op->offs, op->bank, size, size, len, len);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
860 }
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
861 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
862 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
863 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
864 "Decode op custom function failed: op #%d, "
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
865 "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
866 i, op->offs, op->offs, op->bank, size, size, len, len);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
867 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
868 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
869 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
870 }
916
3985f596ece5 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 915
diff changeset
871
508
1ed5025c2538 Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents: 507
diff changeset
872 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
873 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
874
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
875
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
876 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
877 {
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
878 int i, res = DMERR_OK;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
879 Uint8 *buf;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
880 size_t allocated;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
881
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
882 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
883 return DMERR_NULLPTR;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
884
921
2454ddb7363f Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents: 920
diff changeset
885 if (fmt->nencdecOps < 0 || fmt->nencdecOps >= D64_MAX_ENCDEC_OPS)
2454ddb7363f Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents: 920
diff changeset
886 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
887 return dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
888 "Invalid number of enc/dec ops in format. Internal error.\n");
921
2454ddb7363f Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents: 920
diff changeset
889 }
2454ddb7363f Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents: 920
diff changeset
890
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
891 // Allocate the output buffer
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
892 *plen = 0;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
893 if (fmt->size > 0)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
894 *plen = allocated = fmt->size;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
895 else
935
77c07853797b Allocate somewhat larger initial encoding buffer for C64 image encoders.
Matti Hamalainen <ccr@tnsp.org>
parents: 934
diff changeset
896 allocated = 16 * 1024;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
897
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
898 if ((buf = dmMalloc(allocated)) == NULL)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
899 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
900 return dmError(DMERR_MALLOC,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
901 "Could not allocate %d bytes of memory for C64 image encoding buffer.\n",
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
902 allocated);
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
903 goto error;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
904 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
905
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
906 // Perform encoding
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
907 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
908 {
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
909 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
910 Uint8 *dst = 2 + buf + op->offs;
1364
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
911 size_t size, chksize;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
912
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
913 // Check operation validity
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
914 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
915 goto error;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
916
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
917 // Check size
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
918 if (!dmC64GetOpSize(op, fmt, &size))
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
919 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
920 res = dmError(DMERR_INVALID_DATA,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
921 "Decode op SIZE out of bounds, op #%d type=%d, offs=%d ($%04x), "
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
922 "bank=%d, size=%d ($%04x) vs. allocated %d ($%04x)\n",
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
923 i, op->type, op->offs, op->offs, op->bank, size, size, op->size, op->size);
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
924 goto error;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
925 }
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
926
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
927 // Do we need to reallocate some more space?
1364
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
928 chksize = op->offs + size + 2;
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
929 if (chksize > allocated)
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
930 {
1364
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
931 size_t diff = allocated - chksize,
833
4f3828914890 Fix a 100L :S
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
932 grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW;
934
fa15335238cf Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 932
diff changeset
933
833
4f3828914890 Fix a 100L :S
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
934 allocated += grow;
4f3828914890 Fix a 100L :S
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
935
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
936 if ((buf = dmRealloc(buf, allocated)) == NULL)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
937 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
938 res = dmError(DMERR_MALLOC,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
939 "Could not re-allocate %d bytes of memory for C64 image encoding buffer.\n",
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
940 allocated);
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
941 goto error;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
942 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
943 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
944
1364
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
945 if (fmt->size == 0 && chksize > *plen)
0d61895e1763 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1362
diff changeset
946 *plen = chksize;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
947
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
948 // Perform operation
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
949 switch (op->type)
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
950 {
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
951 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
952 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
953 case DT_SCREEN_RAM: memcpy(dst, img->screen[op->bank], size); break;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
954 case DT_CHAR_DATA: memcpy(dst, img->charmem[op->bank], size); break;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
955 case DT_EXTRADATA: memcpy(dst, img->extradata, size); break;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
956
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
957 case DT_COLOR_REG:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
958 switch (op->size)
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
959 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
960 case DC_D020: *dst = img->d020; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
961 case DC_BGCOL:
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
962 case DC_D021: *dst = img->bgcolor; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
963 case DC_D022: *dst = img->d022; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
964 case DC_D023: *dst = img->d023; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
965 case DC_D024: *dst = img->d024; break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
966 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
967 res = dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
968 "Unhandled DT_COLOR_REG mode %d in ",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
969 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
970 op->size, i, op->offs, op->offs, op->bank, size, size, *plen, *plen);
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
971 goto error;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
972 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
973 break;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
974
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
975 case DT_ENC_FUNCTION:
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
976 if (op->encfunction == NULL)
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
977 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
978 res = dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
979 "Encode op is a function, but function ptr is NULL: "
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
980 "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
981 i, op->offs, op->offs, op->bank, size, size, *plen, *plen);
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
982 goto error;
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
983 }
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
984 /*
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
985 if (!op->encfunction(op, buf, len))
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
986 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
987 res = dmError(DMERR_INTERNAL,
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
988 "Encode op custom function failed: op #%d, "
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
989 "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
990 i, op->offs, op->offs, op->bank, size, size, len, len);
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
991 goto out;
904
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
992 }
d3cd9f2a8ef1 Some dummy code for encfunctions.
Matti Hamalainen <ccr@tnsp.org>
parents: 903
diff changeset
993 */
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
994 break;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
995 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
996 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
997
535
ab8d9696225c Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 534
diff changeset
998 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
999 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
1000
ab8d9696225c Add helper macros and use them to set the loading address while encoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 534
diff changeset
1001 *pbuf = buf;
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1002 return DMERR_OK;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1003
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1004 error:
538
45c46bfa03bd Free the correct buffer pointer in error situations in the encoder function.
Matti Hamalainen <ccr@tnsp.org>
parents: 534
diff changeset
1005 dmFree(buf);
532
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1006 *pbuf = NULL;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1007 *plen = 0;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1008 return res;
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1009 }
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1010
128a50feff07 Implement initial generic bitmap "encoding" function, that constructs
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
1011
923
0f477446448d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 921
diff changeset
1012 static inline Uint8 dmC64GetMCColor(const DMC64Image *img,
0f477446448d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 921
diff changeset
1013 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
1014 {
0961b6983b8e Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
1015 switch (bits)
0961b6983b8e Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
1016 {
0961b6983b8e Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
1017 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
1018 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
1019 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
1020 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
1021 }
0961b6983b8e Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
1022 }
0961b6983b8e Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
1023
0961b6983b8e Simplify multicolor/interlaced multicolor decoding by factoring some to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
1024
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1025 // 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
1026 // a indexed/paletted bitmap image.
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1027 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *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
1028 {
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1029 Uint8 *dp = dst->data;
810
cbe263ad963c Some work on charset conversion.
Matti Hamalainen <ccr@tnsp.org>
parents: 803
diff changeset
1030 int yc;
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1031
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1032 // Sanity check arguments
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1033 if (dst == NULL || src == NULL)
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1034 return DMERR_NULLPTR;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1035
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1036 if (dst->width < src->width || dst->height < src->height)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1037 return DMERR_INVALID_DATA;
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1038
1167
848a88ce7a57 Use dmMemset().
Matti Hamalainen <ccr@tnsp.org>
parents: 1134
diff changeset
1039 dmMemset(dst->data, 0, dst->size);
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1040
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1041 // Resolution interlaced pics need to halve the source width
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1042 int rwidth = src->width;
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1043 if ((src->type & D64_FMT_ILACE) && src->laceType == D64_ILACE_RES)
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1044 rwidth /= 2;
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1045
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1046 // Perform conversion
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1047 for (yc = 0; yc < src->height; yc++)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1048 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1049 Uint8 *d = dp;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1050 const int y = yc / 8, yb = yc & 7;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1051 const int scroffsy = y * src->ch_width;
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1052 int xc;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1053
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1054 if (src->type & D64_FMT_CHAR)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1055 {
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1056 // Charmode conversion
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1057 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1058 // Hi-res charmap
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1059 for (xc = 0; xc < rwidth; xc++)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1060 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1061 const int x = xc / 8;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1062 const int scroffs = scroffsy + x;
918
59615f9c2ca9 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 917
diff changeset
1063 const int chr = src->screen[0][scroffs];
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1064 const int v = 7 - (xc & 7);
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1065
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1066 if ((src->charmem[0][chr * C64_CHR_SIZE + yb] >> v) & 1)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1067 *d++ = src->color[0][scroffs];
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1068 else
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1069 *d++ = src->bgcolor;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1070 }
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1071 else
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1072 // Multicolor variants
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1073 for (xc = 0; xc < rwidth; xc++)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1074 {
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1075 const int x = xc / 4;
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1076 const int scroffs = scroffsy + x;
918
59615f9c2ca9 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 917
diff changeset
1077 const int chr = src->screen[0][scroffs];
944
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1078 const int col = src->color[0][scroffs] & 15;
925
23b14d62bf67 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 924
diff changeset
1079
944
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1080 if (col & 8)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1081 {
944
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1082 const int v = 6 - ((xc * 2) & 6);
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1083 switch ((src->charmem[0][chr * C64_CHR_SIZE + yb] >> v) & 3)
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1084 {
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1085 case 0: *d++ = src->bgcolor; break;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1086 case 1: *d++ = src->d022; break;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1087 case 2: *d++ = src->d023; break;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1088 case 3: *d++ = col;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1089 }
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1090 }
944
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1091 else
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1092 {
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1093 const int v = 7 - (xc & 7);
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1094 if ((src->charmem[0][chr * C64_CHR_SIZE + yb] >> v) & 1)
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1095 *d++ = src->color[0][scroffs];
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1096 else
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1097 *d++ = src->bgcolor;
c62bb4028cf0 Implement multicolor / standard switching support based on color ram value's
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
1098 }
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1099 }
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
1100 }
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1101 else
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1102 {
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1103 // Perform generic BITMAP conversion
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1104 const int bmoffsy = y * src->ch_width * 8 + yb;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1105
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1106 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
811
aebc2f8b2c2d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 810
diff changeset
1107 // Hi-res bitmap
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1108 for (xc = 0; xc < rwidth; xc++)
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1109 {
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1110 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
1111 const int scroffs = scroffsy + x;
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1112 const int bmoffs = bmoffsy + (x * 8);
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1113 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
1114
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1115 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
1116 *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
1117 else
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1118 *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
1119 }
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1120 else
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1121 // Multicolor bitmap and variants
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1122 for (xc = 0; xc < rwidth; xc++)
529
1bce06b5026f Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
1123 {
901
f532262f90b1 Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents: 857
diff changeset
1124 const int x = xc / 4;
f532262f90b1 Actually fix commit 16aa5955dfb5.
Matti Hamalainen <ccr@tnsp.org>
parents: 857
diff changeset
1125 const int scroffs = scroffsy + x;
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1126 const int bmoffs = bmoffsy + (x * 8);
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1127 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
1128 Uint8 c;
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1129
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1130 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
1131 {
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
1132 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
1133 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
1134 {
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1135 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
1136 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
1137 break;
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1138 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
1139 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
1140 break;
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1141 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
1142 vbank = yb;
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1143 break;
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1144 }
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
1145 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
1146 *d++ = c;
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1147 }
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1148 else
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1149 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
1150 {
1362
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1151 switch (src->laceType)
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1152 {
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1153 case D64_ILACE_RES:
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1154 *d++ = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, src->laceBank1, scroffs);
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1155 *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs);
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1156 break;
7bc67ba68904 Better handling of resolution interlaced pictures.
Matti Hamalainen <ccr@tnsp.org>
parents: 1361
diff changeset
1157 }
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1158 }
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1159 else
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1160 {
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
1161 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
1162 *d++ = c;
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1163 }
529
1bce06b5026f Combine conversion of interlaced and normal multicolor images to one function.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
1164 }
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1165 }
530
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
1166 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
1167 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1168
508
1ed5025c2538 Return DMLIB error values instead of arbitrary 0/negatives.
Matti Hamalainen <ccr@tnsp.org>
parents: 507
diff changeset
1169 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
1170 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1171
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1172
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1173 int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt)
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1174 {
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1175 int res;
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1176 DMImage *dst;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1177
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1178 if (pdst == NULL || src == NULL)
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1179 return DMERR_NULLPTR;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1180
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1181 // Allocate image structure
1289
Matti Hamalainen <ccr@tnsp.org>
parents: 1235
diff changeset
1182 if ((*pdst = dst = dmImageAlloc(src->width, src->height, DM_IFMT_PALETTE, -1)) == NULL)
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1183 return DMERR_MALLOC;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1184
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1185 // Set palette
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1186 dst->pal = (DMColor *) &dmC64Palette;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1187 dst->ncolors = C64_NCOLORS;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1188 dst->constpal = TRUE;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1189
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1190 // Convert
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1191 if (fmt->convertFrom != NULL)
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1192 res = fmt->convertFrom(dst, src);
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1193 else
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
1194 res = dmC64ConvertGenericBMP2Image(dst, src);
556
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1195
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1196 return res;
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1197 }
44d1e0d4acf3 Improve DMC64Image -> DMImage conversion facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 548
diff changeset
1198
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1199
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1200 int dmC64DecodeBMP(DMC64Image **img, const Uint8 *buf, const size_t len,
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1201 const size_t probeOffs, const size_t loadOffs,
516
6f141f760c54 Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
1202 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
1203 {
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1204 if (img == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1205 return DMERR_NULLPTR;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1206
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1207 // Check for forced format
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1208 if (forced != NULL)
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1209 *fmt = forced;
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1210 else
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1211 {
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1212 // Nope, perform a generic probe
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1213 if (probeOffs >= len)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1214 return DMERR_INVALID_DATA;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1215
537
32d9e67da189 Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 536
diff changeset
1216 if (dmC64ProbeBMP(buf + probeOffs, len - probeOffs, fmt) == DM_PROBE_SCORE_FALSE)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1217 return DMERR_INVALID_DATA;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1218 }
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1219
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1220 if (loadOffs >= len)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1221 return DMERR_INVALID_ARGS;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1222
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1223 if (*fmt == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1224 return DMERR_INVALID_DATA;
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1225
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1226 // Allocate memory
1361
00f47a678482 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1308
diff changeset
1227 if ((*img = dmC64ImageAlloc(
00f47a678482 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1308
diff changeset
1228 (*fmt)->width, (*fmt)->height,
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1229 (*fmt)->ch_width, (*fmt)->ch_height)) == NULL)
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1230 return DMERR_MALLOC;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1231
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1232 // 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
1233 if ((*fmt)->decode != NULL)
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1234 return (*fmt)->decode(*img, buf + loadOffs, len - loadOffs, *fmt);
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1235 else
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
1236 return dmC64DecodeGenericBMP(*img, buf + loadOffs, len - loadOffs, *fmt);
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
1237 }