Mercurial > repos > blastem
diff romdb.c @ 1305:5ceb316c479a
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.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 29 Mar 2017 00:29:44 -0700 |
parents | 65f03a0a426a |
children | 2fc444b69351 |
line wrap: on
line diff
--- a/romdb.c Tue Mar 28 09:39:54 2017 -0700 +++ b/romdb.c Wed Mar 29 00:29:44 2017 -0700 @@ -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 @@ 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 @@ } 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)) {