mirror of
https://github.com/holub/mame
synced 2025-05-18 19:49:35 +03:00
(MESS) pce_slot.c: nuked some auto_allocs, using dynamic_buffer instead. nw.
(MESS) sega8_slot.c: nuked some auto_allocs, using dynamic_buffer instead. nw.
This commit is contained in:
parent
b90a14b1eb
commit
70ba5a57c0
@ -25,11 +25,7 @@ const device_type PCE_CART_SLOT = &device_creator<pce_cart_slot_device>;
|
||||
//-------------------------------------------------
|
||||
|
||||
device_pce_cart_interface::device_pce_cart_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_slot_card_interface(mconfig, device),
|
||||
m_rom(NULL),
|
||||
m_ram(NULL),
|
||||
m_rom_size(0),
|
||||
m_ram_size(0)
|
||||
: device_slot_card_interface(mconfig, device)
|
||||
{
|
||||
}
|
||||
|
||||
@ -46,13 +42,10 @@ device_pce_cart_interface::~device_pce_cart_interface()
|
||||
// rom_alloc - alloc the space for the cart
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_pce_cart_interface::rom_alloc(running_machine &machine, UINT32 size)
|
||||
void device_pce_cart_interface::rom_alloc(UINT32 size)
|
||||
{
|
||||
if (m_rom == NULL)
|
||||
{
|
||||
m_rom = auto_alloc_array_clear(machine, UINT8, size);
|
||||
m_rom_size = size;
|
||||
}
|
||||
m_rom.resize(size);
|
||||
}
|
||||
|
||||
|
||||
@ -60,13 +53,12 @@ void device_pce_cart_interface::rom_alloc(running_machine &machine, UINT32 size)
|
||||
// ram_alloc - alloc the space for the ram
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_pce_cart_interface::ram_alloc(running_machine &machine, UINT32 size)
|
||||
void device_pce_cart_interface::ram_alloc(UINT32 size)
|
||||
{
|
||||
if (m_ram == NULL)
|
||||
{
|
||||
m_ram = auto_alloc_array_clear(machine, UINT8, size);
|
||||
m_ram_size = size;
|
||||
state_save_register_item_pointer(machine, "PCE_CART", this->device().tag(), 0, m_ram, m_ram_size);
|
||||
m_ram.resize(size);
|
||||
device().save_item(NAME(m_ram));
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,7 +220,7 @@ bool pce_cart_slot_device::call_load()
|
||||
fseek(offset, SEEK_SET);
|
||||
}
|
||||
|
||||
m_cart->rom_alloc(machine(), len);
|
||||
m_cart->rom_alloc(len);
|
||||
ROM = m_cart->get_rom_base();
|
||||
|
||||
if (software_entry() == NULL)
|
||||
@ -263,9 +255,9 @@ bool pce_cart_slot_device::call_load()
|
||||
//printf("Type: %s\n", pce_get_slot(m_type));
|
||||
|
||||
if (m_type == PCE_POPULOUS)
|
||||
m_cart->ram_alloc(machine(), 0x8000);
|
||||
m_cart->ram_alloc(0x8000);
|
||||
if (m_type == PCE_CDSYS3J || m_type == PCE_CDSYS3U)
|
||||
m_cart->ram_alloc(machine(), 0x30000);
|
||||
m_cart->ram_alloc(0x30000);
|
||||
|
||||
return IMAGE_INIT_PASS;
|
||||
}
|
||||
|
@ -30,18 +30,16 @@ public:
|
||||
virtual DECLARE_READ8_MEMBER(read_cart) { return 0xff; }
|
||||
virtual DECLARE_WRITE8_MEMBER(write_cart) {};
|
||||
|
||||
void rom_alloc(running_machine &machine, UINT32 size);
|
||||
void ram_alloc(running_machine &machine, UINT32 size);
|
||||
void rom_alloc(UINT32 size);
|
||||
void ram_alloc(UINT32 size);
|
||||
UINT8* get_rom_base() { return m_rom; }
|
||||
UINT8* get_ram_base() { return m_ram; }
|
||||
UINT32 get_rom_size() { return m_rom_size; }
|
||||
UINT32 get_ram_size() { return m_ram_size; }
|
||||
UINT32 get_rom_size() { return m_rom.count(); }
|
||||
UINT32 get_ram_size() { return m_ram.count(); }
|
||||
|
||||
// internal state
|
||||
UINT8 *m_rom;
|
||||
UINT8 *m_ram;
|
||||
UINT32 m_rom_size;
|
||||
UINT32 m_ram_size;
|
||||
dynamic_buffer m_rom;
|
||||
dynamic_buffer m_ram;
|
||||
|
||||
void rom_map_setup(UINT32 size);
|
||||
|
||||
|
@ -329,7 +329,7 @@ READ8_MEMBER(sega8_rom_device::read_cart)
|
||||
int bank = offset / 0x4000;
|
||||
|
||||
if (bank == 2 && m_ram && m_ram_enabled)
|
||||
return m_ram[(m_ram_base * 0x4000 + (offset & 0x3fff)) % m_ram_size];
|
||||
return m_ram[(m_ram_base * 0x4000 + (offset & 0x3fff)) % m_ram.count()];
|
||||
|
||||
if (offset < 0x400) // first 1k is hardcoded
|
||||
return m_rom[offset];
|
||||
@ -342,7 +342,7 @@ WRITE8_MEMBER(sega8_rom_device::write_cart)
|
||||
int bank = offset / 0x4000;
|
||||
|
||||
if (bank == 2 && m_ram && m_ram_enabled)
|
||||
m_ram[(m_ram_base * 0x4000 + (offset & 0x3fff)) % m_ram_size] = data;
|
||||
m_ram[(m_ram_base * 0x4000 + (offset & 0x3fff)) % m_ram.count()] = data;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(sega8_rom_device::write_mapper)
|
||||
@ -422,7 +422,7 @@ READ8_MEMBER(sega8_othello_device::read_cart)
|
||||
if (offset >= 0x8000 && offset < 0xa000)
|
||||
return m_ram[offset & 0x7ff];
|
||||
|
||||
return m_rom[offset % m_rom_size];
|
||||
return m_rom[offset % m_rom.count()];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(sega8_othello_device::write_cart)
|
||||
@ -446,7 +446,7 @@ READ8_MEMBER(sega8_castle_device::read_cart)
|
||||
if (offset >= 0x8000 && offset < 0xa000)
|
||||
return m_ram[offset & 0x1fff];
|
||||
|
||||
return m_rom[offset % m_rom_size];
|
||||
return m_rom[offset % m_rom.count()];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(sega8_castle_device::write_cart)
|
||||
@ -470,7 +470,7 @@ READ8_MEMBER(sega8_basic_l3_device::read_cart)
|
||||
if (offset >= 0x8000)
|
||||
return m_ram[offset & 0x3fff];
|
||||
|
||||
return m_rom[offset % m_rom_size];
|
||||
return m_rom[offset % m_rom.count()];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(sega8_basic_l3_device::write_cart)
|
||||
@ -504,7 +504,7 @@ READ8_MEMBER(sega8_music_editor_device::read_cart)
|
||||
if (offset >= 0x8000 && offset < 0xa000)
|
||||
return m_ram[offset & 0x1fff];
|
||||
|
||||
return m_rom[offset % m_rom_size];
|
||||
return m_rom[offset % m_rom.count()];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(sega8_music_editor_device::write_cart)
|
||||
@ -623,7 +623,7 @@ READ8_MEMBER(sega8_dahjee_typea_device::read_cart)
|
||||
if (offset >= 0x2000 && offset < 0x4000)
|
||||
return m_ram[offset & 0x1fff];
|
||||
|
||||
return m_rom[offset % m_rom_size];
|
||||
return m_rom[offset % m_rom.count()];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(sega8_dahjee_typea_device::write_cart)
|
||||
@ -651,7 +651,7 @@ WRITE8_MEMBER(sega8_dahjee_typea_device::write_ram)
|
||||
// TYPE B
|
||||
READ8_MEMBER(sega8_dahjee_typeb_device::read_cart)
|
||||
{
|
||||
return m_rom[offset % m_rom_size];
|
||||
return m_rom[offset % m_rom.count()];
|
||||
}
|
||||
|
||||
READ8_MEMBER(sega8_dahjee_typeb_device::read_ram)
|
||||
@ -750,7 +750,7 @@ READ8_MEMBER(sega8_codemasters_device::read_cart)
|
||||
int bank = offset / 0x2000;
|
||||
|
||||
if (bank == 5 && m_ram && m_ram_enabled)
|
||||
return m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram_size];
|
||||
return m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.count()];
|
||||
|
||||
return m_rom[m_rom_bank_base[bank/2] * 0x4000 + (offset & 0x3fff)];
|
||||
}
|
||||
@ -782,7 +782,7 @@ WRITE8_MEMBER(sega8_codemasters_device::write_cart)
|
||||
}
|
||||
|
||||
if (bank == 5 && m_ram && m_ram_enabled)
|
||||
m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram_size] = data;
|
||||
m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.count()] = data;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -824,7 +824,7 @@ READ8_MEMBER(sega8_zemina_device::read_cart)
|
||||
int bank = offset / 0x2000;
|
||||
|
||||
if (bank >= 4 && m_ram && m_ram_enabled)
|
||||
return m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram_size];
|
||||
return m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.count()];
|
||||
|
||||
return m_rom[m_rom_bank_base[bank] * 0x2000 + (offset & 0x1fff)];
|
||||
}
|
||||
@ -834,7 +834,7 @@ WRITE8_MEMBER(sega8_zemina_device::write_cart)
|
||||
int bank = offset / 0x2000;
|
||||
|
||||
if (bank >= 4 && m_ram && m_ram_enabled)
|
||||
m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram_size] = data;
|
||||
m_ram[(m_ram_base * 0x2000 + (offset & 0x1fff)) % m_ram.count()] = data;
|
||||
|
||||
if (offset < 4)
|
||||
{
|
||||
|
@ -49,10 +49,6 @@ const device_type SEGA8_CARD_SLOT = &device_creator<sega8_card_slot_device>;
|
||||
|
||||
device_sega8_cart_interface::device_sega8_cart_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_slot_card_interface(mconfig, device),
|
||||
m_rom(NULL),
|
||||
m_ram(NULL),
|
||||
m_rom_size(0),
|
||||
m_ram_size(0),
|
||||
m_rom_page_count(0),
|
||||
has_battery(FALSE),
|
||||
m_late_battery_enable(FALSE),
|
||||
@ -74,12 +70,11 @@ device_sega8_cart_interface::~device_sega8_cart_interface()
|
||||
// rom_alloc - alloc the space for the cart
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_sega8_cart_interface::rom_alloc(running_machine &machine, UINT32 size)
|
||||
void device_sega8_cart_interface::rom_alloc(UINT32 size)
|
||||
{
|
||||
if (m_rom == NULL)
|
||||
{
|
||||
m_rom = auto_alloc_array_clear(machine, UINT8, size);
|
||||
m_rom_size = size;
|
||||
m_rom.resize(size);
|
||||
m_rom_page_count = size / 0x4000;
|
||||
if (!m_rom_page_count)
|
||||
m_rom_page_count = 1; // we compute rom pages through (XXX % m_rom_page_count)!
|
||||
@ -92,13 +87,12 @@ void device_sega8_cart_interface::rom_alloc(running_machine &machine, UINT32 siz
|
||||
// ram_alloc - alloc the space for the ram
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_sega8_cart_interface::ram_alloc(running_machine &machine, UINT32 size)
|
||||
void device_sega8_cart_interface::ram_alloc(UINT32 size)
|
||||
{
|
||||
if (m_ram == NULL)
|
||||
{
|
||||
m_ram = auto_alloc_array_clear(machine, UINT8, size);
|
||||
m_ram_size = size;
|
||||
state_save_register_item_pointer(machine, "SEGA8_CART", this->device().tag(), 0, m_ram, m_ram_size);
|
||||
m_ram.resize(size);
|
||||
device().save_item(NAME(m_ram));
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,38 +278,38 @@ void sega8_cart_slot_device::setup_ram()
|
||||
{
|
||||
if (m_type == SEGA8_CASTLE)
|
||||
{
|
||||
m_cart->ram_alloc(machine(), 0x2000);
|
||||
m_cart->ram_alloc(0x2000);
|
||||
m_cart->set_has_battery(FALSE);
|
||||
}
|
||||
else if (m_type == SEGA8_OTHELLO)
|
||||
{
|
||||
m_cart->ram_alloc(machine(), 0x800);
|
||||
m_cart->ram_alloc(0x800);
|
||||
m_cart->set_has_battery(FALSE);
|
||||
}
|
||||
else if (m_type == SEGA8_BASIC_L3)
|
||||
{
|
||||
m_cart->ram_alloc(machine(), 0x8000);
|
||||
m_cart->ram_alloc(0x8000);
|
||||
m_cart->set_has_battery(FALSE);
|
||||
}
|
||||
else if (m_type == SEGA8_MUSIC_EDITOR)
|
||||
{
|
||||
m_cart->ram_alloc(machine(), 0x2800);
|
||||
m_cart->ram_alloc(0x2800);
|
||||
m_cart->set_has_battery(FALSE);
|
||||
}
|
||||
else if (m_type == SEGA8_DAHJEE_TYPEA)
|
||||
{
|
||||
m_cart->ram_alloc(machine(), 0x2400);
|
||||
m_cart->ram_alloc(0x2400);
|
||||
m_cart->set_has_battery(FALSE);
|
||||
}
|
||||
else if (m_type == SEGA8_DAHJEE_TYPEB)
|
||||
{
|
||||
m_cart->ram_alloc(machine(), 0x2000);
|
||||
m_cart->ram_alloc(0x2000);
|
||||
m_cart->set_has_battery(FALSE);
|
||||
}
|
||||
else if (m_type == SEGA8_CODEMASTERS)
|
||||
{
|
||||
// Codemasters cart can have 64KB of RAM (Ernie Els Golf? or 8KB?) and no battery
|
||||
m_cart->ram_alloc(machine(), 0x10000);
|
||||
m_cart->ram_alloc(0x10000);
|
||||
m_cart->set_has_battery(FALSE);
|
||||
}
|
||||
else
|
||||
@ -324,7 +318,7 @@ void sega8_cart_slot_device::setup_ram()
|
||||
// how much RAM was in the cart and if there was a battery so we always alloc 32KB and
|
||||
// we save its content only if the game enable the RAM
|
||||
m_cart->set_late_battery(TRUE);
|
||||
m_cart->ram_alloc(machine(), 0x08000);
|
||||
m_cart->ram_alloc(0x08000);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -334,7 +328,7 @@ void sega8_cart_slot_device::setup_ram()
|
||||
m_cart->set_late_battery(FALSE);
|
||||
|
||||
if (get_software_region_length("ram"))
|
||||
m_cart->ram_alloc(machine(), get_software_region_length("ram"));
|
||||
m_cart->ram_alloc(get_software_region_length("ram"));
|
||||
|
||||
if (battery && !strcmp(battery, "yes"))
|
||||
m_cart->set_has_battery(TRUE);
|
||||
@ -366,7 +360,7 @@ bool sega8_cart_slot_device::call_load()
|
||||
if (len & 0x3fff)
|
||||
len = ((len >> 14) + 1) << 14;
|
||||
|
||||
m_cart->rom_alloc(machine(), len);
|
||||
m_cart->rom_alloc(len);
|
||||
ROM = m_cart->get_rom_base();
|
||||
|
||||
if (software_entry() == NULL)
|
||||
|
@ -49,8 +49,8 @@ public:
|
||||
virtual DECLARE_READ8_MEMBER(read_ram) { return 0xff; }
|
||||
virtual DECLARE_WRITE8_MEMBER(write_ram) {}
|
||||
|
||||
void rom_alloc(running_machine &machine, UINT32 size);
|
||||
void ram_alloc(running_machine &machine, UINT32 size);
|
||||
void rom_alloc(UINT32 size);
|
||||
void ram_alloc(UINT32 size);
|
||||
|
||||
virtual void late_bank_setup() {}
|
||||
|
||||
@ -66,18 +66,16 @@ public:
|
||||
//protected:
|
||||
UINT8* get_rom_base() { return m_rom; }
|
||||
UINT8* get_ram_base() { return m_ram; }
|
||||
UINT32 get_rom_size() { return m_rom_size; }
|
||||
UINT32 get_ram_size() { return m_ram_size; }
|
||||
UINT32 get_rom_size() { return m_rom.count(); }
|
||||
UINT32 get_ram_size() { return m_ram.count(); }
|
||||
|
||||
void rom_map_setup(UINT32 size);
|
||||
void ram_map_setup(UINT8 banks);
|
||||
|
||||
//private:
|
||||
// internal state
|
||||
UINT8 *m_rom;
|
||||
UINT8 *m_ram;
|
||||
UINT32 m_rom_size;
|
||||
UINT32 m_ram_size;
|
||||
dynamic_buffer m_rom;
|
||||
dynamic_buffer m_ram;
|
||||
int m_rom_page_count;
|
||||
|
||||
bool has_battery;
|
||||
|
@ -86,7 +86,8 @@ device_sns_cart_interface::~device_sns_cart_interface()
|
||||
|
||||
void device_sns_cart_interface::rom_alloc(UINT32 size)
|
||||
{
|
||||
m_rom.resize(size);
|
||||
if (m_rom == NULL)
|
||||
m_rom.resize(size);
|
||||
}
|
||||
|
||||
|
||||
@ -128,7 +129,8 @@ void device_sns_cart_interface::rtc_ram_alloc(UINT32 size)
|
||||
|
||||
void device_sns_cart_interface::addon_bios_alloc(UINT32 size)
|
||||
{
|
||||
m_bios.resize(size);
|
||||
if (m_bios == NULL)
|
||||
m_bios.resize(size);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user