Mercurial > hg > dmlib
annotate tools/lib64gfx.h @ 1503:c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 11 May 2018 07:41:55 +0300 |
parents | 32640e1934d5 |
children | 3265175b24d2 |
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 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
54 #define DM_RLE_MARKER 1 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
55 #define DM_RLE_MASK 2 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
56 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
57 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
58 #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
|
59 #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
|
60 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
61 |
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 // 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
|
63 enum |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 { |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 D64_FMT_FLI = 0x0004, |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
69 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
|
70 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
71 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
|
72 |
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 |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
75 enum |
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
76 { |
1380 | 77 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
|
78 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
|
79 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 |
936
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
81 |
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
82 // Charmode screen memory configuration |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
83 enum |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
84 { |
936
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
85 D64_CHCFG_SCREEN, // Use screen memory |
5104a7c87d7b
Remove some unused structures, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
931
diff
changeset
|
86 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
|
87 // 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
|
88 }; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
89 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
90 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 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
|
92 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 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
|
94 int color, xc, yc; |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
95 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
|
96 } DMC64Sprite; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 |
512
95a6b6af53f1
Add some structures and enums for future.
Matti Hamalainen <ccr@tnsp.org>
parents:
511
diff
changeset
|
98 |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
99 enum |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
100 { |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
101 DC_D020, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
102 DC_BGCOL, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
103 DC_D021, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
104 DC_D022, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
105 DC_D023, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
106 DC_D024, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
107 }; |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
108 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 |
1374
9edb17aa4a0a
Forward declare typedef struct _DMC64Image;
Matti Hamalainen <ccr@tnsp.org>
parents:
1373
diff
changeset
|
110 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
|
111 { |
922 | 112 int type, // Image type (D64_FMT_*) |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
113 laceType, // Interlace type (D64_ILACE_*) |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
114 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
|
115 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
116 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
|
117 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
|
118 |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
119 size_t |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
120 screenSize, |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
121 bitmapSize, |
df6dacb48970
Rename some struct members, and sanitize handling of DMC64Image allocation more.
Matti Hamalainen <ccr@tnsp.org>
parents:
1467
diff
changeset
|
122 charmemSize; |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
123 |
915 | 124 Uint8 |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
125 **color, |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
126 **bitmap, |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
127 **screen, |
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
128 **charmem, |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
129 *extraData[C64_MAX_EXTRA_DATA], |
915 | 130 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
|
131 |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
132 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
|
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 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
|
135 } DMC64Image; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1374
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 enum |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 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
|
145 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
|
146 DT_SCREEN_RAM, |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
147 DT_COLOR_REG, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
148 DT_COLOR_SET, |
1373
fc5ee5b4b0e9
Improve handling of extra data.
Matti Hamalainen <ccr@tnsp.org>
parents:
1365
diff
changeset
|
149 DT_EXTRA_DATA, |
916 | 150 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
151 DT_DEC_FUNCTION, |
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
152 DT_ENC_FUNCTION, |
917
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
153 |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
154 DT_CHAR_DATA, |
df3a74f230d9
Initial implementation of charmode support in lib64gfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
916
diff
changeset
|
155 DT_CHAR_CONFIG, |
925 | 156 |
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 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
|
158 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 |
1379
1e67dd44351e
Increase maximum number of enc/dec operations for C64 images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1378
diff
changeset
|
160 #define D64_MAX_ENCDEC_OPS 64 |
937 | 161 |
1486
bc13af8954d7
Add DMC64ImageFormat to C64 bitmap format encoding/decoding ops function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1482
diff
changeset
|
162 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
|
163 |
510
43ea59887c69
Start work on making C64 formats encoding possible by changing DMDecodeOps
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
164 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
|
165 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 int type; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 } 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
|
173 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
175 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
|
176 { |
922 | 177 int type; // Type flags, see D64_FMT_* |
178 char *fext; // Filename extension | |
179 char *name; // Format description/name | |
180 | |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
181 size_t addr; // Loading address (0 if no loading address) |
1495 | 182 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
|
183 |
732787cccca8
Add dimension (w/h) information fields to C64 image format struct.
Matti Hamalainen <ccr@tnsp.org>
parents:
923
diff
changeset
|
184 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
|
185 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
|
186 |
511
4cdcaeb68b54
Collapse most of the probing functions into one generic probe, as they only
Matti Hamalainen <ccr@tnsp.org>
parents:
510
diff
changeset
|
187 int (*probe)(const Uint8 *buf, const size_t len, const struct _DMC64ImageFormat *fmt); |
1442 | 188 |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
189 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
|
190 int (*encode)(DMGrowBuf *buf, const DMC64Image *img, const struct _DMC64ImageFormat *fmt); |
1442 | 191 |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1374
diff
changeset
|
192 int (*convertFrom)(DMImage *, const DMC64Image *, const struct _DMC64ImageFormat *fmt); |
1442 | 193 int (*convertTo)(DMC64Image *, const DMImage *, const struct _DMC64ImageFormat *fmt); |
194 | |
1375
f5368c13a872
Implement more flexible generic format decoding by separating the pixel
Matti Hamalainen <ccr@tnsp.org>
parents:
1374
diff
changeset
|
195 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
|
196 |
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
|
197 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
|
198 } DMC64ImageFormat; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
199 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
200 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
201 // |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
202 // Global variables |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
203 // |
1426
4c7b456d7f0b
Rename global dmC64Palette to dmDefaultC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
1380
diff
changeset
|
204 extern DMColor dmDefaultC64Palette[C64_NCOLORS]; |
516 | 205 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
|
206 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
|
207 |
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
|
208 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
209 // |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
210 // Miscellaneous functions |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
211 // |
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
|
212 void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt); |
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
|
213 void dmSetDefaultC64Palette(DMImage *img); |
1494
3b220604ae3c
Add short format attribute names to dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents:
1489
diff
changeset
|
214 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng); |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
215 int dmC64ConvertCSDataToImage(DMImage *img, int xoffs, int yoffs, const Uint8 *inBuf, int width, int height, BOOL multicolor, int *colors); |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
216 int dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt); |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
217 BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr); |
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
|
218 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
219 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
220 // C64 bitmap image allocation/freeing |
1378
c465860e44ed
Make c64 image bank allocation dynamic.
Matti Hamalainen <ccr@tnsp.org>
parents:
1376
diff
changeset
|
221 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
|
222 void dmC64ImageFree(DMC64Image *img); |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
223 |
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
224 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
225 // Encoding and decoding of formats and images |
1442 | 226 int dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **fmt); |
227 | |
410
e4b2f689aff6
Stdint -> SDL types conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
228 int dmC64DecodeGenericBMP(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt); |
1499
32640e1934d5
Simplify some encoding bits.
Matti Hamalainen <ccr@tnsp.org>
parents:
1495
diff
changeset
|
229 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
|
230 |
940
ff18d2511843
Remove the doubleMC madness completely. Should be replaced with x/y aspect
Matti Hamalainen <ccr@tnsp.org>
parents:
937
diff
changeset
|
231 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
|
232 int dmC64ConvertImage2BMP(DMC64Image **pdst, const DMImage *src, const DMC64ImageFormat *fmt); |
1446 | 233 |
931
2270d7f3af77
Refactor the DMC64Image handling to be more dynamic, and start
Matti Hamalainen <ccr@tnsp.org>
parents:
926
diff
changeset
|
234 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
|
235 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
|
236 |
1446 | 237 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
|
238 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt); |
1446 | 239 |
1503
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
240 void dmGenericRLEAnalyze(const DMGrowBuf *buf, Uint8 *rleMarker, const int rleType); |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
241 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
242 int dmDecodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
243 const Uint8 rleMarker, const Uint8 rleMask1, const Uint8 rleMask2, const int rleType); |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
244 int dmDecodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
245 const Uint8 rleMarker, const Uint8 rleMask1, const Uint8 rleMask2, const int rleType); |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
246 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
247 int dmEncodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
248 const Uint8 rleMarker, const Uint8 rleMinCount, const Uint8 rleMaxCount, const int rleType); |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
249 int dmEncodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
250 const Uint8 rleMarker, const Uint8 rleMinCount, const Uint8 rleMaxCount, const int rleType); |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
251 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
252 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
253 // |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
254 // 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
|
255 // |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
256 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
|
257 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
|
258 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
|
259 { |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
260 (void) cbank; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
261 if ((img->bitmap[vbitmap][bmoffs] >> vshift) & 1) |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
262 return img->screen[vbank][scroffs] >> 4; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
263 else |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
264 return img->screen[vbank][scroffs] & 15; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
265 } |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
266 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
267 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 { |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
272 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3) |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
273 { |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
274 case 0: return img->bgcolor; break; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
275 case 1: return img->screen[vbank][scroffs] >> 4; break; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
276 case 2: return img->screen[vbank][scroffs] & 15; break; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
277 default: return img->color[cbank][scroffs] & 15; break; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
278 } |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
279 } |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
280 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
281 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
282 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
|
283 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
|
284 const int vshift, const int vbitmap, const int raster) |
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 (void) raster; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
287 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
|
288 } |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
289 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
290 |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
291 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
|
292 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
|
293 const int vshift, const int vbitmap, const int raster) |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
294 { |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
295 (void) raster; |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
296 return dmC64GetGenericMCPixel(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
|
297 } |
c7b9ef56319b
Factor all the c64 file format specific things into lib64fmt.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1499
diff
changeset
|
298 |
435 | 299 |
300 #ifdef __cplusplus | |
301 } | |
302 #endif | |
303 | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
304 #endif // LIB64GFX_H |