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