(MESS) Used shared_ptr instead of UINT8* in the Commodore cartridges. (nw)

This commit is contained in:
Curt Coder 2013-12-20 16:04:11 +00:00
parent 7afab9bda2
commit 8c7486fa5d
53 changed files with 225 additions and 712 deletions

View File

@ -102,7 +102,9 @@ ioport_constructor c64_16kb_cartridge_device::device_input_ports() const
c64_16kb_cartridge_device::c64_16kb_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : c64_16kb_cartridge_device::c64_16kb_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, C64_16KB, "C64 16KB EPROM cartridge", tag, owner, clock, "c64_16kb", __FILE__), device_t(mconfig, C64_16KB, "C64 16KB EPROM cartridge", tag, owner, clock, "c64_16kb", __FILE__),
device_c64_expansion_card_interface(mconfig, *this), device_c64_expansion_card_interface(mconfig, *this),
m_sw1(*this, "SW1") m_sw1(*this, "SW1"),
m_rom_low(*this, "roml"),
m_rom_high(*this, "romh")
{ {
} }
@ -113,8 +115,6 @@ c64_16kb_cartridge_device::c64_16kb_cartridge_device(const machine_config &mconf
void c64_16kb_cartridge_device::device_start() void c64_16kb_cartridge_device::device_start()
{ {
m_roml = memregion("roml")->base();
m_romh = memregion("romh")->base();
} }
@ -139,11 +139,11 @@ UINT8 c64_16kb_cartridge_device::c64_cd_r(address_space &space, offs_t offset, U
{ {
if (!roml) if (!roml)
{ {
data = m_roml[offset & 0x1fff]; data = m_rom_low->base()[offset & 0x1fff];
} }
else if (!romh) else if (!romh)
{ {
data = m_romh[offset & 0x1fff]; data = m_rom_high->base()[offset & 0x1fff];
} }
return data; return data;

View File

@ -49,6 +49,8 @@ protected:
private: private:
required_ioport m_sw1; required_ioport m_sw1;
required_memory_region m_rom_low;
required_memory_region m_rom_high;
}; };

View File

@ -53,7 +53,7 @@ c64_dqbb_cartridge_device::c64_dqbb_cartridge_device(const machine_config &mconf
void c64_dqbb_cartridge_device::device_start() void c64_dqbb_cartridge_device::device_start()
{ {
// allocate memory // allocate memory
c64_nvram_pointer(machine(), 0x4000); m_nvram.allocate(0x4000);
// state saving // state saving
save_item(NAME(m_cs)); save_item(NAME(m_cs));

View File

@ -42,8 +42,8 @@ protected:
// device_nvram_interface overrides // device_nvram_interface overrides
virtual void nvram_default() { } virtual void nvram_default() { }
virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram_size); } } virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram.bytes()); } }
virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram_size); } } virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram.bytes()); } }
// device_c64_expansion_card_interface overrides // device_c64_expansion_card_interface overrides
virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2); virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);

View File

@ -89,6 +89,7 @@ c64_easyflash_cartridge_device::c64_easyflash_cartridge_device(const machine_con
m_flash_roml(*this, AM29F040_0_TAG), m_flash_roml(*this, AM29F040_0_TAG),
m_flash_romh(*this, AM29F040_1_TAG), m_flash_romh(*this, AM29F040_1_TAG),
m_jp1(*this, "JP1"), m_jp1(*this, "JP1"),
m_ram(*this, "ram"),
m_bank(0), m_bank(0),
m_mode(0) m_mode(0)
{ {
@ -102,7 +103,7 @@ c64_easyflash_cartridge_device::c64_easyflash_cartridge_device(const machine_con
void c64_easyflash_cartridge_device::device_start() void c64_easyflash_cartridge_device::device_start()
{ {
// allocate memory // allocate memory
c64_ram_pointer(machine(), 0x100); m_ram.allocate(0x100);
// state saving // state saving
save_item(NAME(m_bank)); save_item(NAME(m_bank));

View File

@ -53,6 +53,7 @@ private:
required_device<amd_29f040_device> m_flash_roml; required_device<amd_29f040_device> m_flash_roml;
required_device<amd_29f040_device> m_flash_romh; required_device<amd_29f040_device> m_flash_romh;
required_ioport m_jp1; required_ioport m_jp1;
optional_shared_ptr<UINT8> m_ram;
UINT8 m_bank; UINT8 m_bank;
UINT8 m_mode; UINT8 m_mode;

View File

@ -31,14 +31,9 @@ const device_type C64_EXPANSION_SLOT = &device_creator<c64_expansion_slot_device
device_c64_expansion_card_interface::device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device) device_c64_expansion_card_interface::device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device)
: device_slot_card_interface(mconfig, device), : device_slot_card_interface(mconfig, device),
m_roml(NULL), m_roml(*this, "roml"),
m_romh(NULL), m_romh(*this, "romh"),
m_ram(NULL), m_nvram(*this, "nvram"),
m_nvram(NULL),
m_nvram_size(0),
m_roml_mask(0),
m_romh_mask(0),
m_ram_mask(0),
m_game(1), m_game(1),
m_exrom(1) m_exrom(1)
{ {
@ -55,75 +50,6 @@ device_c64_expansion_card_interface::~device_c64_expansion_card_interface()
} }
//-------------------------------------------------
// c64_roml_pointer - get low ROM pointer
//-------------------------------------------------
UINT8* device_c64_expansion_card_interface::c64_roml_pointer(running_machine &machine, size_t size)
{
if (m_roml == NULL)
{
m_roml = auto_alloc_array(machine, UINT8, size);
m_roml_mask = size - 1;
}
return m_roml;
}
//-------------------------------------------------
// c64_romh_pointer - get high ROM pointer
//-------------------------------------------------
UINT8* device_c64_expansion_card_interface::c64_romh_pointer(running_machine &machine, size_t size)
{
if (m_romh == NULL)
{
m_romh = auto_alloc_array(machine, UINT8, size);
m_romh_mask = size - 1;
}
return m_romh;
}
//-------------------------------------------------
// c64_ram_pointer - get RAM pointer
//-------------------------------------------------
UINT8* device_c64_expansion_card_interface::c64_ram_pointer(running_machine &machine, size_t size)
{
if (m_ram == NULL)
{
m_ram = auto_alloc_array(machine, UINT8, size);
m_ram_mask = size - 1;
}
return m_ram;
}
//-------------------------------------------------
// c64_ram_pointer - get NVRAM pointer
//-------------------------------------------------
UINT8* device_c64_expansion_card_interface::c64_nvram_pointer(running_machine &machine, size_t size)
{
if (m_nvram == NULL)
{
m_nvram = auto_alloc_array(machine, UINT8, size);
m_nvram_mask = size - 1;
m_nvram_size = size;
}
return m_nvram;
}
//************************************************************************** //**************************************************************************
// LIVE DEVICE // LIVE DEVICE
@ -202,7 +128,7 @@ bool c64_expansion_slot_device::call_load()
if (!mame_stricmp(filetype(), "80")) if (!mame_stricmp(filetype(), "80"))
{ {
fread(m_card->c64_roml_pointer(machine(), size), size); fread(m_card->m_roml, size);
m_card->m_exrom = (0); m_card->m_exrom = (0);
if (size == 0x4000) if (size == 0x4000)
@ -212,14 +138,14 @@ bool c64_expansion_slot_device::call_load()
} }
else if (!mame_stricmp(filetype(), "a0")) else if (!mame_stricmp(filetype(), "a0"))
{ {
fread(m_card->c64_romh_pointer(machine(), 0x2000), 0x2000); fread(m_card->m_romh, 0x2000);
m_card->m_exrom = 0; m_card->m_exrom = 0;
m_card->m_game = 0; m_card->m_game = 0;
} }
else if (!mame_stricmp(filetype(), "e0")) else if (!mame_stricmp(filetype(), "e0"))
{ {
fread(m_card->c64_romh_pointer(machine(), 0x2000), 0x2000); fread(m_card->m_romh, 0x2000);
m_card->m_game = 0; m_card->m_game = 0;
} }
@ -235,8 +161,11 @@ bool c64_expansion_slot_device::call_load()
UINT8 *roml = NULL; UINT8 *roml = NULL;
UINT8 *romh = NULL; UINT8 *romh = NULL;
if (roml_size) roml = m_card->c64_roml_pointer(machine(), roml_size); m_card->m_roml.allocate(roml_size);
if (romh_size) romh = m_card->c64_romh_pointer(machine(), romh_size); m_card->m_romh.allocate(romh_size);
if (roml_size) roml = m_card->m_roml;
if (romh_size) romh = m_card->m_roml;
cbm_crt_read_data(m_file, roml, romh); cbm_crt_read_data(m_file, roml, romh);
} }
@ -252,10 +181,8 @@ bool c64_expansion_slot_device::call_load()
if (size) if (size)
{ {
// Ultimax (VIC-10) cartridge // Ultimax (VIC-10) cartridge
memcpy(m_card->c64_romh_pointer(machine(), size), get_software_region("uprom"), size); load_software_region("lorom", m_card->m_roml);
load_software_region("uprom", m_card->m_romh);
size = get_software_region_length("lorom");
if (size) memcpy(m_card->c64_roml_pointer(machine(), size), get_software_region("lorom"), size);
m_card->m_exrom = 1; m_card->m_exrom = 1;
m_card->m_game = 0; m_card->m_game = 0;
@ -263,17 +190,9 @@ bool c64_expansion_slot_device::call_load()
else else
{ {
// Commodore 64/128 cartridge // Commodore 64/128 cartridge
size = get_software_region_length("roml"); load_software_region("roml", m_card->m_roml);
if (size) memcpy(m_card->c64_roml_pointer(machine(), size), get_software_region("roml"), size); load_software_region("romh", m_card->m_romh);
load_software_region("nvram", m_card->m_nvram);
size = get_software_region_length("romh");
if (size) memcpy(m_card->c64_romh_pointer(machine(), size), get_software_region("romh"), size);
size = get_software_region_length("ram");
if (size) memset(m_card->c64_ram_pointer(machine(), size), 0, size);
size = get_software_region_length("nvram");
if (size) memset(m_card->c64_nvram_pointer(machine(), size), 0, size);
if (get_feature("exrom") != NULL) m_card->m_exrom = atol(get_feature("exrom")); if (get_feature("exrom") != NULL) m_card->m_exrom = atol(get_feature("exrom"));
if (get_feature("game") != NULL) m_card->m_game = atol(get_feature("game")); if (get_feature("game") != NULL) m_card->m_game = atol(get_feature("game"));

View File

@ -167,35 +167,20 @@ public:
device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device); device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device);
virtual ~device_c64_expansion_card_interface(); virtual ~device_c64_expansion_card_interface();
protected:
// initialization
virtual UINT8* c64_roml_pointer(running_machine &machine, size_t size);
virtual UINT8* c64_romh_pointer(running_machine &machine, size_t size);
virtual UINT8* c64_ram_pointer(running_machine &machine, size_t size);
virtual UINT8* c64_nvram_pointer(running_machine &machine, size_t size);
// runtime
virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) { return data; }; virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) { return data; };
virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) { }; virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) { };
virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw) { return m_game; } virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw) { return m_game; }
virtual int c64_exrom_r(offs_t offset, int sphi2, int ba, int rw) { return m_exrom; } virtual int c64_exrom_r(offs_t offset, int sphi2, int ba, int rw) { return m_exrom; }
c64_expansion_slot_device *m_slot; protected:
optional_shared_ptr<UINT8> m_roml;
UINT8 *m_roml; optional_shared_ptr<UINT8> m_romh;
UINT8 *m_romh; optional_shared_ptr<UINT8> m_nvram;
UINT8 *m_ram;
UINT8 *m_nvram;
size_t m_nvram_size;
size_t m_roml_mask;
size_t m_romh_mask;
size_t m_ram_mask;
size_t m_nvram_mask;
int m_game; int m_game;
int m_exrom; int m_exrom;
c64_expansion_slot_device *m_slot;
}; };

