annotate tools/lib64gfx.h @ 1859:f382cde6bb58

Rename various C64 sprite / character constants.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 24 Jun 2018 05:35:23 +0300
parents 219417325036
children 34ba8e2d2dd7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
418
b6a1dc3bd2c3 Update file description.
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
2 * Functions for reading and converting various restricted
b6a1dc3bd2c3 Update file description.
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
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
1456
42fb39da7dde Bump copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 1449
diff changeset
5 * (C) Copyright 2012-2018 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
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
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
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
14
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
15 #ifdef __cplusplus
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
16 extern "C" {
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
17 #endif
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
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
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 // Bitmap constants
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 #define C64_SCR_WIDTH 320
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 #define C64_SCR_HEIGHT 200
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 #define C64_SCR_CH_WIDTH (C64_SCR_WIDTH/8)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 #define C64_SCR_CH_HEIGHT (C64_SCR_HEIGHT/8)
1373
fc5ee5b4b0e9 Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents: 1365
diff changeset
25 #define C64_MAX_EXTRA_DATA 64
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 // C64 video screen pixel aspect ratio on PAL
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 #define C64_SCR_PAR_XY (0.9365f)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 // Sprite constants
1859
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
31 #define C64_SPR_WIDTH_PX 24
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
32 #define C64_SPR_HEIGHT_PX 21
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
33 #define C64_SPR_WIDTH_UT (C64_SPR_WIDTH_PX / 8) // bytes
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
34 #define C64_SPR_HEIGHT_UT C64_SPR_HEIGHT_PX
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
35 #define C64_SPR_SIZE ((C64_SPR_WIDTH_UT * C64_SPR_HEIGHT_UT) + 1)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 // Character constants
1859
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
38 #define C64_CHR_WIDTH_PX 8
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
39 #define C64_CHR_HEIGHT_PX 8
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
40 #define C64_CHR_WIDTH_UT 1 // bytes
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
41 #define C64_CHR_HEIGHT_UT 8 // lines
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
42 #define C64_CHR_SIZE (C64_CHR_WIDTH_UT * C64_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
43
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 // Etc.
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 #define C64_NCOLORS 16
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 #define C64_VIDBANK_SIZE (16*1024)
1859
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
47 #define C64_MAX_SPRITES 1024
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 #define C64_MAX_CHARS 256
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
922
658bf4c452d0 Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 921
diff changeset
50
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
51 #define DM_GET_ADDR_LO(addr) ((addr) & 0xff)
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
52 #define DM_GET_ADDR_HI(addr) (((addr) >> 8) & 0xff)
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
53
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
54
1637
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
55 // 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
56 enum
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 {
1637
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
58 D64_FMT_HIRES = 0x0000, // Hi-res
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
59 D64_FMT_MC = 0x0001, // MultiColor
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
60 D64_FMT_ILACE = 0x0002, // Interlace
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
61 D64_FMT_FLI = 0x0004, // FLI
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
62 D64_FMT_CHAR = 0x0008, // Character mode
1781
e53dc89c0e56 Add a c64 image/format flag for formats that use the border area. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 1780
diff changeset
63 D64_FMT_BORDER = 0x0010, // Uses border area
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 };
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65
1637
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
66
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
67 // 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
68 enum
5b37a2e427b7 Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
69 {
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
70 D64_ILACE_NONE = 0x0000, // Not set (invalid for interlaced images)
1637
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
71 D64_ILACE_RES = 0x0001, // Interlace doubles resolution
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
72 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
73 };
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
936
5104a7c87d7b Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 931
diff changeset
75
5104a7c87d7b Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 931
diff changeset
76 // Charmode screen memory configuration
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
77 enum
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
78 {
936
5104a7c87d7b Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 931
diff changeset
79 D64_CHCFG_SCREEN, // Use screen memory
5104a7c87d7b Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 931
diff changeset
80 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
81 // 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
82 };
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
83
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
84
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
85 // 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
86 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
87 {
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
88 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
89 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
90 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
91
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
92 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
93 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
94
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
95 DO_DEC_FUNC, // Execute specified decoding function (only for decoding operations)
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
96 DO_ENC_FUNC, // Same, but for encoding
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
97
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
98 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
99
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
100 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
101 };
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
512
95a6b6af53f1 Add some structures and enums for future.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
103
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
104 // "Subjects" of operations (op->subject)
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
105 enum
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
106 {
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
107 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
108 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
109 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
110 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
111 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
112
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
113 DS_D020,
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
114 DS_BGCOL,
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
115 DS_D021,
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
116 DS_D022,
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
117 DS_D023,
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
118 DS_D024,
1852
219417325036 Split dmC64GetOpMemBlockAndName() into dmC64GetOpMemBlock() and
Matti Hamalainen <ccr@tnsp.org>
parents: 1846
diff changeset
119
219417325036 Split dmC64GetOpMemBlockAndName() into dmC64GetOpMemBlock() and
Matti Hamalainen <ccr@tnsp.org>
parents: 1846
diff changeset
120 DS_LAST
917
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
121 };
df3a74f230d9 Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 916
diff changeset
122
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
124 typedef struct
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
125 {
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
126 Uint8 *data;
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
127 size_t size;
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
128 } DMC64MemBlock;
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
129
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
130
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
131 typedef struct
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
132 {
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
133 BOOL multicolor, xexpand, yexpand;
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
134 int color, xc, yc;
1859
f382cde6bb58 Rename various C64 sprite / character constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1852
diff changeset
135 Uint8 data[C64_SPR_HEIGHT_UT][C64_SPR_WIDTH_UT];
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
136 } DMC64Sprite;
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
137
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
138
1374
9edb17aa4a0a Forward declare typedef struct _DMC64Image;
Matti Hamalainen <ccr@tnsp.org>
parents: 1373
diff changeset
139 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
140 {
922
658bf4c452d0 Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 921
diff changeset
141 int type, // Image type (D64_FMT_*)
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1376
diff changeset
142 laceType, // Interlace type (D64_ILACE_*)
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1376
diff changeset
143 nbanks;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
145 int width, height; // Width and height in pixels
1482
df6dacb48970 Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents: 1467
diff changeset
146 int chWidth, chHeight; // Width and height in charblocks
df6dacb48970 Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents: 1467
diff changeset
147
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
148 // Bitmaps, color RAM, screen, etc. blocks * nbanks
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
149 // 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
150 DMC64MemBlock
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
151 *color,
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
152 *bitmap,
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
153 *screen,
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
154 *charData;
931
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
155
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
156 // Other standard colours
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
157 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
158
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
159 // 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
160 // for example raster colours might be stored
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
161 DMC64MemBlock extraData[C64_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
162
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 DMC64Sprite sprites[C64_MAX_SPRITES];
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 } DMC64Image;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1374
diff changeset
167 typedef Uint8 (*DMC64GetPixelFunc)(
1376
67ae449cf9e1 More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1375
diff changeset
168 const DMC64Image *img, const int bmoffs, const int scroffs,
1764
52e31cfc1e36 Implement fake X raster position for the pixel getting functions. At some
Matti Hamalainen <ccr@tnsp.org>
parents: 1732
diff changeset
169 const int vshift, const int vbitmap, const int rasterX, const int rasterY);
1375
f5368c13a872 Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1374
diff changeset
170
1379
1e67dd44351e Increase maximum number of enc/dec operations for C64 images.
Matti Hamalainen <ccr@tnsp.org>
parents: 1378
diff changeset
171 #define D64_MAX_ENCDEC_OPS 64
937
51dc33efd126 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 936
diff changeset
172
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
173
1486
bc13af8954d7 Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents: 1482
diff changeset
174 typedef struct _DMC64ImageFormat DMC64ImageFormat;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
176
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 507
diff changeset
177 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
178 {
1668
1741717b1ae5 Big overhaul to the enc/dec operator system to be more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
179 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
180 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
181
1846
88cef7758303 Implement data block offset in certain DMC64EncDecOps. This allows us to
Matti Hamalainen <ccr@tnsp.org>
parents: 1826
diff changeset
182 size_t offs; // Offset in "memory"
88cef7758303 Implement data block offset in certain DMC64EncDecOps. This allows us to
Matti Hamalainen <ccr@tnsp.org>
parents: 1826
diff changeset
183 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
184 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
185 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
186
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1668
diff changeset
187 BOOL (*decFunction)(DMC64Image *img, const struct _DMC64EncDecOp *op, const DMGrowBuf *buf, const DMC64ImageFormat *fmt);
1486
bc13af8954d7 Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents: 1482
diff changeset
188 BOOL (*encFunction)(const struct _DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt);
510
43ea59887c69 Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents: 507
diff changeset
189 } 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
190
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191
1592
91d1bb571fca Implement common encdec ops lists for sharing oplists between formats that
Matti Hamalainen <ccr@tnsp.org>
parents: 1591
diff changeset
192 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
193
91d1bb571fca Implement common encdec ops lists for sharing oplists between formats that
Matti Hamalainen <ccr@tnsp.org>
parents: 1591
diff changeset
194
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
195 typedef struct
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
196 {
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
197 int type; // Type flags, see D64_FMT_*
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
198 int width, height; // Width and height in pixels
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
199 int chWidth, chHeight; // Width and height in charblocks
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
200
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
201 int (*convertFrom)(DMImage *, const DMC64Image *, 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
202 int (*convertTo)(DMC64Image *, const DMImage *, 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
203
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
204 DMC64GetPixelFunc getPixel;
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
205
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
206 DMC64EncDecOpList encdecOps;
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
207 } DMC64ImageCommonFormat;
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
208
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
209
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 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
211 {
922
658bf4c452d0 Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 921
diff changeset
212 char *fext; // Filename extension
658bf4c452d0 Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 921
diff changeset
213 char *name; // Format description/name
658bf4c452d0 Comments, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 921
diff changeset
214
511
4cdcaeb68b54 Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents: 510
diff changeset
215 size_t addr; // Loading address (0 if no loading address)
1495
acb607e2c350 Clarify a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
216 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
217
1545
3b613fcbf3ff Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1537
diff changeset
218 int flags; // DM_FMT_* flags, see libgfx.h
3b613fcbf3ff Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1537
diff changeset
219
1780
5ea4713e9e0f Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 1775
diff changeset
220 int (*probe)(const DMGrowBuf *buf, const DMC64ImageFormat *fmt);
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1426
diff changeset
221
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
222 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
223 int (*encode)(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt);
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1426
diff changeset
224
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
225 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
226 } DMC64ImageFormat;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228
1637
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
229 //
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
230 // Compression types and flags
1637
58ef0124394d Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 1592
diff changeset
231 //
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
232 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
233 {
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
234 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
235 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
236 };
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
237
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
238 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
239 {
1660
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
240 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
241 DM_RLE_WORD_RUNS = 0x0002, // Uses two-byte (word) run lengths
1825
c22d3b309f34 Adjust DM_RLE_RUNS_MASK.
Matti Hamalainen <ccr@tnsp.org>
parents: 1822
diff changeset
242 DM_RLE_RUNS_MASK = 0x0003,
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
243
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
244 DM_RLE_ORDER_1 = 0x0000, // Order: <marker>, <count/run length>, <data>
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
245 DM_RLE_ORDER_2 = 0x0010, // Order: <marker>, <data>, <count/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
246 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
247
1786
52e90130453b Add descriptive comments to some of RLE decoder flags that were missing "documentation".
Matti Hamalainen <ccr@tnsp.org>
parents: 1783
diff changeset
248 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
249 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
250 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
251
77a4d8fab5cc Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 1719
diff changeset
252 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
253 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
254 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
255 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
256 };
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
257
3265175b24d2 Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 1503
diff changeset
258
3265175b24d2 Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 1503
diff changeset
259 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
260 {
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
261 char *func;
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
262 int type;
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
263 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
264 size_t cropOutLen;
77a4d8fab5cc Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 1719
diff changeset
265
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
266 Uint8
1660
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
267 // DM_COMP_RLE_MARKER mode
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
268 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
269 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
270
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
271 // DM_COMP_RLE_MASK mode
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
272 rleMarkerBits,
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
273 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
274 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
275
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1668
diff changeset
276 unsigned int
1660
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
277 // Minimum and maximum run lengths
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
278 rleMinCountB,
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
279 rleMinCountW,
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
280 rleMaxCountB,
7555c8803529 More work on improving the generic RLE decoder/encoder.
Matti Hamalainen <ccr@tnsp.org>
parents: 1650
diff changeset
281 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
282 } 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
283
3265175b24d2 Change the passing of RLE compression/decompression parameters to be in a dedicated struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 1503
diff changeset
284
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
285 //
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
286 // Global variables
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
287 //
1426
4c7b456d7f0b Rename global dmC64Palette to dmDefaultC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents: 1380
diff changeset
288 extern DMColor dmDefaultC64Palette[C64_NCOLORS];
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
289 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
290 extern const int ndmC64ImageFormats;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291
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
292
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
293 //
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
294 // Miscellaneous functions
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
295 //
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
296 void dmC64InitializeFormats(void);
1780
5ea4713e9e0f Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 1775
diff changeset
297 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
298
1644
9d9a0e852b3d Reorder some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1637
diff changeset
299 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng);
1822
9bec535956fd Add indentation parameter to dmC64ImageDump().
Matti Hamalainen <ccr@tnsp.org>
parents: 1786
diff changeset
300 void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt, const char *indent);
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
301
1457
dcff9ac95d3f Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1456
diff changeset
302 void dmSetDefaultC64Palette(DMImage *img);
1732
07111a60cd4e Add dmSetMixedColorC64Palette() for setting a 256 entry "mixed color"
Matti Hamalainen <ccr@tnsp.org>
parents: 1726
diff changeset
303 BOOL dmSetMixedColorC64Palette(DMImage *img);
07111a60cd4e Add dmSetMixedColorC64Palette() for setting a 256 entry "mixed color"
Matti Hamalainen <ccr@tnsp.org>
parents: 1726
diff changeset
304
1780
5ea4713e9e0f Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 1775
diff changeset
305 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
306 int dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt);
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
307
1644
9d9a0e852b3d Reorder some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1637
diff changeset
308 // C64 bitmap image allocation/freeing
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
309 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
310 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
311 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
312
1378
c465860e44ed Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents: 1376
diff changeset
313 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
314 void dmC64ImageFree(DMC64Image *img);
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
315
2270d7f3af77 Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents: 926
diff changeset
316
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
317 // Encoding and decoding of formats and images
1644
9d9a0e852b3d Reorder some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1637
diff changeset
318 int dmC64ConvertCSDataToImage(DMImage *img, int xoffs, int yoffs, const Uint8 *inBuf, int width, int height, BOOL multicolor, int *colors);
9d9a0e852b3d Reorder some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1637
diff changeset
319
1852
219417325036 Split dmC64GetOpMemBlockAndName() into dmC64GetOpMemBlock() and
Matti Hamalainen <ccr@tnsp.org>
parents: 1846
diff changeset
320 const char *dmC64GetOpSubjectName(const int subject);
219417325036 Split dmC64GetOpMemBlockAndName() into dmC64GetOpMemBlock() and
Matti Hamalainen <ccr@tnsp.org>
parents: 1846
diff changeset
321 void dmC64GetOpMemBlock(const DMC64Image *img, const int subject, const int bank, const DMC64MemBlock **blk);
1644
9d9a0e852b3d Reorder some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1637
diff changeset
322 int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img);
9d9a0e852b3d Reorder some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1637
diff changeset
323 BOOL dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size);
9d9a0e852b3d Reorder some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1637
diff changeset
324
1442
3773281491c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1426
diff changeset
325
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1668
diff changeset
326 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
327 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
328
940
ff18d2511843 Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents: 937
diff changeset
329 int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt);
1467
32203356c652 Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 1465
diff changeset
330 int dmC64ConvertImage2BMP(DMC64Image **pdst, const DMImage *src, const DMC64ImageFormat *fmt);
1446
948b32bd67ef Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
331
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1668
diff changeset
332 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
333 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
334
1446
948b32bd67ef Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
335 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt);
1467
32203356c652 Add some new functions that are mostly just stubs and not working tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 1465
diff changeset
336 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt);
1446
948b32bd67ef Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1442
diff changeset
337
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1668
diff changeset
338 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
339
1713
0a9110b4d036 Add few RLE helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1711
diff changeset
340 void dmSetupRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg);
0a9110b4d036 Add few RLE helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1711
diff changeset
341 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
342
1713
0a9110b4d036 Add few RLE helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1711
diff changeset
343 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
344 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
345
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1668
diff changeset
346 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
347 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
348
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1668
diff changeset
349 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
350 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
351
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
352
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 // 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
355 //
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
356 static inline Uint8 dmC64GetGenericSCPixel(
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
357 const DMC64Image *img, const int bmoffs, const int scroffs,
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
358 const int vshift, const int vbank, const int vbitmap, const int cbank)
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
359 {
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
360 (void) cbank;
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
361 if ((img->bitmap[vbitmap].data[bmoffs] >> vshift) & 1)
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
362 return 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
363 else
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
364 return img->screen[vbank].data[scroffs] & 15;
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
365 }
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
366
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
367
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
368 static inline Uint8 dmC64GetGenericMCPixel(
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
369 const DMC64Image *img, const int bmoffs, const int scroffs,
1764
52e31cfc1e36 Implement fake X raster position for the pixel getting functions. At some
Matti Hamalainen <ccr@tnsp.org>
parents: 1732
diff changeset
370 const int vshift, const int vbank, const int vbitmap, 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
371 {
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
372 switch ((img->bitmap[vbitmap].data[bmoffs] >> vshift) & 3)
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
373 {
1577
632f1dbc83eb Get rid of some code duplication by merging functionality of certain pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1573
diff changeset
374 case 0: return bgcolor;
1588
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
375 case 1: return img->screen[vbank].data[scroffs] >> 4;
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
376 case 2: return img->screen[vbank].data[scroffs] & 15;
ca087c0cc9c4 Refactor the c64 format memory handling a bit for more flexibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 1586
diff changeset
377 default: return img->color[cbank].data[scroffs] & 15;
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
378 }
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
379 }
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
380
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
381
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
382 static inline Uint8 fmtGetGenericSCPixel(
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
383 const DMC64Image *img, const int bmoffs, const int scroffs,
1764
52e31cfc1e36 Implement fake X raster position for the pixel getting functions. At some
Matti Hamalainen <ccr@tnsp.org>
parents: 1732
diff changeset
384 const int vshift, const int vbitmap, const int rasterX, const int rasterY)
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
385 {
1764
52e31cfc1e36 Implement fake X raster position for the pixel getting functions. At some
Matti Hamalainen <ccr@tnsp.org>
parents: 1732
diff changeset
386 (void) rasterX;
52e31cfc1e36 Implement fake X raster position for the pixel getting functions. At some
Matti Hamalainen <ccr@tnsp.org>
parents: 1732
diff changeset
387 (void) rasterY;
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
388 return dmC64GetGenericSCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0);
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
389 }
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
390
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
391
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
392 static inline Uint8 fmtGetGenericMCPixel(
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
393 const DMC64Image *img, const int bmoffs, const int scroffs,
1764
52e31cfc1e36 Implement fake X raster position for the pixel getting functions. At some
Matti Hamalainen <ccr@tnsp.org>
parents: 1732
diff changeset
394 const int vshift, const int vbitmap, const int rasterX, const int rasterY)
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
395 {
1764
52e31cfc1e36 Implement fake X raster position for the pixel getting functions. At some
Matti Hamalainen <ccr@tnsp.org>
parents: 1732
diff changeset
396 (void) rasterX;
52e31cfc1e36 Implement fake X raster position for the pixel getting functions. At some
Matti Hamalainen <ccr@tnsp.org>
parents: 1732
diff changeset
397 (void) rasterY;
1577
632f1dbc83eb Get rid of some code duplication by merging functionality of certain pixel
Matti Hamalainen <ccr@tnsp.org>
parents: 1573
diff changeset
398 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0, img->bgcolor);
1503
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
399 }
c7b9ef56319b Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents: 1499
diff changeset
400
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
401
1591
3cc7b2aadda3 Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1588
diff changeset
402 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
403 {
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1774
diff changeset
404 return &fmt->format->encdecOps[index];
1591
3cc7b2aadda3 Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1588
diff changeset
405 }
3cc7b2aadda3 Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1588
diff changeset
406
3cc7b2aadda3 Add inline helper function fmtGetEncDecOp() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1588
diff changeset
407
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
408 #ifdef __cplusplus
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
409 }
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
410 #endif
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
411
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 #endif // LIB64GFX_H