comparison romdb.c @ 1416:11ac0b511cff

Support a couple of bootleg X-in-1 carts
author Michael Pavone <pavone@retrodev.com>
date Sat, 24 Jun 2017 13:55:54 -0700
parents f7d653bb8899
children 49d3c572b3f2
comparison
equal deleted inserted replaced
1415:f7d653bb8899 1416:11ac0b511cff
8 #include "menu.h" 8 #include "menu.h"
9 #include "xband.h" 9 #include "xband.h"
10 #include "realtec.h" 10 #include "realtec.h"
11 #include "nor.h" 11 #include "nor.h"
12 #include "sega_mapper.h" 12 #include "sega_mapper.h"
13 #include "multi_game.h"
13 14
14 #define DOM_TITLE_START 0x120 15 #define DOM_TITLE_START 0x120
15 #define DOM_TITLE_END 0x150 16 #define DOM_TITLE_END 0x150
16 #define TITLE_START DOM_TITLE_END 17 #define TITLE_START DOM_TITLE_END
17 #define TITLE_END (TITLE_START+48) 18 #define TITLE_END (TITLE_START+48)
299 rom_info configure_rom_heuristics(uint8_t *rom, uint32_t rom_size, memmap_chunk const *base_map, uint32_t base_chunks) 300 rom_info configure_rom_heuristics(uint8_t *rom, uint32_t rom_size, memmap_chunk const *base_map, uint32_t base_chunks)
300 { 301 {
301 rom_info info; 302 rom_info info;
302 info.name = get_header_name(rom); 303 info.name = get_header_name(rom);
303 info.regions = get_header_regions(rom); 304 info.regions = get_header_regions(rom);
305 info.is_save_lock_on = 0;
306 info.rom = rom;
307 info.rom_size = rom_size;
304 add_memmap_header(&info, rom, rom_size, base_map, base_chunks); 308 add_memmap_header(&info, rom, rom_size, base_map, base_chunks);
305 info.port1_override = info.port2_override = info.ext_override = info.mouse_mode = NULL; 309 info.port1_override = info.port2_override = info.ext_override = info.mouse_mode = NULL;
306 return info; 310 return info;
307 } 311 }
308 312
679 uint16_t *value = malloc(2); 683 uint16_t *value = malloc(2);
680 map->buffer = value; 684 map->buffer = value;
681 map->mask = 0; 685 map->mask = 0;
682 map->flags = MMAP_READ; 686 map->flags = MMAP_READ;
683 *value = strtol(tern_find_ptr_default(node, "value", "0"), NULL, 16); 687 *value = strtol(tern_find_ptr_default(node, "value", "0"), NULL, 16);
688 } else if (!strcmp(dtype, "multi-game")) {
689 state->info->mapper_start_index = state->ptr_index++;
690 //make a mirror copy of the ROM so we can efficiently support arbitrary start offsets
691 state->rom = realloc(state->rom, state->rom_size * 2);
692 memcpy(state->rom + state->rom_size, state->rom, state->rom_size);
693 state->rom_size *= 2;
694 //make room for an extra map entry
695 state->info->map_chunks+=1;
696 state->info->map = realloc(state->info->map, sizeof(memmap_chunk) * state->info->map_chunks);
697 memset(state->info->map + state->info->map_chunks - 1, 0, sizeof(memmap_chunk) * 1);
698 map = state->info->map + state->index;
699 map->buffer = state->rom;
700 map->mask = calc_mask(state->rom_size, start, end);
701 map->flags = MMAP_READ | MMAP_PTR_IDX | MMAP_CODE;
702 map->ptr_index = state->info->mapper_start_index;
703 map++;
704 state->index++;
705 map->start = 0xA13000;
706 map->end = 0xA13100;
707 map->mask = 0xFF;
708 map->write_16 = write_multi_game_w;
709 map->write_8 = write_multi_game_b;
684 } else { 710 } else {
685 fatal_error("Invalid device type %s for ROM DB map entry %d with address %s\n", dtype, state->index, key); 711 fatal_error("Invalid device type %s for ROM DB map entry %d with address %s\n", dtype, state->index, key);
686 } 712 }
687 state->index++; 713 state->index++;
688 } 714 }
740 } 766 }
741 if (!info.regions) { 767 if (!info.regions) {
742 info.regions = get_header_regions(rom); 768 info.regions = get_header_regions(rom);
743 } 769 }
744 770
771 info.is_save_lock_on = 0;
772 info.rom = vrom;
773 info.rom_size = rom_size;
745 tern_node *map = tern_find_node(entry, "map"); 774 tern_node *map = tern_find_node(entry, "map");
746 if (map) { 775 if (map) {
747 info.save_type = SAVE_NONE; 776 info.save_type = SAVE_NONE;
748 info.map_chunks = tern_count(map); 777 info.map_chunks = tern_count(map);
749 if (info.map_chunks) { 778 if (info.map_chunks) {
766 .num_els = info.map_chunks - base_chunks, 795 .num_els = info.map_chunks - base_chunks,
767 .ptr_index = 0 796 .ptr_index = 0
768 }; 797 };
769 tern_foreach(map, map_iter_fun, &state); 798 tern_foreach(map, map_iter_fun, &state);
770 memcpy(info.map + state.index, base_map, sizeof(memmap_chunk) * base_chunks); 799 memcpy(info.map + state.index, base_map, sizeof(memmap_chunk) * base_chunks);
800 info.rom = state.rom;
801 info.rom_size = state.rom_size;
771 } else { 802 } else {
772 add_memmap_header(&info, rom, rom_size, base_map, base_chunks); 803 add_memmap_header(&info, rom, rom_size, base_map, base_chunks);
773 } 804 }
774 } else { 805 } else {
775 add_memmap_header(&info, rom, rom_size, base_map, base_chunks); 806 add_memmap_header(&info, rom, rom_size, base_map, base_chunks);