# HG changeset patch # User Matti Hamalainen # Date 1560365249 -10800 # Node ID ec47c60d26e2ec8a15dc1ae2a44c8b73c8ad753a # Parent dc8a443accdf3c410a07e02c1eb4efd160dff432 Improve Crest Super Hires FLI probing. diff -r dc8a443accdf -r ec47c60d26e2 tools/lib64fmts.c --- a/tools/lib64fmts.c Wed Jun 12 21:30:58 2019 +0300 +++ b/tools/lib64fmts.c Wed Jun 12 21:47:29 2019 +0300 @@ -1222,21 +1222,35 @@ } -static const Uint8 fmtCrestSHFLI_MagicID_1[] = +#define DM_CREST_SHFLI_BANKS 8 +#define DM_CREST_SHFLI_PTRS 8 +static const Uint8 fmtCrestSHFLI_Sprite_pointers[DM_CREST_SHFLI_BANKS][DM_CREST_SHFLI_PTRS] = { - 0x80, 0x84, 0x85, 0x89, 0x8A, 0x8E, 0x8F, 0x93 + { 0x80, 0x84, 0x85, 0x89, 0x8A, 0x8E, 0x8F, 0x93 }, + { 0x94, 0x98, 0x99, 0x9D, 0x9E, 0xA2, 0xA3, 0xA7 }, + { 0xA8, 0xAC, 0xAD, 0xB1, 0xB2, 0xB6, 0xB7, 0xBB }, + { 0xBC, 0xC0, 0xC1, 0xC5, 0xC6, 0xCA, 0xCB, 0xCF }, + { 0xD0, 0xD4, 0xD5, 0xD9, 0xDA, 0xDE, 0xDF, 0xE3 }, + { 0xE4, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE }, + { 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6 }, + { 0xF7, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E }, }; static int fmtProbeCrestSHFLI(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) { + // Unpacked variant if (buf->len == fmt->size && dmCompareAddr16(buf, 0, fmt->addr)) { - if (DM_MEMCMP_SIZE(buf->data + 0x03f8 + 2, fmtCrestSHFLI_MagicID_1) == 0) - return DM_PROBE_SCORE_MAX; - else - return DM_PROBE_SCORE_MAYBE; + int score = DM_PROBE_SCORE_MAYBE; + for (int nbank = 0; nbank < DM_CREST_SHFLI_BANKS; nbank++) + { + if (memcmp(buf->data + 2 + (nbank * 0x0400) + 0x03f8, + fmtCrestSHFLI_Sprite_pointers[nbank], DM_CREST_SHFLI_PTRS) == 0) + score += DM_PROBE_SCORE_GOOD; + } + return score; } return DM_PROBE_SCORE_FALSE;