# HG changeset patch # User Matti Hamalainen # Date 1544009933 -7200 # Node ID e4dc8fbaa5adc9ecb03cacfe2585f12e9465b921 # Parent 430c010d97c16f4f704697eb26fe806f233c4d23 Improve IFF probing. diff -r 430c010d97c1 -r e4dc8fbaa5ad tools/libgfx.c --- a/tools/libgfx.c Wed Dec 05 13:33:45 2018 +0200 +++ b/tools/libgfx.c Wed Dec 05 13:38:53 2018 +0200 @@ -1505,13 +1505,11 @@ } DMIFF; -static int fmtProbeIFF(const Uint8 *buf, const size_t len) +static int fmtProbeIFF(const Uint8 *buf, const size_t len, const Uint32 id) { if (len > 32 && - DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 0)) == IFF_ID_FORM && ( - DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 8)) == IFF_ID_ILBM || - DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 8)) == IFF_ID_PBM || - DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 8)) == IFF_ID_ACBM)) + DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 0)) == IFF_ID_FORM && + DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 8)) == id) { if (DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 12)) == IFF_ID_BMHD) return DM_PROBE_SCORE_MAX; @@ -1523,6 +1521,24 @@ } +static int fmtProbeIFF_ILBM(const Uint8 *buf, const size_t len) +{ + return fmtProbeIFF(buf, len, IFF_ID_ILBM); +} + + +static int fmtProbeIFF_PBM(const Uint8 *buf, const size_t len) +{ + return fmtProbeIFF(buf, len, IFF_ID_PBM); +} + + +static int fmtProbeIFF_ACBM(const Uint8 *buf, const size_t len) +{ + return fmtProbeIFF(buf, len, IFF_ID_ACBM); +} + + static void dmMakeIFFChunkIDStr(DMIFFChunk *chunk) { chunk->idStr[0] = (chunk->id >> 24) & 0xff; @@ -2430,13 +2446,17 @@ { "lbm", "IFF ILBM (interleaved/old DP)", DM_IMGFMT_IFF_ILBM, DM_FMT_RDWR, - fmtProbeIFF, dmReadIFFImage, dmWriteIFFImage, + fmtProbeIFF_ILBM, dmReadIFFImage, dmWriteIFFImage, }, { "pbm", "IFF PBM (DP2e)", DM_IMGFMT_IFF_PBM, DM_FMT_RDWR, - fmtProbeIFF, dmReadIFFImage, dmWriteIFFImage, - fmtProbeIFF, dmReadIFFImage, dmWriteIFFImage, + fmtProbeIFF_PBM, dmReadIFFImage, dmWriteIFFImage, + }, + { + "acbm", "IFF ACBM (Amiga Basic)", + DM_IMGFMT_IFF_ACBM, DM_FMT_RDWR, + fmtProbeIFF_ACBM, dmReadIFFImage, dmWriteIFFImage, }, { "raw", "Plain bitplaned (planar or non-planar) RAW", diff -r 430c010d97c1 -r e4dc8fbaa5ad tools/libgfx.h --- a/tools/libgfx.h Wed Dec 05 13:33:45 2018 +0200 +++ b/tools/libgfx.h Wed Dec 05 13:38:53 2018 +0200 @@ -24,6 +24,7 @@ DM_IMGFMT_PCX, DM_IMGFMT_IFF_ILBM, DM_IMGFMT_IFF_PBM, + DM_IMGFMT_IFF_ACBM, DM_IMGFMT_RAW, DM_IMGFMT_ARAW, DM_IMGFMT_CDUMP,