(MESS) saturn: made RAM / Backup RAM expansion internal

slot options. you now mount these with the -cart media switch,
i.e. for instance
  mess.exe saturn -cdrm ddsom -cart ram32
or
  mess.exe saturn -cdrm draculax -cart bram16
and not anymore using the -exp option. [Fabio Priuli]

out of whatsnew: this prevents users from passing conflicting setups like
"-exp ram32 -cart kof95", etc. these would have lead to unpredictable effects,
depending on the order of the option (and whether they were set at command
line or inside ini files)
This commit is contained in:
Fabio Priuli 2014-09-29 18:08:35 +00:00
parent b304fbb985
commit c7379ba4b8
8 changed files with 183 additions and 75 deletions

View File

@ -13,10 +13,12 @@
<publisher>SNK</publisher>
<info name="serial" value="T-3101G" />
<part name="cart" interface="sat_cart">
<feature name="slot" value="rom" />
<!-- PCB info from Jpn cart pic -->
<feature name="pcb" value="171-7088A" />
<feature name="ic1" value="MPR-18811-MX" />
<dataarea name="cart" size="0x200000">
<dataarea name="rom" size="0x200000">
<rom name="mpr-18811-mx.ic1" size="0x200000" crc="90412e10" sha1="a67cd4f550751f8b91de2b8b74528ab4e0c11c77" offset="0" />
</dataarea>
</part>
@ -27,7 +29,8 @@
<year>1995</year>
<publisher>Bandai</publisher>
<part name="cart" interface="sat_cart">
<dataarea name="cart" size="0x200000">
<feature name="slot" value="rom" />
<dataarea name="rom" size="0x200000">
<rom name="mpr-19367-mx.ic1" size="0x200000" crc="b9644b52" sha1="56c1b93da6b660bf393fbf48ca47569000ef4047" offset="0" />
</dataarea>
</part>
@ -38,7 +41,8 @@
<year>1994</year>
<publisher>Sega</publisher>
<part name="cart" interface="sat_cart">
<dataarea name="cart" size="0x80000">
<feature name="slot" value="rom" />
<dataarea name="rom" size="0x80000">
<rom name="sega saturn test menu v1.0f.bin" size="0x80000" crc="17031c7a" sha1="433cb101bb6e61873778dfcd61a65c72ec552dd9" offset="0" />
</dataarea>
</part>
@ -50,10 +54,84 @@
<year>199?</year>
<publisher>&lt;unknown&gt;</publisher>
<part name="cart" interface="sat_cart">
<dataarea name="cart" size="84069">
<feature name="slot" value="rom" />
<dataarea name="rom" size="84069">
<rom name="action replay rom.bin" size="84069" crc="cc518d69" sha1="8c091285a2fc863c8b3e6e9e5849a8a3469e02ff" offset="0" />
</dataarea>
</part>
</software>
<!-- RAM cartridges -->
<software name="ram8">
<description>Extended RAM 8Mbit cartridge</description>
<year>199?</year>
<publisher>Sega</publisher>
<part name="cart" interface="sat_cart">
<feature name="slot" value="ram8" />
<dataarea name="dram0" size="0x80000">
</dataarea>
<dataarea name="dram1" size="0x80000">
</dataarea>
</part>
</software>
<software name="ram32">
<description>Extended RAM 32Mbit cartridge</description>
<year>199?</year>
<publisher>Sega</publisher>
<part name="cart" interface="sat_cart">
<feature name="slot" value="ram32" />
<dataarea name="dram0" size="0x200000">
</dataarea>
<dataarea name="dram1" size="0x200000">
</dataarea>
</part>
</software>
<software name="bram4">
<description>Backup RAM 4Mbit cartridge</description>
<year>199?</year>
<publisher>Sega</publisher>
<part name="cart" interface="sat_cart">
<feature name="slot" value="bram4" />
<dataarea name="bram" size="0x80000">
</dataarea>
</part>
</software>
<software name="bram8">
<description>Backup RAM 8Mbit cartridge</description>
<year>199?</year>
<publisher>Sega</publisher>
<part name="cart" interface="sat_cart">
<feature name="slot" value="bram8" />
<dataarea name="bram" size="0x100000">
</dataarea>
</part>
</software>
<software name="bram16">
<description>Backup RAM 16Mbit cartridge</description>
<year>199?</year>
<publisher>Sega</publisher>
<part name="cart" interface="sat_cart">
<feature name="slot" value="bram16" />
<dataarea name="bram" size="0x200000">
</dataarea>
</part>
</software>
<software name="bram32">
<description>Backup RAM 32Mbit cartridge</description>
<year>199?</year>
<publisher>Sega</publisher>
<part name="cart" interface="sat_cart">
<feature name="slot" value="bram32" />
<dataarea name="bram" size="0x400000">
</dataarea>
</part>
</software>
</softwarelist>

