Mercurial > hg > dmlib
comparison tools/gfxconv.c @ 2265:48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
our purposes, but better now.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 17 Jun 2019 02:03:35 +0300 |
parents | fe974f670d1d |
children | 9269a32ba7f9 |
comparison
equal
deleted
inserted
replaced
2264:e25fa516b53a | 2265:48b48251610a |
---|---|
1270 dst->d022 = src->d022; | 1270 dst->d022 = src->d022; |
1271 dst->d023 = src->d023; | 1271 dst->d023 = src->d023; |
1272 dst->d024 = src->d024; | 1272 dst->d024 = src->d024; |
1273 | 1273 |
1274 // Try to do some simple fixups | 1274 // Try to do some simple fixups |
1275 if ((dst->fmt->type & D64_FMT_MODE_MASK) == D64_FMT_MC && | 1275 if ((dst->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_MC && |
1276 (src->fmt->type & D64_FMT_MODE_MASK) == D64_FMT_HIRES) | 1276 (src->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_HIRES) |
1277 { | 1277 { |
1278 dmC64MemBlockCopy(&dst->screen[0], &src->screen[0]); | 1278 dmC64MemBlockCopy(&dst->screen[0], &src->screen[0]); |
1279 } | 1279 } |
1280 else | 1280 else |
1281 if ((dst->fmt->type & D64_FMT_MODE_MASK) == D64_FMT_HIRES && | 1281 if ((dst->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_HIRES && |
1282 (src->fmt->type & D64_FMT_MODE_MASK) == D64_FMT_MC) | 1282 (src->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) == D64_FMT_MC) |
1283 { | 1283 { |
1284 // XXX TODO: Handle FLI mc->hires differently? | 1284 // XXX TODO: Handle FLI mc->hires differently? |
1285 } | 1285 } |
1286 | 1286 |
1287 if ((dst->fmt->type & D64_FMT_FLI) && (src->fmt->type & D64_FMT_FLI) == 0) | 1287 if ((dst->extraInfo[D64_EI_MODE] & D64_FMT_FLI) && |
1288 (src->extraInfo[D64_EI_MODE] & D64_FMT_FLI) == 0) | |
1288 { | 1289 { |
1289 dmMsg(1, "Upconverting multicolor to FLI.\n"); | 1290 dmMsg(1, "Upconverting multicolor to FLI.\n"); |
1290 for (int i = 0; i < dst->nblocks; i++) | 1291 for (int i = 0; i < dst->nblocks; i++) |
1291 { | 1292 { |
1292 if (dst->color[i].data == NULL) | 1293 if (dst->color[i].data == NULL) |
1298 if (dst->bitmap[i].data == NULL) | 1299 if (dst->bitmap[i].data == NULL) |
1299 dmC64MemBlockCopy(&dst->bitmap[i], &src->bitmap[0]); | 1300 dmC64MemBlockCopy(&dst->bitmap[i], &src->bitmap[0]); |
1300 } | 1301 } |
1301 } | 1302 } |
1302 else | 1303 else |
1303 if ((src->fmt->type & D64_FMT_FLI) && (dst->fmt->type & D64_FMT_FLI) == 0) | 1304 if ((src->extraInfo[D64_EI_MODE] & D64_FMT_FLI) && |
1305 (dst->extraInfo[D64_EI_MODE] & D64_FMT_FLI) == 0) | |
1304 { | 1306 { |
1305 dmMsg(1, "Downconverting FLI to multicolor.\n"); | 1307 dmMsg(1, "Downconverting FLI to multicolor.\n"); |
1306 } | 1308 } |
1307 | 1309 |
1308 // Do per opcode copies | 1310 // Do per opcode copies |
2100 | 2102 |
2101 if (optForcedInSubFormat >= 0) | 2103 if (optForcedInSubFormat >= 0) |
2102 { | 2104 { |
2103 forced = &dmC64ImageFormats[optForcedInSubFormat]; | 2105 forced = &dmC64ImageFormats[optForcedInSubFormat]; |
2104 dmMsg(0, "Forced '%s' format image, type %d, %s\n", | 2106 dmMsg(0, "Forced '%s' format image, type %d, %s\n", |
2105 forced->name, forced->format->type, forced->fext); | 2107 forced->name, forced->format->mode, forced->fext); |
2106 } | 2108 } |
2107 | 2109 |
2108 res = dmC64DecodeBMP(&inC64Image, | 2110 res = dmC64DecodeBMP(&inC64Image, |
2109 dmGrowBufConstCreateFrom(&tbuf, dataBuf, dataSize), | 2111 dmGrowBufConstCreateFrom(&tbuf, dataBuf, dataSize), |
2110 0, 2, &inC64Fmt, forced); | 2112 0, 2, &inC64Fmt, forced); |
2111 | 2113 |
2112 if (forced == NULL && inC64Fmt != NULL && res == DMERR_OK) | 2114 if (forced == NULL && inC64Fmt != NULL && res == DMERR_OK) |
2113 { | 2115 { |
2114 dmMsg(1, "Probed '%s' format image, type %d, %s\n", | 2116 dmMsg(1, "Probed '%s' format image, type %d, %s\n", |
2115 inC64Fmt->name, inC64Fmt->format->type, inC64Fmt->fext); | 2117 inC64Fmt->name, inC64Fmt->format->mode, inC64Fmt->fext); |
2116 | 2118 |
2117 optInType = FFMT_BITMAP; | 2119 optInType = FFMT_BITMAP; |
2118 } | 2120 } |
2119 else | 2121 else |
2120 if (res != DMERR_OK && (forced != NULL || optInType == FFMT_BITMAP)) | 2122 if (res != DMERR_OK && (forced != NULL || optInType == FFMT_BITMAP)) |
2223 { | 2225 { |
2224 case FFMT_IMAGE: | 2226 case FFMT_IMAGE: |
2225 case FFMT_CHAR: | 2227 case FFMT_CHAR: |
2226 case FFMT_SPRITE: | 2228 case FFMT_SPRITE: |
2227 // Set character data if required | 2229 // Set character data if required |
2228 if ((inC64Fmt->format->type & D64_FMT_CHAR) && | 2230 if ((inC64Image->extraInfo[D64_EI_MODE] & D64_FMT_CHAR) && |
2229 inC64Image->charData[0].data == NULL) | 2231 inC64Image->charData[0].data == NULL) |
2230 { | 2232 { |
2231 // Check character ROM filename | 2233 // Check character ROM filename |
2232 if (optCharROMFilename == NULL) | 2234 if (optCharROMFilename == NULL) |
2233 optCharROMFilename = DM_DEF_CHARGEN; | 2235 optCharROMFilename = DM_DEF_CHARGEN; |