View File

@ -244,7 +244,7 @@ void c64_final_chesscard_device::c64_cd_w(address_space &space, offs_t offset, U
READ8_MEMBER( c64_final_chesscard_device::nvram_r ) READ8_MEMBER( c64_final_chesscard_device::nvram_r )
{ {
return m_nvram[offset & m_nvram_mask]; return m_nvram[offset & m_nvram.mask()];
} }
@ -254,5 +254,5 @@ READ8_MEMBER( c64_final_chesscard_device::nvram_r )
WRITE8_MEMBER( c64_final_chesscard_device::nvram_w ) WRITE8_MEMBER( c64_final_chesscard_device::nvram_w )
{ {
m_nvram[offset & m_nvram_mask] = data; m_nvram[offset & m_nvram.mask()] = data;
} }

View File

@ -49,8 +49,8 @@ protected:
// device_nvram_interface overrides // device_nvram_interface overrides
virtual void nvram_default() { } virtual void nvram_default() { }
virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram_size); } } virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram.bytes()); } }
virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram_size); } } virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram.bytes()); } }
// device_c64_expansion_card_interface overrides // device_c64_expansion_card_interface overrides
virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2); virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);

View File

@ -31,7 +31,8 @@ const device_type C64_GEORAM = &device_creator<c64_georam_cartridge_device>;
c64_georam_cartridge_device::c64_georam_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : c64_georam_cartridge_device::c64_georam_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, C64_GEORAM, "C64 GeoRAM cartridge", tag, owner, clock, "c64_georam", __FILE__), device_t(mconfig, C64_GEORAM, "C64 GeoRAM cartridge", tag, owner, clock, "c64_georam", __FILE__),
device_c64_expansion_card_interface(mconfig, *this) device_c64_expansion_card_interface(mconfig, *this),
m_ram(*this, "ram")
{ {
} }
@ -43,7 +44,7 @@ c64_georam_cartridge_device::c64_georam_cartridge_device(const machine_config &m
void c64_georam_cartridge_device::device_start() void c64_georam_cartridge_device::device_start()
{ {
// allocate memory // allocate memory
c64_ram_pointer(machine(), 0x80000); m_ram.allocate(0x80000);
// state saving // state saving
save_item(NAME(m_bank)); save_item(NAME(m_bank));

View File

@ -43,6 +43,8 @@ protected:
virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2); virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
private: private:
optional_shared_ptr<UINT8> m_ram;
UINT16 m_bank; UINT16 m_bank;
}; };

View File

@ -103,7 +103,8 @@ c64_ide64_cartridge_device::c64_ide64_cartridge_device(const machine_config &mco
m_flash_rom(*this, AT29C010A_TAG), m_flash_rom(*this, AT29C010A_TAG),
m_rtc(*this, DS1302_TAG), m_rtc(*this, DS1302_TAG),
m_ata(*this, ATA_TAG), m_ata(*this, ATA_TAG),
m_jp1(*this, "JP1") m_jp1(*this, "JP1"),
m_ram(*this, "ram")
{ {
} }
@ -115,7 +116,7 @@ c64_ide64_cartridge_device::c64_ide64_cartridge_device(const machine_config &mco
void c64_ide64_cartridge_device::device_start() void c64_ide64_cartridge_device::device_start()
{ {
// allocate memory // allocate memory
c64_ram_pointer(machine(), 0x8000); m_ram.allocate(0x8000);
// state saving // state saving
save_item(NAME(m_bank)); save_item(NAME(m_bank));

View File

@ -57,6 +57,7 @@ private:
required_device<ds1302_device> m_rtc; required_device<ds1302_device> m_rtc;
required_device<ata_interface_device> m_ata; required_device<ata_interface_device> m_ata;
required_ioport m_jp1; required_ioport m_jp1;
optional_shared_ptr<UINT8> m_ram;
UINT8 m_bank; UINT8 m_bank;
UINT16 m_ata_data; UINT16 m_ata_data;

View File

@ -182,6 +182,7 @@ c64_magic_formel_cartridge_device::c64_magic_formel_cartridge_device(const machi
device_t(mconfig, C64_MAGIC_FORMEL, "C64 Magic Formel cartridge", tag, owner, clock, "c64_magic_formel", __FILE__), device_t(mconfig, C64_MAGIC_FORMEL, "C64 Magic Formel cartridge", tag, owner, clock, "c64_magic_formel", __FILE__),
device_c64_expansion_card_interface(mconfig, *this), device_c64_expansion_card_interface(mconfig, *this),
m_pia(*this, MC6821_TAG), m_pia(*this, MC6821_TAG),
m_ram(*this, "ram"),
m_rom_bank(0), m_rom_bank(0),
m_ram_bank(0), m_ram_bank(0),
m_pb7_ff(0), m_pb7_ff(0),
@ -199,6 +200,9 @@ c64_magic_formel_cartridge_device::c64_magic_formel_cartridge_device(const machi
void c64_magic_formel_cartridge_device::device_start() void c64_magic_formel_cartridge_device::device_start()
{ {
// allocate memory
m_ram.allocate(0x2000);
// state saving // state saving
save_item(NAME(m_rom_bank)); save_item(NAME(m_rom_bank));
save_item(NAME(m_ram_bank)); save_item(NAME(m_ram_bank));

View File

@ -57,6 +57,7 @@ protected:
private: private:
required_device<pia6821_device> m_pia; required_device<pia6821_device> m_pia;
optional_shared_ptr<UINT8> m_ram;
UINT8 m_rom_bank; UINT8 m_rom_bank;
UINT8 m_ram_bank; UINT8 m_ram_bank;

View File

@ -44,7 +44,7 @@ c64_neoram_cartridge_device::c64_neoram_cartridge_device(const machine_config &m
void c64_neoram_cartridge_device::device_start() void c64_neoram_cartridge_device::device_start()
{ {
// allocate memory // allocate memory
c64_nvram_pointer(machine(), 0x200000); m_nvram.allocate(0x200000);
// state saving // state saving
save_item(NAME(m_bank)); save_item(NAME(m_bank));

View File

@ -41,8 +41,8 @@ protected:
// device_nvram_interface overrides // device_nvram_interface overrides
virtual void nvram_default() { } virtual void nvram_default() { }
virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram_size); } } virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram.bytes()); } }
virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram_size); } } virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram.bytes()); } }
// device_c64_expansion_card_interface overrides // device_c64_expansion_card_interface overrides
virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2); virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);