View File

@ -19,34 +19,33 @@ const device_type SATURN_BRAM_16MB = &device_creator<saturn_bram16mb_device>;
const device_type SATURN_BRAM_32MB = &device_creator<saturn_bram32mb_device>;
saturn_bram_device::saturn_bram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source)
saturn_bram_device::saturn_bram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_sat_cart_interface( mconfig, *this ),
device_nvram_interface(mconfig, *this),
m_size(size)
device_nvram_interface(mconfig, *this)
{
}
saturn_bram4mb_device::saturn_bram4mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: saturn_bram_device(mconfig, SATURN_BRAM_4MB, "Saturn Battery RAM 4Mbit Cart", tag, owner, clock, 0x80000, "sat_bram_4mb", __FILE__)
: saturn_bram_device(mconfig, SATURN_BRAM_4MB, "Saturn Battery RAM 4Mbit Cart", tag, owner, clock, "sat_bram_4mb", __FILE__)
{
m_cart_type = 0x21;
}
saturn_bram8mb_device::saturn_bram8mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: saturn_bram_device(mconfig, SATURN_BRAM_8MB, "Saturn Battery RAM 8Mbit Cart", tag, owner, clock, 0x100000, "sat_bram_8mb", __FILE__)
: saturn_bram_device(mconfig, SATURN_BRAM_8MB, "Saturn Battery RAM 8Mbit Cart", tag, owner, clock, "sat_bram_8mb", __FILE__)
{
m_cart_type = 0x22;
}
saturn_bram16mb_device::saturn_bram16mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: saturn_bram_device(mconfig, SATURN_BRAM_16MB, "Saturn Battery RAM 16Mbit Cart", tag, owner, clock, 0x200000, "sat_bram_16mb", __FILE__)
: saturn_bram_device(mconfig, SATURN_BRAM_16MB, "Saturn Battery RAM 16Mbit Cart", tag, owner, clock, "sat_bram_16mb", __FILE__)
{
m_cart_type = 0x23;
}
saturn_bram32mb_device::saturn_bram32mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: saturn_bram_device(mconfig, SATURN_BRAM_32MB, "Saturn Battery RAM 32Mbit Cart", tag, owner, clock, 0x400000, "sat_bram_32mb", __FILE__)
: saturn_bram_device(mconfig, SATURN_BRAM_32MB, "Saturn Battery RAM 32Mbit Cart", tag, owner, clock, "sat_bram_32mb", __FILE__)
{
m_cart_type = 0x24;
}
@ -58,8 +57,6 @@ saturn_bram32mb_device::saturn_bram32mb_device(const machine_config &mconfig, co
void saturn_bram_device::device_start()
{
m_ext_bram.resize(m_size);
save_item(NAME(m_ext_bram));
}
void saturn_bram_device::device_reset()
@ -88,18 +85,18 @@ void saturn_bram_device::nvram_default()
READ32_MEMBER(saturn_bram_device::read_ext_bram)
{
if (offset < m_size/2)
if (offset < m_ext_bram.bytes()/2)
return (m_ext_bram[offset * 2] << 16) | m_ext_bram[offset * 2 + 1];
else
{
osd_printf_error("Battery RAM read beyond its boundary! offs: %X\n", offset);
popmessage("Battery RAM read beyond its boundary! offs: %X\n", offset);
return 0xffffffff;
}
}
WRITE32_MEMBER(saturn_bram_device::write_ext_bram)
{
if (offset < m_size/2)
if (offset < m_ext_bram.bytes()/2)
{
if (ACCESSING_BITS_16_23)
m_ext_bram[offset * 2 + 0] = (data & 0x00ff0000) >> 16;
@ -107,5 +104,5 @@ WRITE32_MEMBER(saturn_bram_device::write_ext_bram)
m_ext_bram[offset * 2 + 1] = (data & 0x000000ff) >> 0;
}
else
osd_printf_error("Battery RAM write beyond its boundary! offs: %X data: %X\n", offset, data);
popmessage("Battery RAM write beyond its boundary! offs: %X data: %X\n", offset, data);
}

View File

@ -12,7 +12,7 @@ class saturn_bram_device : public device_t,
{
public:
// construction/destruction
saturn_bram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source);
saturn_bram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
// device-level overrides
virtual void device_start();
@ -26,8 +26,6 @@ public:
// reading and writing
virtual DECLARE_READ32_MEMBER(read_ext_bram);
virtual DECLARE_WRITE32_MEMBER(write_ext_bram);
UINT32 m_size; // this is the size of Battery RAM in bytes
};
class saturn_bram4mb_device : public saturn_bram_device

View File

@ -17,21 +17,20 @@ const device_type SATURN_DRAM_8MB = &device_creator<saturn_dram8mb_device>;
const device_type SATURN_DRAM_32MB = &device_creator<saturn_dram32mb_device>;
saturn_dram_device::saturn_dram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source)
saturn_dram_device::saturn_dram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_sat_cart_interface( mconfig, *this ),
m_size(size)
device_sat_cart_interface( mconfig, *this )
{
}
saturn_dram8mb_device::saturn_dram8mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: saturn_dram_device(mconfig, SATURN_DRAM_8MB, "Saturn Data RAM 8Mbit Cart", tag, owner, clock, 0x100000, "sat_dram_8mb", __FILE__)
: saturn_dram_device(mconfig, SATURN_DRAM_8MB, "Saturn Data RAM 8Mbit Cart", tag, owner, clock, "sat_dram_8mb", __FILE__)
{
m_cart_type = 0x5a;
}
saturn_dram32mb_device::saturn_dram32mb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: saturn_dram_device(mconfig, SATURN_DRAM_32MB, "Saturn Data RAM 32Mbit Cart", tag, owner, clock, 0x400000, "sat_dram_32mb", __FILE__)
: saturn_dram_device(mconfig, SATURN_DRAM_32MB, "Saturn Data RAM 32Mbit Cart", tag, owner, clock, "sat_dram_32mb", __FILE__)
{
m_cart_type = 0x5c;
}
@ -43,10 +42,6 @@ saturn_dram32mb_device::saturn_dram32mb_device(const machine_config &mconfig, co
void saturn_dram_device::device_start()
{
m_ext_dram0.resize((m_size/2)/sizeof(UINT32));
m_ext_dram1.resize((m_size/2)/sizeof(UINT32));
save_item(NAME(m_ext_dram0));
save_item(NAME(m_ext_dram1));
}
void saturn_dram_device::device_reset()
@ -62,38 +57,38 @@ void saturn_dram_device::device_reset()
READ32_MEMBER(saturn_dram_device::read_ext_dram0)
{
if (offset < (m_size/2)/4)
return m_ext_dram0[offset];
if (offset < (0x400000/2)/4)
return m_ext_dram0[offset % m_ext_dram0.count()];
else
{
osd_printf_error("DRAM0 read beyond its boundary! offs: %X\n", offset);
popmessage("DRAM0 read beyond its boundary! offs: %X\n", offset);
return 0xffffffff;
}
}
READ32_MEMBER(saturn_dram_device::read_ext_dram1)
{
if (offset < (m_size/2)/4)
return m_ext_dram1[offset];
if (offset < (0x400000/2)/4)
return m_ext_dram1[offset % m_ext_dram1.count()];
else
{
osd_printf_error("DRAM1 read beyond its boundary! offs: %X\n", offset);
popmessage("DRAM1 read beyond its boundary! offs: %X\n", offset);
return 0xffffffff;
}
}
WRITE32_MEMBER(saturn_dram_device::write_ext_dram0)
{
if (offset < (m_size/2)/4)
COMBINE_DATA(&m_ext_dram0[offset]);
if (offset < (0x400000/2)/4)
COMBINE_DATA(&m_ext_dram0[offset % m_ext_dram0.count()]);
else
osd_printf_error("DRAM0 write beyond its boundary! offs: %X data: %X\n", offset, data);
popmessage("DRAM0 write beyond its boundary! offs: %X data: %X\n", offset, data);
}
WRITE32_MEMBER(saturn_dram_device::write_ext_dram1)
{
if (offset < (m_size/2)/4)
COMBINE_DATA(&m_ext_dram1[offset]);
if (offset < (0x400000/2)/4)
COMBINE_DATA(&m_ext_dram1[offset % m_ext_dram1.count()]);
else
osd_printf_error("DRAM1 write beyond its boundary! offs: %X data: %X\n", offset, data);
popmessage("DRAM1 write beyond its boundary! offs: %X data: %X\n", offset, data);
}

View File

@ -11,7 +11,7 @@ class saturn_dram_device : public device_t,
{
public:
// construction/destruction
saturn_dram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source);
saturn_dram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
// device-level overrides
virtual void device_start();
@ -22,8 +22,6 @@ public:
virtual DECLARE_READ32_MEMBER(read_ext_dram1);
virtual DECLARE_WRITE32_MEMBER(write_ext_dram0);
virtual DECLARE_WRITE32_MEMBER(write_ext_dram1);
UINT32 m_size; // this is the size of DRAM0 + DRAM1, so accesses to each bank go up to ((m_size/2)/4)-1
};
class saturn_dram8mb_device : public saturn_dram_device

View File

@ -66,6 +66,33 @@ void device_sat_cart_interface::rom_alloc(UINT32 size, const char *tag)
}
//-------------------------------------------------
// bram_alloc - alloc the space for the Backup RAM
//-------------------------------------------------
void device_sat_cart_interface::bram_alloc(UINT32 size)
{
m_ext_bram.resize(size);
device().save_item(NAME(m_ext_bram));
}
//-------------------------------------------------
// dram*_alloc - alloc the space for the DRAM
//-------------------------------------------------
void device_sat_cart_interface::dram0_alloc(UINT32 size)
{
m_ext_dram0.resize(size/sizeof(UINT32));
device().save_item(NAME(m_ext_dram0));
}
void device_sat_cart_interface::dram1_alloc(UINT32 size)
{
m_ext_dram1.resize(size/sizeof(UINT32));
device().save_item(NAME(m_ext_dram1));
}
//**************************************************************************
// LIVE DEVICE
@ -122,32 +149,44 @@ bool sat_cart_slot_device::call_load()
{
if (m_cart)
{
UINT32 *ROM;
UINT32 len;
bool is_rom = ((software_entry() == NULL) || ((software_entry() != NULL) && get_software_region("rom")));
if (software_entry() != NULL)
len = get_software_region_length("cart");
if (is_rom)
{
// from fullpath, only ROM carts
UINT32 len = (software_entry() != NULL) ? get_software_region_length("rom") : length();
UINT32 *ROM;
m_cart->rom_alloc(len, tag());
ROM = m_cart->get_rom_base();
if (software_entry() != NULL)
memcpy(ROM, get_software_region("rom"), len);
else
fread(ROM, len);
// fix endianness....
for (int i = 0; i < len/4; i ++)
ROM[i] = BITSWAP32(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24);
// {
// UINT8 tempa = ROM[i+0];
// UINT8 tempb = ROM[i+1];
// ROM[i+1] = ROM[i+2];
// ROM[i+0] = ROM[i+3];
// ROM[i+3] = tempa;
// ROM[i+2] = tempb;
// }
}
else
len = length();
m_cart->rom_alloc(len, tag());
ROM = m_cart->get_rom_base();
if (software_entry() != NULL)
memcpy(ROM, get_software_region("cart"), len);
else
fread(ROM, len);
// fix endianness....
for (int i = 0; i < len/4; i ++)
ROM[i] = BITSWAP32(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24);
// UINT8 tempa = ROM[i+0];
// UINT8 tempb = ROM[i+1];
// ROM[i+1] = ROM[i+2];
// ROM[i+0] = ROM[i+3];
// ROM[i+3] = tempa;
// ROM[i+2] = tempb;
// }
{
// DRAM or BRAM carts from softlist
if (get_software_region("bram"))
m_cart->bram_alloc(get_software_region_length("bram"));
if (get_software_region("dram0"))
m_cart->dram0_alloc(get_software_region_length("dram0"));
if (get_software_region("dram1"))
m_cart->dram1_alloc(get_software_region_length("dram1"));
}
return IMAGE_INIT_PASS;
}

View File

@ -30,6 +30,9 @@ public:
void rom_alloc(UINT32 size, const char *tag);
void bram_alloc(UINT32 size);
void dram0_alloc(UINT32 size);
void dram1_alloc(UINT32 size);
UINT32* get_rom_base() { return m_rom; }
UINT32* get_ext_dram0_base() { return m_ext_dram0; }
UINT32* get_ext_dram1_base() { return m_ext_dram1; }

View File

@ -756,13 +756,13 @@ static MACHINE_CONFIG_START( saturn, sat_console_state )
MACHINE_CONFIG_END
static SLOT_INTERFACE_START(saturn_cart)
SLOT_INTERFACE_INTERNAL("rom", SATURN_ROM)
SLOT_INTERFACE("ram8", SATURN_DRAM_8MB)
SLOT_INTERFACE("ram32", SATURN_DRAM_32MB)
SLOT_INTERFACE("bram4", SATURN_BRAM_4MB)
SLOT_INTERFACE("bram8", SATURN_BRAM_8MB)
SLOT_INTERFACE("bram16", SATURN_BRAM_16MB)
SLOT_INTERFACE("bram32", SATURN_BRAM_32MB)
SLOT_INTERFACE_INTERNAL("rom", SATURN_ROM)
SLOT_INTERFACE_INTERNAL("ram8", SATURN_DRAM_8MB)
SLOT_INTERFACE_INTERNAL("ram32", SATURN_DRAM_32MB)
SLOT_INTERFACE_INTERNAL("bram4", SATURN_BRAM_4MB)
SLOT_INTERFACE_INTERNAL("bram8", SATURN_BRAM_8MB)
SLOT_INTERFACE_INTERNAL("bram16", SATURN_BRAM_16MB)
SLOT_INTERFACE_INTERNAL("bram32", SATURN_BRAM_32MB)
SLOT_INTERFACE_END