Hash full Lynx file content

This commit is contained in:
Raphaël Zumer 2019-01-05 00:39:59 -05:00
parent 39209dd387
commit 4260f9ffbc

View File

@ -2615,7 +2615,7 @@ static int cheevos_iterate(coro_t *coro)
{
{SNES_MD5, "SNES (discards header)", snes_exts},
{GENESIS_MD5, "Genesis (6Mb padding)", genesis_exts},
{LYNX_MD5, "Atari Lynx (only first 512 bytes)", lynx_exts},
{LYNX_MD5, "Atari Lynx (discards header)", lynx_exts},
{NES_MD5, "NES (discards header)", NULL},
{GENERIC_MD5, "Generic (plain content)", NULL},
{FILENAME_MD5, "Generic (filename)", NULL}
@ -2955,16 +2955,21 @@ found:
*************************************************************************/
CORO_SUB(LYNX_MD5)
if (coro->len < 0x0240)
/* Checks for the existence of a headered Lynx file.
Unheadered files fall back to GENERIC_MD5. */
const int lynx_header_len = 0x40;
if (coro->len <= lynx_header_len ||
memcmp("LYNX", (void *)coro->data, 5) != 0)
{
coro->gameid = 0;
CORO_RET();
}
MD5_Init(&coro->md5);
coro->offset = 0x0040;
coro->count = 0x0200;
coro->offset = lynx_header_len;
coro->count = coro->len - lynx_header_len;
CORO_GOSUB(EVAL_MD5);
MD5_Final(coro->hash, &coro->md5);