View File

@ -86,15 +86,15 @@ void c64_ocean_cartridge_device::device_reset()
UINT8 c64_ocean_cartridge_device::c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) UINT8 c64_ocean_cartridge_device::c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2)
{ {
if (!roml) if (!roml && m_roml.bytes())
{ {
offs_t addr = (m_bank << 13) | (offset & 0x1fff); offs_t addr = (m_bank << 13) | (offset & 0x1fff);
data = m_roml[addr & m_roml_mask]; data = m_roml[addr & m_roml.mask()];
} }
else if (!romh && m_romh) else if (!romh && m_romh.bytes())
{ {
offs_t addr = (m_bank << 13) | (offset & 0x1fff); offs_t addr = (m_bank << 13) | (offset & 0x1fff);
data = m_romh[addr & m_romh_mask]; data = m_romh[addr & m_romh.mask()];
} }
else if (!io1) else if (!io1)
{ {

View File

@ -53,7 +53,8 @@ const device_type C64_PAGEFOX = &device_creator<c64_pagefox_cartridge_device>;
c64_pagefox_cartridge_device::c64_pagefox_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : c64_pagefox_cartridge_device::c64_pagefox_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, C64_PAGEFOX, "C64 Pagefox cartridge", tag, owner, clock, "c64_pagefox", __FILE__), device_t(mconfig, C64_PAGEFOX, "C64 Pagefox cartridge", tag, owner, clock, "c64_pagefox", __FILE__),
device_c64_expansion_card_interface(mconfig, *this) device_c64_expansion_card_interface(mconfig, *this),
m_ram(*this, "ram")
{ {
} }
@ -64,6 +65,9 @@ c64_pagefox_cartridge_device::c64_pagefox_cartridge_device(const machine_config
void c64_pagefox_cartridge_device::device_start() void c64_pagefox_cartridge_device::device_start()
{ {
// allocate memory
m_ram.allocate(0x8000);
// state saving // state saving
save_item(NAME(m_bank)); save_item(NAME(m_bank));
} }

View File

@ -43,6 +43,8 @@ protected:
virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2); virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
private: private:
optional_shared_ptr<UINT8> m_ram;
UINT8 m_bank; UINT8 m_bank;
}; };

View File

@ -82,6 +82,7 @@ ioport_constructor c64_partner_cartridge_device::device_input_ports() const
c64_partner_cartridge_device::c64_partner_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : c64_partner_cartridge_device::c64_partner_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, C64_PARTNER, "C64 PARTNER 64 cartridge", tag, owner, clock, "c64_partner", __FILE__), device_t(mconfig, C64_PARTNER, "C64 PARTNER 64 cartridge", tag, owner, clock, "c64_partner", __FILE__),
device_c64_expansion_card_interface(mconfig, *this), device_c64_expansion_card_interface(mconfig, *this),
m_ram(*this, "ram"),
m_a0(1), m_a0(1),
m_a6(1), m_a6(1),
m_nmi(0) m_nmi(0)
@ -96,7 +97,7 @@ c64_partner_cartridge_device::c64_partner_cartridge_device(const machine_config
void c64_partner_cartridge_device::device_start() void c64_partner_cartridge_device::device_start()
{ {
// allocate memory // allocate memory
c64_ram_pointer(machine(), 0x2000); m_ram.allocate(0x2000);
} }

View File

@ -48,6 +48,8 @@ protected:
virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw); virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw);
private: private:
optional_shared_ptr<UINT8> m_ram;
int m_a0; int m_a0;
int m_a6; int m_a6;
int m_nmi; int m_nmi;

View File

