comparison tools/lib64fmts.c @ 1739:83f50e431206

Implement support for ECI packed format.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 09 Jun 2018 13:07:49 +0300
parents 183d503b17a7
children 2dbb2b63f6b3
comparison
equal deleted inserted replaced
1738:b4992d9f72fe 1739:83f50e431206
759 (void) bitmap; 759 (void) bitmap;
760 return (c1 * C64_NCOLORS) + c2; 760 return (c1 * C64_NCOLORS) + c2;
761 } 761 }
762 762
763 763
764 static int fmtECIConvertBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt) 764 static int fmtConvertECIBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt)
765 { 765 {
766 if (!dmSetMixedColorC64Palette(dst)) 766 if (!dmSetMixedColorC64Palette(dst))
767 return DMERR_MALLOC; 767 return DMERR_MALLOC;
768 768
769 return dmC64ConvertGenericBMP2Image(dst, src, fmt); 769 return dmC64ConvertGenericBMP2Image(dst, src, fmt);
770 }
771
772
773 static int fmtProbeECIPacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
774 {
775 // XXX TODO: Perhaps count statistics about used byte values
776 // and compare to value in buf[2] which is the RLE marker
777 if (len > 128 && dmCompareAddr16(buf, 0, fmt->addr))
778 return DM_PROBE_SCORE_AVG;
779 else
780 return DM_PROBE_SCORE_FALSE;
781 }
782
783
784 static int fmtDecodeECIPacked(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
785 {
786 int res;
787 DMGrowBuf tmp;
788 DMGrowBuf mem;
789 DMCompParams cfg;
790
791 cfg.func = fmt->name;
792 cfg.type = DM_COMP_RLE_MARKER;
793 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
794 cfg.rleMarkerB = buf->data[0];
795
796 if ((res = dmDecodeGenericRLEAlloc(
797 &mem, dmGrowBufCreateFromOffs(&tmp, buf, 1), &cfg)) == DMERR_OK)
798 res = dmC64DecodeGenericBMP(img, &mem, fmt);
799
800 dmGrowBufFree(&mem);
801 return res;
770 } 802 }
771 803
772 804
773 // 805 //
774 // Helper macros for defining screen ram layouts 806 // Helper macros for defining screen ram layouts
855 { DO_COPY , DS_SCREEN_RAM , 0x4400, 1, 0, NULL, NULL }, 887 { DO_COPY , DS_SCREEN_RAM , 0x4400, 1, 0, NULL, NULL },
856 { DO_COPY , DS_COLOR_RAM , 0x4800, 0, 0, NULL, NULL }, 888 { DO_COPY , DS_COLOR_RAM , 0x4800, 0, 0, NULL, NULL },
857 { DO_DEC_FUNC , 0 , 0x0000, 0, 0, fmtTruePaintGetLaceType, NULL }, 889 { DO_DEC_FUNC , 0 , 0x0000, 0, 0, fmtTruePaintGetLaceType, NULL },
858 { DO_LAST , 0 , 0 , 0, 0, NULL, NULL }, 890 { DO_LAST , 0 , 0 , 0, 0, NULL, NULL },
859 }, 891 },
892
893 { // #7: ECI Graphic Editor Hires FLI
894 { DO_COPY , DS_BITMAP_RAM , 0x0000, 0, 0, NULL, NULL },
895 DEF_SCREEN_RAMS_8(0x2000, 0, 0x400),
896 { DO_COPY , DS_BITMAP_RAM , 0x4000, 1, 0, NULL, NULL },
897 DEF_SCREEN_RAMS_8(0x6000, 8, 0x400),
898 { DO_DEC_FUNC , 0 , 0 , 0, 0, fmtECIGetLaceType, NULL },
899 { DO_LAST , 0 , 0 , 0, 0, NULL, NULL },
900 },
860 }; 901 };
861 902
862 903
863 // 904 //
864 // Array with data for supported formats 905 // Array with data for supported formats
1181 "eci", "ECI Graphic Editor 1.0 (unpacked)", 0x4000, 32770, DM_FMT_RD, 1222 "eci", "ECI Graphic Editor 1.0 (unpacked)", 0x4000, 32770, DM_FMT_RD,
1182 C64_SCR_WIDTH, C64_SCR_HEIGHT, 1223 C64_SCR_WIDTH, C64_SCR_HEIGHT,
1183 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT, 1224 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
1184 NULL, 1225 NULL,
1185 NULL, NULL, 1226 NULL, NULL,
1186 fmtECIConvertBMP2Image, NULL, 1227 fmtConvertECIBMP2Image, NULL,
1187 fmtGetPixelECI, 1228 fmtGetPixelECI,
1188 { 1229 { }, &dmC64CommonFormatOps[7]
1189 { DO_COPY , DS_BITMAP_RAM , 0x0000, 0, 0, NULL, NULL }, 1230 },
1190 DEF_SCREEN_RAMS_8(0x2000, 0, 0x400), 1231
1191 { DO_COPY , DS_BITMAP_RAM , 0x4000, 1, 0, NULL, NULL }, 1232 {
1192 DEF_SCREEN_RAMS_8(0x6000, 8, 0x400), 1233 D64_FMT_HIRES | D64_FMT_FLI,
1193 { DO_DEC_FUNC , 0 , 0 , 0, 0, fmtECIGetLaceType, NULL }, 1234 "ecp", "ECI Graphic Editor 1.0 (packed)", 0x4000, 0, DM_FMT_RD,
1194 { DO_LAST , 0 , 0 , 0, 0, NULL, NULL }, 1235 C64_SCR_WIDTH, C64_SCR_HEIGHT,
1195 }, 1236 C64_SCR_CH_WIDTH, C64_SCR_CH_HEIGHT,
1196 NULL 1237 fmtProbeECIPacked,
1238 fmtDecodeECIPacked, NULL,
1239 fmtConvertECIBMP2Image, NULL,
1240 fmtGetPixelECI,
1241 { }, &dmC64CommonFormatOps[7]
1197 }, 1242 },
1198 1243
1199 { 1244 {
1200 D64_FMT_MC, "xx1", "Unknown $2000 format (unpacked)", 0x2000, 10242, DM_FMT_RDWR, 1245 D64_FMT_MC, "xx1", "Unknown $2000 format (unpacked)", 0x2000, 10242, DM_FMT_RDWR,
1201 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, 1246 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,