Mercurial > hg > dmlib
annotate tools/lib64gfx.h @ 1486:bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 11 May 2018 04:52:43 +0300 |
parents | df6dacb48970 |
children | c71b6c5204af |
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 |
1456 | 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 | 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 |
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) |
926 | 25 #define C64_SCR_COLOR_SIZE (C64_SCR_CH_WIDTH * C64_SCR_CH_HEIGHT) |
26 #define C64_SCR_SCREEN_SIZE (C64_SCR_CH_WIDTH * C64_SCR_CH_HEIGHT) | |
923 | 27 #define C64_SCR_BITMAP_SIZE ((C64_SCR_WIDTH * C64_SCR_HEIGHT)/8) |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
28 #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
|
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 // 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
|
31 #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
|
32 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 // Sprite constants |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 #define C64_SPR_WIDTH 3 // bytes |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 #define C64_SPR_HEIGHT 21 // lines |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 #define C64_SPR_WIDTH_PX (8 * C64_SPR_WIDTH) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 #define C64_SPR_SIZE ((C64_SPR_WIDTH * C64_SPR_HEIGHT) + 1) |
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 // Character constants |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 #define C64_CHR_WIDTH 1 // bytes |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 #define C64_CHR_HEIGHT 8 // lines |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 #define C64_CHR_WIDTH_PX (8 * C64_CHR_WIDTH) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 #define C64_CHR_SIZE (C64_CHR_WIDTH * C64_CHR_HEIGHT) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 // Etc. |
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_RAM_SIZE (64*1024) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 #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
|
48 #define C64_MAX_COLORS 16 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 #define C64_VIDBANK_SIZE (16*1024) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 #define C64_MAX_SPRITES (C64_VIDBANK_SIZE / C64_SPR_SIZE) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 #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
|
52 |
922 | 53 |
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 // Different supported C64 bitmap "modes" |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 enum |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 { |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
57 D64_FMT_HIRES = 0x0000, |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
58 D64_FMT_MC = 0x0001, |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
59 D64_FMT_ILACE = 0x0002, |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
60 D64_FMT_FLI = 0x0004, |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
61 D64_FMT_CHAR = 0x0008, |
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 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
63 D64_FMT_MODE_MASK = 0x000f, |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
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
|
65 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
67 enum |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
68 { |
1380 | 69 D64_ILACE_RES, |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
70 D64_ILACE_COLOR, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 |
936
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
73 |
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
74 // Charmode screen memory configuration |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
75 enum |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
76 { |
936
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
77 D64_CHCFG_SCREEN, // Use screen memory |
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
78 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
|
79 // 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
|
80 }; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
81 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
82 |
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 typedef struct |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 BOOL multicolor, xexpand, yexpand; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 int color, xc, yc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
87 Uint8 data[C64_SPR_HEIGHT][C64_SPR_WIDTH]; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 } DMC64Sprite; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 |
512
95a6b6af53f1
Add some structures and enums for future.
Matti Hamalainen <ccr@tnsp.org>
parents:
511
diff
changeset
|
90 |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
91 enum |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
92 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
93 DC_D020, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
94 DC_BGCOL, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
95 DC_D021, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
96 DC_D022, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
97 DC_D023, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
98 DC_D024, |
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 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 |
1374
9edb17aa4a0a
Forward declare typedef struct _DMC64Image;
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
102 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
|
103 { |
922 | 104 int type, // Image type (D64_FMT_*) |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
105 laceType, // Interlace type (D64_ILACE_*) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
106 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
|
107 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
108 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
|
109 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
|
110 |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
111 size_t |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
112 screenSize, |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
113 bitmapSize, |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
114 charmemSize; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
115 |
915 | 116 Uint8 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
117 **color, |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
118 **bitmap, |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
119 **screen, |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
120 **charmem, |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
121 *extraData[C64_MAX_EXTRA_DATA], |
915 | 122 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
|
123 |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
124 size_t extraDataSizes[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
|
125 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 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
|
127 } DMC64Image; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1374
diff
changeset
|
130 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
|
131 const DMC64Image *img, const int bmoffs, const int scroffs, |
67ae449cf9e1
More work on making various FLI etc. format decoding more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents:
1375
diff
changeset
|
132 const int vshift, const int vbitmap, const int raster); |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1374
diff
changeset
|
133 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 enum |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 DT_COLOR_RAM, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 DT_BITMAP, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 DT_SCREEN_RAM, |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
139 DT_COLOR_REG, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
140 DT_COLOR_SET, |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
141 DT_EXTRA_DATA, |
916 | 142 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
143 DT_DEC_FUNCTION, |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
144 DT_ENC_FUNCTION, |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
145 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
146 DT_CHAR_DATA, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
147 DT_CHAR_CONFIG, |
925 | 148 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 DT_LAST, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
151 |
1379
1e67dd44351e
Increase maximum number of enc/dec operations for C64 images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1378
diff
changeset
|
152 #define D64_MAX_ENCDEC_OPS 64 |
937 | 153 |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1482
diff
changeset
|
154 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
|
155 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
156 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
|
157 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 int type; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 size_t offs; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 int bank; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 size_t size; |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1482
diff
changeset
|
162 BOOL (*decFunction)(DMC64Image *img, const struct _DMC64EncDecOp *op, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt); |
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1482
diff
changeset
|
163 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
|
164 } 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
|
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 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
|
168 { |
922 | 169 int type; // Type flags, see D64_FMT_* |
170 char *fext; // Filename extension | |
171 char *name; // Format description/name | |
172 | |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
173 size_t addr; // Loading address (0 if no loading address) |
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
174 size_t size; // Size, including loading address. Only used in encoding, if even there (0 if no static size) |
924
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
175 |
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
176 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
|
177 int chWidth, chHeight; // Width and height in charblocks |
924
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
178 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
179 int (*probe)(const Uint8 *buf, const size_t len, const struct _DMC64ImageFormat *fmt); |
1442 | 180 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
181 int (*decode)(DMC64Image *img, const Uint8 *buf, const size_t len, const struct _DMC64ImageFormat *fmt); |
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
|
182 int (*encode)(DMGrowBuf *buf, const DMC64Image *img, const struct _DMC64ImageFormat *fmt); |
1442 | 183 |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1374
diff
changeset
|
184 int (*convertFrom)(DMImage *, const DMC64Image *, const struct _DMC64ImageFormat *fmt); |
1442 | 185 int (*convertTo)(DMC64Image *, const DMImage *, const struct _DMC64ImageFormat *fmt); |
186 | |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1374
diff
changeset
|
187 DMC64GetPixelFunc getPixel; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 |
921
2454ddb7363f
Add constant for max number of enc/dec ops in C64 image format struct
Matti Hamalainen <ccr@tnsp.org>
parents:
920
diff
changeset
|
189 DMC64EncDecOp encdecOps[D64_MAX_ENCDEC_OPS]; |
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 } DMC64ImageFormat; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
191 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
192 |
1426
4c7b456d7f0b
Rename global dmC64Palette to dmDefaultC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
1380
diff
changeset
|
193 extern DMColor dmDefaultC64Palette[C64_NCOLORS]; |
516 | 194 extern const DMC64ImageFormat dmC64ImageFormats[]; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
195 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
|
196 |
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
|
197 void dmSetDefaultC64Palette(DMImage *img); |
dcff9ac95d3f
Add function to set DMImage's palette to default C64 palette and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1456
diff
changeset
|
198 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
199 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
200 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
|
201 void dmC64ImageFree(DMC64Image *img); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
202 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
203 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
204 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type); |
827 | 205 int dmC64ConvertCSDataToImage(DMImage *img, int xoffs, int yoffs, const Uint8 *inBuf, int width, int height, BOOL multicolor, int *colors); |
537
32d9e67da189
Rename generic probing function to match the style of other lib64gfx functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
206 |
1442 | 207 int dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **fmt); |
208 | |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
209 int dmC64DecodeGenericBMP(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt); |
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
|
210 int dmC64EncodeGenericBMP(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
|
211 |
940
ff18d2511843
Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents:
937
diff
changeset
|
212 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
|
213 int dmC64ConvertImage2BMP(DMC64Image **pdst, const DMImage *src, const DMC64ImageFormat *fmt); |
1446 | 214 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
215 int dmC64DecodeBMP(DMC64Image **img, const Uint8 *buf, const size_t len, 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
|
216 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
|
217 |
1446 | 218 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
|
219 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt); |
1446 | 220 |
435 | 221 |
222 #ifdef __cplusplus | |
223 } | |
224 #endif | |
225 | |
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 #endif // LIB64GFX_H |