@ -86,6 +86,8 @@ c64_reu_cartridge_device::c64_reu_cartridge_device(const machine_config &mconfig
device_t(mconfig, type, name, tag, owner, clock, shortname, source), device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_c64_expansion_card_interface(mconfig, *this), device_c64_expansion_card_interface(mconfig, *this),
m_dmac(*this, MOS8726R1_TAG), m_dmac(*this, MOS8726R1_TAG),
m_rom(*this, "rom"),
m_ram(*this, "ram"),
m_variant(variant), m_variant(variant),
m_jp1(jp1), m_jp1(jp1),
m_ram_size(ram_size) m_ram_size(ram_size)
@ -108,11 +110,8 @@ c64_reu1764_cartridge_device::c64_reu1764_cartridge_device(const machine_config
void c64_reu_cartridge_device::device_start() void c64_reu_cartridge_device::device_start()
{ {
// find memory region
m_roml = memregion("roml")->base();
// allocate memory // allocate memory
c64_ram_pointer(machine(), m_ram_size); m_ram.allocate(m_ram_size);
// setup DMA controller // setup DMA controller
m_dmac->set_unscaled_clock(m_slot->phi2()); m_dmac->set_unscaled_clock(m_slot->phi2());

View File

@ -56,6 +56,8 @@ protected:
virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2); virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
required_device<mos8726_device> m_dmac; required_device<mos8726_device> m_dmac;
required_memory_region m_rom;
optional_shared_ptr<UINT8> m_ram;
int m_variant; int m_variant;
int m_jp1; int m_jp1;

View File

@ -70,7 +70,7 @@ UINT8 c64_ross_cartridge_device::c64_cd_r(address_space &space, offs_t offset, U
{ {
offs_t addr = (m_bank << 14) | (offset & 0x3fff); offs_t addr = (m_bank << 14) | (offset & 0x3fff);
data = m_roml[addr & m_roml_mask]; data = m_roml[addr & m_roml.mask()];
} }
return data; return data;

View File

@ -51,19 +51,19 @@ void c64_standard_cartridge_device::device_start()
UINT8 c64_standard_cartridge_device::c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) UINT8 c64_standard_cartridge_device::c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2)
{ {
if (!roml && m_roml_mask) if (!roml && m_roml.bytes())
{ {
data = m_roml[offset & 0x1fff]; data = m_roml[offset & m_roml.mask()];
} }
else if (!romh) else if (!romh)
{ {
if (m_romh_mask) if (m_romh.bytes())
{ {
data = m_romh[offset & 0x1fff]; data = m_romh[offset & m_romh.mask()];
} }
else if (m_roml_mask == 0x3fff) else if (m_roml.mask() == 0x3fff)
{ {
data = m_roml[offset & 0x3fff]; data = m_roml[offset & m_roml.mask()];
} }
} }

View File

@ -63,17 +63,17 @@ UINT8 c64_westermann_cartridge_device::c64_cd_r(address_space &space, offs_t off
{ {
if (!roml) if (!roml)
{ {
data = m_roml[offset & 0x1fff]; data = m_roml[offset & m_roml.mask()];
} }
else if (!romh) else if (!romh)
{ {
if (m_romh_mask) if (m_romh.bytes())
{ {
data = m_romh[offset & 0x1fff]; data = m_romh[offset & m_romh.mask()];
} }
else else
{ {
data = m_roml[offset & 0x3fff]; data = m_roml[offset & m_roml.mask()];
} }
} }
else if (!io2) else if (!io2)

View File

@ -178,7 +178,8 @@ c64_xl80_device::c64_xl80_device(const machine_config &mconfig, const char *tag,
device_t(mconfig, C64_XL80, "XL 80", tag, owner, clock, "c64_xl80", __FILE__), device_t(mconfig, C64_XL80, "XL 80", tag, owner, clock, "c64_xl80", __FILE__),
device_c64_expansion_card_interface(mconfig, *this), device_c64_expansion_card_interface(mconfig, *this),
m_crtc(*this, HD46505SP_TAG), m_crtc(*this, HD46505SP_TAG),
m_char_rom(*this, HD46505SP_TAG) m_char_rom(*this, HD46505SP_TAG),
m_ram(*this, "ram")
{ {
} }
@ -190,10 +191,7 @@ c64_xl80_device::c64_xl80_device(const machine_config &mconfig, const char *tag,
void c64_xl80_device::device_start() void c64_xl80_device::device_start()
{ {
// allocate memory // allocate memory
c64_ram_pointer(machine(), RAM_SIZE); m_ram.allocate(RAM_SIZE);
// state saving
save_pointer(NAME(m_ram), RAM_SIZE);
} }

View File

@ -55,6 +55,7 @@ protected:
private: private:
required_device<h46505_device> m_crtc; required_device<h46505_device> m_crtc;
required_memory_region m_char_rom; required_memory_region m_char_rom;
optional_shared_ptr<UINT8> m_ram;
}; };

View File

@ -31,7 +31,8 @@ const device_type CBM2_24K = &device_creator<cbm2_24k_cartridge_device>;
cbm2_24k_cartridge_device::cbm2_24k_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : cbm2_24k_cartridge_device::cbm2_24k_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, CBM2_24K, "24K RAM/ROM cartridge", tag, owner, clock, "cbm2_24k", __FILE__), device_t(mconfig, CBM2_24K, "24K RAM/ROM cartridge", tag, owner, clock, "cbm2_24k", __FILE__),
device_cbm2_expansion_card_interface(mconfig, *this) device_cbm2_expansion_card_interface(mconfig, *this),
m_ram(*this, "ram")
{ {
} }
@ -42,7 +43,7 @@ cbm2_24k_cartridge_device::cbm2_24k_cartridge_device(const machine_config &mconf
void cbm2_24k_cartridge_device::device_start() void cbm2_24k_cartridge_device::device_start()
{ {
cbm2_ram_pointer(machine(), 0x6000); m_ram.allocate(0x6000);
} }

View File

@ -39,6 +39,8 @@ protected:
// device_cbm2_expansion_card_interface overrides // device_cbm2_expansion_card_interface overrides
virtual UINT8 cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3); virtual UINT8 cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3);
virtual void cbm2_bd_w(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3); virtual void cbm2_bd_w(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3);
optional_shared_ptr<UINT8> m_ram;
}; };

View File

@ -39,16 +39,9 @@ const device_type CBM2_EXPANSION_SLOT = &device_creator<cbm2_expansion_slot_devi
device_cbm2_expansion_card_interface::device_cbm2_expansion_card_interface(const machine_config &mconfig, device_t &device) device_cbm2_expansion_card_interface::device_cbm2_expansion_card_interface(const machine_config &mconfig, device_t &device)
: device_slot_card_interface(mconfig, device), : device_slot_card_interface(mconfig, device),
m_bank1(NULL), m_bank1(*this, "bank1"),
m_bank2(NULL), m_bank2(*this, "bank2"),
m_bank3(NULL), m_bank3(*this, "bank3")
m_ram(NULL),
m_nvram(NULL),
m_nvram_size(0),
m_bank1_mask(0),
m_bank2_mask(0),
m_bank3_mask(0),
m_ram_mask(0)
{ {
m_slot = dynamic_cast<cbm2_expansion_slot_device *>(device.owner()); m_slot = dynamic_cast<cbm2_expansion_slot_device *>(device.owner());
} }
@ -63,92 +56,6 @@ device_cbm2_expansion_card_interface::~device_cbm2_expansion_card_interface()
} }
//-------------------------------------------------
// cbm2_bank1_pointer - get bank 1 pointer
//-------------------------------------------------
UINT8* device_cbm2_expansion_card_interface::cbm2_bank1_pointer(running_machine &machine, size_t size)
{
if (m_bank1 == NULL)
{
m_bank1 = auto_alloc_array(machine, UINT8, size);
m_bank1_mask = size - 1;
}
return m_bank1;
}
//-------------------------------------------------
// cbm2_bank2_pointer - get bank 2 pointer
//-------------------------------------------------
UINT8* device_cbm2_expansion_card_interface::cbm2_bank2_pointer(running_machine &machine, size_t size)
{
if (m_bank2 == NULL)
{
m_bank2 = auto_alloc_array(machine, UINT8, size);
m_bank2_mask = size - 1;
}
return m_bank2;
}
//-------------------------------------------------
// cbm2_bank3_pointer - get bank 3 pointer
//-------------------------------------------------
UINT8* device_cbm2_expansion_card_interface::cbm2_bank3_pointer(running_machine &machine, size_t size)
{
if (m_bank3 == NULL)
{
m_bank3 = auto_alloc_array(machine, UINT8, size);
m_bank3_mask = size - 1;
}
return m_bank3;
}
//-------------------------------------------------
// cbm2_ram_pointer - get RAM pointer
//-------------------------------------------------
UINT8* device_cbm2_expansion_card_interface::cbm2_ram_pointer(running_machine &machine, size_t size)
{
if (m_ram == NULL)
{
m_ram = auto_alloc_array(machine, UINT8, size);
m_ram_mask = size - 1;
}
return m_ram;
}
//-------------------------------------------------
// cbm2_ram_pointer - get NVRAM pointer
//-------------------------------------------------
UINT8* device_cbm2_expansion_card_interface::cbm2_nvram_pointer(running_machine &machine, size_t size)
{
if (m_nvram == NULL)
{
m_nvram = auto_alloc_array(machine, UINT8, size);
m_nvram_mask = size - 1;
m_nvram_size = size;
}
return m_nvram;
}
//************************************************************************** //**************************************************************************
// LIVE DEVICE // LIVE DEVICE
@ -209,33 +116,25 @@ bool cbm2_expansion_slot_device::call_load()
if (!mame_stricmp(filetype(), "20")) if (!mame_stricmp(filetype(), "20"))
{ {
fread(m_card->cbm2_bank1_pointer(machine(), size), size); m_card->m_bank1.allocate(size);
fread(m_card->m_bank1, size);
} }
else if (!mame_stricmp(filetype(), "40")) else if (!mame_stricmp(filetype(), "40"))
{ {
fread(m_card->cbm2_bank2_pointer(machine(), size), size); m_card->m_bank2.allocate(size);
fread(m_card->m_bank2, size);
} }
else if (!mame_stricmp(filetype(), "60")) else if (!mame_stricmp(filetype(), "60"))
{ {
fread(m_card->cbm2_bank3_pointer(machine(), size), size); m_card->m_bank3.allocate(size);
fread(m_card->m_bank3, size);
} }
} }
else else
{ {
size = get_software_region_length("bank1"); load_software_region("bank1", m_card->m_bank1);
if (size) memcpy(m_card->cbm2_bank1_pointer(machine(), size), get_software_region("bank1"), size); load_software_region("bank2", m_card->m_bank2);
load_software_region("bank3", m_card->m_bank3);
size = get_software_region_length("bank2");
if (size) memcpy(m_card->cbm2_bank2_pointer(machine(), size), get_software_region("bank2"), size);
size = get_software_region_length("bank3");
if (size) memcpy(m_card->cbm2_bank3_pointer(machine(), size), get_software_region("bank3"), size);
size = get_software_region_length("ram");
if (size) memset(m_card->cbm2_ram_pointer(machine(), size), 0, size);
size = get_software_region_length("nvram");
if (size) memset(m_card->cbm2_nvram_pointer(machine(), size), 0, size);
} }
} }

