annotate lib64gfx.c @ 811:aebc2f8b2c2d

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