comparison tools/lib64fmts.c @ 2187:ec47c60d26e2

Improve Crest Super Hires FLI probing.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 12 Jun 2019 21:47:29 +0300
parents dc8a443accdf
children 9b7d5e219d4b
comparison
equal deleted inserted replaced
2186:dc8a443accdf 2187:ec47c60d26e2
1220 *col = color3 ? color3 : ( color2 ? color2 : color1 ); 1220 *col = color3 ? color3 : ( color2 ? color2 : color1 );
1221 return DMERR_OK; 1221 return DMERR_OK;
1222 } 1222 }
1223 1223
1224 1224
1225 static const Uint8 fmtCrestSHFLI_MagicID_1[] = 1225 #define DM_CREST_SHFLI_BANKS 8
1226 { 1226 #define DM_CREST_SHFLI_PTRS 8
1227 0x80, 0x84, 0x85, 0x89, 0x8A, 0x8E, 0x8F, 0x93 1227 static const Uint8 fmtCrestSHFLI_Sprite_pointers[DM_CREST_SHFLI_BANKS][DM_CREST_SHFLI_PTRS] =
1228 {
1229 { 0x80, 0x84, 0x85, 0x89, 0x8A, 0x8E, 0x8F, 0x93 },
1230 { 0x94, 0x98, 0x99, 0x9D, 0x9E, 0xA2, 0xA3, 0xA7 },
1231 { 0xA8, 0xAC, 0xAD, 0xB1, 0xB2, 0xB6, 0xB7, 0xBB },
1232 { 0xBC, 0xC0, 0xC1, 0xC5, 0xC6, 0xCA, 0xCB, 0xCF },
1233 { 0xD0, 0xD4, 0xD5, 0xD9, 0xDA, 0xDE, 0xDF, 0xE3 },
1234 { 0xE4, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE },
1235 { 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6 },
1236 { 0xF7, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E },
1228 }; 1237 };
1229 1238
1230 1239
1231 static int fmtProbeCrestSHFLI(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) 1240 static int fmtProbeCrestSHFLI(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
1232 { 1241 {
1242 // Unpacked variant
1233 if (buf->len == fmt->size && 1243 if (buf->len == fmt->size &&
1234 dmCompareAddr16(buf, 0, fmt->addr)) 1244 dmCompareAddr16(buf, 0, fmt->addr))
1235 { 1245 {
1236 if (DM_MEMCMP_SIZE(buf->data + 0x03f8 + 2, fmtCrestSHFLI_MagicID_1) == 0) 1246 int score = DM_PROBE_SCORE_MAYBE;
1237 return DM_PROBE_SCORE_MAX; 1247 for (int nbank = 0; nbank < DM_CREST_SHFLI_BANKS; nbank++)
1238 else 1248 {
1239 return DM_PROBE_SCORE_MAYBE; 1249 if (memcmp(buf->data + 2 + (nbank * 0x0400) + 0x03f8,
1250 fmtCrestSHFLI_Sprite_pointers[nbank], DM_CREST_SHFLI_PTRS) == 0)
1251 score += DM_PROBE_SCORE_GOOD;
1252 }
1253 return score;
1240 } 1254 }
1241 1255
1242 return DM_PROBE_SCORE_FALSE; 1256 return DM_PROBE_SCORE_FALSE;
1243 } 1257 }
1244 1258