View File

@ -116,33 +116,15 @@ public:
device_cbm2_expansion_card_interface(const machine_config &mconfig, device_t &device); device_cbm2_expansion_card_interface(const machine_config &mconfig, device_t &device);
virtual ~device_cbm2_expansion_card_interface(); virtual ~device_cbm2_expansion_card_interface();
protected:
// initialization
virtual UINT8* cbm2_bank1_pointer(running_machine &machine, size_t size);
virtual UINT8* cbm2_bank2_pointer(running_machine &machine, size_t size);
virtual UINT8* cbm2_bank3_pointer(running_machine &machine, size_t size);
virtual UINT8* cbm2_ram_pointer(running_machine &machine, size_t size);
virtual UINT8* cbm2_nvram_pointer(running_machine &machine, size_t size);
// runtime
virtual UINT8 cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3) { return data; }; virtual UINT8 cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3) { return data; };
virtual void cbm2_bd_w(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3) { }; virtual void cbm2_bd_w(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3) { };
protected:
optional_shared_ptr<UINT8> m_bank1;
optional_shared_ptr<UINT8> m_bank2;
optional_shared_ptr<UINT8> m_bank3;
cbm2_expansion_slot_device *m_slot; cbm2_expansion_slot_device *m_slot;
UINT8 *m_bank1;
UINT8 *m_bank2;
UINT8 *m_bank3;
UINT8 *m_ram;
UINT8 *m_nvram;
size_t m_nvram_size;
size_t m_bank1_mask;
size_t m_bank2_mask;
size_t m_bank3_mask;
size_t m_ram_mask;
size_t m_nvram_mask;
}; };

View File

@ -51,17 +51,17 @@ void cbm2_standard_cartridge_device::device_start()
UINT8 cbm2_standard_cartridge_device::cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3) UINT8 cbm2_standard_cartridge_device::cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3)
{ {
if (!csbank1 && m_bank1_mask) if (!csbank1 && m_bank1.bytes())
{ {
data = m_bank1[offset & m_bank1_mask]; data = m_bank1[offset & m_bank1.mask()];
} }
else if (!csbank2 && m_bank2_mask) else if (!csbank2 && m_bank2.bytes())
{ {
data = m_bank2[offset & m_bank2_mask]; data = m_bank2[offset & m_bank2.mask()];
} }
else if (!csbank3 && m_bank3_mask) else if (!csbank3 && m_bank3.bytes())
{ {
data = m_bank3[offset & m_bank3_mask]; data = m_bank3[offset & m_bank3.mask()];
} }
return data; return data;

View File

@ -39,18 +39,14 @@ const device_type PLUS4_EXPANSION_SLOT = &device_creator<plus4_expansion_slot_de
device_plus4_expansion_card_interface::device_plus4_expansion_card_interface(const machine_config &mconfig, device_t &device) device_plus4_expansion_card_interface::device_plus4_expansion_card_interface(const machine_config &mconfig, device_t &device)
: device_slot_card_interface(mconfig, device), : device_slot_card_interface(mconfig, device),
m_c1l(NULL), m_c1l(*this, "c1l"),
m_c1h(NULL), m_c1h(*this, "c1h"),
m_c2l(NULL), m_c2l(*this, "c2l"),
m_c2h(NULL), m_c2h(*this, "c2h"),
m_ram(NULL),
m_nvram(NULL),
m_nvram_size(0),
m_c1l_mask(0), m_c1l_mask(0),
m_c1h_mask(0), m_c1h_mask(0),
m_c2l_mask(0), m_c2l_mask(0),
m_c2h_mask(0), m_c2h_mask(0)
m_ram_mask(0)
{ {
m_slot = dynamic_cast<plus4_expansion_slot_device *>(device.owner()); m_slot = dynamic_cast<plus4_expansion_slot_device *>(device.owner());
} }
@ -65,109 +61,6 @@ device_plus4_expansion_card_interface::~device_plus4_expansion_card_interface()
} }
//-------------------------------------------------
// plus4_c1l_pointer - get low ROM 1 pointer
//-------------------------------------------------
UINT8* device_plus4_expansion_card_interface::plus4_c1l_pointer(running_machine &machine, size_t size)
{
if (m_c1l == NULL)
{
m_c1l = auto_alloc_array(machine, UINT8, size);
m_c1l_mask = size - 1;
}
return m_c1l;
}
//-------------------------------------------------
// plus4_c1h_pointer - get low ROM 1 pointer
//-------------------------------------------------
UINT8* device_plus4_expansion_card_interface::plus4_c1h_pointer(running_machine &machine, size_t size)
{
if (m_c1h == NULL)
{
m_c1h = auto_alloc_array(machine, UINT8, size);
m_c1h_mask = size - 1;
}
return m_c1h;
}
//-------------------------------------------------
// plus4_c2l_pointer - get low ROM 1 pointer
//-------------------------------------------------
UINT8* device_plus4_expansion_card_interface::plus4_c2l_pointer(running_machine &machine, size_t size)
{
if (m_c2l == NULL)
{
m_c2l = auto_alloc_array(machine, UINT8, size);
m_c2l_mask = size - 1;
}
return m_c2l;
}
//-------------------------------------------------
// plus4_c2h_pointer - get low ROM 1 pointer
//-------------------------------------------------
UINT8* device_plus4_expansion_card_interface::plus4_c2h_pointer(running_machine &machine, size_t size)
{
if (m_c2h == NULL)
{
m_c2h = auto_alloc_array(machine, UINT8, size);
m_c2h_mask = size - 1;
}
return m_c2h;
}
//-------------------------------------------------
// plus4_ram_pointer - get RAM pointer
//-------------------------------------------------
UINT8* device_plus4_expansion_card_interface::plus4_ram_pointer(running_machine &machine, size_t size)
{
if (m_ram == NULL)
{
m_ram = auto_alloc_array(machine, UINT8, size);
m_ram_mask = size - 1;
}
return m_ram;
}
//-------------------------------------------------
// plus4_ram_pointer - get NVRAM pointer
//-------------------------------------------------
UINT8* device_plus4_expansion_card_interface::plus4_nvram_pointer(running_machine &machine, size_t size)
{
if (m_nvram == NULL)
{
m_nvram = auto_alloc_array(machine, UINT8, size);
m_nvram_mask = size - 1;
m_nvram_size = size;
}
return m_nvram;
}
//************************************************************************** //**************************************************************************
// LIVE DEVICE // LIVE DEVICE
@ -234,31 +127,16 @@ bool plus4_expansion_slot_device::call_load()
{ {
if (m_card) if (m_card)
{ {
size_t size = 0;
if (software_entry() == NULL) if (software_entry() == NULL)
{ {
// TODO // TODO
} }
else else
{ {
size = get_software_region_length("c1l"); load_software_region("c1l", m_card->m_c1l);
if (size) memcpy(m_card->plus4_c1l_pointer(machine(), size), get_software_region("c1l"), size); load_software_region("c1h", m_card->m_c1h);
load_software_region("c2l", m_card->m_c2l);
size = get_software_region_length("c1h"); load_software_region("c2h", m_card->m_c2h);
if (size) memcpy(m_card->plus4_c1h_pointer(machine(), size), get_software_region("c1h"), size);
size = get_software_region_length("c2l");
if (size) memcpy(m_card->plus4_c2l_pointer(machine(), size), get_software_region("c2l"), size);
size = get_software_region_length("c2h");
if (size) memcpy(m_card->plus4_c2h_pointer(machine(), size), get_software_region("c2h"), size);
size = get_software_region_length("ram");
if (size) memset(m_card->plus4_ram_pointer(machine(), size), 0, size);
size = get_software_region_length("nvram");
if (size) memset(m_card->plus4_nvram_pointer(machine(), size), 0, size);
} }
} }

View File

@ -152,36 +152,22 @@ public:
device_plus4_expansion_card_interface(const machine_config &mconfig, device_t &device); device_plus4_expansion_card_interface(const machine_config &mconfig, device_t &device);
virtual ~device_plus4_expansion_card_interface(); virtual ~device_plus4_expansion_card_interface();
// initialization
virtual UINT8* plus4_c1l_pointer(running_machine &machine, size_t size);
virtual UINT8* plus4_c1h_pointer(running_machine &machine, size_t size);
virtual UINT8* plus4_c2l_pointer(running_machine &machine, size_t size);
virtual UINT8* plus4_c2h_pointer(running_machine &machine, size_t size);
virtual UINT8* plus4_ram_pointer(running_machine &machine, size_t size);
virtual UINT8* plus4_nvram_pointer(running_machine &machine, size_t size);
// runtime // runtime
virtual UINT8 plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) { return data; }; virtual UINT8 plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) { return data; };
virtual void plus4_cd_w(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) { }; virtual void plus4_cd_w(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) { };
protected: protected:
plus4_expansion_slot_device *m_slot; optional_shared_ptr<UINT8> m_c1l;
optional_shared_ptr<UINT8> m_c1h;
UINT8 *m_c1l; optional_shared_ptr<UINT8> m_c2l;
UINT8 *m_c1h; optional_shared_ptr<UINT8> m_c2h;
UINT8 *m_c2l;
UINT8 *m_c2h;
UINT8 *m_ram;
UINT8 *m_nvram;
size_t m_nvram_size;
size_t m_c1l_mask; size_t m_c1l_mask;
size_t m_c1h_mask; size_t m_c1h_mask;
size_t m_c2l_mask; size_t m_c2l_mask;
size_t m_c2h_mask; size_t m_c2h_mask;
size_t m_ram_mask;
size_t m_nvram_mask; plus4_expansion_slot_device *m_slot;
}; };

