.MD cartridge hardware (SRAM, etc) should not be reseted when emulating MCD hardware (fixes random crash when loading Mode 1 cartridge)

This commit is contained in:
EkeEke 2012-07-22 19:51:42 +02:00
parent f3756f260c
commit 2a381dd290
2 changed files with 47 additions and 32 deletions

View File

@ -258,8 +258,21 @@ void gen_reset(int hard_reset)
/* 8-bit / 16-bit modes */ /* 8-bit / 16-bit modes */
if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
{ {
/* reset cartridge hardware & mapping */ if (system_hw == SYSTEM_MCD)
md_cart_reset(hard_reset); {
/* reset CD hardware */
scd_reset(1);
/* reset & halt SUB-CPU */
s68k.cycles = 0;
s68k_pulse_reset();
s68k_pulse_halt();
}
else
{
/* reset MD cartridge hardware */
md_cart_reset(hard_reset);
}
/* Z80 bus is released & Z80 is reseted */ /* Z80 bus is released & Z80 is reseted */
m68k.memory_map[0xa0].read8 = m68k_read_bus_8; m68k.memory_map[0xa0].read8 = m68k_read_bus_8;
@ -301,17 +314,6 @@ void gen_reset(int hard_reset)
} }
} }
if (system_hw == SYSTEM_MCD)
{
/* reset CD hardware */
scd_reset(1);
/* reset & halt SUB-CPU */
s68k.cycles = 0;
s68k_pulse_reset();
s68k_pulse_halt();
}
/* reset MAIN-CPU */ /* reset MAIN-CPU */
m68k_pulse_reset(); m68k_pulse_reset();
} }
@ -376,21 +378,29 @@ void gen_tmss_w(unsigned int offset, unsigned int data)
void gen_bankswitch_w(unsigned int data) void gen_bankswitch_w(unsigned int data)
{ {
if (data & 1) if (system_hw == SYSTEM_MD)
{ {
/* enable cartridge ROM */ if (data & 1)
m68k.memory_map[0].base = cart.base; {
} /* enable cartridge ROM */
else m68k.memory_map[0].base = cart.base;
{ }
/* enable internal BOOT ROM */ else
m68k.memory_map[0].base = boot_rom; {
/* enable internal BOOT ROM */
m68k.memory_map[0].base = boot_rom;
}
} }
} }
unsigned int gen_bankswitch_r(void) unsigned int gen_bankswitch_r(void)
{ {
return (m68k.memory_map[0].base == cart.base); if (system_hw == SYSTEM_MD)
{
return (m68k.memory_map[0].base == cart.base);
}
return 0xff;
} }

View File

@ -431,12 +431,6 @@ int load_bios(void)
/* loaded BIOS region */ /* loaded BIOS region */
system_bios = (system_bios & 0xf0) | (region_code >> 4); system_bios = (system_bios & 0xf0) | (region_code >> 4);
}
else
{
/* CD BOOT ROM disabled (SYSTEM ERROR) */
memset(scd.bootrom, 0xff, sizeof(scd.bootrom));
} }
return size; return size;
@ -543,13 +537,14 @@ int load_rom(char *filename)
ggenie_shutdown(); ggenie_shutdown();
areplay_shutdown(); areplay_shutdown();
/* unload any existing disc */
if (romtype == SYSTEM_MCD) if (romtype == SYSTEM_MCD)
{ {
/* unload CD image */
cdd_unload(); cdd_unload();
} }
else else
{ {
/* no CD image loaded */
cdd.loaded = 0; cdd.loaded = 0;
} }
@ -590,11 +585,12 @@ int load_rom(char *filename)
/* load file into ROM buffer */ /* load file into ROM buffer */
char extension[4]; char extension[4];
int size = load_archive(filename, cart.rom, sizeof(cart.rom), extension); int size = load_archive(filename, cart.rom, sizeof(cart.rom), extension);
if (!size) return(0);
/* mark CD BIOS as unloaded */ /* mark CD BIOS as unloaded */
system_bios &= ~0x10; system_bios &= ~0x10;
if (!size) return(0);
/* convert lower case to upper case */ /* convert lower case to upper case */
*(uint32 *)(extension) &= 0xdfdfdfdf; *(uint32 *)(extension) &= 0xdfdfdfdf;
@ -721,8 +717,11 @@ int load_rom(char *filename)
/* boot from CD */ /* boot from CD */
scd.cartridge.boot = 0x00; scd.cartridge.boot = 0x00;
/* CD unloaded */ /* no CD image loaded */
cdd.loaded = 0; cdd.loaded = 0;
/* clear CD TOC */
cdd_unload();
} }
/* special ROM cartridges that use CD hardware */ /* special ROM cartridges that use CD hardware */
@ -737,9 +736,12 @@ int load_rom(char *filename)
/* load CD BOOT ROM */ /* load CD BOOT ROM */
if (load_bios()) if (load_bios())
{ {
/* CD unloaded */ /* no CD image loaded */
cdd.loaded = 0; cdd.loaded = 0;
/* clear CD TOC */
cdd_unload();
/* boot from cartridge */ /* boot from cartridge */
scd.cartridge.boot = 0x40; scd.cartridge.boot = 0x40;
} }
@ -747,6 +749,9 @@ int load_rom(char *filename)
{ {
/* assume Mega Drive hardware */ /* assume Mega Drive hardware */
system_hw = SYSTEM_MD; system_hw = SYSTEM_MD;
/* copy back to cartridge ROM area */
memcpy(cart.rom, scd.cartridge.area, sizeof(scd.cartridge.area));
} }
} }