comparison romdb.c @ 1287:65f03a0a426a

Add Mega Everdrive style header detection for homebrew using the SSF2 mapper, though without the Mega Everdrive extensions. Properly invalidate translated code on a bank switch when using the SSF2/Sega mapper
author Michael Pavone <pavone@retrodev.com>
date Sun, 19 Mar 2017 00:34:15 -0700
parents 34113230fd88
children 5ceb316c479a
comparison
equal deleted inserted replaced
1286:ca0383656a82 1287:65f03a0a426a
293 { 293 {
294 context->mem_pointers[gen->mapper_start_index + i] = gen->cart + 0x40000*gen->bank_regs[i]; 294 context->mem_pointers[gen->mapper_start_index + i] = gen->cart + 0x40000*gen->bank_regs[i];
295 } 295 }
296 } 296 }
297 } else { 297 } else {
298 m68k_invalidate_code_range(gen->m68k, address * 0x80000, (address + 1) * 0x80000);
298 context->mem_pointers[gen->mapper_start_index + address] = gen->cart + 0x40000*value; 299 context->mem_pointers[gen->mapper_start_index + address] = gen->cart + 0x40000*value;
299 } 300 }
300 return context; 301 return context;
301 } 302 }
302 303
506 if (size > rom_end) { 507 if (size > rom_end) {
507 rom_end = size; 508 rom_end = size;
508 } else if (rom_end > nearest_pow2(size)) { 509 } else if (rom_end > nearest_pow2(size)) {
509 rom_end = nearest_pow2(size); 510 rom_end = nearest_pow2(size);
510 } 511 }
511 if (rom[RAM_ID] == 'R' && rom[RAM_ID+1] == 'A') { 512 if (size >= 0x80000 && !memcmp("SEGA SSF", rom + 0x100, 8)) {
513 info->mapper_start_index = 0;
514 info->map_chunks = base_chunks + 9;
515 info->map = malloc(sizeof(memmap_chunk) * info->map_chunks);
516 memset(info->map, 0, sizeof(memmap_chunk)*9);
517 memcpy(info->map+9, base_map, sizeof(memmap_chunk) * base_chunks);
518
519 info->map[0].start = 0;
520 info->map[0].end = 0x80000;
521 info->map[0].mask = 0xFFFFFF;
522 info->map[0].flags = MMAP_READ;
523 info->map[0].buffer = rom;
524
525 for (int i = 1; i < 8; i++)
526 {
527 info->map[i].start = i * 0x80000;
528 info->map[i].end = (i + 1) * 0x80000;
529 info->map[i].mask = 0x7FFFF;
530 info->map[i].buffer = (i + 1) * 0x80000 <= size ? rom + i * 0x80000 : rom;
531 info->map[i].ptr_index = i;
532 info->map[i].flags = MMAP_READ | MMAP_PTR_IDX | MMAP_CODE;
533
534 }
535 info->map[8].start = 0xA13000;
536 info->map[8].end = 0xA13100;
537 info->map[8].mask = 0xFF;
538 info->map[8].write_16 = (write_16_fun)write_bank_reg_w;
539 info->map[8].write_8 = (write_8_fun)write_bank_reg_b;
540 } else if (rom[RAM_ID] == 'R' && rom[RAM_ID+1] == 'A') {
512 uint32_t ram_start = get_u32be(rom + RAM_START); 541 uint32_t ram_start = get_u32be(rom + RAM_START);
513 uint32_t ram_end = get_u32be(rom + RAM_END); 542 uint32_t ram_end = get_u32be(rom + RAM_END);
514 uint32_t ram_flags = info->save_type = rom[RAM_FLAGS] & RAM_FLAG_MASK; 543 uint32_t ram_flags = info->save_type = rom[RAM_FLAGS] & RAM_FLAG_MASK;
515 ram_start &= 0xFFFFFE; 544 ram_start &= 0xFFFFFE;
516 ram_end |= 1; 545 ram_end |= 1;
797 map->end = start + (i + 1) * 0x80000; 826 map->end = start + (i + 1) * 0x80000;
798 map->mask = 0x7FFFF; 827 map->mask = 0x7FFFF;
799 map->buffer = state->rom + offset + i * 0x80000; 828 map->buffer = state->rom + offset + i * 0x80000;
800 map->ptr_index = state->ptr_index++; 829 map->ptr_index = state->ptr_index++;
801 if (i < 3 || !save_device) { 830 if (i < 3 || !save_device) {
802 map->flags = MMAP_READ | MMAP_PTR_IDX; 831 map->flags = MMAP_READ | MMAP_PTR_IDX | MMAP_CODE;
803 } else { 832 } else {
804 map->flags = MMAP_READ | MMAP_PTR_IDX | MMAP_FUNC_NULL; 833 map->flags = MMAP_READ | MMAP_PTR_IDX | MMAP_CODE | MMAP_FUNC_NULL;
805 if (!strcmp(save_device, "SRAM")) { 834 if (!strcmp(save_device, "SRAM")) {
806 process_sram_def(key, state); 835 process_sram_def(key, state);
807 map->read_16 = (read_16_fun)read_sram_w;//these will only be called when mem_pointers[2] == NULL 836 map->read_16 = (read_16_fun)read_sram_w;//these will only be called when mem_pointers[2] == NULL
808 map->read_8 = (read_8_fun)read_sram_b; 837 map->read_8 = (read_8_fun)read_sram_b;
809 map->write_16 = (write_16_fun)write_sram_area_w;//these will be called all writes to the area 838 map->write_16 = (write_16_fun)write_sram_area_w;//these will be called all writes to the area