View File

@ -51,21 +51,21 @@ void plus4_standard_cartridge_device::device_start()
UINT8 plus4_standard_cartridge_device::plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) UINT8 plus4_standard_cartridge_device::plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h)
{ {
if (!c1l && m_c1l_mask) if (!c1l && m_c1l.bytes())
{ {
data = m_c1l[offset & m_c1l_mask]; data = m_c1l[offset & m_c1l.mask()];
} }
else if (!c1h && m_c1h_mask) else if (!c1h && m_c1h.bytes())
{ {
data = m_c1h[offset & m_c1h_mask]; data = m_c1h[offset & m_c1h.mask()];
} }
else if (!c2l && m_c2l_mask) else if (!c2l && m_c2l.bytes())
{ {
data = m_c2l[offset & m_c2l_mask]; data = m_c2l[offset & m_c2l.mask()];
} }
else if (!c2h && m_c2h_mask) else if (!c2h && m_c2h.bytes())
{ {
data = m_c2h[offset & m_c2h_mask]; data = m_c2h[offset & m_c2h.mask()];
} }
return data; return data;

View File

@ -39,6 +39,8 @@ protected:
// device_plus4_expansion_card_interface overrides // device_plus4_expansion_card_interface overrides
virtual UINT8 plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h); virtual UINT8 plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h);
}; };

View File

@ -33,9 +33,9 @@ const device_type VIC10_EXPANSION_SLOT = &device_creator<vic10_expansion_slot_de
device_vic10_expansion_card_interface::device_vic10_expansion_card_interface(const machine_config &mconfig, device_t &device) device_vic10_expansion_card_interface::device_vic10_expansion_card_interface(const machine_config &mconfig, device_t &device)
: device_slot_card_interface(mconfig,device), : device_slot_card_interface(mconfig,device),
m_exram(NULL), m_lorom(*this, "lorom"),
m_lorom(NULL), m_exram(*this, "exram"),
m_uprom(NULL) m_uprom(*this, "uprom")
{ {
m_slot = dynamic_cast<vic10_expansion_slot_device *>(device.owner()); m_slot = dynamic_cast<vic10_expansion_slot_device *>(device.owner());
} }
@ -51,52 +51,6 @@ device_vic10_expansion_card_interface::~device_vic10_expansion_card_interface()
//-------------------------------------------------
// vic10_lorom_pointer - get lower ROM pointer
//-------------------------------------------------
UINT8* device_vic10_expansion_card_interface::vic10_lorom_pointer(running_machine &machine, size_t size)
{
if (m_lorom == NULL)
{
m_lorom = auto_alloc_array(machine, UINT8, size);
}
return m_lorom;
}
//-------------------------------------------------
// vic10_uprom_pointer - get upper ROM pointer
//-------------------------------------------------
UINT8* device_vic10_expansion_card_interface::vic10_uprom_pointer(running_machine &machine, size_t size)
{
if (m_uprom == NULL)
{
m_uprom = auto_alloc_array(machine, UINT8, size);
}
return m_uprom;
}
//-------------------------------------------------
// vic10_exram_pointer - get expanded RAM pointer
//-------------------------------------------------
UINT8* device_vic10_expansion_card_interface::vic10_exram_pointer(running_machine &machine, size_t size)
{
if (m_exram == NULL)
{
m_exram = auto_alloc_array(machine, UINT8, size);
}
return m_exram;
}
//************************************************************************** //**************************************************************************
// LIVE DEVICE // LIVE DEVICE
//************************************************************************** //**************************************************************************
@ -170,14 +124,17 @@ bool vic10_expansion_slot_device::call_load()
if (!mame_stricmp(filetype(), "80")) if (!mame_stricmp(filetype(), "80"))
{ {
fread(m_card->vic10_lorom_pointer(machine(), 0x2000), 0x2000); fread(m_card->m_lorom, 0x2000);
if (size == 0x4000) if (size == 0x4000)
{ {
fread(m_card->vic10_uprom_pointer(machine(), 0x2000), 0x2000); fread(m_card->m_uprom, 0x2000);
} }
} }
else if (!mame_stricmp(filetype(), "e0")) fread(m_card->vic10_uprom_pointer(machine(), size), size); else if (!mame_stricmp(filetype(), "e0"))
{
fread(m_card->m_uprom, size);
}
else if (!mame_stricmp(filetype(), "crt")) else if (!mame_stricmp(filetype(), "crt"))
{ {
size_t roml_size = 0; size_t roml_size = 0;
@ -190,8 +147,11 @@ bool vic10_expansion_slot_device::call_load()
UINT8 *roml = NULL; UINT8 *roml = NULL;
UINT8 *romh = NULL; UINT8 *romh = NULL;
if (roml_size) roml = m_card->vic10_lorom_pointer(machine(), roml_size); m_card->m_lorom.allocate(roml_size);
if (romh_size) romh = m_card->vic10_uprom_pointer(machine(), romh_size); m_card->m_uprom.allocate(romh_size);
if (roml_size) roml = m_card->m_lorom;
if (romh_size) romh = m_card->m_lorom;
cbm_crt_read_data(m_file, roml, romh); cbm_crt_read_data(m_file, roml, romh);
} }
@ -199,14 +159,9 @@ bool vic10_expansion_slot_device::call_load()
} }
else else
{ {
size = get_software_region_length("lorom"); load_software_region("lorom", m_card->m_lorom);
if (size) memcpy(m_card->vic10_lorom_pointer(machine(), size), get_software_region("lorom"), size); load_software_region("exram", m_card->m_exram);
load_software_region("uprom", m_card->m_uprom);
size = get_software_region_length("uprom");
if (size) memcpy(m_card->vic10_uprom_pointer(machine(), size), get_software_region("uprom"), size);
size = get_software_region_length("exram");
if (size) m_card->vic10_exram_pointer(machine(), size);
} }
} }

View File

@ -152,13 +152,6 @@ public:
device_vic10_expansion_card_interface(const machine_config &mconfig, device_t &device); device_vic10_expansion_card_interface(const machine_config &mconfig, device_t &device);
virtual ~device_vic10_expansion_card_interface(); virtual ~device_vic10_expansion_card_interface();
protected:
// initialization
virtual UINT8* vic10_exram_pointer(running_machine &machine, size_t size);
virtual UINT8* vic10_lorom_pointer(running_machine &machine, size_t size);
virtual UINT8* vic10_uprom_pointer(running_machine &machine, size_t size);
// runtime
virtual UINT8 vic10_cd_r(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram) { return data; }; virtual UINT8 vic10_cd_r(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram) { return data; };
virtual void vic10_cd_w(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram) { }; virtual void vic10_cd_w(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram) { };
virtual int vic10_p0_r() { return 0; }; virtual int vic10_p0_r() { return 0; };
@ -166,11 +159,12 @@ protected:
virtual void vic10_sp_w(int state) { }; virtual void vic10_sp_w(int state) { };
virtual void vic10_cnt_w(int state) { }; virtual void vic10_cnt_w(int state) { };
vic10_expansion_slot_device *m_slot; protected:
optional_shared_ptr<UINT8> m_lorom;
optional_shared_ptr<UINT8> m_exram;
optional_shared_ptr<UINT8> m_uprom;
UINT8 *m_exram; vic10_expansion_slot_device *m_slot;
UINT8 *m_lorom;
UINT8 *m_uprom;
}; };

