comparison 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
comparison
equal deleted inserted replaced
1304:5b90d7669eee 1305:5ceb316c479a
1 #include <stdlib.h> 1 #include <stdlib.h>
2 #include <string.h> 2 #include <string.h>
3 #include "config.h" 3 #include "config.h"
4 #include "romdb.h" 4 #include "romdb.h"
5 #include "util.h" 5 #include "util.h"
6 #include "hash.h"
6 #include "genesis.h" 7 #include "genesis.h"
7 #include "menu.h" 8 #include "menu.h"
8 #include "xband.h" 9 #include "xband.h"
9 #include "realtec.h" 10 #include "realtec.h"
10 11
854 //fake hardware for supporting menu 855 //fake hardware for supporting menu
855 map->buffer = NULL; 856 map->buffer = NULL;
856 map->mask = 0xFF; 857 map->mask = 0xFF;
857 map->write_16 = menu_write_w; 858 map->write_16 = menu_write_w;
858 map->read_16 = menu_read_w; 859 map->read_16 = menu_read_w;
860 } else if (!strcmp(dtype, "fixed")) {
861 uint16_t *value = malloc(2);
862 map->buffer = value;
863 map->mask = 0;
864 map->flags = MMAP_READ;
865 *value = strtol(tern_find_ptr_default(node, "value", "0"), NULL, 16);
859 } else { 866 } else {
860 fatal_error("Invalid device type %s for ROM DB map entry %d with address %s\n", dtype, state->index, key); 867 fatal_error("Invalid device type %s for ROM DB map entry %d with address %s\n", dtype, state->index, key);
861 } 868 }
862 state->index++; 869 state->index++;
863 } 870 }
875 } 882 }
876 product_id[i] = rom[GAME_ID_OFF + i]; 883 product_id[i] = rom[GAME_ID_OFF + i];
877 884
878 } 885 }
879 printf("Product ID: %s\n", product_id); 886 printf("Product ID: %s\n", product_id);
880 tern_node * entry = tern_find_ptr(rom_db, product_id); 887 uint8_t raw_hash[20];
888 sha1(vrom, rom_size, raw_hash);
889 uint8_t hex_hash[41];
890 bin_to_hex(hex_hash, raw_hash, 20);
891 printf("SHA1: %s\n", hex_hash);
892 tern_node * entry = tern_find_ptr(rom_db, hex_hash);
893 if (!entry) {
894 entry = tern_find_ptr(rom_db, product_id);
895 }
881 if (!entry) { 896 if (!entry) {
882 puts("Not found in ROM DB, examining header\n"); 897 puts("Not found in ROM DB, examining header\n");
883 if (xband_detect(rom, rom_size)) { 898 if (xband_detect(rom, rom_size)) {
884 return xband_configure_rom(rom_db, rom, rom_size, lock_on, lock_on_size, base_map, base_chunks); 899 return xband_configure_rom(rom_db, rom, rom_size, lock_on, lock_on_size, base_map, base_chunks);
885 } 900 }