Skip to content

Commit

Permalink
Add hashing for ZX Spectrum (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
CasualPokePlayer authored Sep 23, 2024
1 parent 037b129 commit b8dd574
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/rhash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -3129,6 +3129,7 @@ int rc_hash_generate_from_buffer(char hash[33], uint32_t console_id, const uint8
case RC_CONSOLE_VIRTUAL_BOY:
case RC_CONSOLE_WASM4:
case RC_CONSOLE_WONDERSWAN:
case RC_CONSOLE_ZX_SPECTRUM:
return rc_hash_buffer(hash, buffer, buffer_size);

case RC_CONSOLE_ARDUBOY:
Expand Down Expand Up @@ -3427,6 +3428,7 @@ int rc_hash_generate_from_file(char hash[33], uint32_t console_id, const char* p
case RC_CONSOLE_VIRTUAL_BOY:
case RC_CONSOLE_WASM4:
case RC_CONSOLE_WONDERSWAN:
case RC_CONSOLE_ZX_SPECTRUM:
/* generic whole-file hash - don't buffer */
return rc_hash_whole_file(hash, path);

Expand Down Expand Up @@ -3592,6 +3594,7 @@ static void rc_hash_initialize_dsk_iterator(struct rc_hash_iterator* iterator, c
/* check MSX first, as Apple II isn't supported by RetroArch, and RAppleWin won't use the iterator */
rc_hash_iterator_append_console(iterator, RC_CONSOLE_MSX);
rc_hash_iterator_append_console(iterator, RC_CONSOLE_AMSTRAD_PC);
rc_hash_iterator_append_console(iterator, RC_CONSOLE_ZX_SPECTRUM);
rc_hash_iterator_append_console(iterator, RC_CONSOLE_APPLE_II);
}

Expand Down Expand Up @@ -3744,6 +3747,10 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
{
iterator->consoles[0] = RC_CONSOLE_NINTENDO_3DS;
}
else if (rc_path_compare_extension(ext, "csw"))
{
iterator->consoles[0] = RC_CONSOLE_ZX_SPECTRUM;
}
break;

case 'd':
Expand Down Expand Up @@ -3929,6 +3936,10 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
{
iterator->consoles[0] = RC_CONSOLE_ELEKTOR_TV_GAMES_COMPUTER;
}
else if (rc_path_compare_extension(ext, "pzx"))
{
iterator->consoles[0] = RC_CONSOLE_ZX_SPECTRUM;
}
break;

case 'r':
Expand Down Expand Up @@ -3967,11 +3978,16 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
{
iterator->consoles[0] = RC_CONSOLE_THOMSONTO8; /* disk */
}
else if (rc_path_compare_extension(ext, "scl"))
{
iterator->consoles[0] = RC_CONSOLE_ZX_SPECTRUM;
}
break;

case 't':
if (rc_path_compare_extension(ext, "tap"))
{
/* also Commodore 64 and ZX Spectrum, but all are full file hashes */
iterator->consoles[0] = RC_CONSOLE_ORIC;
}
else if (rc_path_compare_extension(ext, "tic"))
Expand All @@ -3982,6 +3998,11 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
{
iterator->consoles[0] = RC_CONSOLE_ELEKTOR_TV_GAMES_COMPUTER;
}
else if (rc_path_compare_extension(ext, "trd") ||
rc_path_compare_extension(ext, "tzx"))
{
iterator->consoles[0] = RC_CONSOLE_ZX_SPECTRUM;
}
break;

case 'u':
Expand Down
4 changes: 4 additions & 0 deletions test/rhash/test_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,10 @@ void test_hash(void) {
TEST_PARAMS4(test_hash_full_file, RC_CONSOLE_WONDERSWAN, "test.ws", 524288, "68f0f13b598e0b66461bc578375c3888");
TEST_PARAMS4(test_hash_full_file, RC_CONSOLE_WONDERSWAN, "test.wsc", 4194304, "a247ec8a8c42e18fcb80702dfadac14b");

/* ZX Spectrum */
TEST_PARAMS4(test_hash_full_file, RC_CONSOLE_ZX_SPECTRUM, "test.tap", 1596, "714a9f455e616813dd5421c5b347e5e5");
TEST_PARAMS4(test_hash_full_file, RC_CONSOLE_ZX_SPECTRUM, "test.tzx", 14971, "93723e6d1100f9d1d448a27cf6618c47");

/* m3u support */
TEST(test_hash_m3u_buffered);
TEST(test_hash_m3u_with_comments);
Expand Down

0 comments on commit b8dd574

Please sign in to comment.