[Core/MS] fixed savestate when Boot ROM is running

This commit is contained in:
ekeeke 2019-03-23 13:43:55 +01:00
parent 33328c7abb
commit e819af4553
2 changed files with 40 additions and 11 deletions

View File

@ -610,9 +610,6 @@ void sms_cart_reset(void)
} }
} }
/* reset Memory Control register (RAM & I/O are enabled, either BIOS or Cartridge ROM are enabled) */
io_reg[0x0E] = bios_rom.pages ? 0xE0 : 0xA8;
/* reset Z80 memory map */ /* reset Z80 memory map */
mapper_reset(); mapper_reset();
@ -743,14 +740,32 @@ int sms_cart_region_detect(void)
int sms_cart_context_save(uint8 *state) int sms_cart_context_save(uint8 *state)
{ {
int bufferptr = 0; int bufferptr = 0;
save_param(slot.fcr, 4);
if (io_reg[0x0E] & 0x40)
{
save_param(bios_rom.fcr, 4);
}
else
{
save_param(cart_rom.fcr, 4);
}
return bufferptr; return bufferptr;
} }
int sms_cart_context_load(uint8 *state) int sms_cart_context_load(uint8 *state)
{ {
int bufferptr = 0; int bufferptr = 0;
load_param(slot.fcr, 4);
if (io_reg[0x0E] & 0x40)
{
load_param(bios_rom.fcr, 4);
}
else
{
load_param(cart_rom.fcr, 4);
}
return bufferptr; return bufferptr;
} }

View File

@ -321,13 +321,27 @@ void io_reset(void)
io_reg[0x0D] |= IO_CONT1_HI; io_reg[0x0D] |= IO_CONT1_HI;
} }
/* Control registers */ /* Memory Control register (Master System and Game Gear hardware only) */
io_reg[0x0E] = 0x00; if ((system_hw & SYSTEM_SMS) || (system_hw & SYSTEM_GG))
io_reg[0x0F] = 0xFF;
/* on SG-1000 & Mark-III, TH is not connected (always return 1) */
if (system_hw < SYSTEM_SMS)
{ {
/* RAM, I/O and either BIOS or Cartridge ROM are enabled */
io_reg[0x0E] = (z80_readmap[0] == cart.rom + 0x400000) ? 0xE0 : 0xA8;
}
else
{
/* default value (no Memory Control register) */
io_reg[0x0E] = 0x00;
}
/* I/O control register (Master System, Mega Drive and Game Gear hardware only) */
if (system_hw >= SYSTEM_SMS)
{
/* on power-on, TR and TH are configured as inputs */
io_reg[0x0F] = 0xFF;
}
else
{
/* on SG-1000 & Mark-III, TR is always an input and TH is not connected (always return 1) */
io_reg[0x0F] = 0xF5; io_reg[0x0F] = 0xF5;
} }
} }