diff options
author | 2013-12-20 16:04:11 +0000 | |
---|---|---|
committer | 2013-12-20 16:04:11 +0000 | |
commit | 8c7486fa5d9eb873577770a92bc524770ed402ba (patch) | |
tree | 7343677631c224588f7113cd61c40747293de5b8 /src/emu/bus/c64 | |
parent | 7afab9bda2b90efc60412ec7ef3215466b53fb21 (diff) |
(MESS) Used shared_ptr instead of UINT8* in the Commodore cartridges. (nw)
Diffstat (limited to 'src/emu/bus/c64')
30 files changed, 91 insertions, 164 deletions
diff --git a/src/emu/bus/c64/16kb.c b/src/emu/bus/c64/16kb.c index e92eff8704f..2e05459f4bd 100644 --- a/src/emu/bus/c64/16kb.c +++ b/src/emu/bus/c64/16kb.c @@ -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) : device_t(mconfig, C64_16KB, "C64 16KB EPROM cartridge", tag, owner, clock, "c64_16kb", __FILE__), 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() { - 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) { - data = m_roml[offset & 0x1fff]; + data = m_rom_low->base()[offset & 0x1fff]; } else if (!romh) { - data = m_romh[offset & 0x1fff]; + data = m_rom_high->base()[offset & 0x1fff]; } return data; diff --git a/src/emu/bus/c64/16kb.h b/src/emu/bus/c64/16kb.h index ddfdad85b25..3e0e16a5d9d 100644 --- a/src/emu/bus/c64/16kb.h +++ b/src/emu/bus/c64/16kb.h @@ -49,6 +49,8 @@ protected: private: required_ioport m_sw1; + required_memory_region m_rom_low; + required_memory_region m_rom_high; }; diff --git a/src/emu/bus/c64/dqbb.c b/src/emu/bus/c64/dqbb.c index f7b4b2a504a..dbbdc5f1d8b 100644 --- a/src/emu/bus/c64/dqbb.c +++ b/src/emu/bus/c64/dqbb.c @@ -53,7 +53,7 @@ c64_dqbb_cartridge_device::c64_dqbb_cartridge_device(const machine_config &mconf void c64_dqbb_cartridge_device::device_start() { // allocate memory - c64_nvram_pointer(machine(), 0x4000); + m_nvram.allocate(0x4000); // state saving save_item(NAME(m_cs)); diff --git a/src/emu/bus/c64/dqbb.h b/src/emu/bus/c64/dqbb.h index 46ffd277fca..75a02e7d745 100644 --- a/src/emu/bus/c64/dqbb.h +++ b/src/emu/bus/c64/dqbb.h @@ -42,8 +42,8 @@ protected: // device_nvram_interface overrides 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_write(emu_file &file) { if (m_nvram != NULL) { file.write(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.bytes()); } } // 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); diff --git a/src/emu/bus/c64/easyflash.c b/src/emu/bus/c64/easyflash.c index cc50bc2d5a4..aee84fed48f 100644 --- a/src/emu/bus/c64/easyflash.c +++ b/src/emu/bus/c64/easyflash.c @@ -89,6 +89,7 @@ c64_easyflash_cartridge_device::c64_easyflash_cartridge_device(const machine_con m_flash_roml(*this, AM29F040_0_TAG), m_flash_romh(*this, AM29F040_1_TAG), m_jp1(*this, "JP1"), + m_ram(*this, "ram"), m_bank(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() { // allocate memory - c64_ram_pointer(machine(), 0x100); + m_ram.allocate(0x100); // state saving save_item(NAME(m_bank)); diff --git a/src/emu/bus/c64/easyflash.h b/src/emu/bus/c64/easyflash.h index 14a6a2472b8..4e7b1091abd 100644 --- a/src/emu/bus/c64/easyflash.h +++ b/src/emu/bus/c64/easyflash.h @@ -53,6 +53,7 @@ private: required_device<amd_29f040_device> m_flash_roml; required_device<amd_29f040_device> m_flash_romh; required_ioport m_jp1; + optional_shared_ptr<UINT8> m_ram; UINT8 m_bank; UINT8 m_mode; diff --git a/src/emu/bus/c64/exp.c b/src/emu/bus/c64/exp.c index 8d0ef2ee017..01ca45beba1 100644 --- a/src/emu/bus/c64/exp.c +++ b/src/emu/bus/c64/exp.c @@ -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_slot_card_interface(mconfig, device), - m_roml(NULL), - m_romh(NULL), - m_ram(NULL), - m_nvram(NULL), - m_nvram_size(0), - m_roml_mask(0), - m_romh_mask(0), - m_ram_mask(0), + m_roml(*this, "roml"), + m_romh(*this, "romh"), + m_nvram(*this, "nvram"), m_game(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 @@ -202,7 +128,7 @@ bool c64_expansion_slot_device::call_load() 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); if (size == 0x4000) @@ -212,14 +138,14 @@ bool c64_expansion_slot_device::call_load() } 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_game = 0; } 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; } @@ -235,8 +161,11 @@ bool c64_expansion_slot_device::call_load() UINT8 *roml = NULL; UINT8 *romh = NULL; - if (roml_size) roml = m_card->c64_roml_pointer(machine(), roml_size); - if (romh_size) romh = m_card->c64_romh_pointer(machine(), romh_size); + m_card->m_roml.allocate(roml_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); } @@ -252,10 +181,8 @@ bool c64_expansion_slot_device::call_load() if (size) { // Ultimax (VIC-10) cartridge - memcpy(m_card->c64_romh_pointer(machine(), size), get_software_region("uprom"), size); - - size = get_software_region_length("lorom"); - if (size) memcpy(m_card->c64_roml_pointer(machine(), size), get_software_region("lorom"), size); + load_software_region("lorom", m_card->m_roml); + load_software_region("uprom", m_card->m_romh); m_card->m_exrom = 1; m_card->m_game = 0; @@ -263,17 +190,9 @@ bool c64_expansion_slot_device::call_load() else { // Commodore 64/128 cartridge - size = get_software_region_length("roml"); - if (size) memcpy(m_card->c64_roml_pointer(machine(), size), get_software_region("roml"), size); - - 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); + load_software_region("roml", m_card->m_roml); + load_software_region("romh", m_card->m_romh); + load_software_region("nvram", m_card->m_nvram); 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")); diff --git a/src/emu/bus/c64/exp.h b/src/emu/bus/c64/exp.h index 265a7b725a5..d1cb258fa55 100644 --- a/src/emu/bus/c64/exp.h +++ b/src/emu/bus/c64/exp.h @@ -167,35 +167,20 @@ public: device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device); 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 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_exrom_r(offs_t offset, int sphi2, int ba, int rw) { return m_exrom; } - c64_expansion_slot_device *m_slot; - - UINT8 *m_roml; - UINT8 *m_romh; - 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; +protected: + optional_shared_ptr<UINT8> m_roml; + optional_shared_ptr<UINT8> m_romh; + optional_shared_ptr<UINT8> m_nvram; int m_game; int m_exrom; + + c64_expansion_slot_device *m_slot; }; diff --git a/src/emu/bus/c64/fcc.c b/src/emu/bus/c64/fcc.c index 3f2ceb36fef..09b5258c6d4 100644 --- a/src/emu/bus/c64/fcc.c +++ b/src/emu/bus/c64/fcc.c @@ -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 ) { - 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 ) { - m_nvram[offset & m_nvram_mask] = data; + m_nvram[offset & m_nvram.mask()] = data; } diff --git a/src/emu/bus/c64/fcc.h b/src/emu/bus/c64/fcc.h index 0bca67fda03..e41136cdb30 100644 --- a/src/emu/bus/c64/fcc.h +++ b/src/emu/bus/c64/fcc.h @@ -49,8 +49,8 @@ protected: // device_nvram_interface overrides 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_write(emu_file &file) { if (m_nvram != NULL) { file.write(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.bytes()); } } // 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); diff --git a/src/emu/bus/c64/georam.c b/src/emu/bus/c64/georam.c index ef0938150c7..a778cfad1c1 100644 --- a/src/emu/bus/c64/georam.c +++ b/src/emu/bus/c64/georam.c @@ -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) : 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() { // allocate memory - c64_ram_pointer(machine(), 0x80000); + m_ram.allocate(0x80000); // state saving save_item(NAME(m_bank)); diff --git a/src/emu/bus/c64/georam.h b/src/emu/bus/c64/georam.h index 53b94775b23..feb158d1d6f 100644 --- a/src/emu/bus/c64/georam.h +++ b/src/emu/bus/c64/georam.h @@ -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); private: + optional_shared_ptr<UINT8> m_ram; + UINT16 m_bank; }; diff --git a/src/emu/bus/c64/ide64.c b/src/emu/bus/c64/ide64.c index e6e80103948..94f804a831b 100644 --- a/src/emu/bus/c64/ide64.c +++ b/src/emu/bus/c64/ide64.c @@ -103,7 +103,8 @@ c64_ide64_cartridge_device::c64_ide64_cartridge_device(const machine_config &mco m_flash_rom(*this, AT29C010A_TAG), m_rtc(*this, DS1302_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() { // allocate memory - c64_ram_pointer(machine(), 0x8000); + m_ram.allocate(0x8000); // state saving save_item(NAME(m_bank)); diff --git a/src/emu/bus/c64/ide64.h b/src/emu/bus/c64/ide64.h index fb2a69ea7e0..037f561fdf0 100644 --- a/src/emu/bus/c64/ide64.h +++ b/src/emu/bus/c64/ide64.h @@ -57,6 +57,7 @@ private: required_device<ds1302_device> m_rtc; required_device<ata_interface_device> m_ata; required_ioport m_jp1; + optional_shared_ptr<UINT8> m_ram; UINT8 m_bank; UINT16 m_ata_data; diff --git a/src/emu/bus/c64/magic_formel.c b/src/emu/bus/c64/magic_formel.c index 8258e6dd3ed..267ce46464a 100644 --- a/src/emu/bus/c64/magic_formel.c +++ b/src/emu/bus/c64/magic_formel.c @@ -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_c64_expansion_card_interface(mconfig, *this), m_pia(*this, MC6821_TAG), + m_ram(*this, "ram"), m_rom_bank(0), m_ram_bank(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() { + // allocate memory + m_ram.allocate(0x2000); + // state saving save_item(NAME(m_rom_bank)); save_item(NAME(m_ram_bank)); diff --git a/src/emu/bus/c64/magic_formel.h b/src/emu/bus/c64/magic_formel.h index 79955b6c6ba..0e422603523 100644 --- a/src/emu/bus/c64/magic_formel.h +++ b/src/emu/bus/c64/magic_formel.h @@ -57,6 +57,7 @@ protected: private: required_device<pia6821_device> m_pia; + optional_shared_ptr<UINT8> m_ram; UINT8 m_rom_bank; UINT8 m_ram_bank; diff --git a/src/emu/bus/c64/neoram.c b/src/emu/bus/c64/neoram.c index 33a0f16b0de..f1142774a51 100644 --- a/src/emu/bus/c64/neoram.c +++ b/src/emu/bus/c64/neoram.c @@ -44,7 +44,7 @@ c64_neoram_cartridge_device::c64_neoram_cartridge_device(const machine_config &m void c64_neoram_cartridge_device::device_start() { // allocate memory - c64_nvram_pointer(machine(), 0x200000); + m_nvram.allocate(0x200000); // state saving save_item(NAME(m_bank)); diff --git a/src/emu/bus/c64/neoram.h b/src/emu/bus/c64/neoram.h index ea42810f5c6..aa173423ce5 100644 --- a/src/emu/bus/c64/neoram.h +++ b/src/emu/bus/c64/neoram.h @@ -41,8 +41,8 @@ protected: // device_nvram_interface overrides 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_write(emu_file &file) { if (m_nvram != NULL) { file.write(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.bytes()); } } // 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); diff --git a/src/emu/bus/c64/ocean.c b/src/emu/bus/c64/ocean.c index 261662dafa8..df68b111423 100644 --- a/src/emu/bus/c64/ocean.c +++ b/src/emu/bus/c64/ocean.c @@ -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) { - if (!roml) + if (!roml && m_roml.bytes()) { 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); - data = m_romh[addr & m_romh_mask]; + data = m_romh[addr & m_romh.mask()]; } else if (!io1) { diff --git a/src/emu/bus/c64/pagefox.c b/src/emu/bus/c64/pagefox.c index 4f5033814e0..2edc58983c6 100644 --- a/src/emu/bus/c64/pagefox.c +++ b/src/emu/bus/c64/pagefox.c @@ -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) : 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() { + // allocate memory + m_ram.allocate(0x8000); + // state saving save_item(NAME(m_bank)); } diff --git a/src/emu/bus/c64/pagefox.h b/src/emu/bus/c64/pagefox.h index 79d7030d497..5437510b3c1 100644 --- a/src/emu/bus/c64/pagefox.h +++ b/src/emu/bus/c64/pagefox.h @@ -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); private: + optional_shared_ptr<UINT8> m_ram; + UINT8 m_bank; }; diff --git a/src/emu/bus/c64/partner.c b/src/emu/bus/c64/partner.c index 1d1227e6256..a81dc50c1da 100644 --- a/src/emu/bus/c64/partner.c +++ b/src/emu/bus/c64/partner.c @@ -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) : device_t(mconfig, C64_PARTNER, "C64 PARTNER 64 cartridge", tag, owner, clock, "c64_partner", __FILE__), device_c64_expansion_card_interface(mconfig, *this), + m_ram(*this, "ram"), m_a0(1), m_a6(1), 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() { // allocate memory - c64_ram_pointer(machine(), 0x2000); + m_ram.allocate(0x2000); } diff --git a/src/emu/bus/c64/partner.h b/src/emu/bus/c64/partner.h index 64cee99de14..bf383f2fa31 100644 --- a/src/emu/bus/c64/partner.h +++ b/src/emu/bus/c64/partner.h @@ -48,6 +48,8 @@ protected: virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw); private: + optional_shared_ptr<UINT8> m_ram; + int m_a0; int m_a6; int m_nmi; diff --git a/src/emu/bus/c64/reu.c b/src/emu/bus/c64/reu.c index 28f2e8e45b2..67723fd0885 100644 --- a/src/emu/bus/c64/reu.c +++ b/src/emu/bus/c64/reu.c @@ -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_c64_expansion_card_interface(mconfig, *this), m_dmac(*this, MOS8726R1_TAG), + m_rom(*this, "rom"), + m_ram(*this, "ram"), m_variant(variant), m_jp1(jp1), 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() { - // find memory region - m_roml = memregion("roml")->base(); - // allocate memory - c64_ram_pointer(machine(), m_ram_size); + m_ram.allocate(m_ram_size); // setup DMA controller m_dmac->set_unscaled_clock(m_slot->phi2()); diff --git a/src/emu/bus/c64/reu.h b/src/emu/bus/c64/reu.h index 29a8c6775e0..a2918891268 100644 --- a/src/emu/bus/c64/reu.h +++ b/src/emu/bus/c64/reu.h @@ -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); required_device<mos8726_device> m_dmac; + required_memory_region m_rom; + optional_shared_ptr<UINT8> m_ram; int m_variant; int m_jp1; diff --git a/src/emu/bus/c64/ross.c b/src/emu/bus/c64/ross.c index 150a096b037..b380f22e5ea 100644 --- a/src/emu/bus/c64/ross.c +++ b/src/emu/bus/c64/ross.c @@ -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); - data = m_roml[addr & m_roml_mask]; + data = m_roml[addr & m_roml.mask()]; } return data; diff --git a/src/emu/bus/c64/std.c b/src/emu/bus/c64/std.c index 066188da5e3..954854af5ed 100644 --- a/src/emu/bus/c64/std.c +++ b/src/emu/bus/c64/std.c @@ -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) { - 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) { - 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()]; } } diff --git a/src/emu/bus/c64/westermann.c b/src/emu/bus/c64/westermann.c index 369b77c437c..4e76c0b1618 100644 --- a/src/emu/bus/c64/westermann.c +++ b/src/emu/bus/c64/westermann.c @@ -63,17 +63,17 @@ UINT8 c64_westermann_cartridge_device::c64_cd_r(address_space &space, offs_t off { if (!roml) { - data = m_roml[offset & 0x1fff]; + data = m_roml[offset & m_roml.mask()]; } else if (!romh) { - if (m_romh_mask) + if (m_romh.bytes()) { - data = m_romh[offset & 0x1fff]; + data = m_romh[offset & m_romh.mask()]; } else { - data = m_roml[offset & 0x3fff]; + data = m_roml[offset & m_roml.mask()]; } } else if (!io2) diff --git a/src/emu/bus/c64/xl80.c b/src/emu/bus/c64/xl80.c index a0956eaa115..5c1875cd59e 100644 --- a/src/emu/bus/c64/xl80.c +++ b/src/emu/bus/c64/xl80.c @@ -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_c64_expansion_card_interface(mconfig, *this), 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() { // allocate memory - c64_ram_pointer(machine(), RAM_SIZE); - - // state saving - save_pointer(NAME(m_ram), RAM_SIZE); + m_ram.allocate(RAM_SIZE); } diff --git a/src/emu/bus/c64/xl80.h b/src/emu/bus/c64/xl80.h index 30896134fe9..a8ec1aadb53 100644 --- a/src/emu/bus/c64/xl80.h +++ b/src/emu/bus/c64/xl80.h @@ -55,6 +55,7 @@ protected: private: required_device<h46505_device> m_crtc; required_memory_region m_char_rom; + optional_shared_ptr<UINT8> m_ram; }; |