View File

@ -51,17 +51,17 @@ void vic10_standard_cartridge_device::device_start()
UINT8 vic10_standard_cartridge_device::vic10_cd_r(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram) UINT8 vic10_standard_cartridge_device::vic10_cd_r(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram)
{ {
if (!lorom && (m_lorom != NULL)) if (!lorom && m_lorom.bytes())
{ {
data = m_lorom[offset & 0x1fff]; data = m_lorom[offset & m_lorom.mask()];
} }
else if (!exram && (m_exram != NULL)) else if (!exram && m_exram.bytes())
{ {
data = m_exram[offset & 0x7ff]; data = m_exram[offset & m_exram.mask()];
} }
else if (!uprom && (m_uprom != NULL)) else if (!uprom && m_uprom.bytes())
{ {
data = m_uprom[offset & 0x1fff]; data = m_uprom[offset & m_uprom.mask()];
} }
return data; return data;
@ -74,8 +74,8 @@ UINT8 vic10_standard_cartridge_device::vic10_cd_r(address_space &space, offs_t o
void vic10_standard_cartridge_device::vic10_cd_w(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram) void vic10_standard_cartridge_device::vic10_cd_w(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram)
{ {
if (!exram && (m_exram != NULL)) if (!exram && m_exram.bytes())
{ {
m_exram[offset & 0x7ff] = data; m_exram[offset & m_exram.mask()] = data;
} }
} }

View File

@ -33,111 +33,16 @@ const device_type VIC20_EXPANSION_SLOT = &device_creator<vic20_expansion_slot_de
device_vic20_expansion_card_interface::device_vic20_expansion_card_interface(const machine_config &mconfig, device_t &device) device_vic20_expansion_card_interface::device_vic20_expansion_card_interface(const machine_config &mconfig, device_t &device)
: device_slot_card_interface(mconfig, device), : device_slot_card_interface(mconfig, device),
m_blk1(NULL), m_blk1(*this, "blk1"),
m_blk2(NULL), m_blk2(*this, "blk2"),
m_blk3(NULL), m_blk3(*this, "blk3"),
m_blk5(NULL), m_blk5(*this, "blk5"),
m_ram(NULL), m_nvram(*this, "nvram")
m_nvram(NULL),
m_nvram_size(0)
{ {
m_slot = dynamic_cast<vic20_expansion_slot_device *>(device.owner()); m_slot = dynamic_cast<vic20_expansion_slot_device *>(device.owner());
} }
//-------------------------------------------------
// vic20_blk1_pointer - get block 1 pointer
//-------------------------------------------------
UINT8* device_vic20_expansion_card_interface::vic20_blk1_pointer(running_machine &machine, size_t size)
{
if (m_blk1 == NULL)
{
m_blk1 = auto_alloc_array(machine, UINT8, size);
}
return m_blk1;
}
//-------------------------------------------------
// vic20_blk2_pointer - get block 2 pointer
//-------------------------------------------------
UINT8* device_vic20_expansion_card_interface::vic20_blk2_pointer(running_machine &machine, size_t size)
{
if (m_blk2 == NULL)
{
m_blk2 = auto_alloc_array(machine, UINT8, size);
}
return m_blk2;
}
//-------------------------------------------------
// vic20_blk3_pointer - get block 3 pointer
//-------------------------------------------------
UINT8* device_vic20_expansion_card_interface::vic20_blk3_pointer(running_machine &machine, size_t size)
{
if (m_blk3 == NULL)
{
m_blk3 = auto_alloc_array(machine, UINT8, size);
}
return m_blk3;
}
//-------------------------------------------------
// vic20_blk5_pointer - get block 5 pointer
//-------------------------------------------------
UINT8* device_vic20_expansion_card_interface::vic20_blk5_pointer(running_machine &machine, size_t size)
{
if (m_blk5 == NULL)
{
m_blk5 = auto_alloc_array(machine, UINT8, size);
}
return m_blk5;
}
//-------------------------------------------------
// vic20_ram_pointer - get RAM pointer
//-------------------------------------------------
UINT8* device_vic20_expansion_card_interface::vic20_ram_pointer(running_machine &machine, size_t size)
{
if (m_ram == NULL)
{
m_ram = auto_alloc_array(machine, UINT8, size);
}
return m_ram;
}
//-------------------------------------------------
// vic20_nvram_pointer - get NVRAM pointer
//-------------------------------------------------
UINT8* device_vic20_expansion_card_interface::vic20_nvram_pointer(running_machine &machine, size_t size)
{
if (m_nvram == NULL)
{
m_nvram = auto_alloc_array(machine, UINT8, size);
m_nvram_mask = size - 1;
m_nvram_size = size;
}
return m_nvram;
}
//------------------------------------------------- //-------------------------------------------------
// ~device_vic20_expansion_card_interface - destructor // ~device_vic20_expansion_card_interface - destructor
//------------------------------------------------- //-------------------------------------------------
@ -211,16 +116,14 @@ bool vic20_expansion_slot_device::call_load()
{ {
if (m_card) if (m_card)
{ {
size_t size = 0;
if (software_entry() == NULL) if (software_entry() == NULL)
{ {
if (!mame_stricmp(filetype(), "20")) fread(m_card->vic20_blk1_pointer(machine(), 0x2000), 0x2000); if (!mame_stricmp(filetype(), "20")) fread(m_card->m_blk1, 0x2000);
else if (!mame_stricmp(filetype(), "40")) fread(m_card->vic20_blk2_pointer(machine(), 0x2000), 0x2000); else if (!mame_stricmp(filetype(), "40")) fread(m_card->m_blk2, 0x2000);
else if (!mame_stricmp(filetype(), "60")) fread(m_card->vic20_blk3_pointer(machine(), 0x2000), 0x2000); else if (!mame_stricmp(filetype(), "60")) fread(m_card->m_blk3, 0x2000);
else if (!mame_stricmp(filetype(), "70")) fread(m_card->vic20_blk3_pointer(machine(), 0x2000) + 0x1000, 0x1000); else if (!mame_stricmp(filetype(), "70")) fread(m_card->m_blk3, 0x2000, 0x1000);
else if (!mame_stricmp(filetype(), "a0")) fread(m_card->vic20_blk5_pointer(machine(), 0x2000), 0x2000); else if (!mame_stricmp(filetype(), "a0")) fread(m_card->m_blk5, 0x2000);
else if (!mame_stricmp(filetype(), "b0")) fread(m_card->vic20_blk5_pointer(machine(), 0x2000) + 0x1000, 0x1000); else if (!mame_stricmp(filetype(), "b0")) fread(m_card->m_blk5, 0x2000, 0x1000);
else if (!mame_stricmp(filetype(), "crt")) else if (!mame_stricmp(filetype(), "crt"))
{ {
// read the header // read the header
@ -230,36 +133,22 @@ bool vic20_expansion_slot_device::call_load()
switch (address) switch (address)
{ {
case 0x2000: fread(m_card->vic20_blk1_pointer(machine(), 0x2000), 0x2000); break; case 0x2000: fread(m_card->m_blk1, 0x2000); break;
case 0x4000: fread(m_card->vic20_blk2_pointer(machine(), 0x2000), 0x2000); break; case 0x4000: fread(m_card->m_blk2, 0x2000); break;
case 0x6000: fread(m_card->vic20_blk3_pointer(machine(), 0x2000), 0x2000); break; case 0x6000: fread(m_card->m_blk3, 0x2000); break;
case 0x7000: fread(m_card->vic20_blk3_pointer(machine(), 0x2000) + 0x1000, 0x1000); break; case 0x7000: fread(m_card->m_blk3, 0x2000, 0x1000); break;
case 0xa000: fread(m_card->vic20_blk5_pointer(machine(), 0x2000), 0x2000); break; case 0xa000: fread(m_card->m_blk5, 0x2000); break;
case 0xb000: fread(m_card->vic20_blk5_pointer(machine(), 0x2000) + 0x1000, 0x1000); break; case 0xb000: fread(m_card->m_blk5, 0x2000, 0x1000); break;
default: return IMAGE_INIT_FAIL; default: return IMAGE_INIT_FAIL;
} }
} }
} }
else else
{ {
size = get_software_region_length("blk1"); load_software_region("blk1", m_card->m_blk1);
if (size) memcpy(m_card->vic20_blk1_pointer(machine(), size), get_software_region("blk1"), size); load_software_region("blk2", m_card->m_blk2);
load_software_region("blk3", m_card->m_blk3);
size = get_software_region_length("blk2"); load_software_region("blk5", m_card->m_blk5);
if (size) memcpy(m_card->vic20_blk2_pointer(machine(), size), get_software_region("blk2"), size);
size = get_software_region_length("blk3");
if (size) memcpy(m_card->vic20_blk3_pointer(machine(), size), get_software_region("blk3"), size);
size = get_software_region_length("blk5");
if (size) memcpy(m_card->vic20_blk5_pointer(machine(), size), get_software_region("blk5"), size);
size = get_software_region_length("ram");
if (size) memcpy(m_card->vic20_ram_pointer(machine(), size), get_software_region("ram"), size);
size = get_software_region_length("nvram");
if (size) memcpy(m_card->vic20_nvram_pointer(machine(), size), get_software_region("nvram"), size);
} }
} }

View File

@ -144,31 +144,17 @@ public:
device_vic20_expansion_card_interface(const machine_config &mconfig, device_t &device); device_vic20_expansion_card_interface(const machine_config &mconfig, device_t &device);
virtual ~device_vic20_expansion_card_interface(); virtual ~device_vic20_expansion_card_interface();
protected:
// initialization
virtual UINT8* vic20_blk1_pointer(running_machine &machine, size_t size);
virtual UINT8* vic20_blk2_pointer(running_machine &machine, size_t size);
virtual UINT8* vic20_blk3_pointer(running_machine &machine, size_t size);
virtual UINT8* vic20_blk5_pointer(running_machine &machine, size_t size);
virtual UINT8* vic20_ram_pointer(running_machine &machine, size_t size);
virtual UINT8* vic20_nvram_pointer(running_machine &machine, size_t size);
// runtime
virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3) { return data; }; virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3) { return data; };
virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3) { }; virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3) { };
protected:
optional_shared_ptr<UINT8> m_blk1;
optional_shared_ptr<UINT8> m_blk2;
optional_shared_ptr<UINT8> m_blk3;
optional_shared_ptr<UINT8> m_blk5;
optional_shared_ptr<UINT8> m_nvram;
vic20_expansion_slot_device *m_slot; vic20_expansion_slot_device *m_slot;
UINT8 *m_blk1;
UINT8 *m_blk2;
UINT8 *m_blk3;
UINT8 *m_blk5;
UINT8 *m_ram;
UINT8 *m_nvram;
size_t m_nvram_size;
size_t m_nvram_mask;
}; };

