# HG changeset patch # User Matti Hamalainen # Date 1528815395 -10800 # Node ID aa427e68e1149c0ee27c46235c547da35dff8eb8 # Parent 4e4d54135baf649ca3bf822778378a6c7e015597 Theoretically fix Gun Paint format writing. diff -r 4e4d54135baf -r aa427e68e114 tools/lib64fmts.c --- a/tools/lib64fmts.c Tue Jun 12 17:12:48 2018 +0300 +++ b/tools/lib64fmts.c Tue Jun 12 17:56:35 2018 +0300 @@ -251,17 +251,32 @@ } +static const char *fmtGunPaintMagicID = "GUNPAINT (JZ) "; +#define fmtGunPaintMagicLen (14) +#define fmtGunPaintMagicOffs (0x3e8) + static int fmtProbeGunPaint(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) { if (len > 0x400 && dmCompareAddr16(buf, 0, fmt->addr) && - memcmp(buf + 0x3ea, "GUNPAINT (JZ) ", 14) == 0) + memcmp(buf + fmtGunPaintMagicOffs + 2, fmtGunPaintMagicID, fmtGunPaintMagicLen) == 0) return DM_PROBE_SCORE_MAX; return DM_PROBE_SCORE_FALSE; } +static BOOL fmtEncodeGunPaint(const DMC64EncDecOp *op, DMGrowBuf *buf, + const DMC64Image *img, const DMC64ImageFormat *fmt) +{ + (void) op; + (void) img; + (void) fmt; + memcpy(buf->data + fmtGunPaintMagicOffs, fmtGunPaintMagicID, fmtGunPaintMagicLen); + return TRUE; +} + + static int fmtProbeAmicaPaintPacked(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) { size_t i, n; @@ -1501,7 +1516,7 @@ }, { - "gun", "GunPaint (unpacked)", 0x4000, 0, DM_FMT_RD, + "gun", "GunPaint (unpacked)", 0x4000, 0, DM_FMT_RDWR, fmtProbeGunPaint, NULL, NULL, { @@ -1519,6 +1534,7 @@ { DO_COPY , DS_BITMAP_RAM , 0x6400, 1, 0, NULL, NULL }, { DO_COPY , DS_EXTRA_DATA , 0x47e8, 1, 20, NULL, NULL }, { DO_DEC_FUNC , 0 , 0x2742, 0, 1, fmtTruePaintGetLaceType, NULL }, + { DO_ENC_FUNC , 0 , fmtGunPaintMagicOffs, 0, fmtGunPaintMagicLen, NULL, fmtEncodeGunPaint }, { DO_LAST , 0 , 0 , 0, 0, NULL, NULL }, } },