comparison tools/gfxconv.c @ 1493:d987a4933e1c

Some dabbling work on basic C64 bitmap conversion.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 May 2018 05:46:50 +0300
parents 665a0b917d22
children 3b220604ae3c
comparison
equal deleted inserted replaced
1492:5f9080d24f3c 1493:d987a4933e1c
1026 } 1026 }
1027 1027
1028 1028
1029 int dmConvertC64Bitmap(DMC64Image **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt) 1029 int dmConvertC64Bitmap(DMC64Image **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt)
1030 { 1030 {
1031 DMC64Image *dst;
1032
1031 if (pdst == NULL || fmt == NULL || src == NULL) 1033 if (pdst == NULL || fmt == NULL || src == NULL)
1032 return DMERR_NULLPTR; 1034 return DMERR_NULLPTR;
1035
1036 if ((dst = *pdst = dmC64ImageAlloc(fmt)) == NULL)
1037 return DMERR_MALLOC;
1038
1039 if (src->type == dst->type)
1040 {
1041 for (int i = 0; i < dst->nbanks; i++)
1042 {
1043 memcpy(dst->color[i], src->color[i], dst->screenSize);
1044 memcpy(dst->bitmap[i], src->bitmap[i], dst->bitmapSize);
1045 memcpy(dst->screen[i], src->screen[i], dst->screenSize);
1046 memcpy(dst->charmem[i], src->charmem[i], dst->charmemSize);
1047 }
1048 }
1049 else
1050 {
1051 // Try to do some simple fixups
1052 if ((dst->type & D64_FMT_FLI) && (src->type & D64_FMT_FLI) == 0)
1053 {
1054 dmMsg(1, "Upconverting multicolor to FLI.\n");
1055 for (int i = 0; i < src->nbanks; i++)
1056 {
1057 memcpy(dst->color[i], src->color[0], dst->screenSize);
1058 memcpy(dst->screen[i], src->screen[0], dst->screenSize);
1059 }
1060
1061 for (int i = 0; i < dst->nbanks; i++)
1062 {
1063 memcpy(dst->bitmap[i], src->bitmap[i], dst->bitmapSize);
1064 memcpy(dst->charmem[i], src->charmem[i], dst->charmemSize);
1065 }
1066 }
1067 }
1068
1033 return DMERR_OK; 1069 return DMERR_OK;
1034 } 1070 }
1035 1071
1036 1072
1037 int dmWriteBitmap(const char *filename, const DMC64Image *image, const DMC64ImageFormat *fmt) 1073 int dmWriteBitmap(const char *filename, const DMC64Image *image, const DMC64ImageFormat *fmt)