comparison tools/lib64fmts.c @ 1850:3d6917948061

Backed out changeset 914dbb50139f
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 22 Jun 2018 23:10:20 +0300
parents 914dbb50139f
children 31c9884321b1
comparison
equal deleted inserted replaced
1849:914dbb50139f 1850:3d6917948061
709 709
710 return DM_PROBE_SCORE_FALSE; 710 return DM_PROBE_SCORE_FALSE;
711 } 711 }
712 712
713 713
714 714 #define FUNPAINT2_HEADER_SIZE (0x10)
715 715 static const char *fmtFunPaint2MagicID = "FUNPAINT (MT) ";
716 #define FUNPAINTER2_HEADER_SIZE (0x10) 716
717 static const char *fmtFunPainter2MagicID = "FUNPAINT (MT) "; 717
718 718 static int fmtProbeFunPaint2(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
719
720 static int fmtProbeFunPainter2(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
721 { 719 {
722 if (buf->len > 30 && 720 if (buf->len > 30 &&
723 dmCompareAddr16(buf, 0, fmt->addr) && 721 dmCompareAddr16(buf, 0, fmt->addr) &&
724 memcmp(buf->data + 2, fmtFunPainter2MagicID, strlen(fmtFunPainter2MagicID)) == 0) 722 memcmp(buf->data + 2, fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) == 0)
725 { 723 {
726 // Unpacked variant 724 // Unpacked variant
727 if (fmt->size != 0 && buf->data[14 + 2] == 0) 725 if (fmt->size != 0 && buf->data[14 + 2] == 0)
728 return DM_PROBE_SCORE_MAX; 726 return DM_PROBE_SCORE_MAX;
729 727
734 732
735 return DM_PROBE_SCORE_FALSE; 733 return DM_PROBE_SCORE_FALSE;
736 } 734 }
737 735
738 736
739 static int fmtDecodeFunPainter2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) 737 static int fmtDecodeFunPaint2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
740 { 738 {
741 int res; 739 int res;
742 DMGrowBuf tmp; 740 DMGrowBuf tmp;
743 741
744 // Check if the data is compressed 742 // Check if the data is compressed
750 cfg.func = fmt->name; 748 cfg.func = fmt->name;
751 cfg.type = DM_COMP_RLE_MARKER; 749 cfg.type = DM_COMP_RLE_MARKER;
752 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1; 750 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
753 cfg.rleMarkerB = buf->data[15]; 751 cfg.rleMarkerB = buf->data[15];
754 752
755 dmGrowBufCopyOffs(&tmp, buf, FUNPAINTER2_HEADER_SIZE, 1); 753 dmGrowBufCopyOffs(&tmp, buf, FUNPAINT2_HEADER_SIZE, 1);
756 tmp.len = tmp.size; 754 tmp.len = tmp.size;
757 755
758 if ((res = dmDecodeGenericRLEAlloc( 756 if ((res = dmDecodeGenericRLEAlloc(
759 &mem, &tmp, &cfg)) == DMERR_OK) 757 &mem, &tmp, &cfg)) == DMERR_OK)
760 res = dmC64DecodeGenericBMP(img, &mem, fmt); 758 res = dmC64DecodeGenericBMP(img, &mem, fmt);
762 dmGrowBufFree(&mem); 760 dmGrowBufFree(&mem);
763 dmGrowBufFree(&tmp); 761 dmGrowBufFree(&tmp);
764 } 762 }
765 else 763 else
766 { 764 {
767 res = dmC64DecodeGenericBMP(img, dmGrowBufConstCopyOffs(&tmp, buf, FUNPAINTER2_HEADER_SIZE), fmt); 765 res = dmC64DecodeGenericBMP(img, dmGrowBufConstCopyOffs(&tmp, buf, FUNPAINT2_HEADER_SIZE), fmt);
768 } 766 }
769 767
770 return res; 768 return res;
771 } 769 }
772 770
773 771
774 static int fmtEncodeFunPainter2Unpacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) 772 static int fmtEncodeFunPaint2Unpacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt)
775 { 773 {
776 // Add the header bits 774 // Add the header bits
777 if (!dmGrowBufPut(buf, (Uint8 *) fmtFunPainter2MagicID, strlen(fmtFunPainter2MagicID)) || 775 if (!dmGrowBufPut(buf, (Uint8 *) fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) ||
778 !dmGrowBufPutU8(buf, 0) || // 0 == unpacked variant 776 !dmGrowBufPutU8(buf, 0) || // 0 == unpacked variant
779 !dmGrowBufPutU8(buf, 0)) // RLE marker byte (not used in unpacked) 777 !dmGrowBufPutU8(buf, 0)) // RLE marker byte (not used in unpacked)
780 return DMERR_MALLOC; 778 return DMERR_MALLOC;
781 779
782 return dmC64EncodeGenericBMP(FALSE, buf, img, fmt); 780 return dmC64EncodeGenericBMP(FALSE, buf, img, fmt);
783 } 781 }
784 782
785 783
786 static int fmtEncodeFunPainter2Packed(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) 784 static int fmtEncodeFunPaint2Packed(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt)
787 { 785 {
788 int res; 786 int res;
789 DMGrowBuf mem; 787 DMGrowBuf mem;
790 DMCompParams cfg; 788 DMCompParams cfg;
791 789
801 cfg.rleMaxCountB = 255; 799 cfg.rleMaxCountB = 255;
802 800
803 dmGenericRLEAnalyze(&mem, &cfg); 801 dmGenericRLEAnalyze(&mem, &cfg);
804 802
805 // Add the header bits 803 // Add the header bits
806 if (!dmGrowBufPut(buf, (Uint8 *) fmtFunPainter2MagicID, strlen(fmtFunPainter2MagicID)) || 804 if (!dmGrowBufPut(buf, (Uint8 *) fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) ||
807 !dmGrowBufPutU8(buf, 1) || // non-zero == packed variant 805 !dmGrowBufPutU8(buf, 1) || // non-zero == packed variant
808 !dmGrowBufPutU8(buf, cfg.rleMarkerB)) 806 !dmGrowBufPutU8(buf, cfg.rleMarkerB))
809 { 807 {
810 res = DMERR_MALLOC; 808 res = DMERR_MALLOC;
811 goto out; 809 goto out;
818 dmGrowBufFree(&mem); 816 dmGrowBufFree(&mem);
819 return res; 817 return res;
820 } 818 }
821 819
822 820
823 static Uint8 fmtGetPixelFunPainter2( 821 static Uint8 fmtGetPixelFunPaint2(
824 const DMC64Image *img, const int bmoffs, const int scroffs, 822 const DMC64Image *img, const int bmoffs, const int scroffs,
825 const int shift, const int bitmap, const int rasterX, const int rasterY) 823 const int shift, const int bitmap, const int rasterX, const int rasterY)
826 { 824 {
827 const int vbank = (rasterY & 7) + (bitmap * 8); 825 const int vbank = (rasterY & 7) + (bitmap * 8);
828 (void) rasterX; 826 (void) rasterX;
1022 { DO_COPY , DS_SCREEN_RAM , 0x1f40, 0, 0, 0, NULL, NULL }, 1020 { DO_COPY , DS_SCREEN_RAM , 0x1f40, 0, 0, 0, NULL, NULL },
1023 { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL }, 1021 { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL },
1024 } 1022 }
1025 }, 1023 },
1026 1024
1027 { // #3: FunPainter II 1025 { // #3: FunPaint II
1028 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, 1026 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE,
1029 C64_SCR_WIDTH, C64_SCR_HEIGHT, 1027 C64_SCR_WIDTH, C64_SCR_HEIGHT,
1030 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, 1028 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1031 NULL, NULL, 1029 NULL, NULL,
1032 fmtGetPixelFunPainter2, 1030 fmtGetPixelFunPaint2,
1033 { 1031 {
1034 DEF_SCREEN_RAMS_8(0x0000, 0, 0x400), 1032 DEF_SCREEN_RAMS_8(0x0000, 0, 0x400),
1035 { DO_COPY , DS_BITMAP_RAM , 0x2000, 0, 0 , 0, NULL, NULL }, 1033 { DO_COPY , DS_BITMAP_RAM , 0x2000, 0, 0 , 0, NULL, NULL },
1036 { DO_COPY , DS_EXTRA_DATA , 0x3f40, 0, 100, 0, NULL, NULL }, 1034 { DO_COPY , DS_EXTRA_DATA , 0x3f40, 0, 100, 0, NULL, NULL },
1037 { DO_COPY , DS_COLOR_RAM , 0x4000, 0, 0 , 0, NULL, NULL }, 1035 { DO_COPY , DS_COLOR_RAM , 0x4000, 0, 0 , 0, NULL, NULL },
1652 }, 1650 },
1653 NULL 1651 NULL
1654 }, 1652 },
1655 1653
1656 { 1654 {
1657 "fp2", "FunPainter II (unpacked)", 0x3ff0, 33694, DM_FMT_RDWR, 1655 "fp2", "FunPaint II (unpacked)", 0x3ff0, 33694, DM_FMT_RDWR,
1658 fmtProbeFunPainter2, 1656 fmtProbeFunPaint2,
1659 fmtDecodeFunPainter2, fmtEncodeFunPainter2Unpacked, 1657 fmtDecodeFunPaint2, fmtEncodeFunPaint2Unpacked,
1660 { }, &dmC64CommonFormats[3] 1658 { }, &dmC64CommonFormats[3]
1661 }, 1659 },
1662 1660
1663 { 1661 {
1664 "fp2p", "FunPainter II (packed)", 0x3ff0, 0, DM_FMT_RDWR, 1662 "fp2p", "FunPaint II (packed)", 0x3ff0, 0, DM_FMT_RDWR,
1665 fmtProbeFunPainter2, 1663 fmtProbeFunPaint2,
1666 fmtDecodeFunPainter2, fmtEncodeFunPainter2Packed, 1664 fmtDecodeFunPaint2, fmtEncodeFunPaint2Packed,
1667 { }, &dmC64CommonFormats[3] 1665 { }, &dmC64CommonFormats[3]
1668 }, 1666 },
1669 1667
1670 { 1668 {
1671 "gun", "GunPaint (unpacked)", 0x4000, 0, DM_FMT_RDWR, 1669 "gun", "GunPaint (unpacked)", 0x4000, 0, DM_FMT_RDWR,
1674 { 1672 {
1675 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, 1673 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE,
1676 C64_SCR_WIDTH, C64_SCR_HEIGHT, 1674 C64_SCR_WIDTH, C64_SCR_HEIGHT,
1677 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, 1675 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
1678 NULL, NULL, 1676 NULL, NULL,
1679 fmtGetPixelFunPainter2, // The format is essentially same as FP2 1677 fmtGetPixelFunPaint2, // The format is essentially same as FP2
1680 { 1678 {
1681 DEF_SCREEN_RAMS_8(0x0000, 0, 0x400), 1679 DEF_SCREEN_RAMS_8(0x0000, 0, 0x400),
1682 { DO_COPY , DS_BITMAP_RAM , 0x2000, 0, 0 , 0, NULL, NULL }, 1680 { DO_COPY , DS_BITMAP_RAM , 0x2000, 0, 0 , 0, NULL, NULL },
1683 { DO_COPY , DS_EXTRA_DATA , 0x3f4f, 0, 177, 0, NULL, NULL }, 1681 { DO_COPY , DS_EXTRA_DATA , 0x3f4f, 0, 177, 0, NULL, NULL },
1684 { DO_COPY , DS_COLOR_RAM , 0x4000, 0, 0 , 0, NULL, NULL }, 1682 { DO_COPY , DS_COLOR_RAM , 0x4000, 0, 0 , 0, NULL, NULL },