From 60a2e7bf23dc0d4746807d565bfabe9a8c9fe417 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 29 Mar 2017 00:29:44 -0700 Subject: Allow games to be specified in ROM DB via sha1 instead of product ID. Added a new ROM DB memory map device type fixed for emulating simple fixed value copy protection registers. Used those two features to support Ya Se Chuan Shuo via a ROM DB entry. --- romdb.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'romdb.c') diff --git a/romdb.c b/romdb.c index cf463fd..48a76a7 100644 --- a/romdb.c +++ b/romdb.c @@ -3,6 +3,7 @@ #include "config.h" #include "romdb.h" #include "util.h" +#include "hash.h" #include "genesis.h" #include "menu.h" #include "xband.h" @@ -856,6 +857,12 @@ void map_iter_fun(char *key, tern_val val, void *data) map->mask = 0xFF; map->write_16 = menu_write_w; map->read_16 = menu_read_w; + } else if (!strcmp(dtype, "fixed")) { + uint16_t *value = malloc(2); + map->buffer = value; + map->mask = 0; + map->flags = MMAP_READ; + *value = strtol(tern_find_ptr_default(node, "value", "0"), NULL, 16); } else { fatal_error("Invalid device type %s for ROM DB map entry %d with address %s\n", dtype, state->index, key); } @@ -877,7 +884,15 @@ rom_info configure_rom(tern_node *rom_db, void *vrom, uint32_t rom_size, void *l } printf("Product ID: %s\n", product_id); - tern_node * entry = tern_find_ptr(rom_db, product_id); + uint8_t raw_hash[20]; + sha1(vrom, rom_size, raw_hash); + uint8_t hex_hash[41]; + bin_to_hex(hex_hash, raw_hash, 20); + printf("SHA1: %s\n", hex_hash); + tern_node * entry = tern_find_ptr(rom_db, hex_hash); + if (!entry) { + entry = tern_find_ptr(rom_db, product_id); + } if (!entry) { puts("Not found in ROM DB, examining header\n"); if (xband_detect(rom, rom_size)) { -- cgit v1.2.3