Mercurial > hg > dmlib
annotate tools/lib64gfx.h @ 2316:ffdc51f0c9cd
Comment adjustments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 27 Aug 2019 12:18:39 +0300 |
parents | 87533af8db64 |
children | b2d8b054b2f7 |
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 /* |
418 | 2 * Functions for reading and converting various restricted |
3 * C64/etc and/or indexed/paletted graphics formats. | |
407
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 |
2120 | 5 * (C) Copyright 2012-2019 Tecnic Software productions (TNSP) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 * Please read file 'COPYING' for information on license and distribution. |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 */ |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #ifndef LIB64GFX_H |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 #define LIB64GFX_H 1 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 |
435 | 12 #include "libgfx.h" |
1465
88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1457
diff
changeset
|
13 #include "dmgrowbuf.h" |
435 | 14 |
15 #ifdef __cplusplus | |
16 extern "C" { | |
17 #endif | |
18 | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
20 // Max defines |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
21 #define D64_MAX_EXTRA_DATA 16 |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
22 #define D64_MAX_EXTRA_INFO 64 |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
23 |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
24 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 // Bitmap constants |
2125
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
26 #define D64_SCR_WIDTH 320 |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
27 #define D64_SCR_HEIGHT 200 |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
28 #define D64_SCR_CH_WIDTH (D64_SCR_WIDTH/8) |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
29 #define D64_SCR_CH_HEIGHT (D64_SCR_HEIGHT/8) |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
30 |
2266
ecc17b2e129e
Add constants for "full" C64 screen dimensions, including the border
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
31 #define D64_SCR_FULL_WIDTH 384 |
ecc17b2e129e
Add constants for "full" C64 screen dimensions, including the border
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
32 #define D64_SCR_FULL_HEIGHT 272 |
ecc17b2e129e
Add constants for "full" C64 screen dimensions, including the border
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
33 #define D64_SCR_VIS_XOFFS 24 |
ecc17b2e129e
Add constants for "full" C64 screen dimensions, including the border
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
34 #define D64_SCR_VIS_YOFFS 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
|
35 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 // C64 video screen pixel aspect ratio on PAL |
2125
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
37 #define D64_SCR_PAR_XY (0.9365f) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 // Sprite constants |
2125
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
40 #define D64_SPR_WIDTH_PX 24 |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
41 #define D64_SPR_HEIGHT_PX 21 |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
42 #define D64_SPR_WIDTH_UT (D64_SPR_WIDTH_PX / 8) // bytes |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
43 #define D64_SPR_HEIGHT_UT D64_SPR_HEIGHT_PX |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
44 #define D64_SPR_SIZE ((D64_SPR_WIDTH_UT * D64_SPR_HEIGHT_UT) + 1) |
2309 | 45 #define D64_MAX_SPRITES 8 // Max sprites per scanline (in simple cases) |
46 | |
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 // Character constants |
2125
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
49 #define D64_CHR_WIDTH_PX 8 |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
50 #define D64_CHR_HEIGHT_PX 8 |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
51 #define D64_CHR_WIDTH_UT 1 // bytes |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
52 #define D64_CHR_HEIGHT_UT 8 // lines |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
53 #define D64_CHR_SIZE (D64_CHR_WIDTH_UT * D64_CHR_HEIGHT_UT) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 // Etc. |
2125
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
56 #define D64_NCOLORS 16 |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
57 #define D64_VIDBANK_SIZE (16*1024) |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
58 #define D64_MAX_CHARS 256 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
922 | 60 |
1637 | 61 // Different supported flags/modes |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 enum |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 { |
2118
05a6e00b09d0
Change D64_FMT_* MASK constants and how they are used.
Matti Hamalainen <ccr@tnsp.org>
parents:
2116
diff
changeset
|
64 D64_FMT_HIRES = 0x0001, // Hi-res |
05a6e00b09d0
Change D64_FMT_* MASK constants and how they are used.
Matti Hamalainen <ccr@tnsp.org>
parents:
2116
diff
changeset
|
65 D64_FMT_MC = 0x0002, // MultiColor |
05a6e00b09d0
Change D64_FMT_* MASK constants and how they are used.
Matti Hamalainen <ccr@tnsp.org>
parents:
2116
diff
changeset
|
66 D64_FMT_ECM = 0x0003, // ECM mode (applies only to character mode) |
2180
33cf1b330b7b
s/D64_FMT_MASK/D64_FMT_MODE_MASK/g
Matti Hamalainen <ccr@tnsp.org>
parents:
2179
diff
changeset
|
67 D64_FMT_MODE_MASK = 0x000f, |
2116
b49d7cb20a73
Implement initial ECM support in charmap decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2114
diff
changeset
|
68 |
b49d7cb20a73
Implement initial ECM support in charmap decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2114
diff
changeset
|
69 D64_FMT_ILACE = 0x0010, // Interlace |
b49d7cb20a73
Implement initial ECM support in charmap decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2114
diff
changeset
|
70 D64_FMT_FLI = 0x0020, // FLI |
b49d7cb20a73
Implement initial ECM support in charmap decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2114
diff
changeset
|
71 D64_FMT_CHAR = 0x0040, // Character mode |
b49d7cb20a73
Implement initial ECM support in charmap decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2114
diff
changeset
|
72 D64_FMT_BORDER = 0x0080, // Uses border area |
2314
87533af8db64
Add format flag for formats that use sprite layer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2309
diff
changeset
|
73 D64_FMT_SPRITES = 0x0100, // Uses sprite layer |
407
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 |
1637 | 76 |
77 // Different types of interlace | |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
78 enum |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
79 { |
1647
948d6fda722d
Add sanity check for interlaced formats: check that the interlace type flags are set.
Matti Hamalainen <ccr@tnsp.org>
parents:
1645
diff
changeset
|
80 D64_ILACE_NONE = 0x0000, // Not set (invalid for interlaced images) |
1637 | 81 D64_ILACE_RES = 0x0001, // Interlace doubles resolution |
82 D64_ILACE_COLOR = 0x0002, // Uses color mixing | |
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 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 |
936
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
85 |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
86 // Different types of interlace |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
87 enum |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
88 { |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
89 D64_FLI_8 = 8, |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
90 }; |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
91 |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
92 |
936
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
93 // Charmode screen memory configuration |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
94 enum |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
95 { |
936
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
96 D64_CHCFG_SCREEN, // Use screen memory |
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
97 D64_CHCFG_LINEAR = 1, // Generate linear pattern so that first line |
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
98 // of chars is 0-39, second 40-79, up to 255. |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
99 }; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
100 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
101 |
2139
84780a9d8d17
Improve and fix charmap format decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2132
diff
changeset
|
102 // Various extra settings (see DMC64Image::extraInfo[]) |
84780a9d8d17
Improve and fix charmap format decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2132
diff
changeset
|
103 enum |
84780a9d8d17
Improve and fix charmap format decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2132
diff
changeset
|
104 { |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2239
diff
changeset
|
105 D64_EI_MODE = 0, // Actual mode, if the format supports several |
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2239
diff
changeset
|
106 |
2309 | 107 D64_EI_CHAR_CASE, // [CHAR] 0 = upper case, != lower case |
108 D64_EI_CHAR_CUSTOM, // [CHAR] 0 = ROM charset, != custom charset | |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
109 |
2309 | 110 D64_EI_FLI_TYPE, // FLI type (see D64_FLI_*) |
111 D64_EI_ILACE_TYPE, // Interlace type (see D64_ILACE_*) | |
2139
84780a9d8d17
Improve and fix charmap format decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2132
diff
changeset
|
112 }; |
84780a9d8d17
Improve and fix charmap format decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2132
diff
changeset
|
113 |
84780a9d8d17
Improve and fix charmap format decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2132
diff
changeset
|
114 |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
115 // Image <-> bitmap conversion dithering |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
116 enum |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
117 { |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
118 D64_DITH_NONE = 0, // No dithering |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
119 }; |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
120 |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
121 |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
122 // Different enc/dec operation types (op->type) |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
123 enum |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 { |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
125 DO_COPY, // Perform copy between memory (from/to offset) and subject |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
126 DO_SET_MEM, // Set subject value or fill subject memory area to byte value from offset |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
127 DO_SET_OP, // Like above but value from op->offs field instead |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
128 |
1726
f9128665a47e
Implement operator types DO_SET_MEM_HI and DO_SET_MEM_LO. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1722
diff
changeset
|
129 DO_SET_MEM_HI, // Copy one byte value like DO_SET_MEM, but high nibble only |
f9128665a47e
Implement operator types DO_SET_MEM_HI and DO_SET_MEM_LO. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1722
diff
changeset
|
130 DO_SET_MEM_LO, // Like above, but low nibble |
f9128665a47e
Implement operator types DO_SET_MEM_HI and DO_SET_MEM_LO. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1722
diff
changeset
|
131 |
1922
3c6f638ce402
Remove the useless distinction of DO_ENC_FUNC and DO_DEC_FUNC, as the
Matti Hamalainen <ccr@tnsp.org>
parents:
1916
diff
changeset
|
132 DO_FUNC, // Execute specified decoding / encoding function |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
133 |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
134 DO_CHAR_CFG, // Set character mode configuration |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
135 |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
136 DO_LAST, // Last opcode, end processing |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
137 }; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 |
512
95a6b6af53f1
Add some structures and enums for future.
Matti Hamalainen <ccr@tnsp.org>
parents:
511
diff
changeset
|
139 |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
140 // "Subjects" of operations (op->subject) |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
141 enum |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
142 { |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
143 DS_COLOR_RAM, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
144 DS_BITMAP_RAM, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
145 DS_SCREEN_RAM, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
146 DS_EXTRA_DATA, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
147 DS_CHAR_DATA, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
148 |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
149 DS_D020, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
150 DS_BGCOL, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
151 DS_D021, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
152 DS_D022, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
153 DS_D023, |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
154 DS_D024, |
1852
219417325036
Split dmC64GetOpMemBlockAndName() into dmC64GetOpMemBlock() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1846
diff
changeset
|
155 |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
156 DS_EXTRA_INFO, |
2224
a36c81c3df85
Make color interlace type generate a mixed palette instead of using special
Matti Hamalainen <ccr@tnsp.org>
parents:
2223
diff
changeset
|
157 |
1852
219417325036
Split dmC64GetOpMemBlockAndName() into dmC64GetOpMemBlock() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1846
diff
changeset
|
158 DS_LAST |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
159 }; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
160 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 |
2196
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
162 // Operation flags (op->flags) |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
163 enum |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
164 { |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
165 DF_NORMAL = 0xffff, |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
166 DF_DECODE = 0x0001, |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
167 DF_ENCODE = 0x0002, |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
168 }; |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
169 |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
170 |
1588
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
171 typedef struct |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
172 { |
2201
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
173 char *name; |
2203
b259312ddb59
Add description field to DMC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
2201
diff
changeset
|
174 char *desc; |
2201
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
175 DMColor colors[D64_NCOLORS]; |
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
176 } DMC64Palette; |
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
177 |
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
178 |
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
179 typedef struct |
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
180 { |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
181 int dither; // Dither mode (D64_DITH_*) |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
182 BOOL aspect; // Correct pixel aspect ratio? |
2201
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
183 |
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
184 DMPalette *pal; // Use this palette |
9f3fb4004c20
Improvements to the lib64gfx palette handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2200
diff
changeset
|
185 DMC64Palette *cpal; // If ^pal == NULL, use this C64 palette |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
186 } DMC64ImageConvSpec; |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
187 |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
188 |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
189 typedef struct |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
190 { |
1588
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
191 Uint8 *data; |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
192 size_t size; |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
193 } DMC64MemBlock; |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
194 |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
195 |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
196 typedef struct |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
197 { |
2309 | 198 int xc, yc; // Sprite coordinates (XXX TODO: borders etc.) |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
199 BOOL multicolor, xexpand, yexpand; |
2309 | 200 int color; // Color |
201 int sprnum; // Physical sprite number for priority checking | |
202 Uint8 *data; // "const" pointer to sprite data, do not deallocate | |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
203 } DMC64Sprite; |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
204 |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
205 |
1934 | 206 typedef struct _DMC64ImageCommonFormat DMC64ImageCommonFormat; |
207 typedef struct _DMC64ImageFormat DMC64ImageFormat; | |
208 | |
209 | |
1374
9edb17aa4a0a
Forward declare typedef struct _DMC64Image;
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
210 typedef struct _DMC64Image |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
211 { |
1947
8896d5676f1b
Architectural change: remove some duplicated variables from DMC64Image
Matti Hamalainen <ccr@tnsp.org>
parents:
1935
diff
changeset
|
212 DMC64ImageCommonFormat *fmt; |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
213 int nblocks; // Number of internal blocks used |
1482
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
214 |
2179
8d53da5bf067
Rename DMC64Image::nbanks to nblocks, which reflects better what it does.
Matti Hamalainen <ccr@tnsp.org>
parents:
2176
diff
changeset
|
215 // Bitmaps, color RAM, screen, etc. blocks * nblocks |
1588
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
216 // Not all of them may be allocated |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
217 DMC64MemBlock |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
218 *color, |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
219 *bitmap, |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
220 *screen, |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
221 *charData; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
222 |
1588
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
223 // Other standard colours |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
224 Uint8 d020, bgcolor, d022, d023, d024; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
225 |
1588
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
226 // Extra data areas used by some formats, |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
227 // for example raster colours might be stored |
2125
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2121
diff
changeset
|
228 DMC64MemBlock extraData[D64_MAX_EXTRA_DATA]; |
1376
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
229 |
2316 | 230 // Extra information / settings |
2139
84780a9d8d17
Improve and fix charmap format decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2132
diff
changeset
|
231 // See D64_EI_* constants. |
2239
adb0480f6ebd
Change DMC64Image::extraInfo[] type from Uint8 to int.
Matti Hamalainen <ccr@tnsp.org>
parents:
2238
diff
changeset
|
232 int extraInfo[D64_MAX_EXTRA_INFO]; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
233 } DMC64Image; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
234 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
236 typedef struct _DMC64EncDecOp |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
237 { |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
238 int type; // Operation type (DO_*) |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
239 int subject; // Operation "subject" (DS_*) |
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
240 |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
241 int offs; // Offset in "memory" |
1846
88cef7758303
Implement data block offset in certain DMC64EncDecOps. This allows us to
Matti Hamalainen <ccr@tnsp.org>
parents:
1826
diff
changeset
|
242 int bank; // Bank number or extradata index |
88cef7758303
Implement data block offset in certain DMC64EncDecOps. This allows us to
Matti Hamalainen <ccr@tnsp.org>
parents:
1826
diff
changeset
|
243 size_t size; // Size of data (0 for "default") |
88cef7758303
Implement data block offset in certain DMC64EncDecOps. This allows us to
Matti Hamalainen <ccr@tnsp.org>
parents:
1826
diff
changeset
|
244 size_t offs2; // Offset in data-block |
1668
1741717b1ae5
Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
245 |
2114
27cf33c3a646
Return actual error code from enc and dec functions instead of just BOOL.
Matti Hamalainen <ccr@tnsp.org>
parents:
2113
diff
changeset
|
246 int (*decFunction)(const struct _DMC64EncDecOp *op, DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt); |
27cf33c3a646
Return actual error code from enc and dec functions instead of just BOOL.
Matti Hamalainen <ccr@tnsp.org>
parents:
2113
diff
changeset
|
247 int (*encFunction)(const struct _DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageCommonFormat *fmt); |
2196
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
248 |
28871f500e84
Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to
Matti Hamalainen <ccr@tnsp.org>
parents:
2180
diff
changeset
|
249 int flags; // Operation flags (DF_*) |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
250 } DMC64EncDecOp; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
251 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
252 |
2176
8e6713705786
Reduce number of max enc/dec ops from 64 to 32, this reduces produced binary sizes by 100kB :P
Matti Hamalainen <ccr@tnsp.org>
parents:
2175
diff
changeset
|
253 #define D64_MAX_ENCDEC_OPS 32 |
1592
91d1bb571fca
Implement common encdec ops lists for sharing oplists between formats that
Matti Hamalainen <ccr@tnsp.org>
parents:
1591
diff
changeset
|
254 typedef DMC64EncDecOp DMC64EncDecOpList[D64_MAX_ENCDEC_OPS]; |
91d1bb571fca
Implement common encdec ops lists for sharing oplists between formats that
Matti Hamalainen <ccr@tnsp.org>
parents:
1591
diff
changeset
|
255 |
91d1bb571fca
Implement common encdec ops lists for sharing oplists between formats that
Matti Hamalainen <ccr@tnsp.org>
parents:
1591
diff
changeset
|
256 |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
257 typedef int (*DMC64GetPixelFunc)(Uint8 *col, const DMC64Image *img, const int rasterX, const int rasterY); |
1934 | 258 |
259 | |
260 typedef struct _DMC64ImageCommonFormat | |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
261 { |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2239
diff
changeset
|
262 int mode, // Format mode/type flags, see D64_FMT_* |
1935 | 263 width, height, // Width and height in pixels |
2056
c27ed6465022
Add pixel aspect ratio information for C64 formats. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1984
diff
changeset
|
264 chWidth, chHeight, // Width and height in charblocks |
c27ed6465022
Add pixel aspect ratio information for C64 formats. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
1984
diff
changeset
|
265 aspectX, aspectY; // Pixel aspectX/Y |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
266 |
2223
5477e792def3
Remove useless DMC64ImageFormat parameter from some conversion functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
2222
diff
changeset
|
267 int (*convertFrom)(DMImage *, const DMC64Image *, const DMC64ImageConvSpec *spec); |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
268 int (*convertTo)(DMC64Image *, const DMImage *, const DMC64ImageFormat *fmt, const DMC64ImageConvSpec *spec); |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
269 |
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
270 DMC64GetPixelFunc getPixel; |
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
271 |
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
272 DMC64EncDecOpList encdecOps; |
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
273 } DMC64ImageCommonFormat; |
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
274 |
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
275 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
276 typedef struct _DMC64ImageFormat |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
277 { |
922 | 278 char *fext; // Filename extension |
279 char *name; // Format description/name | |
280 | |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
281 size_t addr; // Loading address (0 if no loading address) |
1495 | 282 size_t size; // Size, including loading address. Only used in probing and encoding. |
924
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
283 |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2239
diff
changeset
|
284 int flags; // DM_FMT_* flags (read/write/broken/etc.), see libgfx.h |
1545
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1537
diff
changeset
|
285 |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
286 int (*probe)(const DMGrowBuf *buf, const DMC64ImageFormat *fmt); |
1442 | 287 |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
288 int (*decode)(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt); |
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
289 int (*encode)(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt); |
1442 | 290 |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
291 DMC64ImageCommonFormat formatDef, *format; |
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 } DMC64ImageFormat; |
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 |
1637 | 295 // |
2148
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2139
diff
changeset
|
296 // Compression types |
1637 | 297 // |
1650
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
298 enum |
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
299 { |
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
300 DM_COMP_RLE_MARKER = 1, // RLE with a separate marker byte |
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
301 DM_COMP_RLE_MASK = 2, // RLE that has marker bits and lower part acts as run length |
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
302 }; |
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
303 |
2148
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2139
diff
changeset
|
304 |
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2139
diff
changeset
|
305 // Compression flags |
1650
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
306 enum |
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
307 { |
1660
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
308 DM_RLE_BYTE_RUNS = 0x0001, // Uses one-byte run lengths |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
309 DM_RLE_WORD_RUNS = 0x0002, // Uses two-byte (word) run lengths |
2148
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2139
diff
changeset
|
310 DM_RLE_RUNS_MASK = 0x000f, |
1650
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
311 |
2148
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2139
diff
changeset
|
312 DM_RLE_ORDER_1 = 0x0010, // Order: <marker>, <count/run length>, <data> |
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2139
diff
changeset
|
313 DM_RLE_ORDER_2 = 0x0020, // Order: <marker>, <data>, <count/run length> |
1650
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
314 DM_RLE_ORDER_MASK = 0x00f0, |
1707
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
315 |
1786
52e90130453b
Add descriptive comments to some of RLE decoder flags that were missing "documentation".
Matti Hamalainen <ccr@tnsp.org>
parents:
1783
diff
changeset
|
316 DM_RLE_BACKWARDS_INPUT = 0x0100, // Input is read backwards |
52e90130453b
Add descriptive comments to some of RLE decoder flags that were missing "documentation".
Matti Hamalainen <ccr@tnsp.org>
parents:
1783
diff
changeset
|
317 DM_RLE_BACKWARDS_OUTPUT = 0x0200, // Output is written backwards |
52e90130453b
Add descriptive comments to some of RLE decoder flags that were missing "documentation".
Matti Hamalainen <ccr@tnsp.org>
parents:
1783
diff
changeset
|
318 DM_RLE_ZERO_COUNT_MAX = 0x0400, // Zero "count" / run length value is max run (2^8, 2^16) |
1720
77a4d8fab5cc
Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1719
diff
changeset
|
319 |
77a4d8fab5cc
Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1719
diff
changeset
|
320 DM_OUT_CROP_NONE = 0x0000, |
77a4d8fab5cc
Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1719
diff
changeset
|
321 DM_OUT_CROP_START = 0x1000, |
77a4d8fab5cc
Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1719
diff
changeset
|
322 DM_OUT_CROP_END = 0x2000, |
77a4d8fab5cc
Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1719
diff
changeset
|
323 DM_OUT_CROP_MASK = 0xf000, |
1650
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
324 }; |
1505
3265175b24d2
Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
1503
diff
changeset
|
325 |
3265175b24d2
Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
1503
diff
changeset
|
326 |
3265175b24d2
Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
1503
diff
changeset
|
327 typedef struct |
3265175b24d2
Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
1503
diff
changeset
|
328 { |
1711
4fd94bf558b3
Add function name field to DMCompParams struct and set it in places where we use DMCompParams.
Matti Hamalainen <ccr@tnsp.org>
parents:
1709
diff
changeset
|
329 char *func; |
1720
77a4d8fab5cc
Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1719
diff
changeset
|
330 size_t cropOutLen; |
2148
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2139
diff
changeset
|
331 int type; // DM_COMP_* |
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2139
diff
changeset
|
332 int flags; // |
1720
77a4d8fab5cc
Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1719
diff
changeset
|
333 |
1650
9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
1647
diff
changeset
|
334 Uint8 |
1660
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
335 // DM_COMP_RLE_MARKER mode |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
336 rleMarkerB, // Marker byte for byte length runs (if DM_RLE_BYTE_RUNS used) |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
337 rleMarkerW, // Marker byte for word length runs (if DM_RLE_WORD_RUNS used) |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
338 |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
339 // DM_COMP_RLE_MASK mode |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
340 rleMarkerBits, |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
341 rleMarkerMask, // Mask bits for marker: data & rleMarkerMask == rleMarkerBits |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
342 rleCountMask; // Mask bits for length: count = data & rleCountMask |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
343 |
1707
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
344 unsigned int |
1660
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
345 // Minimum and maximum run lengths |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
346 rleMinCountB, |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
347 rleMinCountW, |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
348 rleMaxCountB, |
7555c8803529
More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents:
1650
diff
changeset
|
349 rleMaxCountW; |
1505
3265175b24d2
Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
1503
diff
changeset
|
350 } DMCompParams; |
3265175b24d2
Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
1503
diff
changeset
|
351 |
3265175b24d2
Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
1503
diff
changeset
|
352 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
353 // |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
354 // Global variables |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
355 // |
2175
58fab91830d5
Change default C64 palette system a bit, add two more palettes. These are
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
356 extern DMC64Palette dmC64DefaultPalettes[]; |
58fab91830d5
Change default C64 palette system a bit, add two more palettes. These are
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
357 extern const int ndmC64DefaultPalettes; |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
358 extern 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
|
359 extern const int ndmC64ImageFormats; |
2200
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2196
diff
changeset
|
360 extern DMC64ImageFormat **dmC64ImageFormatsSorted; |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2196
diff
changeset
|
361 |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2196
diff
changeset
|
362 |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2196
diff
changeset
|
363 // |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2196
diff
changeset
|
364 // Library init/close |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2196
diff
changeset
|
365 // |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2196
diff
changeset
|
366 int dmLib64GFXInit(void); |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2196
diff
changeset
|
367 void dmLib64GFXClose(void); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
368 |
1488
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1486
diff
changeset
|
369 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
370 // |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
371 // Miscellaneous functions |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
372 // |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
373 int dmC64ProbeBMP(const DMGrowBuf *buf, const DMC64ImageFormat **fmt); |
1774
88354355b8e1
Move dmC64ProbeBMP() to more logical place in the source.
Matti Hamalainen <ccr@tnsp.org>
parents:
1764
diff
changeset
|
374 |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2206
diff
changeset
|
375 int dmC64PaletteFromC64Palette(DMPalette **ppal, const DMC64Palette *cpal, const BOOL mixed); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2206
diff
changeset
|
376 int dmC64SetImagePalette(DMImage *img, const DMC64ImageConvSpec *spec, const BOOL mixed); |
1732
07111a60cd4e
Add dmSetMixedColorC64Palette() for setting a 256 entry "mixed color"
Matti Hamalainen <ccr@tnsp.org>
parents:
1726
diff
changeset
|
377 |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
378 BOOL dmCompareAddr16(const DMGrowBuf *buf, const size_t offs, const Uint16 addr); |
1588
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
379 |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
380 int dmC64MemBlockAlloc(DMC64MemBlock *blk, const size_t size); |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
381 int dmC64MemBlockCopy(DMC64MemBlock *dst, const DMC64MemBlock *src); |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
382 void dmC64MemBlockFree(DMC64MemBlock *blk); |
ca087c0cc9c4
Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
1586
diff
changeset
|
383 |
2205 | 384 // C64 bitmap image allocation/freeing |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
385 DMC64Image *dmC64ImageAlloc(const DMC64ImageFormat *fmt); |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
386 void dmC64ImageFree(DMC64Image *img); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
387 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
388 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
389 // Encoding and decoding of formats and images |
1644 | 390 int dmC64ConvertCSDataToImage(DMImage *img, int xoffs, int yoffs, const Uint8 *inBuf, int width, int height, BOOL multicolor, int *colors); |
391 | |
2205 | 392 int dmC64ImageGetNumBlocks(const DMC64ImageFormat *fmt); |
393 | |
1852
219417325036
Split dmC64GetOpMemBlockAndName() into dmC64GetOpMemBlock() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1846
diff
changeset
|
394 const char *dmC64GetOpSubjectName(const int subject); |
2108
5f8f170f8774
Change dmC64GetOpMemBlock() function API.
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
395 const DMC64MemBlock * dmC64GetOpMemBlock(const DMC64Image *img, const int subject, const int bank); |
1644 | 396 int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img); |
2109
510ea816d1ff
Add helper function dmC64MemBlockAllocSubj().
Matti Hamalainen <ccr@tnsp.org>
parents:
2108
diff
changeset
|
397 int dmC64MemBlockAllocSubj(DMC64Image *img, const int subject, const int bank); |
1916
34ba8e2d2dd7
Split dmC64GetOpSize() to dmC64GetSubjectSize() and dmC64GetOpSubjectSize().
Matti Hamalainen <ccr@tnsp.org>
parents:
1859
diff
changeset
|
398 |
1933
c5a46cb4cce5
Change DMC64ImageFormat parameter of dmC64GetSubjectSize() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1932
diff
changeset
|
399 size_t dmC64GetSubjectSize(const int subject, const DMC64ImageCommonFormat *fmt); |
c5a46cb4cce5
Change DMC64ImageFormat parameter of dmC64GetSubjectSize() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1932
diff
changeset
|
400 size_t dmC64GetOpSubjectSize(const DMC64EncDecOp *op, const DMC64ImageCommonFormat *fmt); |
1644 | 401 |
1442 | 402 |
1707
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
403 int dmC64DecodeGenericBMP(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt); |
1499
32640e1934d5
Simplify some encoding bits.
Matti Hamalainen <ccr@tnsp.org>
parents:
1495
diff
changeset
|
404 int dmC64EncodeGenericBMP(const BOOL allocate, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt); |
537
32d9e67da189
Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
405 |
2223
5477e792def3
Remove useless DMC64ImageFormat parameter from some conversion functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
2222
diff
changeset
|
406 int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageConvSpec *spec); |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
407 int dmC64ConvertImage2BMP(DMC64Image **pdst, const DMImage *src, const DMC64ImageFormat *fmt, const DMC64ImageConvSpec *spec); |
1446 | 408 |
1707
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
409 int dmC64DecodeBMP(DMC64Image **img, const DMGrowBuf *buf, const size_t probeOffs, const size_t loadOffs, const DMC64ImageFormat **fmt, const DMC64ImageFormat *forced); |
1467
32203356c652
Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents:
1465
diff
changeset
|
410 int dmC64EncodeBMP(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt); |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
418
diff
changeset
|
411 |
2223
5477e792def3
Remove useless DMC64ImageFormat parameter from some conversion functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
2222
diff
changeset
|
412 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageConvSpec *spec); |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1923
diff
changeset
|
413 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt, const DMC64ImageConvSpec *spec); |
1446 | 414 |
1707
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
415 void dmGenericRLEAnalyze(const DMGrowBuf *buf, DMCompParams *cfg); |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
416 |
1713
0a9110b4d036
Add few RLE helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
1711
diff
changeset
|
417 void dmSetupRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg); |
0a9110b4d036
Add few RLE helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
1711
diff
changeset
|
418 void dmFinishRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg); |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
419 |
1713
0a9110b4d036
Add few RLE helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
1711
diff
changeset
|
420 int dmGenericRLEOutputRun(DMGrowBuf *dst, const DMCompParams *cfg, const Uint8 data, const unsigned int count); |
1719
8f47bd264458
Make dmEncodeGenericRLESequence() a public function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1713
diff
changeset
|
421 int dmEncodeGenericRLESequence(DMGrowBuf *dst, const Uint8 data, const unsigned int count, const DMCompParams *cfg); |
8f47bd264458
Make dmEncodeGenericRLESequence() a public function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1713
diff
changeset
|
422 |
1707
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
423 int dmDecodeGenericRLE(DMGrowBuf *dst, const DMGrowBuf *src, const DMCompParams *cfg); |
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
424 int dmDecodeGenericRLEAlloc(DMGrowBuf *dst, const DMGrowBuf *src, const DMCompParams *cfg); |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
425 |
1707
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
426 int dmEncodeGenericRLE(DMGrowBuf *dst, const DMGrowBuf *src, const DMCompParams *cfg); |
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1668
diff
changeset
|
427 int dmEncodeGenericRLEAlloc(DMGrowBuf *dst, const DMGrowBuf *src, const DMCompParams *cfg); |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
428 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
429 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
430 // |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
431 // Macros for defining variables used in getpixel functions |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
432 // |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
433 #define DM_C64_GENERIC_SC_PIXEL_DEFS(ximg) \ |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
434 const int \ |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
435 x = rasterX / 8, \ |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
436 y = rasterY / 8, \ |
2306
e798a41f27a5
Clean up some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
2266
diff
changeset
|
437 yb = rasterY & 7, \ |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
438 yoffs = y * ximg->fmt->chWidth, \ |
2306
e798a41f27a5
Clean up some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
2266
diff
changeset
|
439 bmoffs = yoffs * 8 + yb + (x * 8), \ |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
440 scroffs = yoffs + x, \ |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
441 vshift = 7 - (rasterX & 7); |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
442 |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
443 |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
444 #define DM_C64_GENERIC_MC_PIXEL_DEFS(ximg) \ |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
445 const int \ |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
446 x = rasterX / 4, \ |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
447 y = rasterY / 8, \ |
2306
e798a41f27a5
Clean up some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
2266
diff
changeset
|
448 yb = rasterY & 7, \ |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
449 yoffs = y * (ximg)->fmt->chWidth, \ |
2306
e798a41f27a5
Clean up some code duplication.
Matti Hamalainen <ccr@tnsp.org>
parents:
2266
diff
changeset
|
450 bmoffs = yoffs * 8 + yb + (x * 8), \ |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
451 scroffs = yoffs + x, \ |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
452 vshift = 6 - ((rasterX * 2) & 6); |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
453 |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
454 |
2132
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
455 #define DM_C64_GENERIC_CHAR_PIXEL(ximg) \ |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
456 const int \ |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
457 x = rasterX / 8, \ |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
458 y = rasterY / 8, \ |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
459 scroffs = y * (ximg)->fmt->chWidth + x; \ |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
460 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
461 |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
462 // |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
463 // Inline helper functions for pixel format decoding |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
464 // |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
465 static inline int dmC64GetGenericSCPixel(Uint8 *col, |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
466 const DMC64Image *img, const int bmoffs, const int scroffs, |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
467 const int vshift, const int vbank, const int bitmap) |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
468 { |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
469 if ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 1) |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
470 *col = img->screen[vbank].data[scroffs] >> 4; |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
471 else |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
472 *col = img->screen[vbank].data[scroffs] & 15; |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
473 |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
474 return DMERR_OK; |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
475 } |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
476 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
477 |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
478 static inline int dmC64GetGenericMCPixel(Uint8 *col, |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
479 const DMC64Image *img, const int bmoffs, const int scroffs, |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
480 const int vshift, const int vbank, const int bitmap, |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
481 const int cbank, const int bgcolor) |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
482 { |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
483 switch ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 3) |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
484 { |
2222
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
485 case 0: *col = bgcolor & 15; break; |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
486 case 1: *col = img->screen[vbank].data[scroffs] >> 4; break; |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
487 case 2: *col = img->screen[vbank].data[scroffs] & 15; break; |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
488 default: *col = img->color[cbank].data[scroffs] & 15; break; |
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
489 } |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
490 |
2129
2129d4ac6f45
Refactor c64 image rendering completely to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
491 return DMERR_OK; |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
492 } |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
493 |
435 | 494 |
2132
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
495 static inline int dmC64GetGenericCharSCPixel(Uint8 *col, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
496 const DMC64Image *img, const int scroffs, const int rasterX, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
497 const int chrbank, const size_t chroffs, const int chr, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
498 const int cbank, const int bgcolor) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
499 { |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
500 if (chroffs >= img->charData[chrbank].size) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
501 { |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
502 return dmError(DMERR_INVALID_DATA, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
503 "Character map index #%d out of bounds for char ROM data.\n", |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
504 chr); |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
505 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
506 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
507 const int vshift = 7 - (rasterX & 7); |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
508 if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) |
2222
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
509 *col = img->color[cbank].data[scroffs] & 15; |
2132
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
510 else |
2222
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
511 *col = bgcolor & 15; |
2132
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
512 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
513 return DMERR_OK; |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
514 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
515 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
516 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
517 static inline int dmC64GetGenericCharMCPixel(Uint8 *col, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
518 const DMC64Image *img, const int scroffs, const int rasterX, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
519 const int chrbank, const size_t chroffs, const int chr, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
520 const int cbank, const int bgcolor, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
521 const int bgd022, const int bgd023) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
522 { |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
523 if (chroffs >= img->charData[chrbank].size) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
524 { |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
525 return dmError(DMERR_INVALID_DATA, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
526 "Character map index #%d out of bounds for char ROM data.\n", |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
527 chr); |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
528 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
529 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
530 const int ccol = img->color[cbank].data[scroffs]; |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
531 if (ccol & 8) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
532 { |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
533 const int vshift = 6 - (rasterX & 6); |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
534 switch ((img->charData[chrbank].data[chroffs] >> vshift) & 3) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
535 { |
2222
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
536 case 0: *col = bgcolor & 15; break; |
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
537 case 1: *col = bgd022 & 15; break; |
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
538 case 2: *col = bgd023 & 15; break; |
2139
84780a9d8d17
Improve and fix charmap format decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2132
diff
changeset
|
539 case 3: *col = ccol & 7; |
2132
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
540 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
541 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
542 else |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
543 { |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
544 const int vshift = 7 - (rasterX & 7); |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
545 if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
546 *col = ccol & 7; |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
547 else |
2222
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
548 *col = bgcolor & 15; |
2132
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
549 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
550 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
551 return DMERR_OK; |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
552 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
553 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
554 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
555 static inline int dmC64GetGenericCharECMPixel(Uint8 *col, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
556 const DMC64Image *img, const int scroffs, const int rasterX, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
557 const int chrbank, const size_t chroffs, const int chr, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
558 const int cbank, const int bgcolor, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
559 const int bgd022, const int bgd023, const int bgd024) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
560 { |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
561 if (chroffs >= img->charData[0].size) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
562 { |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
563 return dmError(DMERR_INVALID_DATA, |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
564 "Character map index #%d out of bounds for char ROM data.\n", |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
565 chr); |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
566 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
567 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
568 const int vshift = 7 - (rasterX & 7); |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
569 if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
570 *col = img->color[cbank].data[scroffs] & 15; |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
571 else |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
572 switch ((chr >> 6) & 3) |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
573 { |
2222
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
574 case 0: *col = bgcolor & 15; break; |
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
575 case 1: *col = bgd022 & 15; break; |
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
576 case 2: *col = bgd023 & 15; break; |
75b5bb490f38
Add & 15 to deeper helper functions and remove it from unnecessary places.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
577 case 3: *col = bgd024 & 15; break; |
2132
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
578 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
579 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
580 return DMERR_OK; |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
581 } |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
582 |
6528a1398e8e
Add char map helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
2129
diff
changeset
|
583 |
1591
3cc7b2aadda3
Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1588
diff
changeset
|
584 static inline const DMC64EncDecOp * fmtGetEncDecOp(const DMC64ImageFormat *fmt, const int index) |
3cc7b2aadda3
Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1588
diff
changeset
|
585 { |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1774
diff
changeset
|
586 return &fmt->format->encdecOps[index]; |
1591
3cc7b2aadda3
Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1588
diff
changeset
|
587 } |
3cc7b2aadda3
Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1588
diff
changeset
|
588 |
3cc7b2aadda3
Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1588
diff
changeset
|
589 |
435 | 590 #ifdef __cplusplus |
591 } | |
592 #endif | |
593 | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
594 #endif // LIB64GFX_H |