fixed multisession crash when the new cart needed a dynamic buffer/array

larger than the original one. this got introduced when converting from 
auto_alloc_array to dynamic buffers, because such buffers are not made
NULL at reset, but got unnoticed/unreported up to now. many thanks to 
Trebor for catching it! nw.
This commit is contained in:
Fabio Priuli 2014-09-23 06:18:02 +00:00
parent af251eb276
commit 69fdbd5872
16 changed files with 122 additions and 199 deletions

View File

@ -61,8 +61,6 @@ device_a78_cart_interface::~device_a78_cart_interface ()
//-------------------------------------------------
void device_a78_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
{
m_rom.resize(size);
@ -77,20 +75,16 @@ void device_a78_cart_interface::rom_alloc(UINT32 size)
// the access handling
m_base_rom = 0x10000 - size;
}
}
//-------------------------------------------------
// ram_alloc - alloc the space for the on-cart RAM
//-------------------------------------------------
void device_a78_cart_interface::ram_alloc(UINT32 size)
{
if (m_ram == NULL)
{
m_ram.resize(size);
device().save_item(NAME(m_ram));
}
}
//-------------------------------------------------
@ -98,13 +92,10 @@ void device_a78_cart_interface::ram_alloc(UINT32 size)
//-------------------------------------------------
void device_a78_cart_interface::nvram_alloc(UINT32 size)
{
if (m_nvram == NULL)
{
m_nvram.resize(size);
device().save_item(NAME(m_nvram));
}
}
@ -120,7 +111,6 @@ a78_cart_slot_device::a78_cart_slot_device(const machine_config &mconfig, const
device_image_interface(mconfig, *this),
device_slot_interface(mconfig, *this)
{
m_type = A78_NOCART;
}
@ -321,8 +311,7 @@ static const a78_slot slot_list[] =
{ A78_TYPE1_POK450, "a78_p450_t1" },
{ A78_TYPE6_POK450, "a78_p450_t6" },
{ A78_TYPEA_POK450, "a78_p450_ta" },
{ A78_VERSA_POK450, "a78_p450_vb" },
{ A78_NOCART, "empty" }, // the code should never get here, of course...
{ A78_VERSA_POK450, "a78_p450_vb" }
};
static int a78_get_pcb_id(const char *slot)

View File

@ -30,8 +30,7 @@ enum
A78_TYPE1_POK450 = 0x21,
A78_TYPE6_POK450 = 0x24,
A78_TYPEA_POK450 = 0x25,
A78_VERSA_POK450 = 0x30,
A78_NOCART
A78_VERSA_POK450 = 0x30
};

View File

@ -58,28 +58,22 @@ device_a800_cart_interface::~device_a800_cart_interface ()
//-------------------------------------------------
void device_a800_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
{
m_rom.resize(size);
// setup other helpers
m_bank_mask = (size / 0x2000) - 1; // code for XEGS carts makes use of this to simplify banking
}
}
//-------------------------------------------------
// ram_alloc - alloc the space for the on-cart RAM
//-------------------------------------------------
void device_a800_cart_interface::ram_alloc(UINT32 size)
{
if (m_ram == NULL)
{
m_ram.resize(size);
device().save_item(NAME(m_ram));
}
}
//-------------------------------------------------
@ -87,13 +81,10 @@ void device_a800_cart_interface::ram_alloc(UINT32 size)
//-------------------------------------------------
void device_a800_cart_interface::nvram_alloc(UINT32 size)
{
if (m_nvram == NULL)
{
m_nvram.resize(size);
device().save_item(NAME(m_nvram));
}
}
@ -109,7 +100,6 @@ a800_cart_slot_device::a800_cart_slot_device(const machine_config &mconfig, devi
device_image_interface(mconfig, *this),
device_slot_interface(mconfig, *this)
{
m_type = A800_NOCART;
}
a800_cart_slot_device::a800_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
@ -117,7 +107,6 @@ a800_cart_slot_device::a800_cart_slot_device(const machine_config &mconfig, cons
device_image_interface(mconfig, *this),
device_slot_interface(mconfig, *this)
{
m_type = A800_NOCART;
}
@ -215,8 +204,7 @@ static const a800_slot slot_list[] =
{ A5200_32K, "a5200" },
{ A5200_16K_2CHIPS, "a5200_2chips" },
{ A5200_32K, "a5200" },
{ A5200_BBSB, "a5200_bbsb" },
{ A800_NOCART, "empty" },
{ A5200_BBSB, "a5200_bbsb" }
};

View File

@ -37,8 +37,7 @@ enum
A5200_16K,
A5200_32K,
A5200_16K_2CHIPS,
A5200_BBSB,
A800_NOCART
A5200_BBSB
};