View File

@ -21,10 +21,10 @@ const device_type VIC20_MEGACART = &device_creator<vic20_megacart_device>;
//------------------------------------------------- //-------------------------------------------------
// MACHINE_DRIVER( vic1112 ) // MACHINE_DRIVER( vic20_megacart )
//------------------------------------------------- //-------------------------------------------------
static MACHINE_CONFIG_FRAGMENT( vic1112 ) static MACHINE_CONFIG_FRAGMENT( vic20_megacart )
MACHINE_CONFIG_END MACHINE_CONFIG_END
@ -36,7 +36,7 @@ MACHINE_CONFIG_END
machine_config_constructor vic20_megacart_device::device_mconfig_additions() const machine_config_constructor vic20_megacart_device::device_mconfig_additions() const
{ {
return MACHINE_CONFIG_NAME( vic1112 ); return MACHINE_CONFIG_NAME( vic20_megacart );
} }
@ -64,6 +64,8 @@ vic20_megacart_device::vic20_megacart_device(const machine_config &mconfig, cons
void vic20_megacart_device::device_start() void vic20_megacart_device::device_start()
{ {
m_nvram.allocate(0x2000);
// state saving // state saving
save_item(NAME(m_nvram_en)); save_item(NAME(m_nvram_en));
} }

View File

@ -43,8 +43,8 @@ protected:
// device_nvram_interface overrides // device_nvram_interface overrides
virtual void nvram_default() { } virtual void nvram_default() { }
virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram_size); } } virtual void nvram_read(emu_file &file) { file.read(m_nvram, m_nvram.bytes()); }
virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram_size); } } virtual void nvram_write(emu_file &file) { file.write(m_nvram, m_nvram.bytes()); }
// device_vic20_expansion_card_interface overrides // device_vic20_expansion_card_interface overrides
virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3); virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);

View File

@ -71,6 +71,7 @@ ioport_constructor vic1110_device::device_input_ports() const
vic1110_device::vic1110_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) vic1110_device::vic1110_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, VIC1110, "VIC1110", tag, owner, clock, "vic1110", __FILE__), : device_t(mconfig, VIC1110, "VIC1110", tag, owner, clock, "vic1110", __FILE__),
device_vic20_expansion_card_interface(mconfig, *this), device_vic20_expansion_card_interface(mconfig, *this),
m_ram(*this, "ram"),
m_sw(*this, "SW") m_sw(*this, "SW")
{ {
} }
@ -83,7 +84,7 @@ vic1110_device::vic1110_device(const machine_config &mconfig, const char *tag, d
void vic1110_device::device_start() void vic1110_device::device_start()
{ {
// allocate memory // allocate memory
vic20_ram_pointer(machine(), 0x2000); m_ram.allocate(0x2000);
} }

View File

@ -44,6 +44,7 @@ protected:
virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3); virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
private: private:
optional_shared_ptr<UINT8> m_ram;
required_ioport m_sw; required_ioport m_sw;
}; };

View File

@ -31,7 +31,8 @@ const device_type VIC1111 = &device_creator<vic1111_device>;
vic1111_device::vic1111_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) vic1111_device::vic1111_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, VIC1111, "VIC1111", tag, owner, clock, "vic1111", __FILE__), : device_t(mconfig, VIC1111, "VIC1111", tag, owner, clock, "vic1111", __FILE__),
device_vic20_expansion_card_interface(mconfig, *this) device_vic20_expansion_card_interface(mconfig, *this),
m_ram(*this, "ram")
{ {
} }
@ -43,7 +44,7 @@ vic1111_device::vic1111_device(const machine_config &mconfig, const char *tag, d
void vic1111_device::device_start() void vic1111_device::device_start()
{ {
// allocate memory // allocate memory
m_ram = auto_alloc_array(machine(), UINT8, 0x4000); m_ram.allocate(0x4000);
} }

View File

@ -39,6 +39,9 @@ protected:
// device_vic20_expansion_card_interface overrides // device_vic20_expansion_card_interface overrides
virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3); virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3); virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
private:
optional_shared_ptr<UINT8> m_ram;
}; };

View File

@ -32,7 +32,8 @@ const device_type VIC1210 = &device_creator<vic1210_device>;
vic1210_device::vic1210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) vic1210_device::vic1210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, VIC1210, "VIC1210", tag, owner, clock, "vic1210", __FILE__), : device_t(mconfig, VIC1210, "VIC1210", tag, owner, clock, "vic1210", __FILE__),
device_vic20_expansion_card_interface(mconfig, *this) device_vic20_expansion_card_interface(mconfig, *this),
m_ram(*this, "ram")
{ {
} }
@ -44,7 +45,7 @@ vic1210_device::vic1210_device(const machine_config &mconfig, const char *tag, d
void vic1210_device::device_start() void vic1210_device::device_start()
{ {
// allocate memory // allocate memory
m_ram = auto_alloc_array(machine(), UINT8, 0xc00); m_ram.allocate(0xc00);
} }

View File

@ -40,6 +40,9 @@ protected:
// device_vic20_expansion_card_interface overrides // device_vic20_expansion_card_interface overrides
virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3); virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3); virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
private:
optional_shared_ptr<UINT8> m_ram;
}; };