# HG changeset patch # User Matti Hamalainen # Date 1526089568 -10800 # Node ID 776aa43b2c578b772d074da8b7409e7acabfd2f0 # Parent 064fc2e3ee64da6a2513f998b84602de6cf5cd7d Tiny improvement in MC->FLI upconversion. diff -r 064fc2e3ee64 -r 776aa43b2c57 tools/gfxconv.c --- a/tools/gfxconv.c Sat May 12 04:12:46 2018 +0300 +++ b/tools/gfxconv.c Sat May 12 04:46:08 2018 +0300 @@ -1051,16 +1051,35 @@ if ((dst->type & D64_FMT_FLI) && (src->type & D64_FMT_FLI) == 0) { dmMsg(1, "Upconverting multicolor to FLI.\n"); - for (int i = 0; i < src->nbanks; i++) + for (int i = 0; i < dst->nbanks; i++) { memcpy(dst->color[i], src->color[0], dst->screenSize); memcpy(dst->screen[i], src->screen[0], dst->screenSize); + memcpy(dst->bitmap[i], src->bitmap[0], dst->bitmapSize); + memcpy(dst->charmem[i], src->charmem[0], dst->charmemSize); } - for (int i = 0; i < dst->nbanks; i++) + for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++) { - memcpy(dst->bitmap[i], src->bitmap[i], dst->bitmapSize); - memcpy(dst->charmem[i], src->charmem[i], dst->charmemSize); + const DMC64EncDecOp *op = &fmt->encdecOps[i]; + size_t size; + + // Check for last operator + if (op->type == DT_LAST) + break; + + // Check size + if (!dmC64GetOpSize(op, fmt, &size)) + return DMERR_INVALID_DATA; + + // Perform operation + switch (op->type) + { + case DT_EXTRA_DATA: + dst->extraData[op->bank] = dmMalloc0(size); + dst->extraDataSizes[op->bank] = size; + break; + } } } } diff -r 064fc2e3ee64 -r 776aa43b2c57 tools/lib64gfx.c --- a/tools/lib64gfx.c Sat May 12 04:12:46 2018 +0300 +++ b/tools/lib64gfx.c Sat May 12 04:46:08 2018 +0300 @@ -445,7 +445,7 @@ } -static int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img) +int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img) { switch (op->type) { @@ -482,7 +482,7 @@ } -static BOOL dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size) +BOOL dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size) { switch (op->type) { diff -r 064fc2e3ee64 -r 776aa43b2c57 tools/lib64gfx.h --- a/tools/lib64gfx.h Sat May 12 04:12:46 2018 +0300 +++ b/tools/lib64gfx.h Sat May 12 04:46:08 2018 +0300 @@ -224,6 +224,8 @@ int dmC64ConvertCSDataToImage(DMImage *img, int xoffs, int yoffs, const Uint8 *inBuf, int width, int height, BOOL multicolor, int *colors); int dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt); BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr); +int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img); +BOOL dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size); // C64 bitmap image allocation/freeing