comparison tools/lib64fmts.c @ 1777:a7f9e12bcd9b

Improve probing of FunPaint 2 packed vs. unpacked format variants.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 12 Jun 2018 18:20:00 +0300
parents aa427e68e114
children e8041923767d
comparison
equal deleted inserted replaced
1776:aa427e68e114 1777:a7f9e12bcd9b
574 static int fmtProbeFunPaint2(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) 574 static int fmtProbeFunPaint2(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
575 { 575 {
576 if (len > 30 && 576 if (len > 30 &&
577 dmCompareAddr16(buf, 0, fmt->addr) && 577 dmCompareAddr16(buf, 0, fmt->addr) &&
578 memcmp(buf + 2, fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) == 0) 578 memcmp(buf + 2, fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) == 0)
579 return DM_PROBE_SCORE_MAX; 579 {
580 else 580 // Unpacked variant
581 return DM_PROBE_SCORE_FALSE; 581 if (fmt->size != 0 && buf[14 + 2] == 0)
582 return DM_PROBE_SCORE_MAX;
583
584 // Packed variant
585 if (fmt->size == 0 && buf[14 + 2] != 0)
586 return DM_PROBE_SCORE_MAX;
587 }
588
589 return DM_PROBE_SCORE_FALSE;
582 } 590 }
583 591
584 592
585 static int fmtDecodeFunPaint2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) 593 static int fmtDecodeFunPaint2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
586 { 594 {
1508 { }, &dmC64CommonFormats[3] 1516 { }, &dmC64CommonFormats[3]
1509 }, 1517 },
1510 1518
1511 { 1519 {
1512 "fp2p", "FunPaint II (packed)", 0x3ff0, 0, DM_FMT_RDWR, 1520 "fp2p", "FunPaint II (packed)", 0x3ff0, 0, DM_FMT_RDWR,
1513 NULL, 1521 fmtProbeFunPaint2,
1514 fmtDecodeFunPaint2, fmtEncodeFunPaint2Packed, 1522 fmtDecodeFunPaint2, fmtEncodeFunPaint2Packed,
1515 { }, &dmC64CommonFormats[3] 1523 { }, &dmC64CommonFormats[3]
1516 }, 1524 },
1517 1525
1518 { 1526 {