View File

@ -57,7 +57,6 @@ device_gb_cart_interface::~device_gb_cart_interface()
void device_gb_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
m_rom.resize(size);
}
@ -67,13 +66,10 @@ void device_gb_cart_interface::rom_alloc(UINT32 size)
//-------------------------------------------------
void device_gb_cart_interface::ram_alloc(UINT32 size)
{
if (m_ram == NULL)
{
m_ram.resize(size);
device().save_item(NAME(m_ram));
}
}
//-------------------------------------------------

View File

@ -45,13 +45,10 @@ device_gba_cart_interface::~device_gba_cart_interface()
//-------------------------------------------------
void device_gba_cart_interface::nvram_alloc(UINT32 size)
{
if (m_nvram == NULL)
{
m_nvram.resize(size/sizeof(UINT32));
device().save_item(NAME(m_nvram));
}
}
//**************************************************************************

View File

@ -97,13 +97,10 @@ void device_md_cart_interface::rom_alloc(size_t size, const char *tag)
//-------------------------------------------------
void device_md_cart_interface::nvram_alloc(size_t size)
{
if (m_nvram == NULL)
{
m_nvram.resize(size/sizeof(UINT16));
device().save_item(NAME(m_nvram));
}
}
//-------------------------------------------------
// rom_map_setup - setup map of rom banks in 64K

View File

@ -78,13 +78,6 @@ enum
};
// ======================> md_cart_interface
struct md_cart_interface
{
};
// ======================> device_md_cart_interface
class device_md_cart_interface : public device_slot_card_interface
@ -138,7 +131,6 @@ public:
// ======================> base_md_cart_slot_device
class base_md_cart_slot_device : public device_t,
public md_cart_interface,
public device_image_interface,
public device_slot_interface
{

View File

@ -141,8 +141,6 @@ device_nes_cart_interface::~device_nes_cart_interface()
//-------------------------------------------------
void device_nes_cart_interface::prg_alloc(size_t size)
{
if (m_prg == NULL)
{
m_prg.resize(size);
m_prg_chunks = size / 0x4000;
@ -204,35 +202,26 @@ void device_nes_cart_interface::prg_alloc(size_t size)
// }
}
}
}
void device_nes_cart_interface::prgram_alloc(size_t size)
{
if (m_prgram == NULL)
m_prgram.resize(size);
}
void device_nes_cart_interface::vrom_alloc(size_t size)
{
if (m_vrom == NULL)
{
m_vrom.resize(size);
m_vrom_chunks = size / 0x2000;
}
}
void device_nes_cart_interface::vram_alloc(size_t size)
{
if (m_vram == NULL)
{
m_vram.resize(size);
m_vram_chunks = size / 0x2000;
}
}
void device_nes_cart_interface::battery_alloc(size_t size)
{
if (m_battery == NULL)
m_battery.resize(size);
}

View File

