Mercurial > hg > dmlib
comparison tools/lib64util.c @ 2263:891acec47aa0
Rename variables.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 17 Jun 2019 01:42:00 +0300 |
parents | bb7255792dd6 |
children | e25fa516b53a |
comparison
equal
deleted
inserted
replaced
2262:f92d4f056587 | 2263:891acec47aa0 |
---|---|
98 indent, fmt->format->chWidth, fmt->format->chHeight); | 98 indent, fmt->format->chWidth, fmt->format->chHeight); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 | 102 |
103 void argShowC64Formats(FILE *fp, const BOOL rw) | 103 void argShowC64Formats(FILE *fh, const BOOL rw) |
104 { | 104 { |
105 fprintf(fp, | 105 fprintf(fh, |
106 "Available C64 bitmap formats (-f <frmt>):\n" | 106 "Available C64 bitmap formats (-f <frmt>):\n" |
107 " frmt %s| Type | Description\n" | 107 " frmt %s| Type | Description\n" |
108 "------%s+-----------------+-------------------------------------\n", | 108 "------%s+-----------------+-------------------------------------\n", |
109 rw ? "| RW " : "", | 109 rw ? "| RW " : "", |
110 rw ? "+----" : "" | 110 rw ? "+----" : "" |
113 for (int i = 0; i < ndmC64ImageFormats; i++) | 113 for (int i = 0; i < ndmC64ImageFormats; i++) |
114 { | 114 { |
115 const DMC64ImageFormat *fmt = dmC64ImageFormatsSorted[i]; | 115 const DMC64ImageFormat *fmt = dmC64ImageFormatsSorted[i]; |
116 char buf[64]; | 116 char buf[64]; |
117 | 117 |
118 fprintf(fp, "%-6s", | 118 fprintf(fh, "%-6s", |
119 fmt->fext); | 119 fmt->fext); |
120 | 120 |
121 if (rw) | 121 if (rw) |
122 { | 122 { |
123 fprintf(fp, "| %c%c ", | 123 fprintf(fh, "| %c%c ", |
124 (fmt->flags & DM_FMT_RD) ? 'R' : ' ', | 124 (fmt->flags & DM_FMT_RD) ? 'R' : ' ', |
125 (fmt->flags & DM_FMT_WR) ? 'W' : ' ' | 125 (fmt->flags & DM_FMT_WR) ? 'W' : ' ' |
126 ); | 126 ); |
127 } | 127 } |
128 | 128 |
129 fprintf(fp, | 129 fprintf(fh, |
130 "| %-15s | %s%s\n", | 130 "| %-15s | %s%s\n", |
131 dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->type, FALSE), | 131 dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->mode, FALSE), |
132 fmt->name, | 132 fmt->name, |
133 fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : ""); | 133 fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : ""); |
134 } | 134 } |
135 | 135 |
136 fprintf(fp, "%d formats supported.\n", ndmC64ImageFormats); | 136 fprintf(fh, "%d formats supported.\n", ndmC64ImageFormats); |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 void argShowC64PaletteHelp(FILE *fp) | 140 void argShowC64PaletteHelp(FILE *fh) |
141 { | 141 { |
142 fprintf(fp, | 142 fprintf(fh, |
143 "\n" | 143 "\n" |
144 "Available C64 palettes (-p <name>):\n" | 144 "Available C64 palettes (-p <name>):\n" |
145 "-----------------------------------\n"); | 145 "-----------------------------------\n"); |
146 | 146 |
147 for (int n = 0; n < ndmC64DefaultPalettes; n++) | 147 for (int n = 0; n < ndmC64DefaultPalettes; n++) |
148 { | 148 { |
149 DMC64Palette *pal = &dmC64DefaultPalettes[n]; | 149 DMC64Palette *pal = &dmC64DefaultPalettes[n]; |
150 fprintf(fp, | 150 fprintf(fh, |
151 "%-10s | %s\n", | 151 "%-10s | %s\n", |
152 pal->name, pal->desc); | 152 pal->name, pal->desc); |
153 } | 153 } |
154 | 154 |
155 fprintf(fp, | 155 fprintf(fh, |
156 "\n" | 156 "\n" |
157 "Instead one of the internal palettes, you can\n" | 157 "Instead one of the internal palettes, you can\n" |
158 "also specify an external palette file.\n" | 158 "also specify an external palette file.\n" |
159 "Supported palette file formats are:\n" | 159 "Supported palette file formats are:\n" |
160 "-----------------------------------\n" | 160 "-----------------------------------\n" |
163 for (int n = 0; n < ndmPaletteFormatList; n++) | 163 for (int n = 0; n < ndmPaletteFormatList; n++) |
164 { | 164 { |
165 const DMPaletteFormat *fmt = &dmPaletteFormatList[n]; | 165 const DMPaletteFormat *fmt = &dmPaletteFormatList[n]; |
166 if (fmt->flags & DM_FMT_RD) | 166 if (fmt->flags & DM_FMT_RD) |
167 { | 167 { |
168 fprintf(fp, | 168 fprintf(fh, |
169 "%-6s | %s\n", | 169 "%-6s | %s\n", |
170 fmt->fext, fmt->name); | 170 fmt->fext, fmt->name); |
171 } | 171 } |
172 } | 172 } |
173 fprintf(fp, "\n"); | 173 fprintf(fh, "\n"); |
174 } | 174 } |
175 | 175 |
176 | 176 |
177 BOOL argHandleC64PaletteOption(char *optArg, DMC64Palette **ppal, char **palFile) | 177 BOOL argHandleC64PaletteOption(char *optArg, DMC64Palette **ppal, char **palFile) |
178 { | 178 { |
198 } | 198 } |
199 | 199 |
200 | 200 |
201 int dmHandleExternalPalette(const char *filename, DMPalette **ppal) | 201 int dmHandleExternalPalette(const char *filename, DMPalette **ppal) |
202 { | 202 { |
203 DMResource *fp = NULL; | 203 DMResource *fh = NULL; |
204 const DMImageFormat *ifmt = NULL; | 204 const DMImageFormat *ifmt = NULL; |
205 const DMPaletteFormat *pfmt = NULL; | 205 const DMPaletteFormat *pfmt = NULL; |
206 DMImage *inImage = NULL; | 206 DMImage *inImage = NULL; |
207 Uint8 *dataBuf = NULL; | 207 Uint8 *dataBuf = NULL; |
208 size_t dataSize; | 208 size_t dataSize; |
215 dmErrorMsg("No such palette '%s', and no such file found (%s).\n", | 215 dmErrorMsg("No such palette '%s', and no such file found (%s).\n", |
216 filename, dmErrorStr(res)); | 216 filename, dmErrorStr(res)); |
217 goto done; | 217 goto done; |
218 } | 218 } |
219 | 219 |
220 if ((res = dmf_open_memio(NULL, filename, dataBuf, dataSize, &fp)) != DMERR_OK) | 220 if ((res = dmf_open_memio(NULL, filename, dataBuf, dataSize, &fh)) != DMERR_OK) |
221 { | 221 { |
222 dmErrorMsg("Could not create MemIO handle for input.\n"); | 222 dmErrorMsg("Could not create MemIO handle for input.\n"); |
223 goto done; | 223 goto done; |
224 } | 224 } |
225 | 225 |
227 ifmt->read != NULL) | 227 ifmt->read != NULL) |
228 { | 228 { |
229 dmMsg(1, "Probed image format %s (%s)\n", | 229 dmMsg(1, "Probed image format %s (%s)\n", |
230 ifmt->name, ifmt->fext); | 230 ifmt->name, ifmt->fext); |
231 | 231 |
232 res = ifmt->read(fp, &inImage); | 232 res = ifmt->read(fh, &inImage); |
233 if (res != DMERR_OK) | 233 if (res != DMERR_OK) |
234 { | 234 { |
235 dmErrorMsg("Could not read image file: %s\n", | 235 dmErrorMsg("Could not read image file: %s\n", |
236 dmErrorStr(res)); | 236 dmErrorStr(res)); |
237 goto done; | 237 goto done; |
250 pfmt->read != NULL) | 250 pfmt->read != NULL) |
251 { | 251 { |
252 dmMsg(1, "Probed palette format %s (%s)\n", | 252 dmMsg(1, "Probed palette format %s (%s)\n", |
253 pfmt->name, pfmt->fext); | 253 pfmt->name, pfmt->fext); |
254 | 254 |
255 res = pfmt->read(fp, ppal); | 255 res = pfmt->read(fh, ppal); |
256 } | 256 } |
257 else | 257 else |
258 { | 258 { |
259 res = DMERR_NOT_SUPPORTED; | 259 res = DMERR_NOT_SUPPORTED; |
260 dmErrorMsg("Not an internal palette or recognized palette file '%s'.\n", | 260 dmErrorMsg("Not an internal palette or recognized palette file '%s'.\n", |
261 filename); | 261 filename); |
262 } | 262 } |
263 | 263 |
264 done: | 264 done: |
265 dmf_close(fp); | 265 dmf_close(fh); |
266 dmImageFree(inImage); | 266 dmImageFree(inImage); |
267 dmFree(dataBuf); | 267 dmFree(dataBuf); |
268 | 268 |
269 return res; | 269 return res; |
270 } | 270 } |