From aa8b7f65c5313a17ec40067557c62afb5ca55d8a Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Sat, 21 Oct 2017 19:22:22 +0100 Subject: [PATCH 1/2] Added a different code path to calculate the hash for Atari Lynx ROMs --- cheevos/cheevos.c | 60 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 977e38a9cf..e9f4408278 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -2866,17 +2866,18 @@ static int cheevos_iterate(coro_t* coro) /* Negative values because CORO_SUB generates positive values */ SNES_MD5 = -1, GENESIS_MD5 = -2, - NES_MD5 = -3, - GENERIC_MD5 = -4, - EVAL_MD5 = -5, - FILL_MD5 = -6, - GET_GAMEID = -7, - GET_CHEEVOS = -8, - LOGIN = -9, - HTTP_GET = -10, - DEACTIVATE = -11, - PLAYING = -12, - DELAY = -13, + LYNX_MD5 = -3, + NES_MD5 = -4, + GENERIC_MD5 = -5, + EVAL_MD5 = -6, + FILL_MD5 = -7, + GET_GAMEID = -8, + GET_CHEEVOS = -9, + LOGIN = -10, + HTTP_GET = -11, + DEACTIVATE = -12, + PLAYING = -13, + DELAY = -14, }; static const uint32_t genesis_exts[] = @@ -2907,12 +2908,19 @@ static int cheevos_iterate(coro_t* coro) 0 }; + static const uint32_t lynx_exts[] = + { + 0x0b888cf7U, /* lnx */ + 0 + }; + static cheevos_finder_t finders[] = { - {SNES_MD5, "SNES (8Mb padding)", snes_exts}, - {GENESIS_MD5, "Genesis (6Mb padding)", genesis_exts}, - {NES_MD5, "NES (discards VROM)", NULL}, - {GENERIC_MD5, "Generic (plain content)", NULL}, + {SNES_MD5, "SNES (8Mb padding)", snes_exts}, + {GENESIS_MD5, "Genesis (6Mb padding)", genesis_exts}, + {LYNX_MD5, "Atari Lynx (only first 512 bytes)", lynx_exts}, + {NES_MD5, "NES (discards VROM)", NULL}, + {GENERIC_MD5, "Generic (plain content)", NULL}, }; CORO_ENTER() @@ -3208,6 +3216,28 @@ static int cheevos_iterate(coro_t* coro) MD5_Final(CHEEVOS_VAR_HASH, &CHEEVOS_VAR_MD5); CORO_GOTO(GET_GAMEID); + /************************************************************************** + * Info Tries to identify an Atari Lynx game + * Input CHEEVOS_VAR_INFO the content info + * Output CHEEVOS_VAR_GAMEID the Retro Achievements game ID, or 0 if not found + *************************************************************************/ + CORO_SUB(LYNX_MD5) + + if (CHEEVOS_VAR_LEN < 0x0240) + { + CHEEVOS_VAR_GAMEID = 0; + CORO_RET(); + } + + MD5_Init(&CHEEVOS_VAR_MD5); + + CHEEVOS_VAR_OFFSET = 0x0040; + CHEEVOS_VAR_COUNT = 0x0200; + CORO_GOSUB(EVAL_MD5); + + MD5_Final(CHEEVOS_VAR_HASH, &CHEEVOS_VAR_MD5); + CORO_GOTO(GET_GAMEID); + /************************************************************************** * Info Tries to identify a NES game * Input CHEEVOS_VAR_INFO the content info From 83f6e70bfa675014218fde1c9c95cd6b290571a4 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Sun, 22 Oct 2017 11:51:39 +0100 Subject: [PATCH 2/2] Removed commas from the last enumerations values --- cheevos/cheevos.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index e9f4408278..ff5bdd5e48 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -2861,6 +2861,7 @@ static int cheevos_iterate(coro_t* coro) size_t to_read = 4096; uint8_t *buffer = NULL; const char *end = NULL; + enum { /* Negative values because CORO_SUB generates positive values */ @@ -2877,7 +2878,7 @@ static int cheevos_iterate(coro_t* coro) HTTP_GET = -11, DEACTIVATE = -12, PLAYING = -13, - DELAY = -14, + DELAY = -14 }; static const uint32_t genesis_exts[] = @@ -2920,7 +2921,7 @@ static int cheevos_iterate(coro_t* coro) {GENESIS_MD5, "Genesis (6Mb padding)", genesis_exts}, {LYNX_MD5, "Atari Lynx (only first 512 bytes)", lynx_exts}, {NES_MD5, "NES (discards VROM)", NULL}, - {GENERIC_MD5, "Generic (plain content)", NULL}, + {GENERIC_MD5, "Generic (plain content)", NULL} }; CORO_ENTER()