Mercurial > hg > dmlib
annotate tools/lib64util.c @ 2571:bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
variable 'CHARGEN_ROM' and use it instead of the compile-time hardcoded
value.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 02 Mar 2022 23:23:05 +0200 |
parents | c6ee41fd98dd |
children | 9807ae37ad69 |
rev | line source |
---|---|
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Common utility functions for gfxconv and 64vw |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
2539 | 4 * (C) Copyright 2019-2021 Tecnic Software productions (TNSP) |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #include "lib64util.h" |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
9 #include "dmfile.h" |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 |
2571
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
11 // Default character file ROM path, if not defined yet |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
12 #ifndef DM_DEF_CHARGEN |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
13 #define DM_DEF_CHARGEN "/usr/local/lib64/vice/C64/chargen" |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
14 #endif |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
15 |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 |
2380
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
17 // |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
18 // Some common C64 palettes |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
19 // |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
20 DMC64Palette dmC64DefaultPalettes[] = |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
21 { |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
22 { |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
23 "pepto", |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
24 "Pepto's classic (default)", |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
25 { |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
26 { 0x00, 0x00, 0x00, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
27 { 0xFF, 0xFF, 0xFF, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
28 { 0x68, 0x37, 0x2B, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
29 { 0x70, 0xA4, 0xB2, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
30 { 0x6F, 0x3D, 0x86, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
31 { 0x58, 0x8D, 0x43, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
32 { 0x35, 0x28, 0x79, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
33 { 0xB8, 0xC7, 0x6F, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
34 { 0x6F, 0x4F, 0x25, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
35 { 0x43, 0x39, 0x00, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
36 { 0x9A, 0x67, 0x59, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
37 { 0x44, 0x44, 0x44, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
38 { 0x6C, 0x6C, 0x6C, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
39 { 0x9A, 0xD2, 0x84, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
40 { 0x6C, 0x5E, 0xB5, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
41 { 0x95, 0x95, 0x95, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
42 }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
43 }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
44 { |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
45 "colodore", |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
46 "Colodore", |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
47 { |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
48 { 0x00, 0x00, 0x00, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
49 { 0xff, 0xff, 0xff, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
50 { 0x96, 0x28, 0x2e, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
51 { 0x5b, 0xd6, 0xce, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
52 { 0x9f, 0x2d, 0xad, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
53 { 0x41, 0xb9, 0x36, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
54 { 0x27, 0x24, 0xc4, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
55 { 0xef, 0xf3, 0x47, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
56 { 0x9f, 0x48, 0x15, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
57 { 0x5e, 0x35, 0x00, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
58 { 0xda, 0x5f, 0x66, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
59 { 0x47, 0x47, 0x47, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
60 { 0x78, 0x78, 0x78, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
61 { 0x91, 0xff, 0x84, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
62 { 0x68, 0x64, 0xff, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
63 { 0xae, 0xae, 0xae, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
64 }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
65 }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
66 { |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
67 "vice3", |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
68 "VICE 3.3", |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
69 { |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
70 { 0x00, 0x00, 0x00, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
71 { 0xfd, 0xfe, 0xfc, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
72 { 0xbe, 0x1a, 0x24, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
73 { 0x30, 0xe6, 0xc6, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
74 { 0xb4, 0x1a, 0xe2, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
75 { 0x1f, 0xd2, 0x1e, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
76 { 0x21, 0x1b, 0xae, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
77 { 0xdf, 0xf6, 0x0a, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
78 { 0xb8, 0x41, 0x04, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
79 { 0x6a, 0x33, 0x04, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
80 { 0xfe, 0x4a, 0x57, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
81 { 0x42, 0x45, 0x40, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
82 { 0x70, 0x74, 0x6f, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
83 { 0x59, 0xfe, 0x59, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
84 { 0x5f, 0x53, 0xfe, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
85 { 0xa4, 0xa7, 0xa2, 0xff }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
86 }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
87 }, |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
88 }; |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
89 |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
90 const int ndmC64DefaultPalettes = sizeof(dmC64DefaultPalettes) / sizeof(dmC64DefaultPalettes[0]); |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
91 |
89cb93184175
Move dmC64DefaultPalettes from lib64gfx to lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2373
diff
changeset
|
92 |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 static const char *fmtModesShort[] = { "*", "HiR", "MC", "ECM" }; |
2314
87533af8db64
Add format flag for formats that use sprite layer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
96 static const char *fmtModesLong[] = { "*", "Hires", "Multi-color", "Extended Color Mode" }; |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 const char *fmtStr; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 size_t nfmt = type & D64_FMT_MODE_MASK; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 if (nfmt < sizeof(fmtModesShort) / sizeof(fmtModesShort[0])) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 fmtStr = lng ? fmtModesLong[nfmt] : fmtModesShort[nfmt]; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 else |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 fmtStr = lng ? "ERROR" : "ERR"; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 snprintf(buf, len, |
2314
87533af8db64
Add format flag for formats that use sprite layer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
106 "%s %s%s%s%s", |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 fmtStr, |
2314
87533af8db64
Add format flag for formats that use sprite layer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
108 (type & D64_FMT_ILACE) ? (lng ? "interlaced " : "ILace ") : "", |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 (type & D64_FMT_FLI) ? "FLI " : "", |
2314
87533af8db64
Add format flag for formats that use sprite layer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
110 (type & D64_FMT_CHAR) ? (lng ? "char-mode" : "CHAR") : "", |
87533af8db64
Add format flag for formats that use sprite layer.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
111 (type & D64_FMT_SPRITES) ? (lng ? "+ sprite-layer" : "SPR") : "" |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 ); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 return buf; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 |
2385
5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
Matti Hamalainen <ccr@tnsp.org>
parents:
2383
diff
changeset
|
118 DM_ATTR_PRINTF_FMT(4, 5) |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
119 static void dmC64ImageDumpLine(FILE *fh, const char *indent, const char *field, const char *fmt, ...) |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
120 { |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
121 va_list ap; |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
122 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
123 fputs(indent, fh); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
124 fprintf(fh, "%-20s: ", field); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
125 va_start(ap, fmt); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
126 vfprintf(fh, fmt, ap); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
127 va_end(ap); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
128 fputs("\n", fh); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
129 } |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
130 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
131 |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt, const char *indent) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 char typeStr[64]; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 if (fmt != NULL) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 { |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
138 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
139 "Format", "%s [%s]", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
140 fmt->name, fmt->fext); |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
141 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 if (img != NULL) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 { |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2264
diff
changeset
|
145 dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->extraInfo[D64_EI_MODE], TRUE); |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
147 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
148 "Type", "%s", typeStr); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
149 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
150 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
151 "Internal blocks", "%d", img->nblocks); |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2264
diff
changeset
|
153 if (img->extraInfo[D64_EI_MODE] & D64_FMT_ILACE) |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 char *tmps; |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
156 switch (img->extraInfo[D64_EI_ILACE_TYPE]) |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 case D64_ILACE_COLOR: tmps = "color"; break; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 case D64_ILACE_RES: tmps = "resolution"; break; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 default: tmps = "ERROR"; break; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 } |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
162 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
163 "Interlace type", "%s", tmps); |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2264
diff
changeset
|
166 if (img->extraInfo[D64_EI_MODE] & D64_FMT_FLI) |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
167 { |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
168 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
169 "FLI type", "%d", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
170 img->extraInfo[D64_EI_FLI_TYPE]); |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
171 } |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
172 |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
173 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
174 "Width x Height", "%d x %d pixels", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
175 img->fmt->width, img->fmt->height); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
176 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
177 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
178 "CHwidth x CHheight", "%d x %d", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
179 img->fmt->chWidth, img->fmt->chHeight); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
180 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
181 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
182 "d020 / border", "%d ($%02x)", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
183 img->d020, img->d020); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
184 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
185 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
186 "d021 / background", "%d ($%02x)", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
187 img->bgcolor, img->bgcolor); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
188 |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2264
diff
changeset
|
189 if (img->extraInfo[D64_EI_MODE] & D64_FMT_CHAR) |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
190 { |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2264
diff
changeset
|
191 if ((img->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == (D64_FMT_MC | D64_FMT_ECM)) |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
192 { |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
193 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
194 "d022", "%d ($%02x)", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
195 img->d022, img->d022); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
196 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
197 "d023", "%d ($%02x)", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
198 img->d023, img->d023); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
199 } |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
200 |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2264
diff
changeset
|
201 if ((img->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_ECM) |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
202 { |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
203 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
204 "d024", "%d ($%02x)", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
205 img->d024, img->d024); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
206 } |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
207 } |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
208 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
209 else |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
210 if (fmt != NULL) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
211 { |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2264
diff
changeset
|
212 dmC64GetImageTypeString(typeStr, sizeof(typeStr), fmt->format->mode, TRUE); |
2264
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
213 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
214 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
215 "Type", "%s", typeStr); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
216 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
217 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
218 "Width x Height", "%d x %d pixels", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
219 fmt->format->width, fmt->format->height); |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
220 |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
221 dmC64ImageDumpLine(fh, indent, |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
222 "CHwidth x CHheight", "%d x %d", |
e25fa516b53a
Add helper function dmC64ImageDumpLine() for printing information out in
Matti Hamalainen <ccr@tnsp.org>
parents:
2263
diff
changeset
|
223 fmt->format->chWidth, fmt->format->chHeight); |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
224 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
225 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
226 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
227 |
2515
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
228 void argShowC64Formats(FILE *fh, const BOOL rw, const BOOL verbose) |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
229 { |
2263 | 230 fprintf(fh, |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
231 "Available C64 bitmap formats (-f <frmt>):\n" |
2515
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
232 " frmt %s| Type %s| Description\n" |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
233 "------%s+-----------------%s+-------------------------------------\n", |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
234 rw ? "| RW " : "", |
2515
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
235 verbose ? "| Load | Size " : "", |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
236 rw ? "+----" : "", |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
237 verbose ? "+-------+-------" : "" |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
238 ); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
239 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
240 for (int i = 0; i < ndmC64ImageFormats; i++) |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
241 { |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
242 const DMC64ImageFormat *fmt = dmC64ImageFormatsSorted[i]; |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
243 char buf[64]; |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
244 |
2263 | 245 fprintf(fh, "%-6s", |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
246 fmt->fext); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
247 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
248 if (rw) |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
249 { |
2263 | 250 fprintf(fh, "| %c%c ", |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
251 (fmt->flags & DM_FMT_RD) ? 'R' : ' ', |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
252 (fmt->flags & DM_FMT_WR) ? 'W' : ' ' |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
253 ); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
254 } |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
255 |
2263 | 256 fprintf(fh, |
2515
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
257 "| %-15s ", |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
258 dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->mode, FALSE) |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
259 ); |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
260 |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
261 if (verbose) |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
262 { |
2517
106f4426c729
List formats without a loading address differently in argShowC64Formats().
Matti Hamalainen <ccr@tnsp.org>
parents:
2515
diff
changeset
|
263 if (fmt->addr < 0) |
106f4426c729
List formats without a loading address differently in argShowC64Formats().
Matti Hamalainen <ccr@tnsp.org>
parents:
2515
diff
changeset
|
264 { |
106f4426c729
List formats without a loading address differently in argShowC64Formats().
Matti Hamalainen <ccr@tnsp.org>
parents:
2515
diff
changeset
|
265 fprintf(fh, "| %4s ", |
106f4426c729
List formats without a loading address differently in argShowC64Formats().
Matti Hamalainen <ccr@tnsp.org>
parents:
2515
diff
changeset
|
266 fmt->addr == -1 ? "?" : ""); |
106f4426c729
List formats without a loading address differently in argShowC64Formats().
Matti Hamalainen <ccr@tnsp.org>
parents:
2515
diff
changeset
|
267 } |
106f4426c729
List formats without a loading address differently in argShowC64Formats().
Matti Hamalainen <ccr@tnsp.org>
parents:
2515
diff
changeset
|
268 else |
106f4426c729
List formats without a loading address differently in argShowC64Formats().
Matti Hamalainen <ccr@tnsp.org>
parents:
2515
diff
changeset
|
269 { |
2515
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
270 fprintf(fh, "| $%04x ", |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
271 (uint32_t) fmt->addr); |
2517
106f4426c729
List formats without a loading address differently in argShowC64Formats().
Matti Hamalainen <ccr@tnsp.org>
parents:
2515
diff
changeset
|
272 } |
2515
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
273 |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
274 if (fmt->size > 0) |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
275 { |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
276 fprintf(fh, "| $%04" DM_PRIx_SIZE_T " ", |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
277 fmt->size); |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
278 } |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
279 else |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
280 { |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
281 fprintf(fh, "| "); |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
282 } |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
283 } |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
284 |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
285 fprintf(fh, |
a40de347fcb0
Make c64 formats listing (optionally) more verbose. Handle --help a bit
Matti Hamalainen <ccr@tnsp.org>
parents:
2463
diff
changeset
|
286 "| %s%s\n", |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
287 fmt->name, |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
288 fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : ""); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
289 } |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
290 |
2263 | 291 fprintf(fh, "%d formats supported.\n", ndmC64ImageFormats); |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
292 } |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
293 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
294 |
2263 | 295 void argShowC64PaletteHelp(FILE *fh) |
2244
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
296 { |
2263 | 297 fprintf(fh, |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
298 "\n" |
2373
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
299 "Available internal C64 palettes (-p <name>):\n" |
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
300 "--------------------------------------------\n"); |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
301 |
2244
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
302 for (int n = 0; n < ndmC64DefaultPalettes; n++) |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
303 { |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
304 DMC64Palette *pal = &dmC64DefaultPalettes[n]; |
2263 | 305 fprintf(fh, |
2244
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
306 "%-10s | %s\n", |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
307 pal->name, pal->desc); |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
308 } |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
309 |
2263 | 310 fprintf(fh, |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
311 "\n" |
2373
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
312 "Instead of using one of the internal palettes,\n" |
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
313 "you can specify an external palette file.\n" |
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
314 "\n" |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
315 "Supported palette file formats are:\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
316 "-----------------------------------\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
317 ); |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
318 |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
319 for (int n = 0; n < ndmPaletteFormatList; n++) |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
320 { |
2247 | 321 const DMPaletteFormat *fmt = &dmPaletteFormatList[n]; |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
322 if (fmt->flags & DM_FMT_RD) |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
323 { |
2263 | 324 fprintf(fh, |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
325 "%-6s | %s\n", |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
326 fmt->fext, fmt->name); |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
327 } |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
328 } |
2373
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
329 fprintf(fh, |
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
330 "\n" |
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
331 "Example: -p foobar.bin\n" |
f35ee6f8d994
Improve the help text in argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2372
diff
changeset
|
332 "\n"); |
2244
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
333 } |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
334 |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
335 |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
336 BOOL argHandleC64PaletteOption(char *optArg, DMC64Palette **ppal, char **palFile) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
337 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
338 if (strcasecmp(optArg, "help") == 0 || |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
339 strcasecmp(optArg, "list") == 0) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
340 { |
2240
e2c6af0c9431
Add FILE argument to argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2238
diff
changeset
|
341 argShowC64PaletteHelp(stdout); |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
342 return FALSE; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
343 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
344 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
345 for (int n = 0; n < ndmC64DefaultPalettes; n++) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
346 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
347 DMC64Palette *pal = &dmC64DefaultPalettes[n]; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
348 if (strcasecmp(pal->name, optArg) == 0) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
349 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
350 *ppal = pal; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
351 return TRUE; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
352 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
353 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
354 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
355 *palFile = optArg; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
356 return TRUE; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
357 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
358 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
359 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
360 int dmHandleExternalPalette(const char *filename, DMPalette **ppal) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
361 { |
2263 | 362 DMResource *fh = NULL; |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
363 const DMImageFormat *ifmt = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
364 const DMPaletteFormat *pfmt = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
365 DMImage *inImage = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
366 Uint8 *dataBuf = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
367 size_t dataSize; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
368 int index, res; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
369 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
370 dmMsg(1, "Probing file '%s' for palette data.\n", filename); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
371 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
372 if ((res = dmReadDataFile(NULL, filename, &dataBuf, &dataSize)) != DMERR_OK) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
373 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
374 dmErrorMsg("No such palette '%s', and no such file found (%s).\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
375 filename, dmErrorStr(res)); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
376 goto done; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
377 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
378 |
2263 | 379 if ((res = dmf_open_memio(NULL, filename, dataBuf, dataSize, &fh)) != DMERR_OK) |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
380 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
381 dmErrorMsg("Could not create MemIO handle for input.\n"); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
382 goto done; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
383 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
384 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
385 if (dmImageProbeGeneric(dataBuf, dataSize, &ifmt, &index) > 0 && |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
386 ifmt->read != NULL) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
387 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
388 dmMsg(1, "Probed image format %s (%s)\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
389 ifmt->name, ifmt->fext); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
390 |
2263 | 391 res = ifmt->read(fh, &inImage); |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
392 if (res != DMERR_OK) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
393 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
394 dmErrorMsg("Could not read image file: %s\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
395 dmErrorStr(res)); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
396 goto done; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
397 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
398 |
2463
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
399 if (inImage->pixfmt != DM_PIXFMT_PALETTE) |
2210
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
400 { |
2463
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
401 res = dmError(DMERR_INVALID_DATA, |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
402 "Image file is not a paletted format.\n"); |
2210
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
403 } |
2463
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
404 |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
405 if (inImage->pal == NULL) |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
406 { |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
407 res = dmError(DMERR_NULLPTR, |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
408 "Image file does not have a palette.\n"); |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
409 } |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
410 |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
411 res = dmPaletteCopy(ppal, inImage->pal); |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
412 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
413 else |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
414 if (dmPaletteProbeGeneric(dataBuf, dataSize, &pfmt, &index) > 0 && |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
415 pfmt->read != NULL) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
416 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
417 dmMsg(1, "Probed palette format %s (%s)\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
418 pfmt->name, pfmt->fext); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
419 |
2263 | 420 res = pfmt->read(fh, ppal); |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
421 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
422 else |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
423 { |
2463
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
424 res = dmError(DMERR_NOT_SUPPORTED, |
45d863deb00b
Improve error and validity checks for external palette loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
2385
diff
changeset
|
425 "Not an internal palette or recognized palette file '%s'.\n", |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
426 filename); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
427 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
428 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
429 done: |
2263 | 430 dmf_close(fh); |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
431 dmImageFree(inImage); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
432 dmFree(dataBuf); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
433 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
434 return res; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
435 } |
2571
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
436 |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
437 |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
438 const char *dmGetChargenROMPath() |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
439 { |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
440 const char *path = getenv("CHARGEN_ROM"); |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
441 if (path != NULL) |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
442 return path; |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
443 else |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
444 return DM_DEF_CHARGEN; |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
445 } |
bb44c48cffac
Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents:
2539
diff
changeset
|
446 |