# HG changeset patch # User Matti Hamalainen # Date 1526006810 -10800 # Node ID d987a4933e1ca1317be31afa69a5291c40493130 # Parent 5f9080d24f3cdbe614e4ddd9b994de52a8a60e3d Some dabbling work on basic C64 bitmap conversion. diff -r 5f9080d24f3c -r d987a4933e1c tools/gfxconv.c --- a/tools/gfxconv.c Fri May 11 05:31:46 2018 +0300 +++ b/tools/gfxconv.c Fri May 11 05:46:50 2018 +0300 @@ -1028,8 +1028,44 @@ int dmConvertC64Bitmap(DMC64Image **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt) { + DMC64Image *dst; + if (pdst == NULL || fmt == NULL || src == NULL) return DMERR_NULLPTR; + + if ((dst = *pdst = dmC64ImageAlloc(fmt)) == NULL) + return DMERR_MALLOC; + + if (src->type == dst->type) + { + for (int i = 0; i < dst->nbanks; i++) + { + memcpy(dst->color[i], src->color[i], dst->screenSize); + memcpy(dst->bitmap[i], src->bitmap[i], dst->bitmapSize); + memcpy(dst->screen[i], src->screen[i], dst->screenSize); + memcpy(dst->charmem[i], src->charmem[i], dst->charmemSize); + } + } + else + { + // Try to do some simple fixups + 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++) + { + memcpy(dst->color[i], src->color[0], dst->screenSize); + memcpy(dst->screen[i], src->screen[0], dst->screenSize); + } + + for (int i = 0; i < dst->nbanks; i++) + { + memcpy(dst->bitmap[i], src->bitmap[i], dst->bitmapSize); + memcpy(dst->charmem[i], src->charmem[i], dst->charmemSize); + } + } + } + return DMERR_OK; }