Mercurial > hg > dmlib
comparison tools/64vw.c @ 1775:4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 12 Jun 2018 17:12:48 +0300 |
parents | b940b72d1b4d |
children | 5ea4713e9e0f |
comparison
equal
deleted
inserted
replaced
1774:88354355b8e1 | 1775:4e4d54135baf |
---|---|
59 { | 59 { |
60 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; | 60 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; |
61 char buf[64]; | 61 char buf[64]; |
62 printf("%-6s| %-15s | %s%s\n", | 62 printf("%-6s| %-15s | %s%s\n", |
63 fmt->fext, | 63 fmt->fext, |
64 dmC64GetImageTypeString(buf, sizeof(buf), fmt->type, FALSE), | 64 dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->type, FALSE), |
65 fmt->name, | 65 fmt->name, |
66 fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : ""); | 66 fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : ""); |
67 } | 67 } |
68 printf("%d formats supported.\n", ndmC64ImageFormats); | 68 printf("%d formats supported.\n", ndmC64ImageFormats); |
69 } | 69 } |
219 bmap.height = surf->h; | 219 bmap.height = surf->h; |
220 bmap.ncolors = C64_NCOLORS; | 220 bmap.ncolors = C64_NCOLORS; |
221 bmap.constpal = TRUE; | 221 bmap.constpal = TRUE; |
222 bmap.pal = dmDefaultC64Palette; | 222 bmap.pal = dmDefaultC64Palette; |
223 | 223 |
224 if (fmt->convertFrom != NULL) | 224 if (fmt->format->convertFrom != NULL) |
225 ret = fmt->convertFrom(&bmap, cimage, fmt); | 225 ret = fmt->format->convertFrom(&bmap, cimage, fmt); |
226 else | 226 else |
227 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt); | 227 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt); |
228 | 228 |
229 SDL_SetPaletteColors(surf->format->palette, (SDL_Color *) bmap.pal, 0, bmap.ncolors); | 229 SDL_SetPaletteColors(surf->format->palette, (SDL_Color *) bmap.pal, 0, bmap.ncolors); |
230 | 230 |
241 BOOL initSDL = FALSE, exitFlag, needRedraw; | 241 BOOL initSDL = FALSE, exitFlag, needRedraw; |
242 const DMC64ImageFormat *forced; | 242 const DMC64ImageFormat *forced; |
243 size_t currIndex, prevIndex; | 243 size_t currIndex, prevIndex; |
244 int ret; | 244 int ret; |
245 | 245 |
246 dmC64InitializeFormats(); | |
246 dmSetScaleFactor(2.0); | 247 dmSetScaleFactor(2.0); |
247 | 248 |
248 dmInitProg("64vw", "Display some C64 bitmap graphics formats", "0.3", NULL, NULL); | 249 dmInitProg("64vw", "Display some C64 bitmap graphics formats", "0.3", NULL, NULL); |
249 | 250 |
250 // Parse arguments, round #1 | 251 // Parse arguments, round #1 |
273 // Check for forced input format | 274 // Check for forced input format |
274 if (optForcedFormat >= 0) | 275 if (optForcedFormat >= 0) |
275 { | 276 { |
276 forced = &dmC64ImageFormats[optForcedFormat]; | 277 forced = &dmC64ImageFormats[optForcedFormat]; |
277 dmMsg(0, "Forced %s format image, type %d, %s\n", | 278 dmMsg(0, "Forced %s format image, type %d, %s\n", |
278 forced->name, forced->type, forced->fext); | 279 forced->name, forced->format->type, forced->fext); |
279 } | 280 } |
280 else | 281 else |
281 forced = NULL; | 282 forced = NULL; |
282 | 283 |
283 // If we are simply displaying file information, no need to initialize SDL etc | 284 // If we are simply displaying file information, no need to initialize SDL etc |