@ -44,7 +44,6 @@ device_pce_cart_interface::~device_pce_cart_interface()
void device_pce_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
m_rom.resize(size);
}
@ -54,13 +53,10 @@ void device_pce_cart_interface::rom_alloc(UINT32 size)
//-------------------------------------------------
void device_pce_cart_interface::ram_alloc(UINT32 size)
{
if (m_ram == NULL)
{
m_ram.resize(size);
device().save_item(NAME(m_ram));
}
}
//-------------------------------------------------
// rom_map_setup - setup map of rom banks in 128K
@ -69,8 +65,6 @@ void device_pce_cart_interface::ram_alloc(UINT32 size)
void device_pce_cart_interface::rom_map_setup(UINT32 size)
{
int i;
if (size == 0x60000)
{
// HuCard 384K are mapped with mirrored pieces
@ -85,6 +79,8 @@ void device_pce_cart_interface::rom_map_setup(UINT32 size)
}
else
{
int i;
// setup the rom_bank_map array to faster ROM read
for (i = 0; i < size / 0x20000 && i < 8; i++)
rom_bank_map[i] = i;

View File

@ -54,7 +54,6 @@ device_sat_cart_interface::~device_sat_cart_interface()
void device_sat_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
m_rom.resize(size/sizeof(UINT32));
}

View File

@ -71,8 +71,6 @@ device_sega8_cart_interface::~device_sega8_cart_interface()
//-------------------------------------------------
void device_sega8_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
{
m_rom.resize(size);
m_rom_page_count = size / 0x4000;
@ -80,7 +78,6 @@ void device_sega8_cart_interface::rom_alloc(UINT32 size)
m_rom_page_count = 1; // we compute rom pages through (XXX % m_rom_page_count)!
late_bank_setup();
}
}
//-------------------------------------------------
@ -88,13 +85,10 @@ void device_sega8_cart_interface::rom_alloc(UINT32 size)
//-------------------------------------------------
void device_sega8_cart_interface::ram_alloc(UINT32 size)
{
if (m_ram == NULL)
{
m_ram.resize(size);
device().save_item(NAME(m_ram));
}
}

View File

@ -86,7 +86,6 @@ device_sns_cart_interface::~device_sns_cart_interface()
void device_sns_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
m_rom.resize(size);
}
@ -96,13 +95,10 @@ void device_sns_cart_interface::rom_alloc(UINT32 size)
//-------------------------------------------------
void device_sns_cart_interface::nvram_alloc(UINT32 size)
{
if (m_nvram == NULL)
{
m_nvram.resize(size);
device().save_item(NAME(m_nvram));
}
}
//-------------------------------------------------
@ -113,13 +109,10 @@ void device_sns_cart_interface::nvram_alloc(UINT32 size)
//-------------------------------------------------
void device_sns_cart_interface::rtc_ram_alloc(UINT32 size)
{
if (m_rtc_ram == NULL)
{
m_rtc_ram.resize(size);
device().save_item(NAME(m_rtc_ram));
}
}
//-------------------------------------------------
@ -129,7 +122,6 @@ void device_sns_cart_interface::rtc_ram_alloc(UINT32 size)
void device_sns_cart_interface::addon_bios_alloc(UINT32 size)
{
if (m_bios == NULL)
m_bios.resize(size);
}

View File

@ -47,7 +47,6 @@ device_vcs_cart_interface::~device_vcs_cart_interface()
void device_vcs_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
m_rom.resize(size);
}
@ -56,13 +55,10 @@ void device_vcs_cart_interface::rom_alloc(UINT32 size)
//-------------------------------------------------
void device_vcs_cart_interface::ram_alloc(UINT32 size)
{
if (m_ram == NULL)
{
m_ram.resize(size);
device().save_item(NAME(m_ram));
}
}

View File

@ -1315,7 +1315,7 @@ void a7800_state::machine_start()
save_item(NAME(m_maria_flag));
// install additional handlers, if needed
switch (m_cartslot->get_cart_type())
switch (m_cartslot->exists() && m_cartslot->get_cart_type())
{
case A78_HSC:
// ROM+NVRAM accesses for HiScore

View File

@ -1735,7 +1735,7 @@ READ8_MEMBER(a400_state::read_d5xx)
WRITE8_MEMBER(a400_state::disable_cart)
{
switch (m_cartslot->get_cart_type())
switch (m_cartslot->exists() && m_cartslot->get_cart_type())
{
case A800_PHOENIX:
case A800_BLIZZARD:
@ -1834,7 +1834,7 @@ void a400_state::setup_cart(a800_cart_slot_device *slot)
m_cart_disabled = 0;
m_last_offs = -1;
switch (slot->get_cart_type())
switch (slot->exists() && slot->get_cart_type())
{
case A800_8K:
m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot));