(MESS) saturn: replaced auto_allocs with dynamic_arrays, and

reduced BRAM & DRAM allocation to actual RAM size. nw.
This commit is contained in:
Fabio Priuli 2014-05-01 17:33:20 +00:00
parent 73f2391262
commit 4916f13f47
7 changed files with 41 additions and 51 deletions

View File

@ -58,10 +58,11 @@ saturn_bram32mb_device::saturn_bram32mb_device(const machine_config &mconfig, co
void saturn_bram_device::device_start()
{
// TODO: only allocate the real amount of RAM
m_ext_bram = auto_alloc_array_clear(machine(), UINT8, 0x400000);
m_ext_bram_size = 0x400000;
save_pointer(NAME(m_ext_bram), 0x400000);
if (m_ext_bram == NULL)
{
m_ext_bram.resize(m_size);
save_item(NAME(m_ext_bram));
}
}
void saturn_bram_device::device_reset()
@ -72,7 +73,7 @@ void saturn_bram_device::nvram_default()
{
static const UINT8 init[16] =
{ 'B', 'a', 'c', 'k', 'U', 'p', 'R', 'a', 'm', ' ', 'F', 'o', 'r', 'm', 'a', 't' };
memset(m_ext_bram, 0, m_ext_bram_size);
memset(m_ext_bram, 0, m_ext_bram.bytes());
for (int i = 0; i < 32; i++)
{

View File

@ -20,8 +20,8 @@ public:
// device_nvram_interface overrides
virtual void nvram_default();
virtual void nvram_read(emu_file &file) { if (m_ext_bram != NULL) { file.read(m_ext_bram, m_ext_bram_size); } }
virtual void nvram_write(emu_file &file) { if (m_ext_bram != NULL) { file.write(m_ext_bram, m_ext_bram_size); } }
virtual void nvram_read(emu_file &file) { if (m_ext_bram != NULL) { file.read(m_ext_bram, m_ext_bram.bytes()); } }
virtual void nvram_write(emu_file &file) { if (m_ext_bram != NULL) { file.write(m_ext_bram, m_ext_bram.bytes()); } }
// reading and writing
virtual DECLARE_READ32_MEMBER(read_ext_bram);

View File

@ -25,13 +25,13 @@ saturn_dram_device::saturn_dram_device(const machine_config &mconfig, device_typ
}
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, 0x400000/4, "sat_dram_8mb", __FILE__)
: saturn_dram_device(mconfig, SATURN_DRAM_8MB, "Saturn Data RAM 8Mbit Cart", tag, owner, clock, 0x100000, "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, 0x800000/4, "sat_dram_32mb", __FILE__)
: saturn_dram_device(mconfig, SATURN_DRAM_32MB, "Saturn Data RAM 32Mbit Cart", tag, owner, clock, 0x400000, "sat_dram_32mb", __FILE__)
{
m_cart_type = 0x5c;
}
@ -43,13 +43,17 @@ saturn_dram32mb_device::saturn_dram32mb_device(const machine_config &mconfig, co
void saturn_dram_device::device_start()
{
// TODO: only allocate the real amount of RAM
m_ext_dram0 = auto_alloc_array_clear(machine(), UINT32, 0x400000/4);
m_ext_dram1 = auto_alloc_array_clear(machine(), UINT32, 0x400000/4);
m_ext_dram0_size = 0x400000;
m_ext_dram1_size = 0x400000;
save_pointer(NAME(m_ext_dram0), 0x400000/4);
save_pointer(NAME(m_ext_dram1), 0x400000/4);
if (m_ext_dram0 == NULL)
{
m_ext_dram0.resize((m_size/2)/sizeof(UINT32));
save_item(NAME(m_ext_dram0));
}
if (m_ext_dram1 == NULL)
{
m_ext_dram1.resize((m_size/2)/sizeof(UINT32));
save_item(NAME(m_ext_dram1));
}
}
void saturn_dram_device::device_reset()
@ -61,11 +65,11 @@ void saturn_dram_device::device_reset()
mapper specific handlers
-------------------------------------------------*/
// RAM: two DRAM chips are present in the cart
// RAM: two DRAM chips are present in the cart, thus accesses only go up to m_size/2!
READ32_MEMBER(saturn_dram_device::read_ext_dram0)
{
if (offset < m_size/2)
if (offset < (m_size/2)/4)
return m_ext_dram0[offset];
else
{
@ -76,7 +80,7 @@ READ32_MEMBER(saturn_dram_device::read_ext_dram0)
READ32_MEMBER(saturn_dram_device::read_ext_dram1)
{
if (offset < m_size/2)
if (offset < (m_size/2)/4)
return m_ext_dram1[offset];
else
{
@ -87,7 +91,7 @@ READ32_MEMBER(saturn_dram_device::read_ext_dram1)
WRITE32_MEMBER(saturn_dram_device::write_ext_dram0)
{
if (offset < m_size/2)
if (offset < (m_size/2)/4)
COMBINE_DATA(&m_ext_dram0[offset]);
else
osd_printf_error("DRAM0 write beyond its boundary! offs: %X data: %X\n", offset, data);
@ -95,7 +99,7 @@ WRITE32_MEMBER(saturn_dram_device::write_ext_dram0)
WRITE32_MEMBER(saturn_dram_device::write_ext_dram1)
{
if (offset < m_size/2)
if (offset < (m_size/2)/4)
COMBINE_DATA(&m_ext_dram1[offset]);
else
osd_printf_error("DRAM1 write beyond its boundary! offs: %X data: %X\n", offset, data);

View File

@ -23,7 +23,7 @@ public:
virtual DECLARE_WRITE32_MEMBER(write_ext_dram0);
virtual DECLARE_WRITE32_MEMBER(write_ext_dram1);
UINT32 m_size; // this is the size of DRAM0 + DRAM1 in dword units, so accesses to each bank go up to (m_size/2)-1
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

@ -49,5 +49,5 @@ void saturn_rom_device::device_reset()
READ32_MEMBER(saturn_rom_device::read_rom)
{
return m_rom[offset & (m_rom_size - 1)];
return m_rom[offset & (m_rom.count() - 1)];
}

View File

@ -35,15 +35,7 @@ const device_type SATURN_CART_SLOT = &device_creator<sat_cart_slot_device>;
//-------------------------------------------------
device_sat_cart_interface::device_sat_cart_interface(const machine_config &mconfig, device_t &device)
: device_slot_card_interface(mconfig, device),
m_rom(NULL),
m_ext_dram0(NULL),
m_ext_dram1(NULL),
m_ext_bram(NULL),
m_rom_size(0),
m_ext_dram0_size(0),
m_ext_dram1_size(0),
m_ext_bram_size(0)
: device_slot_card_interface(mconfig, device)
{
}
@ -60,13 +52,10 @@ device_sat_cart_interface::~device_sat_cart_interface()
// rom_alloc - alloc the space for the cart
//-------------------------------------------------
void device_sat_cart_interface::rom_alloc(running_machine &machine, UINT32 size)
void device_sat_cart_interface::rom_alloc(UINT32 size)
{
if (m_rom == NULL)
{
m_rom = auto_alloc_array_clear(machine, UINT32, size/4);
m_rom_size = size;
}
m_rom.resize(size/sizeof(UINT32));
}
@ -134,7 +123,7 @@ bool sat_cart_slot_device::call_load()
else
len = length();
m_cart->rom_alloc(machine(), len);
m_cart->rom_alloc(len);
ROM = m_cart->get_rom_base();
if (software_entry() != NULL)

View File

@ -29,28 +29,24 @@ public:
virtual int get_cart_type() { return m_cart_type; };
void rom_alloc(running_machine &machine, UINT32 size);
void rom_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; }
UINT8* get_ext_bram_base() { return m_ext_bram; }
UINT32 get_rom_size() { return m_rom_size; }
UINT32 get_ext_dram0_size() { return m_ext_dram0_size; }
UINT32 get_ext_dram1_size() { return m_ext_dram1_size; }
UINT32 get_ext_bram_size() { return m_ext_bram_size; }
UINT32 get_rom_size() { return m_rom.bytes(); }
UINT32 get_ext_dram0_size() { return m_ext_dram0.bytes(); }
UINT32 get_ext_dram1_size() { return m_ext_dram1.bytes(); }
UINT32 get_ext_bram_size() { return m_ext_bram.bytes(); }
protected:
int m_cart_type;
// internal state
UINT32 *m_rom;
UINT32 *m_ext_dram0;
UINT32 *m_ext_dram1;
UINT8 *m_ext_bram;
UINT32 m_rom_size;
UINT32 m_ext_dram0_size;
UINT32 m_ext_dram1_size;
UINT32 m_ext_bram_size;
dynamic_array<UINT32> m_rom;
dynamic_array<UINT32> m_ext_dram0;
dynamic_array<UINT32> m_ext_dram1;
dynamic_buffer m_ext_bram;
};