summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2016-04-07 18:59:38 -0400
committer AJR <ajrhacker@users.noreply.github.com>2016-04-07 18:59:38 -0400
commitc0f366c61374775f8f8b7661e84705b568134dea (patch)
tree626e95fa31e6e8480983abbe305c0415ded783d2 /src/devices
parent5933d47ed740fd08c2f66f37fdca4f95e08df3d4 (diff)
Devfind revision phase 1, cleaning out some legacy stuff
- Eliminate the cached device_t::m_region pointer and its region() getter method. Devices that need to bind to a region with the same tag should use optional/required_memory_region or optional/required_region_ptr with DEVICE_SELF as the subtag; this improves error checking. (DEVICE_SELF has been moved to device.h for greater visibility in the source.) - Allow required/optional_region_ptr to specify a specific length which must match that of the region found. - Implement finder_base::finder_tag() getter for diagnostic purposes. - Perform some (not very efficient) validity checks on memory region finders instead of allowing them to automatically pass. - Privatize device_memory_interface::m_addrspace.
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/bus/msx_slot/bunsetsu.cpp28
-rw-r--r--src/devices/bus/msx_slot/bunsetsu.h10
-rw-r--r--src/devices/bus/msx_slot/disk.h12
-rw-r--r--src/devices/bus/msx_slot/fs4600.cpp14
-rw-r--r--src/devices/bus/msx_slot/fs4600.h4
-rw-r--r--src/devices/bus/msx_slot/music.h2
-rw-r--r--src/devices/bus/msx_slot/panasonic08.cpp14
-rw-r--r--src/devices/bus/msx_slot/panasonic08.h4
-rw-r--r--src/devices/bus/msx_slot/rom.cpp16
-rw-r--r--src/devices/bus/msx_slot/rom.h4
-rw-r--r--src/devices/bus/msx_slot/sony08.cpp14
-rw-r--r--src/devices/bus/msx_slot/sony08.h4
-rw-r--r--src/devices/cpu/avr8/avr8.cpp5
-rw-r--r--src/devices/cpu/avr8/avr8.h7
-rw-r--r--src/devices/cpu/m6809/m6809.cpp4
-rw-r--r--src/devices/machine/at28c16.cpp33
-rw-r--r--src/devices/machine/at28c16.h1
-rw-r--r--src/devices/machine/at45dbxx.cpp7
-rw-r--r--src/devices/machine/ds1204.cpp3
-rw-r--r--src/devices/machine/ds1204.h2
-rw-r--r--src/devices/machine/ds2401.cpp9
-rw-r--r--src/devices/machine/eeprom.cpp27
-rw-r--r--src/devices/machine/eeprom.h2
-rw-r--r--src/devices/machine/er2055.cpp15
-rw-r--r--src/devices/machine/er2055.h2
-rw-r--r--src/devices/machine/gt64xxx.cpp3
-rw-r--r--src/devices/machine/gt64xxx.h2
-rw-r--r--src/devices/machine/i2cmem.cpp17
-rw-r--r--src/devices/machine/i2cmem.h2
-rw-r--r--src/devices/machine/i6300esb.cpp3
-rw-r--r--src/devices/machine/i6300esb.h1
-rw-r--r--src/devices/machine/intelfsh.cpp59
-rw-r--r--src/devices/machine/intelfsh.h10
-rw-r--r--src/devices/machine/k033906.cpp5
-rw-r--r--src/devices/machine/k033906.h7
-rw-r--r--src/devices/machine/k053252.cpp13
-rw-r--r--src/devices/machine/k053252.h5
-rw-r--r--src/devices/machine/mc146818.cpp9
-rw-r--r--src/devices/machine/mc146818.h2
-rw-r--r--src/devices/machine/mos6530n.cpp1
-rw-r--r--src/devices/machine/mos6530n.h3
-rw-r--r--src/devices/machine/nvram.cpp5
-rw-r--r--src/devices/machine/nvram.h1
-rw-r--r--src/devices/machine/pci.cpp3
-rw-r--r--src/devices/machine/pci.h2
-rw-r--r--src/devices/machine/pla.cpp6
-rw-r--r--src/devices/machine/pla.h2
-rw-r--r--src/devices/machine/rp5h01.cpp15
-rw-r--r--src/devices/machine/rp5h01.h5
-rw-r--r--src/devices/machine/timekpr.cpp27
-rw-r--r--src/devices/machine/timekpr.h2
-rw-r--r--src/devices/machine/vrc4373.cpp4
-rw-r--r--src/devices/machine/vrc4373.h1
-rw-r--r--src/devices/machine/x2212.cpp60
-rw-r--r--src/devices/machine/x2212.h11
-rw-r--r--src/devices/machine/x76f041.cpp3
-rw-r--r--src/devices/machine/x76f041.h2
-rw-r--r--src/devices/machine/x76f100.cpp3
-rw-r--r--src/devices/machine/x76f100.h2
-rw-r--r--src/devices/sound/2608intf.cpp7
-rw-r--r--src/devices/sound/2608intf.h1
-rw-r--r--src/devices/sound/2610intf.cpp6
-rw-r--r--src/devices/sound/2610intf.h1
-rw-r--r--src/devices/sound/8950intf.cpp5
-rw-r--r--src/devices/sound/8950intf.h1
-rw-r--r--src/devices/sound/digitalk.cpp3
-rw-r--r--src/devices/sound/digitalk.h2
-rw-r--r--src/devices/sound/gaelco.cpp8
-rw-r--r--src/devices/sound/gaelco.h8
-rw-r--r--src/devices/sound/iremga20.cpp9
-rw-r--r--src/devices/sound/iremga20.h3
-rw-r--r--src/devices/sound/k005289.cpp8
-rw-r--r--src/devices/sound/k005289.h2
-rw-r--r--src/devices/sound/k007232.cpp2
-rw-r--r--src/devices/sound/k053260.cpp16
-rw-r--r--src/devices/sound/k053260.h9
-rw-r--r--src/devices/sound/k054539.cpp38
-rw-r--r--src/devices/sound/k054539.h8
-rw-r--r--src/devices/sound/l7a1045_l6028_dsp_a.cpp14
-rw-r--r--src/devices/sound/l7a1045_l6028_dsp_a.h3
-rw-r--r--src/devices/sound/nile.cpp5
-rw-r--r--src/devices/sound/nile.h2
-rw-r--r--src/devices/sound/okim6295.cpp1
-rw-r--r--src/devices/sound/okim6295.h1
-rw-r--r--src/devices/sound/tc8830f.cpp18
-rw-r--r--src/devices/sound/tc8830f.h3
-rw-r--r--src/devices/sound/tms5110.cpp10
-rw-r--r--src/devices/sound/tms5110.h9
-rw-r--r--src/devices/sound/vlm5030.cpp6
-rw-r--r--src/devices/sound/vlm5030.h1
-rw-r--r--src/devices/sound/ymf278b.cpp2
-rw-r--r--src/devices/sound/ymz280b.cpp7
-rw-r--r--src/devices/sound/ymz770.cpp25
-rw-r--r--src/devices/sound/ymz770.h3
-rw-r--r--src/devices/video/bufsprite.h2
-rw-r--r--src/devices/video/ef9345.cpp8
-rw-r--r--src/devices/video/ef9345.h2
-rw-r--r--src/devices/video/ef9364.cpp4
-rw-r--r--src/devices/video/ef9364.h2
-rw-r--r--src/devices/video/ef9365.cpp4
-rw-r--r--src/devices/video/ef9365.h2
-rw-r--r--src/devices/video/hd44352.cpp5
-rw-r--r--src/devices/video/hd44352.h1
-rw-r--r--src/devices/video/hd44780.cpp12
-rw-r--r--src/devices/video/hd44780.h2
-rw-r--r--src/devices/video/msm6222b.cpp19
-rw-r--r--src/devices/video/msm6222b.h3
-rw-r--r--src/devices/video/tms9927.cpp13
-rw-r--r--src/devices/video/tms9927.h7
109 files changed, 379 insertions, 493 deletions
diff --git a/src/devices/bus/msx_slot/bunsetsu.cpp b/src/devices/bus/msx_slot/bunsetsu.cpp
index 1289a84704b..e7cc47e4c2a 100644
--- a/src/devices/bus/msx_slot/bunsetsu.cpp
+++ b/src/devices/bus/msx_slot/bunsetsu.cpp
@@ -13,36 +13,12 @@ const device_type MSX_SLOT_BUNSETSU = &device_creator<msx_slot_bunsetsu_device>;
msx_slot_bunsetsu_device::msx_slot_bunsetsu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: msx_slot_rom_device(mconfig, MSX_SLOT_BUNSETSU, "MSX Internal BUNSETSU", tag, owner, clock, "msx_slot_bunsetsu", __FILE__)
- , m_bunsetsu_region(nullptr)
- , m_bunsetsu_region_tag(nullptr)
+ , m_bunsetsu_region(*this, 0x20000)
, m_bunsetsu_address(0)
{
}
-void msx_slot_bunsetsu_device::device_start()
-{
- msx_slot_rom_device::device_start();
-
- if (m_bunsetsu_region_tag == nullptr)
- {
- fatalerror("msx_slot_bunsetsu_device: no bunsetsu region tag specified\n");
- }
-
- m_bunsetsu_region = owner()->memregion(m_bunsetsu_region_tag);
-
- if (m_bunsetsu_region == nullptr)
- {
- fatalerror("msx_slot_bunsetsu_device: Unable to find region with tag '%s'\n", m_bunsetsu_region_tag);
- }
-
- if (m_bunsetsu_region->bytes() != 0x20000)
- {
- fatalerror("msx_slot_bunsetsu_device: Bunsetsu region must be 0x20000 bytes.\n");
- }
-}
-
-
void msx_slot_bunsetsu_device::device_reset()
{
m_bunsetsu_address = 0;
@@ -53,7 +29,7 @@ READ8_MEMBER(msx_slot_bunsetsu_device::read)
{
if (offset == 0xbfff)
{
- return m_bunsetsu_region->u8(m_bunsetsu_address++ & 0x1ffff);
+ return m_bunsetsu_region[m_bunsetsu_address++ & 0x1ffff];
}
return msx_slot_rom_device::read(space, offset);
}
diff --git a/src/devices/bus/msx_slot/bunsetsu.h b/src/devices/bus/msx_slot/bunsetsu.h
index 701e6bb8640..90e1cbd5bf5 100644
--- a/src/devices/bus/msx_slot/bunsetsu.h
+++ b/src/devices/bus/msx_slot/bunsetsu.h
@@ -12,25 +12,23 @@ extern const device_type MSX_SLOT_BUNSETSU;
#define MCFG_MSX_SLOT_BUNSETSU_ADD(_tag, _startpage, _numpages, _region, _offset, _bunsetsu_region_tag) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_BUNSETSU, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
- msx_slot_bunsetsu_device::set_bunsetsu_region_tag(*device, _bunsetsu_region_tag);
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset); \
+ msx_slot_bunsetsu_device::set_bunsetsu_region_tag(*device, "^" _bunsetsu_region_tag);
class msx_slot_bunsetsu_device : public msx_slot_rom_device
{
public:
msx_slot_bunsetsu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// static configuration helpers
- static void set_bunsetsu_region_tag(device_t &device, const char *tag) { dynamic_cast<msx_slot_bunsetsu_device &>(device).m_bunsetsu_region_tag = tag; }
+ static void set_bunsetsu_region_tag(device_t &device, const char *tag) { dynamic_cast<msx_slot_bunsetsu_device &>(device).m_bunsetsu_region.set_tag(tag); }
- virtual void device_start() override;
virtual void device_reset() override;
virtual DECLARE_READ8_MEMBER(read) override;
virtual DECLARE_WRITE8_MEMBER(write) override;
private:
- memory_region *m_bunsetsu_region;
- const char *m_bunsetsu_region_tag;
+ required_region_ptr<UINT8> m_bunsetsu_region;
UINT32 m_bunsetsu_address;
};
diff --git a/src/devices/bus/msx_slot/disk.h b/src/devices/bus/msx_slot/disk.h
index fb0bdad5cdf..d5ce0982f82 100644
--- a/src/devices/bus/msx_slot/disk.h
+++ b/src/devices/bus/msx_slot/disk.h
@@ -27,35 +27,35 @@ extern const device_type MSX_SLOT_DISK6;
#define MCFG_MSX_SLOT_DISK1_ADD(_tag, _startpage, _numpages, _region, _offset, _fdc_tag, _floppy0_tag, _floppy1_tag) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_DISK1, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset); \
msx_slot_disk_device::set_fdc_tag(*device, _fdc_tag); \
msx_slot_disk_device::set_floppy0_tag(*device, _floppy0_tag); \
msx_slot_disk_device::set_floppy1_tag(*device, _floppy1_tag);
#define MCFG_MSX_SLOT_DISK2_ADD(_tag, _startpage, _numpages, _region, _offset, _fdc_tag, _floppy0_tag, _floppy1_tag) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_DISK2, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset); \
msx_slot_disk_device::set_fdc_tag(*device, _fdc_tag); \
msx_slot_disk_device::set_floppy0_tag(*device, _floppy0_tag); \
msx_slot_disk_device::set_floppy1_tag(*device, _floppy1_tag);
#define MCFG_MSX_SLOT_DISK3_ADD(_tag, _startpage, _numpages, _region, _offset, _fdc_tag, _floppy0_tag, _floppy1_tag) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_DISK3, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset); \
msx_slot_disk_device::set_fdc_tag(*device, _fdc_tag); \
msx_slot_disk_device::set_floppy0_tag(*device, _floppy0_tag); \
msx_slot_disk_device::set_floppy1_tag(*device, _floppy1_tag);
#define MCFG_MSX_SLOT_DISK4_ADD(_tag, _startpage, _numpages, _region, _offset, _fdc_tag, _floppy0_tag, _floppy1_tag) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_DISK4, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset); \
msx_slot_disk_device::set_fdc_tag(*device, _fdc_tag); \
msx_slot_disk_device::set_floppy0_tag(*device, _floppy0_tag); \
msx_slot_disk_device::set_floppy1_tag(*device, _floppy1_tag);
#define MCFG_MSX_SLOT_DISK5_ADD(_tag, _startpage, _numpages, _region, _offset, _fdc_tag, _floppy0_tag, _floppy1_tag, _floppy2_tag, _floppy3_tag) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_DISK5, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset); \
msx_slot_disk_device::set_fdc_tag(*device, _fdc_tag); \
msx_slot_disk_device::set_floppy0_tag(*device, _floppy0_tag); \
msx_slot_disk_device::set_floppy1_tag(*device, _floppy1_tag); \
@@ -64,7 +64,7 @@ extern const device_type MSX_SLOT_DISK6;
#define MCFG_MSX_SLOT_DISK6_ADD(_tag, _startpage, _numpages, _region, _offset, _fdc_tag, _floppy0_tag, _floppy1_tag) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_DISK6, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset); \
msx_slot_disk_device::set_fdc_tag(*device, _fdc_tag); \
msx_slot_disk_device::set_floppy0_tag(*device, _floppy0_tag); \
msx_slot_disk_device::set_floppy1_tag(*device, _floppy1_tag);
diff --git a/src/devices/bus/msx_slot/fs4600.cpp b/src/devices/bus/msx_slot/fs4600.cpp
index e6d6d8b9b9f..8c33b51a692 100644
--- a/src/devices/bus/msx_slot/fs4600.cpp
+++ b/src/devices/bus/msx_slot/fs4600.cpp
@@ -15,7 +15,7 @@ msx_slot_fs4600_device::msx_slot_fs4600_device(const machine_config &mconfig, co
: device_t(mconfig, MSX_SLOT_FS4600, "MSX Internal FS4600 Firmware", tag, owner, clock, "msx_slot_fs4600", __FILE__)
, msx_internal_slot_interface()
, m_nvram(*this, "nvram")
- , m_region(nullptr)
+ , m_rom_region(*this)
, m_region_offset(0)
, m_rom(nullptr)
, m_sram_address(0)
@@ -45,25 +45,17 @@ void msx_slot_fs4600_device::set_rom_start(device_t &device, const char *region,
{
msx_slot_fs4600_device &dev = downcast<msx_slot_fs4600_device &>(device);
- dev.m_region = region;
+ dev.m_rom_region.set_tag(region);
dev.m_region_offset = offset;
}
void msx_slot_fs4600_device::device_start()
{
- assert(m_region != nullptr );
-
- memory_region *m_rom_region = owner()->memregion(m_region);
-
// Sanity checks
- if (m_rom_region == nullptr )
- {
- fatalerror("Rom slot '%s': Unable to find memory region '%s'\n", tag(), m_region);
- }
if (m_rom_region->bytes() < m_region_offset + 0x100000)
{
- fatalerror("Memory region '%s' is too small for the FS4600 firmware\n", m_region);
+ fatalerror("Memory region '%s' is too small for the FS4600 firmware\n", m_rom_region.finder_tag());
}
m_rom = m_rom_region->base() + m_region_offset;
diff --git a/src/devices/bus/msx_slot/fs4600.h b/src/devices/bus/msx_slot/fs4600.h
index 57ae25aa47e..a1b0cdb4792 100644
--- a/src/devices/bus/msx_slot/fs4600.h
+++ b/src/devices/bus/msx_slot/fs4600.h
@@ -12,7 +12,7 @@ extern const device_type MSX_SLOT_FS4600;
#define MCFG_MSX_SLOT_FS4600_ADD(_tag, _startpage, _numpages, _region, _offset) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_FS4600, _startpage, _numpages) \
- msx_slot_fs4600_device::set_rom_start(*device, _region, _offset);
+ msx_slot_fs4600_device::set_rom_start(*device, "^" _region, _offset);
class msx_slot_fs4600_device : public device_t,
public msx_internal_slot_interface
@@ -33,7 +33,7 @@ public:
private:
required_device<nvram_device> m_nvram;
- const char *m_region;
+ required_memory_region m_rom_region;
UINT32 m_region_offset;
const UINT8 *m_rom;
UINT8 m_selected_bank[4];
diff --git a/src/devices/bus/msx_slot/music.h b/src/devices/bus/msx_slot/music.h
index eb2501b6746..3165982aaf0 100644
--- a/src/devices/bus/msx_slot/music.h
+++ b/src/devices/bus/msx_slot/music.h
@@ -14,7 +14,7 @@ extern const device_type MSX_SLOT_MUSIC;
#define MCFG_MSX_SLOT_MUSIC_ADD(_tag, _startpage, _numpages, _region, _offset, _ym2413_tag) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_MUSIC, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset); \
msx_slot_music_device::set_ym2413_tag(*device, _ym2413_tag);
class msx_slot_music_device : public msx_slot_rom_device
{
diff --git a/src/devices/bus/msx_slot/panasonic08.cpp b/src/devices/bus/msx_slot/panasonic08.cpp
index ec9fdcf20ea..b6da40189e7 100644
--- a/src/devices/bus/msx_slot/panasonic08.cpp
+++ b/src/devices/bus/msx_slot/panasonic08.cpp
@@ -20,7 +20,7 @@ msx_slot_panasonic08_device::msx_slot_panasonic08_device(const machine_config &m
: device_t(mconfig, MSX_SLOT_PANASONIC08, "MSX Internal Panasonic08", tag, owner, clock, "msx_slot_panasonic08", __FILE__)
, msx_internal_slot_interface()
, m_nvram(*this, "nvram")
- , m_region(nullptr)
+ , m_rom_region(*this)
, m_region_offset(0)
, m_rom(nullptr)
, m_control(0)
@@ -48,25 +48,17 @@ void msx_slot_panasonic08_device::set_rom_start(device_t &device, const char *re
{
msx_slot_panasonic08_device &dev = downcast<msx_slot_panasonic08_device &>(device);
- dev.m_region = region;
+ dev.m_rom_region.set_tag(region);
dev.m_region_offset = offset;
}
void msx_slot_panasonic08_device::device_start()
{
- assert(m_region != nullptr );
-
- memory_region *m_rom_region = owner()->memregion(m_region);
-
// Sanity checks
- if (m_rom_region == nullptr )
- {
- fatalerror("Rom slot '%s': Unable to find memory region '%s'\n", tag(), m_region);
- }
if (m_rom_region->bytes() < m_region_offset + 0x200000)
{
- fatalerror("Memory region '%s' is too small for the FS4600 firmware\n", m_region);
+ fatalerror("Memory region '%s' is too small for the FS4600 firmware\n", m_rom_region.finder_tag());
}
m_sram.resize(0x4000);
diff --git a/src/devices/bus/msx_slot/panasonic08.h b/src/devices/bus/msx_slot/panasonic08.h
index d42ebd308f5..18295c78598 100644
--- a/src/devices/bus/msx_slot/panasonic08.h
+++ b/src/devices/bus/msx_slot/panasonic08.h
@@ -12,7 +12,7 @@ extern const device_type MSX_SLOT_PANASONIC08;
#define MCFG_MSX_SLOT_PANASONIC08_ADD(_tag, _startpage, _numpages, _region, _offset) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_PANASONIC08, _startpage, _numpages) \
- msx_slot_panasonic08_device::set_rom_start(*device, _region, _offset);
+ msx_slot_panasonic08_device::set_rom_start(*device, "^" _region, _offset);
class msx_slot_panasonic08_device : public device_t,
public msx_internal_slot_interface
@@ -33,7 +33,7 @@ public:
private:
required_device<nvram_device> m_nvram;
- const char *m_region;
+ required_memory_region m_rom_region;
UINT32 m_region_offset;
const UINT8 *m_rom;
UINT8 m_selected_bank[8];
diff --git a/src/devices/bus/msx_slot/rom.cpp b/src/devices/bus/msx_slot/rom.cpp
index 2d4593bed2b..5a6bef72e91 100644
--- a/src/devices/bus/msx_slot/rom.cpp
+++ b/src/devices/bus/msx_slot/rom.cpp
@@ -10,7 +10,7 @@ const device_type MSX_SLOT_ROM = &device_creator<msx_slot_rom_device>;
msx_slot_rom_device::msx_slot_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, MSX_SLOT_ROM, "MSX Internal ROM", tag, owner, clock, "msx_slot_rom", __FILE__)
, msx_internal_slot_interface()
- , m_region(nullptr)
+ , m_rom_region(*this)
, m_region_offset(0)
, m_rom(nullptr)
{
@@ -20,7 +20,7 @@ msx_slot_rom_device::msx_slot_rom_device(const machine_config &mconfig, const ch
msx_slot_rom_device::msx_slot_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source)
, msx_internal_slot_interface()
- , m_region(nullptr)
+ , m_rom_region(*this)
, m_region_offset(0)
, m_rom(nullptr)
{
@@ -31,25 +31,17 @@ void msx_slot_rom_device::set_rom_start(device_t &device, const char *region, UI
{
msx_slot_rom_device &dev = downcast<msx_slot_rom_device &>(device);
- dev.m_region = region;
+ dev.m_rom_region.set_tag(region);
dev.m_region_offset = offset;
}
void msx_slot_rom_device::device_start()
{
- assert(m_region != nullptr );
-
- memory_region *m_rom_region = owner()->memregion(m_region);
-
// Sanity checks
- if (m_rom_region == nullptr )
- {
- fatalerror("Rom slot '%s': Unable to find memory region '%s'\n", tag(), m_region);
- }
if (m_rom_region->bytes() < m_region_offset + m_size)
{
- fatalerror("Memory region '%s' is too small for rom slot '%s'\n", m_region, tag());
+ fatalerror("Memory region '%s' is too small for rom slot '%s'\n", m_rom_region.finder_tag(), tag());
}
m_rom = m_rom_region->base() + m_region_offset;
diff --git a/src/devices/bus/msx_slot/rom.h b/src/devices/bus/msx_slot/rom.h
index e46fea28186..98679eaa452 100644
--- a/src/devices/bus/msx_slot/rom.h
+++ b/src/devices/bus/msx_slot/rom.h
@@ -7,7 +7,7 @@
#define MCFG_MSX_SLOT_ROM_ADD(_tag, _startpage, _numpages, _region, _offset) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_ROM, _startpage, _numpages) \
- msx_slot_rom_device::set_rom_start(*device, _region, _offset);
+ msx_slot_rom_device::set_rom_start(*device, "^" _region, _offset);
class msx_slot_rom_device : public device_t,
public msx_internal_slot_interface
@@ -24,7 +24,7 @@ public:
virtual DECLARE_READ8_MEMBER(read) override;
private:
- const char *m_region;
+ required_memory_region m_rom_region;
UINT32 m_region_offset;
const UINT8 *m_rom;
};
diff --git a/src/devices/bus/msx_slot/sony08.cpp b/src/devices/bus/msx_slot/sony08.cpp
index 2f48869c291..551f69062a7 100644
--- a/src/devices/bus/msx_slot/sony08.cpp
+++ b/src/devices/bus/msx_slot/sony08.cpp
@@ -17,7 +17,7 @@ msx_slot_sony08_device::msx_slot_sony08_device(const machine_config &mconfig, co
: device_t(mconfig, MSX_SLOT_SONY08, "MSX Internal SONY08", tag, owner, clock, "msx_slot_sony08", __FILE__)
, msx_internal_slot_interface()
, m_nvram(*this, "nvram")
- , m_region(nullptr)
+ , m_rom_region(*this)
, m_region_offset(0)
, m_rom(nullptr)
{
@@ -45,25 +45,17 @@ void msx_slot_sony08_device::set_rom_start(device_t &device, const char *region,
{
msx_slot_sony08_device &dev = downcast<msx_slot_sony08_device &>(device);
- dev.m_region = region;
+ dev.m_rom_region.set_tag(region);
dev.m_region_offset = offset;
}
void msx_slot_sony08_device::device_start()
{
- assert(m_region != nullptr );
-
- memory_region *m_rom_region = owner()->memregion(m_region);
-
// Sanity checks
- if (m_rom_region == nullptr )
- {
- fatalerror("Rom slot '%s': Unable to find memory region '%s'\n", tag(), m_region);
- }
if (m_rom_region->bytes() < m_region_offset + 0x100000)
{
- fatalerror("Memory region '%s' is too small for the SONY08 firmware\n", m_region);
+ fatalerror("Memory region '%s' is too small for the SONY08 firmware\n", m_rom_region.finder_tag());
}
m_rom = m_rom_region->base() + m_region_offset;
diff --git a/src/devices/bus/msx_slot/sony08.h b/src/devices/bus/msx_slot/sony08.h
index ebef6145c4f..87b10934511 100644
--- a/src/devices/bus/msx_slot/sony08.h
+++ b/src/devices/bus/msx_slot/sony08.h
@@ -12,7 +12,7 @@ extern const device_type MSX_SLOT_SONY08;
#define MCFG_MSX_SLOT_SONY08_ADD(_tag, _startpage, _numpages, _region, _offset) \
MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_SONY08, _startpage, _numpages) \
- msx_slot_sony08_device::set_rom_start(*device, _region, _offset);
+ msx_slot_sony08_device::set_rom_start(*device, "^" _region, _offset);
class msx_slot_sony08_device : public device_t,
public msx_internal_slot_interface
@@ -33,7 +33,7 @@ public:
private:
required_device<nvram_device> m_nvram;
- const char *m_region;
+ required_memory_region m_rom_region;
UINT32 m_region_offset;
const UINT8 *m_rom;
UINT8 m_selected_bank[8];
diff --git a/src/devices/cpu/avr8/avr8.cpp b/src/devices/cpu/avr8/avr8.cpp
index d4a00c1d325..6b2b19a2021 100644
--- a/src/devices/cpu/avr8/avr8.cpp
+++ b/src/devices/cpu/avr8/avr8.cpp
@@ -638,8 +638,7 @@ avr8_device::avr8_device(const machine_config &mconfig, const char *name, const
m_program_config("program", ENDIANNESS_LITTLE, 8, 22),
m_data_config("data", ENDIANNESS_LITTLE, 8, 16, 0, internal_map),
m_io_config("io", ENDIANNESS_LITTLE, 8, 4),
- m_eeprom_tag(nullptr),
- m_eeprom(nullptr),
+ m_eeprom(*this),
m_cpu_type(cpu_type),
m_lfuses(0x62),
m_hfuses(0x99),
@@ -824,8 +823,6 @@ void avr8_device::device_start()
// set our instruction counter
m_icountptr = &m_icount;
-
- m_eeprom = machine().root_device().memregion(m_eeprom_tag)->base();
}
//-------------------------------------------------
diff --git a/src/devices/cpu/avr8/avr8.h b/src/devices/cpu/avr8/avr8.h
index 86207566ffc..ea9cf8c8a19 100644
--- a/src/devices/cpu/avr8/avr8.h
+++ b/src/devices/cpu/avr8/avr8.h
@@ -64,7 +64,7 @@
//**************************************************************************
#define MCFG_CPU_AVR8_EEPROM(_tag) \
- avr8_device::set_eeprom_tag(*device, _tag);
+ avr8_device::set_eeprom_tag(*device, "^" _tag);
//**************************************************************************
@@ -80,7 +80,7 @@ class avr8_device : public cpu_device
{
public:
// inline configuration helpers
- static void set_eeprom_tag(device_t &device, const char *tag) { downcast<avr8_device &>(device).m_eeprom_tag = tag; }
+ static void set_eeprom_tag(device_t &device, const char *tag) { downcast<avr8_device &>(device).m_eeprom.set_tag(tag); }
// fuse configs
void set_low_fuses(UINT8 byte);
@@ -137,8 +137,7 @@ protected:
const address_space_config m_program_config;
const address_space_config m_data_config;
const address_space_config m_io_config;
- const char *m_eeprom_tag;
- UINT8 *m_eeprom;
+ required_region_ptr<UINT8> m_eeprom;
// bootloader
UINT16 m_boot_size;
diff --git a/src/devices/cpu/m6809/m6809.cpp b/src/devices/cpu/m6809/m6809.cpp
index 8ebba313047..ce226e23739 100644
--- a/src/devices/cpu/m6809/m6809.cpp
+++ b/src/devices/cpu/m6809/m6809.cpp
@@ -210,8 +210,8 @@ void m6809_base_device::device_reset()
m_cc |= CC_I; // IRQ disabled
m_cc |= CC_F; // FIRQ disabled
- m_pc.b.h = m_addrspace[AS_PROGRAM]->read_byte(VECTOR_RESET_FFFE + 0);
- m_pc.b.l = m_addrspace[AS_PROGRAM]->read_byte(VECTOR_RESET_FFFE + 1);
+ m_pc.b.h = space(AS_PROGRAM).read_byte(VECTOR_RESET_FFFE + 0);
+ m_pc.b.l = space(AS_PROGRAM).read_byte(VECTOR_RESET_FFFE + 1);
// reset sub-instruction state
reset_state();
diff --git a/src/devices/machine/at28c16.cpp b/src/devices/machine/at28c16.cpp
index 9461850043d..f54e28f8bda 100644
--- a/src/devices/machine/at28c16.cpp
+++ b/src/devices/machine/at28c16.cpp
@@ -45,7 +45,8 @@ at28c16_device::at28c16_device( const machine_config &mconfig, const char *tag,
device_nvram_interface(mconfig, *this),
m_a9_12v( 0 ),
m_oe_12v( 0 ),
- m_last_write( -1 )
+ m_last_write( -1 ),
+ m_default_data(*this, DEVICE_SELF, AT28C16_DATA_BYTES)
{
}
@@ -116,26 +117,14 @@ void at28c16_device::nvram_default()
UINT16 default_value = 0xff;
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, default_value );
+ space(AS_PROGRAM).write_byte( offs, default_value );
}
/* populate from a memory region if present */
- if( m_region != nullptr )
+ if (m_default_data.found())
{
- if( m_region->bytes() != AT28C16_DATA_BYTES )
- {
- fatalerror( "at28c16 region '%s' wrong size (expected size = 0x%X)\n", tag(), AT28C16_DATA_BYTES );
- }
-
- if( m_region->bytewidth() != 1 )
- {
- fatalerror( "at28c16 region '%s' needs to be an 8-bit region\n", tag() );
- }
-
- UINT8 *default_data = m_region->base();
-
for( offs_t offs = 0; offs < AT28C16_DATA_BYTES; offs++ )
- m_addrspace[ 0 ]->write_byte( offs, default_data[offs] );
+ space(AS_PROGRAM).write_byte(offs, m_default_data[offs]);
}
}
@@ -153,7 +142,7 @@ void at28c16_device::nvram_read( emu_file &file )
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, buffer[ offs ] );
+ space(AS_PROGRAM).write_byte( offs, buffer[ offs ] );
}
}
@@ -168,7 +157,7 @@ void at28c16_device::nvram_write( emu_file &file )
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
- buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs );
+ buffer[ offs ] = space(AS_PROGRAM).read_byte( offs );
}
file.write( &buffer[0], AT28C16_TOTAL_BYTES );
@@ -193,7 +182,7 @@ WRITE8_MEMBER( at28c16_device::write )
{
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, 0xff );
+ this->space(AS_PROGRAM).write_byte( offs, 0xff );
}
m_last_write = 0xff;
@@ -208,9 +197,9 @@ WRITE8_MEMBER( at28c16_device::write )
}
// logerror( "%s: AT28C16: write( %04x, %02x )\n", machine.describe_context(), offset, data );
- if( m_last_write < 0 && m_addrspace[ 0 ]->read_byte( offset ) != data )
+ if( m_last_write < 0 && this->space(AS_PROGRAM).read_byte( offset ) != data )
{
- m_addrspace[ 0 ]->write_byte( offset, data );
+ this->space(AS_PROGRAM).write_byte( offset, data );
m_last_write = data;
m_write_timer->adjust( attotime::from_usec( 200 ) );
}
@@ -233,7 +222,7 @@ READ8_MEMBER( at28c16_device::read )
offset += AT28C16_ID_BYTES;
}
- UINT8 data = m_addrspace[ 0 ]->read_byte( offset );
+ UINT8 data = this->space(AS_PROGRAM).read_byte( offset );
// logerror( "%s: AT28C16: read( %04x ) data %02x\n", machine.describe_context(), offset, data );
return data;
}
diff --git a/src/devices/machine/at28c16.h b/src/devices/machine/at28c16.h
index 5cc51cf9078..c33f92785e8 100644
--- a/src/devices/machine/at28c16.h
+++ b/src/devices/machine/at28c16.h
@@ -65,6 +65,7 @@ protected:
int m_a9_12v;
int m_oe_12v;
int m_last_write;
+ optional_region_ptr<UINT8> m_default_data;
};
diff --git a/src/devices/machine/at45dbxx.cpp b/src/devices/machine/at45dbxx.cpp
index e61fcca498a..8b127986679 100644
--- a/src/devices/machine/at45dbxx.cpp
+++ b/src/devices/machine/at45dbxx.cpp
@@ -144,13 +144,14 @@ void at45db041_device::nvram_default()
{
memset(&m_data[0], 0xff, m_data.size());
- if (region() != nullptr)
+ memory_region *region = memregion(DEVICE_SELF);
+ if (region != nullptr)
{
- UINT32 bytes = region()->bytes();
+ UINT32 bytes = region->bytes();
if (bytes > m_size)
bytes = m_size;
- memcpy(&m_data[0], region()->base(), bytes);
+ memcpy(&m_data[0], region->base(), bytes);
}
}
diff --git a/src/devices/machine/ds1204.cpp b/src/devices/machine/ds1204.cpp
index 72029b2aecc..56d57267ad3 100644
--- a/src/devices/machine/ds1204.cpp
+++ b/src/devices/machine/ds1204.cpp
@@ -32,6 +32,7 @@ const device_type DS1204 = &device_creator<ds1204_device>;
ds1204_device::ds1204_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
: device_t( mconfig, DS1204, "DS1204", tag, owner, clock, "ds1204", __FILE__ ),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_rst( 0 ),
m_clk( 0 ),
m_dqw( 0 ), m_dqr(0), m_state(0), m_bit(0)
@@ -69,7 +70,7 @@ void ds1204_device::nvram_default()
int expected_bytes = sizeof( m_unique_pattern ) + sizeof( m_identification ) + sizeof( m_security_match ) + sizeof( m_secure_memory );
- if( !m_region )
+ if (!m_region.found())
{
logerror( "ds1204(%s) region not found\n", tag() );
}
diff --git a/src/devices/machine/ds1204.h b/src/devices/machine/ds1204.h
index 42b68de7538..35e84c7771f 100644
--- a/src/devices/machine/ds1204.h
+++ b/src/devices/machine/ds1204.h
@@ -72,6 +72,8 @@ private:
static const int DQ_HIGH_IMPEDANCE = -1;
+ optional_memory_region m_region;
+
int m_rst;
int m_clk;
int m_dqw;
diff --git a/src/devices/machine/ds2401.cpp b/src/devices/machine/ds2401.cpp
index 7298fa888ee..7c74924404a 100644
--- a/src/devices/machine/ds2401.cpp
+++ b/src/devices/machine/ds2401.cpp
@@ -65,15 +65,16 @@ void ds2401_device::device_reset()
m_rx = true;
m_tx = true;
- if(m_region)
+ memory_region *region = memregion(DEVICE_SELF);
+ if (region != nullptr)
{
- if(m_region->bytes() == SIZE_DATA)
+ if (region->bytes() == SIZE_DATA)
{
- memcpy(m_data, m_region->base(), SIZE_DATA);
+ memcpy(m_data, region->base(), SIZE_DATA);
return;
}
- logerror("ds2401 %s: Wrong region length for id data, expected 0x%x, got 0x%x\n", tag(), SIZE_DATA, m_region->bytes());
+ logerror("ds2401 %s: Wrong region length for id data, expected 0x%x, got 0x%x\n", tag(), SIZE_DATA, region->bytes());
}
else
{
diff --git a/src/devices/machine/eeprom.cpp b/src/devices/machine/eeprom.cpp
index 042e4535918..43523c18fb1 100644
--- a/src/devices/machine/eeprom.cpp
+++ b/src/devices/machine/eeprom.cpp
@@ -48,6 +48,7 @@ eeprom_base_device::eeprom_base_device(const machine_config &mconfig, device_typ
: device_t(mconfig, devtype, name, tag, owner, 0, shortname, file),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_cells(0),
m_address_bits(0),
m_data_bits(0),
@@ -271,9 +272,9 @@ void eeprom_base_device::nvram_default()
UINT32 default_value = m_default_value_set ? m_default_value : ~0;
for (offs_t offs = 0; offs < eeprom_length; offs++)
if (m_data_bits == 8)
- m_addrspace[0]->write_byte(offs, default_value);
+ space(AS_PROGRAM).write_byte(offs, default_value);
else
- m_addrspace[0]->write_word(offs * 2, default_value);
+ space(AS_PROGRAM).write_word(offs * 2, default_value);
// handle hard-coded data from the driver
if (m_default_data.u8 != nullptr)
@@ -282,14 +283,14 @@ void eeprom_base_device::nvram_default()
for (offs_t offs = 0; offs < m_default_data_size; offs++)
{
if (m_data_bits == 8)
- m_addrspace[0]->write_byte(offs, m_default_data.u8[offs]);
+ space(AS_PROGRAM).write_byte(offs, m_default_data.u8[offs]);
else
- m_addrspace[0]->write_word(offs * 2, m_default_data.u16[offs]);
+ space(AS_PROGRAM).write_word(offs * 2, m_default_data.u16[offs]);
}
}
// populate from a memory region if present
- if (m_region != nullptr)
+ if (m_region.found())
{
if (m_region->bytes() != eeprom_bytes)
fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)\n", tag(), eeprom_bytes);
@@ -303,13 +304,13 @@ void eeprom_base_device::nvram_default()
{
UINT8 *default_data = m_region->base();
for (offs_t offs = 0; offs < eeprom_length; offs++)
- m_addrspace[0]->write_byte(offs, default_data[offs]);
+ space(AS_PROGRAM).write_byte(offs, default_data[offs]);
}
else
{
UINT16 *default_data = (UINT16 *)(m_region->base());
for (offs_t offs = 0; offs < eeprom_length; offs++)
- m_addrspace[0]->write_word(offs * 2, default_data[offs]);
+ space(AS_PROGRAM).write_word(offs * 2, default_data[offs]);
}
}
}
@@ -328,7 +329,7 @@ void eeprom_base_device::nvram_read(emu_file &file)
dynamic_buffer buffer(eeprom_bytes);
file.read(&buffer[0], eeprom_bytes);
for (offs_t offs = 0; offs < eeprom_bytes; offs++)
- m_addrspace[0]->write_byte(offs, buffer[offs]);
+ space(AS_PROGRAM).write_byte(offs, buffer[offs]);
}
@@ -344,7 +345,7 @@ void eeprom_base_device::nvram_write(emu_file &file)
dynamic_buffer buffer(eeprom_bytes);
for (offs_t offs = 0; offs < eeprom_bytes; offs++)
- buffer[offs] = m_addrspace[0]->read_byte(offs);
+ buffer[offs] = space(AS_PROGRAM).read_byte(offs);
file.write(&buffer[0], eeprom_bytes);
}
@@ -356,9 +357,9 @@ void eeprom_base_device::nvram_write(emu_file &file)
UINT32 eeprom_base_device::internal_read(offs_t address)
{
if (m_data_bits == 16)
- return m_addrspace[0]->read_word(address * 2);
+ return space(AS_PROGRAM).read_word(address * 2);
else
- return m_addrspace[0]->read_byte(address);
+ return space(AS_PROGRAM).read_byte(address);
}
@@ -370,7 +371,7 @@ UINT32 eeprom_base_device::internal_read(offs_t address)
void eeprom_base_device::internal_write(offs_t address, UINT32 data)
{
if (m_data_bits == 16)
- m_addrspace[0]->write_word(address * 2, data);
+ space(AS_PROGRAM).write_word(address * 2, data);
else
- m_addrspace[0]->write_byte(address, data);
+ space(AS_PROGRAM).write_byte(address, data);
}
diff --git a/src/devices/machine/eeprom.h b/src/devices/machine/eeprom.h
index 23ba81cf42f..6eb802641e3 100644
--- a/src/devices/machine/eeprom.h
+++ b/src/devices/machine/eeprom.h
@@ -97,6 +97,8 @@ protected:
UINT32 internal_read(offs_t address);
void internal_write(offs_t address, UINT32 data);
+ optional_memory_region m_region;
+
// configuration state
UINT32 m_cells;
UINT8 m_address_bits;
diff --git a/src/devices/machine/er2055.cpp b/src/devices/machine/er2055.cpp
index 7c395a83b62..c0c5966b5a9 100644
--- a/src/devices/machine/er2055.cpp
+++ b/src/devices/machine/er2055.cpp
@@ -37,6 +37,7 @@ er2055_device::er2055_device(const machine_config &mconfig, const char *tag, dev
: device_t(mconfig, ER2055, "ER2055 EAROM", tag, owner, clock, "er2055", __FILE__),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_space_config("EAROM", ENDIANNESS_BIG, 8, 6, 0, *ADDRESS_MAP_NAME(er2055_map)),
m_control_state(0),
m_address(0),
@@ -79,7 +80,7 @@ void er2055_device::nvram_default()
{
// default to all-0xff
for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, 0xff);
+ space(AS_PROGRAM).write_byte(byte, 0xff);
// populate from a memory region if present
if (m_region != nullptr)
@@ -91,7 +92,7 @@ void er2055_device::nvram_default()
UINT8 *default_data = m_region->base();
for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, default_data[byte]);
+ space(AS_PROGRAM).write_byte(byte, default_data[byte]);
}
}
@@ -106,7 +107,7 @@ void er2055_device::nvram_read(emu_file &file)
UINT8 buffer[SIZE_DATA];
file.read(buffer, sizeof(buffer));
for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, buffer[byte]);
+ space(AS_PROGRAM).write_byte(byte, buffer[byte]);
}
@@ -119,7 +120,7 @@ void er2055_device::nvram_write(emu_file &file)
{
UINT8 buffer[SIZE_DATA];
for (int byte = 0; byte < SIZE_DATA; byte++)
- buffer[byte] = m_addrspace[0]->read_byte(byte);
+ buffer[byte] = space(AS_PROGRAM).read_byte(byte);
file.write(buffer, sizeof(buffer));
}
@@ -155,13 +156,13 @@ void er2055_device::set_control(UINT8 cs1, UINT8 cs2, UINT8 c1, UINT8 c2, UINT8
// write mode; erasing is required, so we perform an AND against previous
// data to simulate incorrect behavior if erasing was not done
case 0:
- m_addrspace[0]->write_byte(m_address, m_addrspace[0]->read_byte(m_address) & m_data);
+ space(AS_PROGRAM).write_byte(m_address, space(AS_PROGRAM).read_byte(m_address) & m_data);
//printf("Write %02X = %02X\n", m_address, m_data);
break;
// erase mode
case C2:
- m_addrspace[0]->write_byte(m_address, 0xff);
+ space(AS_PROGRAM).write_byte(m_address, 0xff);
//printf("Erase %02X\n", m_address);
break;
@@ -169,7 +170,7 @@ void er2055_device::set_control(UINT8 cs1, UINT8 cs2, UINT8 c1, UINT8 c2, UINT8
case C1:
if ((oldstate & CK) != 0 && (m_control_state & CK) == 0)
{
- m_data = m_addrspace[0]->read_byte(m_address);
+ m_data = space(AS_PROGRAM).read_byte(m_address);
//printf("Read %02X = %02X\n", m_address, m_data);
}
break;
diff --git a/src/devices/machine/er2055.h b/src/devices/machine/er2055.h
index 900cac15b06..82ad9d2c0e9 100644
--- a/src/devices/machine/er2055.h
+++ b/src/devices/machine/er2055.h
@@ -66,6 +66,8 @@ protected:
static const UINT8 CS1 = 0x08;
static const UINT8 CS2 = 0x10;
+ optional_memory_region m_region;
+
// configuration state
address_space_config m_space_config;
diff --git a/src/devices/machine/gt64xxx.cpp b/src/devices/machine/gt64xxx.cpp
index b11d55160bb..126741f3730 100644
--- a/src/devices/machine/gt64xxx.cpp
+++ b/src/devices/machine/gt64xxx.cpp
@@ -27,7 +27,8 @@ gt64xxx_device::gt64xxx_device(const machine_config &mconfig, const char *tag, d
: pci_host_device(mconfig, GT64XXX, "Galileo GT-64XXX System Controller", tag, owner, clock, "gt64xxx", __FILE__),
m_be(0), m_autoconfig(0), m_irq_num(-1),
m_mem_config("memory_space", ENDIANNESS_LITTLE, 32, 32),
- m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32)
+ m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/machine/gt64xxx.h b/src/devices/machine/gt64xxx.h
index e29637bae00..6653c9ca552 100644
--- a/src/devices/machine/gt64xxx.h
+++ b/src/devices/machine/gt64xxx.h
@@ -231,6 +231,8 @@ private:
address_space_config m_mem_config, m_io_config;
+ required_memory_region m_region;
+
DECLARE_ADDRESS_MAP(cpu_map, 32);
void map_cpu_space();
diff --git a/src/devices/machine/i2cmem.cpp b/src/devices/machine/i2cmem.cpp
index d77e12ef4be..ba320d1f5cd 100644
--- a/src/devices/machine/i2cmem.cpp
+++ b/src/devices/machine/i2cmem.cpp
@@ -78,6 +78,7 @@ i2cmem_device::i2cmem_device( const machine_config &mconfig, const char *tag, de
: device_t(mconfig, I2CMEM, "I2C Memory", tag, owner, clock, "i2cmem", __FILE__),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_slave_address( I2CMEM_SLAVE_ADDRESS ),
m_page_size( 0 ),
m_data_size( 0 ),
@@ -175,11 +176,11 @@ void i2cmem_device::nvram_default()
UINT16 default_value = 0xff;
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, default_value );
+ space(AS_PROGRAM).write_byte( offs, default_value );
}
/* populate from a memory region if present */
- if( m_region != nullptr )
+ if (m_region.found())
{
if( m_region->bytes() != i2cmem_bytes )
{
@@ -193,7 +194,7 @@ void i2cmem_device::nvram_default()
UINT8 *default_data = m_region->base();
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
- m_addrspace[ 0 ]->write_byte( offs, default_data[offs] );
+ space(AS_PROGRAM).write_byte( offs, default_data[offs] );
}
}
@@ -212,7 +213,7 @@ void i2cmem_device::nvram_read( emu_file &file )
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, buffer[ offs ] );
+ space(AS_PROGRAM).write_byte( offs, buffer[ offs ] );
}
}
@@ -228,7 +229,7 @@ void i2cmem_device::nvram_write( emu_file &file )
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
{
- buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs );
+ buffer[ offs ] = space(AS_PROGRAM).read_byte( offs );
}
file.write( &buffer[0], i2cmem_bytes );
@@ -375,7 +376,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_scl )
for( int i = 0; i < m_page_size; i++ )
{
- m_addrspace[ 0 ]->write_byte( offset + i, m_page[ i ] );
+ space(AS_PROGRAM).write_byte( offset + i, m_page[ i ] );
}
m_page_offset = 0;
@@ -386,7 +387,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_scl )
int offset = data_offset();
verboselog( this, 1, "data[ %04x ] <- %02x\n", offset, m_shift );
- m_addrspace[ 0 ]->write_byte( offset, m_shift );
+ space(AS_PROGRAM).write_byte( offset, m_shift );
m_byteaddr++;
}
@@ -419,7 +420,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_scl )
{
int offset = data_offset();
- m_shift = m_addrspace[ 0 ]->read_byte( offset );
+ m_shift = space(AS_PROGRAM).read_byte( offset );
verboselog( this, 1, "data[ %04x ] -> %02x\n", offset, m_shift );
m_byteaddr++;
}
diff --git a/src/devices/machine/i2cmem.h b/src/devices/machine/i2cmem.h
index d17d6f2f277..a45a51098e3 100644
--- a/src/devices/machine/i2cmem.h
+++ b/src/devices/machine/i2cmem.h
@@ -128,6 +128,8 @@ protected:
int select_device();
int data_offset();
+ optional_memory_region m_region;
+
// device-specific configuration
address_space_config m_space_config;
diff --git a/src/devices/machine/i6300esb.cpp b/src/devices/machine/i6300esb.cpp
index ec7ca934d31..649c437befd 100644
--- a/src/devices/machine/i6300esb.cpp
+++ b/src/devices/machine/i6300esb.cpp
@@ -90,7 +90,8 @@ i6300esb_lpc_device::i6300esb_lpc_device(const machine_config &mconfig, const ch
: pci_device(mconfig, I6300ESB_LPC, "i6300ESB southbridge ISA/LPC bridge", tag, owner, clock, "i6300esb_lpc", __FILE__),
acpi(*this, "acpi"),
rtc (*this, "rtc"),
- pit (*this, "pit")
+ pit (*this, "pit"),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/machine/i6300esb.h b/src/devices/machine/i6300esb.h
index 325e768dbba..e3f216123bc 100644
--- a/src/devices/machine/i6300esb.h
+++ b/src/devices/machine/i6300esb.h
@@ -35,6 +35,7 @@ private:
required_device<lpc_acpi_device> acpi;
required_device<lpc_rtc_device> rtc;
required_device<lpc_pit_device> pit;
+ required_memory_region m_region;
DECLARE_ADDRESS_MAP(internal_io_map, 32);
diff --git a/src/devices/machine/intelfsh.cpp b/src/devices/machine/intelfsh.cpp
index 54f9d4f722f..5f2c0a154ac 100644
--- a/src/devices/machine/intelfsh.cpp
+++ b/src/devices/machine/intelfsh.cpp
@@ -165,6 +165,7 @@ intelfsh_device::intelfsh_device(const machine_config &mconfig, device_type type
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_type(variant),
m_size(0),
m_bits(8),
@@ -543,7 +544,7 @@ const address_space_config *intelfsh_device::memory_space_config(address_spacenu
void intelfsh_device::nvram_default()
{
// region always wins
- if (m_region != nullptr)
+ if (m_region.found())
{
UINT32 bytes = m_region->bytes();
if (bytes > m_size)
@@ -552,19 +553,19 @@ void intelfsh_device::nvram_default()
if (m_bits == 8)
{
for (offs_t offs = 0; offs < bytes; offs++)
- m_addrspace[0]->write_byte(offs, m_region->u8(offs));
+ space(AS_PROGRAM).write_byte(offs, m_region->u8(offs));
}
else
{
for (offs_t offs = 0; offs < bytes; offs += 2)
- m_addrspace[0]->write_word(offs, m_region->u16(offs / 2));
+ space(AS_PROGRAM).write_word(offs, m_region->u16(offs / 2));
}
return;
}
// otherwise, default to 0xff
for (offs_t offs = 0; offs < m_size; offs++)
- m_addrspace[0]->write_byte(offs, 0xff);
+ space(AS_PROGRAM).write_byte(offs, 0xff);
}
@@ -578,7 +579,7 @@ void intelfsh_device::nvram_read(emu_file &file)
dynamic_buffer buffer(m_size);
file.read(&buffer[0], m_size);
for (int byte = 0; byte < m_size; byte++)
- m_addrspace[0]->write_byte(byte, buffer[byte]);
+ space(AS_PROGRAM).write_byte(byte, buffer[byte]);
}
@@ -591,7 +592,7 @@ void intelfsh_device::nvram_write(emu_file &file)
{
dynamic_buffer buffer(m_size);
for (int byte = 0; byte < m_size; byte++)
- buffer[byte] = m_addrspace[0]->read_byte(byte);
+ buffer[byte] = space(AS_PROGRAM).read_byte(byte);
file.write(&buffer[0], m_size);
}
@@ -613,12 +614,12 @@ UINT32 intelfsh_device::read_full(UINT32 address)
{
case 8:
{
- data = m_addrspace[0]->read_byte(address);
+ data = space(AS_PROGRAM).read_byte(address);
}
break;
case 16:
{
- data = m_addrspace[0]->read_word(address * 2);
+ data = space(AS_PROGRAM).read_word(address * 2);
}
break;
}
@@ -692,12 +693,12 @@ UINT32 intelfsh_device::read_full(UINT32 address)
{
case 8:
{
- data = m_addrspace[0]->read_byte(address);
+ data = space(AS_PROGRAM).read_byte(address);
}
break;
case 16:
{
- data = m_addrspace[0]->read_word(address * 2);
+ data = space(AS_PROGRAM).read_word(address * 2);
}
break;
}
@@ -921,7 +922,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
{
// chip erase
for (offs_t offs = 0; offs < m_size; offs++)
- m_addrspace[0]->write_byte(offs, 0xff);
+ space(AS_PROGRAM).write_byte(offs, 0xff);
m_status = 1 << 3;
m_flash_mode = FM_ERASEAMD4;
@@ -947,14 +948,14 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
if (m_sector_is_4k)
{
for (offs_t offs = 0; offs < 4 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xfff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0xfff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x7ff : ~0xfff);
m_timer->adjust( attotime::from_msec( 125 ) );
}
else if(m_sector_is_16k)
{
for (offs_t offs = 0; offs < 16 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x3fff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0x3fff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x1fff : ~0x3fff);
m_timer->adjust( attotime::from_msec( 500 ) );
}
@@ -963,21 +964,21 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
if (address >= (m_size - (16*1024)))
{
for (offs_t offs = 0; offs < 16 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x3fff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0x3fff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x1fff : ~0x3fff);
m_timer->adjust( attotime::from_msec( 500 ) );
}
else if (address >= (m_size - (32*1024)))
{
for (offs_t offs = 0; offs < 8 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x1fff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0x1fff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0xfff : ~0x1fff);
m_timer->adjust( attotime::from_msec( 250 ) );
}
else
{
for (offs_t offs = 0; offs < 32 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x7fff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0x7fff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x3fff : ~0x7fff);
m_timer->adjust( attotime::from_msec( 500 ) );
}
@@ -985,7 +986,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
else
{
for (offs_t offs = 0; offs < 64 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xffff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0xffff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x7fff : ~0xffff);
m_timer->adjust( attotime::from_seconds( 1 ) );
}
@@ -1003,7 +1004,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
{
case 8:
{
- m_addrspace[0]->write_byte(address, data);
+ space(AS_PROGRAM).write_byte(address, data);
}
break;
default:
@@ -1016,14 +1017,10 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
switch( m_bits )
{
case 8:
- {
- m_addrspace[0]->write_byte(address, data);
- }
+ space(AS_PROGRAM).write_byte(address, data);
break;
case 16:
- {
- m_addrspace[0]->write_word(address * 2, data);
- }
+ space(AS_PROGRAM).write_word(address * 2, data);
break;
default:
logerror( "FM_WRITEPART1 not supported when m_bits == %d\n", m_bits );
@@ -1039,14 +1036,10 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
switch( m_bits )
{
case 8:
- {
- m_addrspace[0]->write_byte(address, data);
- }
+ space(AS_PROGRAM).write_byte(address, data);
break;
case 16:
- {
- m_addrspace[0]->write_word(address * 2, data);
- }
+ space(AS_PROGRAM).write_word(address * 2, data);
break;
default:
logerror( "FM_WRITEPAGEATMEL not supported when m_bits == %d\n", m_bits );
@@ -1068,7 +1061,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
// clear the 256 bytes block containing the current address to all 0xffs
UINT32 base = address * ((m_bits == 16) ? 2 : 1);
for (offs_t offs = 0; offs < 256; offs++)
- m_addrspace[0]->write_byte((base & ~0xff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0xff) + offs, 0xff);
m_timer->adjust( attotime::from_msec( 4 ) );
}
@@ -1111,7 +1104,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
// clear the block containing the current address to all 0xffffs
for (offs_t offs = 0; offs < size / 2; offs += 2)
- m_addrspace[0]->write_word(base | offs, 0xffff);
+ space(AS_PROGRAM).write_word(base | offs, 0xffff);
m_timer->adjust( attotime::from_msec( duration ) );
}
@@ -1120,7 +1113,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
// clear the 64k block containing the current address to all 0xffs
UINT32 base = address * ((m_bits == 16) ? 2 : 1);
for (offs_t offs = 0; offs < 64 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xffff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0xffff) + offs, 0xff);
m_timer->adjust( attotime::from_seconds( 1 ) );
}
diff --git a/src/devices/machine/intelfsh.h b/src/devices/machine/intelfsh.h
index 437d8c946c2..611c2a01d49 100644
--- a/src/devices/machine/intelfsh.h
+++ b/src/devices/machine/intelfsh.h
@@ -166,6 +166,8 @@ protected:
UINT32 read_full(UINT32 offset);
void write_full(UINT32 offset, UINT32 data);
+ optional_memory_region m_region;
+
// configuration state
address_space_config m_space_config;
UINT32 m_type;
@@ -205,8 +207,8 @@ public:
DECLARE_READ8_MEMBER(read) { return read_full(offset); }
DECLARE_WRITE8_MEMBER(write) { write_full(offset, data); }
- UINT8 read_raw(offs_t offset) { return m_addrspace[0]->read_byte(offset); }
- void write_raw(offs_t offset, UINT8 data) { m_addrspace[0]->write_byte(offset, data); }
+ UINT8 read_raw(offs_t offset) { return space(AS_PROGRAM).read_byte(offset); }
+ void write_raw(offs_t offset, UINT8 data) { space(AS_PROGRAM).write_byte(offset, data); }
};
@@ -225,8 +227,8 @@ public:
DECLARE_READ16_MEMBER(read) { return read_full(offset); }
DECLARE_WRITE16_MEMBER(write) { write_full(offset, data); }
- UINT16 read_raw(offs_t offset) { return m_addrspace[0]->read_word(offset * 2); }
- void write_raw(offs_t offset, UINT16 data) { m_addrspace[0]->write_word(offset * 2, data); }
+ UINT16 read_raw(offs_t offset) { return space(AS_PROGRAM).read_word(offset * 2); }
+ void write_raw(offs_t offset, UINT16 data) { space(AS_PROGRAM).write_word(offset * 2, data); }
};
diff --git a/src/devices/machine/k033906.cpp b/src/devices/machine/k033906.cpp
index d9953d2864f..b799ad11cd0 100644
--- a/src/devices/machine/k033906.cpp
+++ b/src/devices/machine/k033906.cpp
@@ -8,7 +8,6 @@
#include "emu.h"
#include "k033906.h"
-#include "video/voodoo.h"
//**************************************************************************
@@ -23,7 +22,7 @@ const device_type K033906 = &device_creator<k033906_device>;
//-------------------------------------------------
k033906_device::k033906_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, K033906, "K033906 PCI bridge", tag, owner, clock, "k033906", __FILE__), m_reg_set(0), m_voodoo_tag(nullptr), m_voodoo(nullptr)
+ : device_t(mconfig, K033906, "K033906 PCI bridge", tag, owner, clock, "k033906", __FILE__), m_reg_set(0), m_voodoo(*this)
{
}
@@ -33,8 +32,6 @@ k033906_device::k033906_device(const machine_config &mconfig, const char *tag, d
void k033906_device::device_start()
{
- m_voodoo = (voodoo_device*)machine().device(m_voodoo_tag);
-
m_reg_set = 0;
save_item(NAME(m_reg));
diff --git a/src/devices/machine/k033906.h b/src/devices/machine/k033906.h
index 438cc5796ab..e493244ce81 100644
--- a/src/devices/machine/k033906.h
+++ b/src/devices/machine/k033906.h
@@ -20,7 +20,7 @@
***************************************************************************/
#define MCFG_K033906_VOODOO(_tag) \
- k033906_device::set_voodoo_tag(*device, _tag);
+ k033906_device::set_voodoo_tag(*device, "^" _tag);
/***************************************************************************
TYPE DEFINITIONS
@@ -35,7 +35,7 @@ public:
// construction/destruction
k033906_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- static void set_voodoo_tag(device_t &device, const char *tag) { downcast<k033906_device &>(device).m_voodoo_tag = tag; }
+ static void set_voodoo_tag(device_t &device, const char *tag) { downcast<k033906_device &>(device).m_voodoo.set_tag(tag); }
DECLARE_READ32_MEMBER( read );
DECLARE_WRITE32_MEMBER( write );
@@ -57,8 +57,7 @@ private:
int m_reg_set; // 1 = access reg / 0 = access ram
- const char *m_voodoo_tag;
- voodoo_device *m_voodoo;
+ required_device<voodoo_device> m_voodoo;
UINT32 m_reg[256];
UINT32 m_ram[32768];
diff --git a/src/devices/machine/k053252.cpp b/src/devices/machine/k053252.cpp
index 45020926ace..2a857d04bf5 100644
--- a/src/devices/machine/k053252.cpp
+++ b/src/devices/machine/k053252.cpp
@@ -76,8 +76,7 @@ k053252_device::k053252_device(const machine_config &mconfig, const char *tag, d
m_offsx(0),
m_offsy(0),
// ugly, needed to work with the rungun etc. video demux board
- m_slave_screen_tag(nullptr),
- m_slave_screen(nullptr)
+ m_slave_screen(*this)
{
}
@@ -103,12 +102,6 @@ void k053252_device::device_start()
save_item(NAME(m_vbp));
save_item(NAME(m_vsw));
save_item(NAME(m_hsw));
-
- if (m_slave_screen_tag != nullptr)
- {
- // find the screen device if explicitly configured
- m_slave_screen = device().siblingdevice<screen_device>(m_slave_screen_tag);
- }
}
//-------------------------------------------------
@@ -181,7 +174,7 @@ void k053252_device::res_change()
m_screen->configure(m_hc, m_vc, visarea, refresh);
- if (m_slave_screen)
+ if (m_slave_screen.found())
m_slave_screen->configure(m_hc, m_vc, visarea, refresh);
#if 0
@@ -262,5 +255,5 @@ WRITE8_MEMBER( k053252_device::write )
void k053252_device::static_set_slave_screen(device_t &device, const char *tag)
{
k053252_device &dev = downcast<k053252_device &>(device);
- dev.m_slave_screen_tag = tag;
+ dev.m_slave_screen.set_tag(tag);
}
diff --git a/src/devices/machine/k053252.h b/src/devices/machine/k053252.h
index a00743789ad..54787a6ee78 100644
--- a/src/devices/machine/k053252.h
+++ b/src/devices/machine/k053252.h
@@ -27,7 +27,7 @@
k053252_device::set_offsets(*device, _offsx, _offsy);
#define MCFG_K053252_SET_SLAVE_SCREEN(_tag) \
- k053252_device::static_set_slave_screen(*device, _tag);
+ k053252_device::static_set_slave_screen(*device, "^" _tag);
class k053252_device : public device_t,
@@ -75,8 +75,7 @@ protected:
int m_offsx;
int m_offsy;
- const char * m_slave_screen_tag;
- screen_device * m_slave_screen;
+ optional_device<screen_device> m_slave_screen;
};
diff --git a/src/devices/machine/mc146818.cpp b/src/devices/machine/mc146818.cpp
index 9166e189952..1b659a610a0 100644
--- a/src/devices/machine/mc146818.cpp
+++ b/src/devices/machine/mc146818.cpp
@@ -33,6 +33,7 @@ const device_type MC146818 = &device_creator<mc146818_device>;
mc146818_device::mc146818_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, MC146818, "MC146818 RTC", tag, owner, clock, "mc146818", __FILE__),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_index(0),
m_last_refresh(attotime::zero), m_clock_timer(nullptr), m_periodic_timer(nullptr),
m_write_irq(*this),
@@ -48,6 +49,7 @@ mc146818_device::mc146818_device(const machine_config &mconfig, const char *tag,
mc146818_device::mc146818_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_index(0),
m_last_refresh(attotime::zero), m_clock_timer(nullptr), m_periodic_timer(nullptr),
m_write_irq(*this),
@@ -193,14 +195,15 @@ void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int par
void mc146818_device::nvram_default()
{
// populate from a memory region if present
- if (m_region != nullptr)
+ memory_region *region = memregion(DEVICE_SELF);
+ if (region != nullptr)
{
- UINT32 bytes = m_region->bytes();
+ UINT32 bytes = region->bytes();
if (bytes > data_size())
bytes = data_size();
- memcpy(&m_data[0], m_region->base(), bytes);
+ memcpy(&m_data[0], region->base(), bytes);
}
else
{
diff --git a/src/devices/machine/mc146818.h b/src/devices/machine/mc146818.h
index c1c30eae17e..a7f16300b4b 100644
--- a/src/devices/machine/mc146818.h
+++ b/src/devices/machine/mc146818.h
@@ -167,6 +167,8 @@ private:
int get_year();
void set_year(int year);
+ optional_memory_region m_region;
+
// internal state
UINT8 m_index;
diff --git a/src/devices/machine/mos6530n.cpp b/src/devices/machine/mos6530n.cpp
index 31c15c65e1d..8f43b58405c 100644
--- a/src/devices/machine/mos6530n.cpp
+++ b/src/devices/machine/mos6530n.cpp
@@ -116,6 +116,7 @@ WRITE8_MEMBER(mos6532_t::io_w)
mos6530_base_t::mos6530_base_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
device_t(mconfig, type, name, tag, owner, clock, shortname, source),
m_ram(*this),
+ m_rom(*this, DEVICE_SELF),
m_irq_cb(*this),
m_in_pa_cb(*this),
m_out_pa_cb(*this),
diff --git a/src/devices/machine/mos6530n.h b/src/devices/machine/mos6530n.h
index 71688040e89..b29fea9af93 100644
--- a/src/devices/machine/mos6530n.h
+++ b/src/devices/machine/mos6530n.h
@@ -268,7 +268,7 @@ protected:
void timer_w(offs_t offset, UINT8 data, bool ie);
UINT8 timer_r(bool ie);
- DECLARE_READ8_MEMBER( rom_r ) { return m_region->base()[offset]; }
+ DECLARE_READ8_MEMBER( rom_r ) { return m_rom[offset]; }
DECLARE_READ8_MEMBER( ram_r ) { return m_ram[offset]; }
DECLARE_WRITE8_MEMBER( ram_w ) { m_ram[offset] = data; }
DECLARE_READ8_MEMBER( pa_data_r );
@@ -287,6 +287,7 @@ protected:
DECLARE_WRITE8_MEMBER( edge_w );
optional_shared_ptr<UINT8> m_ram;
+ optional_region_ptr<UINT8> m_rom;
devcb_write_line m_irq_cb;
devcb_read8 m_in_pa_cb;
diff --git a/src/devices/machine/nvram.cpp b/src/devices/machine/nvram.cpp
index 88d1191187a..3a88345eab3 100644
--- a/src/devices/machine/nvram.cpp
+++ b/src/devices/machine/nvram.cpp
@@ -25,6 +25,7 @@ const device_type NVRAM = &device_creator<nvram_device>;
nvram_device::nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, NVRAM, "NVRAM", tag, owner, clock, "nvram", __FILE__),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_default_value(DEFAULT_ALL_1),
m_base(nullptr),
m_length(0)
@@ -79,7 +80,7 @@ void nvram_device::nvram_default()
determine_final_base();
// region always wins
- if (m_region != nullptr)
+ if (m_region.found())
{
memcpy(m_base, m_region->base(), m_length);
return;
@@ -164,6 +165,6 @@ void nvram_device::determine_final_base()
}
// if we are region-backed for the default, find it now and make sure it's the right size
- if (m_region != nullptr && m_region->bytes() != m_length)
+ if (m_region.found() && m_region->bytes() != m_length)
throw emu_fatalerror("%s",string_format("NVRAM device '%s' has a default region, but it should be 0x%I64uX bytes", tag(), m_length).c_str());
}
diff --git a/src/devices/machine/nvram.h b/src/devices/machine/nvram.h
index ac6b62e7bca..c1a733a3953 100644
--- a/src/devices/machine/nvram.h
+++ b/src/devices/machine/nvram.h
@@ -99,6 +99,7 @@ protected:
void determine_final_base();
// configuration state
+ optional_memory_region m_region;
default_value m_default_value;
nvram_init_delegate m_custom_handler;
diff --git a/src/devices/machine/pci.cpp b/src/devices/machine/pci.cpp
index 5987a423a09..859b44dc939 100644
--- a/src/devices/machine/pci.cpp
+++ b/src/devices/machine/pci.cpp
@@ -59,7 +59,8 @@ DEVICE_ADDRESS_MAP_START(config_map, 32, pci_bridge_device)
ADDRESS_MAP_END
pci_device::pci_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
+ m_region(*this, DEVICE_SELF)
{
main_id = 0xffffffff;
revision = 0x00;
diff --git a/src/devices/machine/pci.h b/src/devices/machine/pci.h
index a88f0a3b7fb..9650efa8132 100644
--- a/src/devices/machine/pci.h
+++ b/src/devices/machine/pci.h
@@ -82,6 +82,8 @@ public:
virtual DECLARE_READ8_MEMBER(capptr_r);
protected:
+ optional_memory_region m_region;
+
enum {
M_MEM = 0,
M_IO = 1,
diff --git a/src/devices/machine/pla.cpp b/src/devices/machine/pla.cpp
index f96a2bd8f60..f2310201771 100644
--- a/src/devices/machine/pla.cpp
+++ b/src/devices/machine/pla.cpp
@@ -19,6 +19,7 @@ const device_type PLA = &device_creator<pla_device>;
pla_device::pla_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, PLA, "PLA", tag, owner, clock, "pla", __FILE__),
+ m_region(*this, DEVICE_SELF),
m_format(PLA_FMT_JEDBIN),
m_inputs(0),
m_outputs(0),
@@ -35,7 +36,6 @@ pla_device::pla_device(const machine_config &mconfig, const char *tag, device_t
void pla_device::device_start()
{
- assert(region() != nullptr);
assert(m_terms < MAX_TERMS);
assert(m_inputs < 32 && m_outputs <= 32);
@@ -74,11 +74,11 @@ void pla_device::parse_fusemap()
switch (m_format)
{
case PLA_FMT_JEDBIN:
- result = jedbin_parse(region()->base(), region()->bytes(), &jed);
+ result = jedbin_parse(m_region->base(), m_region->bytes(), &jed);
break;
case PLA_FMT_BERKELEY:
- result = pla_parse(region()->base(), region()->bytes(), &jed);
+ result = pla_parse(m_region->base(), m_region->bytes(), &jed);
break;
}
diff --git a/src/devices/machine/pla.h b/src/devices/machine/pla.h
index 9f14a155ac5..1fdffd023d9 100644
--- a/src/devices/machine/pla.h
+++ b/src/devices/machine/pla.h
@@ -109,6 +109,8 @@ protected:
private:
void parse_fusemap();
+ required_memory_region m_region;
+
int m_format;
UINT32 m_inputs;
diff --git a/src/devices/machine/rp5h01.cpp b/src/devices/machine/rp5h01.cpp
index 4a3138225a7..009757b6acf 100644
--- a/src/devices/machine/rp5h01.cpp
+++ b/src/devices/machine/rp5h01.cpp
@@ -20,7 +20,7 @@
#include "machine/rp5h01.h"
// this is the contents of an unprogrammed PROM
-static const UINT8 initial_data[0x10] =
+UINT8 rp5h01_device::s_initial_data[0x10] =
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00
@@ -34,7 +34,7 @@ const device_type RP5H01 = &device_creator<rp5h01_device>;
rp5h01_device::rp5h01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, RP5H01, "RP5H01 6/7-bit Counter", tag, owner, clock, "rp5h01", __FILE__)
- , m_rom_ptr(*this, DEVICE_SELF)
+ , m_data(*this, DEVICE_SELF, 0x10)
{
}
@@ -54,15 +54,8 @@ void rp5h01_device::device_config_complete()
void rp5h01_device::device_start()
{
- if (m_rom_ptr == nullptr)
- {
- m_data = initial_data;
- }
- else
- {
- m_data = m_rom_ptr;
- assert(region()->bytes() == 0x10);
- }
+ if (!m_data.found())
+ m_data.set_target(s_initial_data, 0x10);
/* register for state saving */
save_item(NAME(m_counter));
diff --git a/src/devices/machine/rp5h01.h b/src/devices/machine/rp5h01.h
index 0585b5ddf55..c33a80a998b 100644
--- a/src/devices/machine/rp5h01.h
+++ b/src/devices/machine/rp5h01.h
@@ -36,6 +36,8 @@ enum {
class rp5h01_device : public device_t
{
+ static UINT8 s_initial_data[0x10];
+
public:
rp5h01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
@@ -60,8 +62,7 @@ private:
int m_enabled; /* chip enable */
int m_old_reset; /* reset pin state (level-triggered) */
int m_old_clock; /* clock pin state (level-triggered) */
- const UINT8 *m_data;
- optional_region_ptr<UINT8> m_rom_ptr;
+ optional_region_ptr<UINT8> m_data;
};
extern const device_type RP5H01;
diff --git a/src/devices/machine/timekpr.cpp b/src/devices/machine/timekpr.cpp
index 7b602c896c6..06aba0b7221 100644
--- a/src/devices/machine/timekpr.cpp
+++ b/src/devices/machine/timekpr.cpp
@@ -119,15 +119,16 @@ static int counter_from_ram( UINT8 *data, int offset )
// timekeeper_device_config - constructor
//-------------------------------------------------
-timekeeper_device::timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
+timekeeper_device::timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int size)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source)
, device_nvram_interface(mconfig, *this)
- , m_default_data(*this, DEVICE_SELF)
+ , m_default_data(*this, DEVICE_SELF, size)
+ , m_size(size)
{
}
m48t02_device::m48t02_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T02, "M48T02 Timekeeper", tag, owner, clock, "m48t02", __FILE__)
+ : timekeeper_device(mconfig, M48T02, "M48T02 Timekeeper", tag, owner, clock, "m48t02", __FILE__, 0x800)
{
m_offset_control = 0x7f8;
m_offset_seconds = 0x7f9;
@@ -139,11 +140,10 @@ m48t02_device::m48t02_device(const machine_config &mconfig, const char *tag, dev
m_offset_year = 0x7ff;
m_offset_century = -1;
m_offset_flags = -1;
- m_size = 0x800;
}
m48t35_device::m48t35_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T35, "M48T35 Timekeeper", tag, owner, clock, "m48t35", __FILE__)
+ : timekeeper_device(mconfig, M48T35, "M48T35 Timekeeper", tag, owner, clock, "m48t35", __FILE__, 0x8000)
{
m_offset_control = 0x7ff8;
m_offset_seconds = 0x7ff9;
@@ -155,11 +155,10 @@ m48t35_device::m48t35_device(const machine_config &mconfig, const char *tag, dev
m_offset_year = 0x7fff;
m_offset_century = -1;
m_offset_flags = -1;
- m_size = 0x8000;
}
m48t37_device::m48t37_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T37, "M48T37 Timekeeper", tag, owner, clock, "m48t37", __FILE__)
+ : timekeeper_device(mconfig, M48T37, "M48T37 Timekeeper", tag, owner, clock, "m48t37", __FILE__, 0x8000)
{
m_offset_control = 0x7ff8;
m_offset_seconds = 0x7ff9;
@@ -171,11 +170,10 @@ m48t37_device::m48t37_device(const machine_config &mconfig, const char *tag, dev
m_offset_year = 0x7fff;
m_offset_century = 0x7ff1;
m_offset_flags = 0x7ff0;
- m_size = 0x8000;
}
m48t58_device::m48t58_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T58, "M48T58 Timekeeper", tag, owner, clock, "m48t58", __FILE__)
+ : timekeeper_device(mconfig, M48T58, "M48T58 Timekeeper", tag, owner, clock, "m48t58", __FILE__, 0x2000)
{
m_offset_control = 0x1ff8;
m_offset_seconds = 0x1ff9;
@@ -187,11 +185,10 @@ m48t58_device::m48t58_device(const machine_config &mconfig, const char *tag, dev
m_offset_year = 0x1fff;
m_offset_century = -1;
m_offset_flags = -1;
- m_size = 0x2000;
}
mk48t08_device::mk48t08_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, MK48T08, "MK48T08 Timekeeper", tag, owner, clock, "m48t08", __FILE__)
+ : timekeeper_device(mconfig, MK48T08, "MK48T08 Timekeeper", tag, owner, clock, "m48t08", __FILE__, 0x2000)
{
m_offset_control = 0x1ff8;
m_offset_seconds = 0x1ff9;
@@ -203,7 +200,6 @@ mk48t08_device::mk48t08_device(const machine_config &mconfig, const char *tag, d
m_offset_year = 0x1fff;
m_offset_century = 0x1ff1;
m_offset_flags = 0x1ff0;
- m_size = 0x2000;
}
@@ -231,11 +227,6 @@ void timekeeper_device::device_start()
m_century = make_bcd( systime.local_time.year / 100 );
m_data.resize( m_size );
- if (m_default_data)
- {
- assert(m_default_data.bytes() == m_size);
- }
-
save_item( NAME(m_control) );
save_item( NAME(m_seconds) );
save_item( NAME(m_minutes) );
@@ -398,7 +389,7 @@ READ8_MEMBER( timekeeper_device::read )
void timekeeper_device::nvram_default()
{
- if( m_default_data != nullptr )
+ if (m_default_data.found())
{
memcpy( &m_data[0], m_default_data, m_size );
}
diff --git a/src/devices/machine/timekpr.h b/src/devices/machine/timekpr.h
index 84c969b076d..3d96d2f394a 100644
--- a/src/devices/machine/timekpr.h
+++ b/src/devices/machine/timekpr.h
@@ -55,7 +55,7 @@ class timekeeper_device : public device_t,
{
protected:
// construction/destruction
- timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
+ timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int size);
public:
DECLARE_WRITE8_MEMBER( write );
diff --git a/src/devices/machine/vrc4373.cpp b/src/devices/machine/vrc4373.cpp
index c6797193c49..50257a2d076 100644
--- a/src/devices/machine/vrc4373.cpp
+++ b/src/devices/machine/vrc4373.cpp
@@ -31,8 +31,8 @@ ADDRESS_MAP_END
vrc4373_device::vrc4373_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: pci_host_device(mconfig, VRC4373, "NEC VRC4373 System Controller", tag, owner, clock, "vrc4373", __FILE__), m_cpu_space(nullptr), m_cpu(nullptr), cpu_tag(nullptr),
m_mem_config("memory_space", ENDIANNESS_LITTLE, 32, 32),
- m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32), m_ram_size(0), m_ram_base(0), m_simm_size(0), m_simm_base(0), m_pci1_laddr(0), m_pci2_laddr(0), m_pci_io_laddr(0), m_target1_laddr(0), m_target2_laddr(0)
-
+ m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32), m_ram_size(0), m_ram_base(0), m_simm_size(0), m_simm_base(0), m_pci1_laddr(0), m_pci2_laddr(0), m_pci_io_laddr(0), m_target1_laddr(0), m_target2_laddr(0),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/machine/vrc4373.h b/src/devices/machine/vrc4373.h
index bbd740b8084..9c9e65588a8 100644
--- a/src/devices/machine/vrc4373.h
+++ b/src/devices/machine/vrc4373.h
@@ -124,6 +124,7 @@ private:
UINT32 m_pci1_laddr, m_pci2_laddr, m_pci_io_laddr;
UINT32 m_target1_laddr, m_target2_laddr;
+ required_memory_region m_region;
};
diff --git a/src/devices/machine/x2212.cpp b/src/devices/machine/x2212.cpp
index cb6fc2b57e9..63d28a322e4 100644
--- a/src/devices/machine/x2212.cpp
+++ b/src/devices/machine/x2212.cpp
@@ -46,11 +46,13 @@ x2212_device::x2212_device(const machine_config &mconfig, const char *tag, devic
m_sram_space_config("SRAM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_sram_map)),
m_e2prom_space_config("E2PROM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_e2prom_map)),
m_store(false),
- m_array_recall(false)
+ m_array_recall(false),
+ m_size_data(0x100),
+ m_default_data(*this, DEVICE_SELF, 0x100)
{
}
-x2212_device::x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
+x2212_device::x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int size_data)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
@@ -58,7 +60,9 @@ x2212_device::x2212_device(const machine_config &mconfig, device_type type, cons
m_sram_space_config("SRAM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_sram_map)),
m_e2prom_space_config("E2PROM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_e2prom_map)),
m_store(false),
- m_array_recall(false)
+ m_array_recall(false),
+ m_size_data(size_data),
+ m_default_data(*this, DEVICE_SELF, size_data)
{
}
@@ -81,22 +85,8 @@ void x2212_device::device_start()
{
save_item(NAME(m_store));
save_item(NAME(m_array_recall));
-
- m_sram = m_addrspace[0];
- m_e2prom = m_addrspace[1];
-
- SIZE_DATA = 0x100;
-}
-
-void x2210_device::device_start()
-{
- save_item(NAME(m_store));
- save_item(NAME(m_array_recall));
-
- m_sram = m_addrspace[0];
- m_e2prom = m_addrspace[1];
-
- SIZE_DATA = 0x40;
+ m_sram = &space(AS_0);
+ m_e2prom = &space(AS_1);
}
@@ -119,23 +109,17 @@ const address_space_config *x2212_device::memory_space_config(address_spacenum s
void x2212_device::nvram_default()
{
// default to all-0xff
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ for (int byte = 0; byte < m_size_data; byte++)
{
m_sram->write_byte(byte, 0xff);
m_e2prom->write_byte(byte, 0xff);
}
// populate from a memory region if present
- if (m_region != nullptr)
+ if (m_default_data.found())
{
- if (m_region->bytes() != SIZE_DATA)
- fatalerror("x2212 region '%s' wrong size (expected size = 0x100)\n", tag());
- if (m_region->bytewidth() != 1)
- fatalerror("x2212 region '%s' needs to be an 8-bit region\n", tag());
-
- UINT8 *default_data = m_region->base();
- for (int byte = 0; byte < SIZE_DATA; byte++)
- m_e2prom->write_byte(byte, default_data[byte]);
+ for (int byte = 0; byte < m_size_data; byte++)
+ m_e2prom->write_byte(byte, m_default_data[byte]);
}
}
@@ -147,9 +131,9 @@ void x2212_device::nvram_default()
void x2212_device::nvram_read(emu_file &file)
{
- UINT8 *buffer = (UINT8 *) alloca(SIZE_DATA);
- file.read(buffer, SIZE_DATA);
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ UINT8 *buffer = (UINT8 *) alloca(m_size_data);
+ file.read(buffer, m_size_data);
+ for (int byte = 0; byte < m_size_data; byte++)
{
m_sram->write_byte(byte, 0xff);
m_e2prom->write_byte(byte, buffer[byte]);
@@ -168,10 +152,10 @@ void x2212_device::nvram_write(emu_file &file)
if (m_auto_save)
store();
- UINT8 *buffer = (UINT8 *) alloca(SIZE_DATA);
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ UINT8 *buffer = (UINT8 *) alloca(m_size_data);
+ for (int byte = 0; byte < m_size_data; byte++)
buffer[byte] = m_e2prom->read_byte(byte);
- file.write(buffer, SIZE_DATA);
+ file.write(buffer, m_size_data);
}
@@ -187,7 +171,7 @@ void x2212_device::nvram_write(emu_file &file)
void x2212_device::store()
{
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ for (int byte = 0; byte < m_size_data; byte++)
m_e2prom->write_byte(byte, m_sram->read_byte(byte));
}
@@ -199,7 +183,7 @@ void x2212_device::store()
void x2212_device::recall()
{
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ for (int byte = 0; byte < m_size_data; byte++)
m_sram->write_byte(byte, m_e2prom->read_byte(byte));
}
@@ -256,6 +240,6 @@ WRITE_LINE_MEMBER( x2212_device::recall )
x2210_device::x2210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : x2212_device(mconfig, X2210, "X2210", tag, owner, clock, "x2210", __FILE__)
+ : x2212_device(mconfig, X2210, "X2210", tag, owner, clock, "x2210", __FILE__, 0x40)
{
}
diff --git a/src/devices/machine/x2212.h b/src/devices/machine/x2212.h
index 161cf399457..ffcc1dcf84b 100644
--- a/src/devices/machine/x2212.h
+++ b/src/devices/machine/x2212.h
@@ -49,7 +49,7 @@ class x2212_device : public device_t,
public:
// construction/destruction
x2212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
+ x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int size_data);
// inline configuration helpers
static void static_set_auto_save(device_t &device);
@@ -77,8 +77,6 @@ protected:
virtual void nvram_read(emu_file &file) override;
virtual void nvram_write(emu_file &file) override;
- int SIZE_DATA;
-
// configuration state
bool m_auto_save;
@@ -92,16 +90,15 @@ protected:
bool m_store;
bool m_array_recall;
+
+ int m_size_data;
+ optional_region_ptr<UINT8> m_default_data;
};
class x2210_device : public x2212_device
{
public:
x2210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- // device-level overrides
- virtual void device_start() override;
};
diff --git a/src/devices/machine/x76f041.cpp b/src/devices/machine/x76f041.cpp
index 21dea0ae141..481434abc77 100644
--- a/src/devices/machine/x76f041.cpp
+++ b/src/devices/machine/x76f041.cpp
@@ -37,6 +37,7 @@ const device_type X76F041 = &device_creator<x76f041_device>;
x76f041_device::x76f041_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
: device_t( mconfig, X76F041, "X76F041 Flash", tag, owner, clock, "x76f041", __FILE__ ),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_cs( 0 ),
m_rst( 0 ),
m_scl( 0 ),
@@ -498,7 +499,7 @@ void x76f041_device::nvram_default()
int expected_bytes = sizeof( m_response_to_reset ) + sizeof( m_write_password ) + sizeof( m_read_password ) +
sizeof( m_configuration_password ) + sizeof( m_configuration_registers ) + sizeof( m_data );
- if( !m_region )
+ if (!m_region.found())
{
logerror( "x76f041(%s) region not found\n", tag() );
}
diff --git a/src/devices/machine/x76f041.h b/src/devices/machine/x76f041.h
index 228540969eb..5c453aad6ee 100644
--- a/src/devices/machine/x76f041.h
+++ b/src/devices/machine/x76f041.h
@@ -99,6 +99,8 @@ private:
STATE_WRITE_CONFIGURATION_REGISTERS
};
+ optional_memory_region m_region;
+
// internal state
int m_cs;
int m_rst;
diff --git a/src/devices/machine/x76f100.cpp b/src/devices/machine/x76f100.cpp
index 830a0e51448..f254eed7ffc 100644
--- a/src/devices/machine/x76f100.cpp
+++ b/src/devices/machine/x76f100.cpp
@@ -35,6 +35,7 @@ const device_type X76F100 = &device_creator<x76f100_device>;
x76f100_device::x76f100_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
: device_t( mconfig, X76F100, "X76F100 Flash", tag, owner, clock, "x76f100", __FILE__ ),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_cs( 0 ),
m_rst( 0 ),
m_scl( 0 ),
@@ -391,7 +392,7 @@ void x76f100_device::nvram_default()
int expected_size = sizeof( m_response_to_reset ) + sizeof( m_write_password ) + sizeof( m_read_password ) + sizeof( m_data );
- if( !m_region )
+ if (!m_region.found())
{
logerror( "x76f100(%s) region not found\n", tag() );
}
diff --git a/src/devices/machine/x76f100.h b/src/devices/machine/x76f100.h
index 287a4a17a56..5ce4b5241c9 100644
--- a/src/devices/machine/x76f100.h
+++ b/src/devices/machine/x76f100.h
@@ -66,6 +66,8 @@ private:
STATE_WRITE_DATA
};
+ optional_memory_region m_region;
+
// internal state
int m_cs;
int m_rst;
diff --git a/src/devices/sound/2608intf.cpp b/src/devices/sound/2608intf.cpp
index ba6baba7bce..7c4a9d0739c 100644
--- a/src/devices/sound/2608intf.cpp
+++ b/src/devices/sound/2608intf.cpp
@@ -144,8 +144,8 @@ void ym2608_device::device_start()
/* stream system initialize */
m_stream = machine().sound().stream_alloc(*this,0,2,rate, stream_update_delegate(FUNC(ym2608_device::stream_generate),this));
/* setup adpcm buffers */
- pcmbufa = region()->base();
- pcmsizea = region()->bytes();
+ pcmbufa = m_region->base();
+ pcmsizea = m_region->bytes();
/* initialize YM2608 */
m_chip = ym2608_init(this,this,clock(),rate,
@@ -187,7 +187,8 @@ const device_type YM2608 = &device_creator<ym2608_device>;
ym2608_device::ym2608_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: ay8910_device(mconfig, YM2608, "YM2608", tag, owner, clock, PSG_TYPE_YM, 1, 2, "ym2608", __FILE__),
- m_irq_handler(*this)
+ m_irq_handler(*this),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/sound/2608intf.h b/src/devices/sound/2608intf.h
index f827f998521..0ec973b69ff 100644
--- a/src/devices/sound/2608intf.h
+++ b/src/devices/sound/2608intf.h
@@ -45,6 +45,7 @@ private:
emu_timer * m_timer[2];
void * m_chip;
devcb_write_line m_irq_handler;
+ required_memory_region m_region;
};
extern const device_type YM2608;
diff --git a/src/devices/sound/2610intf.cpp b/src/devices/sound/2610intf.cpp
index 4cc7f303795..776ad96d009 100644
--- a/src/devices/sound/2610intf.cpp
+++ b/src/devices/sound/2610intf.cpp
@@ -157,8 +157,8 @@ void ym2610_device::device_start()
m_stream = machine().sound().stream_alloc(*this,0,2,rate, stream_update_delegate(FUNC(ym2610_device::stream_generate),this));
/* setup adpcm buffers */
- void *pcmbufa = region()->base();
- int pcmsizea = region()->bytes();
+ void *pcmbufa = m_region->base();
+ int pcmsizea = m_region->bytes();
std::string name = tag() + std::string(".deltat");
memory_region *deltat_region = machine().root_device().memregion(name.c_str());
@@ -212,12 +212,14 @@ const device_type YM2610 = &device_creator<ym2610_device>;
ym2610_device::ym2610_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: ay8910_device(mconfig, YM2610, "YM2610", tag, owner, clock, PSG_TYPE_YM, 1, 0, "ym2610", __FILE__)
, m_irq_handler(*this)
+ , m_region(*this, DEVICE_SELF)
{
}
ym2610_device::ym2610_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: ay8910_device(mconfig, type, name, tag, owner, clock, PSG_TYPE_YM, 1, 0, shortname, source)
, m_irq_handler(*this)
+ , m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/sound/2610intf.h b/src/devices/sound/2610intf.h
index dcd0ef01787..b41843053ab 100644
--- a/src/devices/sound/2610intf.h
+++ b/src/devices/sound/2610intf.h
@@ -50,6 +50,7 @@ private:
sound_stream * m_stream;
emu_timer * m_timer[2];
devcb_write_line m_irq_handler;
+ required_memory_region m_region;
};
extern const device_type YM2610;
diff --git a/src/devices/sound/8950intf.cpp b/src/devices/sound/8950intf.cpp
index 4454b37f941..adc51009a0c 100644
--- a/src/devices/sound/8950intf.cpp
+++ b/src/devices/sound/8950intf.cpp
@@ -150,7 +150,7 @@ void y8950_device::device_start()
assert_always(m_chip != nullptr, "Error creating Y8950 chip");
/* ADPCM ROM data */
- y8950_set_delta_t_memory(m_chip, region()->base(), region()->bytes());
+ y8950_set_delta_t_memory(m_chip, m_region->base(), m_region->bytes());
m_stream = machine().sound().stream_alloc(*this,0,1,rate);
/* port and keyboard handler */
@@ -212,7 +212,8 @@ y8950_device::y8950_device(const machine_config &mconfig, const char *tag, devic
m_keyboard_read_handler(*this),
m_keyboard_write_handler(*this),
m_io_read_handler(*this),
- m_io_write_handler(*this)
+ m_io_write_handler(*this),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/sound/8950intf.h b/src/devices/sound/8950intf.h
index 53a35111f77..e548beffa62 100644
--- a/src/devices/sound/8950intf.h
+++ b/src/devices/sound/8950intf.h
@@ -73,6 +73,7 @@ private:
devcb_write8 m_keyboard_write_handler;
devcb_read8 m_io_read_handler;
devcb_write8 m_io_write_handler;
+ required_memory_region m_region;
};
extern const device_type Y8950;
diff --git a/src/devices/sound/digitalk.cpp b/src/devices/sound/digitalk.cpp
index 262e930bddf..d36bb77e4c3 100644
--- a/src/devices/sound/digitalk.cpp
+++ b/src/devices/sound/digitalk.cpp
@@ -266,7 +266,7 @@ const device_type DIGITALKER = &device_creator<digitalker_device>;
digitalker_device::digitalker_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, DIGITALKER, "Digitalker", tag, owner, clock, "digitalker", __FILE__),
device_sound_interface(mconfig, *this),
- m_rom(nullptr),
+ m_rom(*this, DEVICE_SELF),
m_stream(nullptr),
m_data(0),
m_cs(0),
@@ -655,7 +655,6 @@ void digitalker_device::digitalker_register_for_save()
void digitalker_device::device_start()
{
- m_rom = m_region->base();
m_stream = stream_alloc(0, 1, clock()/4);
m_dac_index = 128;
m_data = 0xff;
diff --git a/src/devices/sound/digitalk.h b/src/devices/sound/digitalk.h
index 7be2a733c56..4142a50e3e2 100644
--- a/src/devices/sound/digitalk.h
+++ b/src/devices/sound/digitalk.h
@@ -59,7 +59,7 @@ private:
void digitalker_register_for_save();
private:
- const UINT8 *m_rom;
+ required_region_ptr<UINT8> m_rom;
sound_stream *m_stream;
// Port/lines state
diff --git a/src/devices/sound/gaelco.cpp b/src/devices/sound/gaelco.cpp
index 6fe6b0de784..16d647ba444 100644
--- a/src/devices/sound/gaelco.cpp
+++ b/src/devices/sound/gaelco.cpp
@@ -60,8 +60,7 @@ gaelco_gae1_device::gaelco_gae1_device(const machine_config &mconfig, const char
: device_t(mconfig, GAELCO_GAE1, "Gaelco GAE1", tag, owner, clock, "gaelco_gae1", __FILE__),
device_sound_interface(mconfig, *this),
m_stream(nullptr),
- m_snd_data(nullptr),
- m_data_tag(nullptr)
+ m_snd_data(*this)
{
}
@@ -69,8 +68,7 @@ gaelco_gae1_device::gaelco_gae1_device(const machine_config &mconfig, device_typ
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_sound_interface(mconfig, *this),
m_stream(nullptr),
- m_snd_data(nullptr),
- m_data_tag(nullptr)
+ m_snd_data(*this)
{
}
@@ -242,8 +240,6 @@ void gaelco_gae1_device::device_start()
{
m_stream = stream_alloc(0, 2, 8000);
- m_snd_data = owner()->memregion(m_data_tag)->base();
-
/* init volume table */
for (int vol = 0; vol < GAELCO_VOLUME_LEVELS; vol++){
for (int j = -128; j <= 127; j++){
diff --git a/src/devices/sound/gaelco.h b/src/devices/sound/gaelco.h
index 8c128ab4bdc..91b90158667 100644
--- a/src/devices/sound/gaelco.h
+++ b/src/devices/sound/gaelco.h
@@ -14,7 +14,7 @@
//**************************************************************************
#define MCFG_GAELCO_SND_DATA(_tag) \
- gaelco_gae1_device::set_snd_data_tag(*device, _tag);
+ gaelco_gae1_device::set_snd_data_tag(*device, "^" _tag);
#define MCFG_GAELCO_BANKS(_offs1, _offs2, _offs3, _offs4) \
gaelco_gae1_device::set_bank_offsets(*device, _offs1, _offs2, _offs3, _offs4);
@@ -44,7 +44,7 @@ public:
gaelco_gae1_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
~gaelco_gae1_device() { }
- static void set_snd_data_tag(device_t &device, const char *tag) { downcast<gaelco_gae1_device &>(device).m_data_tag = tag; }
+ static void set_snd_data_tag(device_t &device, const char *tag) { downcast<gaelco_gae1_device &>(device).m_snd_data.set_tag(tag); }
static void set_bank_offsets(device_t &device, int offs1, int offs2, int offs3, int offs4)
{
gaelco_gae1_device &dev = downcast<gaelco_gae1_device &>(device);
@@ -68,12 +68,10 @@ public:
private:
sound_stream *m_stream; /* our stream */
- UINT8 *m_snd_data; /* PCM data */
+ required_region_ptr<UINT8> m_snd_data; /* PCM data */
int m_banks[4]; /* start of each ROM bank */
gaelco_sound_channel m_channel[GAELCO_NUM_CHANNELS]; /* 7 stereo channels */
- const char *m_data_tag;
-
UINT16 m_sndregs[0x38];
// Table for converting from 8 to 16 bits with volume control
diff --git a/src/devices/sound/iremga20.cpp b/src/devices/sound/iremga20.cpp
index b913546337e..8f5daf20762 100644
--- a/src/devices/sound/iremga20.cpp
+++ b/src/devices/sound/iremga20.cpp
@@ -49,8 +49,7 @@ const device_type IREMGA20 = &device_creator<iremga20_device>;
iremga20_device::iremga20_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, IREMGA20, "Irem GA20", tag, owner, clock, "iremga20", __FILE__),
device_sound_interface(mconfig, *this),
- m_rom(nullptr),
- m_rom_size(0),
+ m_rom(*this, DEVICE_SELF),
m_stream(nullptr)
{
}
@@ -64,10 +63,6 @@ void iremga20_device::device_start()
{
int i;
- /* Initialize our chip structure */
- m_rom = m_region->base();
- m_rom_size = m_region->bytes();
-
iremga20_reset();
for ( i = 0; i < 0x40; i++ )
@@ -125,7 +120,7 @@ void iremga20_device::sound_stream_update(sound_stream &stream, stream_sample_t
}
i = samples;
- pSamples = m_rom;
+ pSamples = &m_rom[0];
outL = outputs[0];
outR = outputs[1];
diff --git a/src/devices/sound/iremga20.h b/src/devices/sound/iremga20.h
index 1b6d73674e2..daf1469df74 100644
--- a/src/devices/sound/iremga20.h
+++ b/src/devices/sound/iremga20.h
@@ -65,8 +65,7 @@ private:
void iremga20_reset();
private:
- UINT8 *m_rom;
- INT32 m_rom_size;
+ required_region_ptr<UINT8> m_rom;
sound_stream *m_stream;
UINT16 m_regs[0x40];
IremGA20_channel_def m_channel[4];
diff --git a/src/devices/sound/k005289.cpp b/src/devices/sound/k005289.cpp
index b49d97b1555..aa0fa52c110 100644
--- a/src/devices/sound/k005289.cpp
+++ b/src/devices/sound/k005289.cpp
@@ -56,7 +56,7 @@ const device_type K005289 = &device_creator<k005289_device>;
k005289_device::k005289_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, K005289, "K005289 SCC", tag, owner, clock, "k005289", __FILE__),
device_sound_interface(mconfig, *this),
- m_sound_prom(nullptr),
+ m_sound_prom(*this, DEVICE_SELF),
m_stream(nullptr),
m_rate(0),
m_mixer_table(nullptr),
@@ -82,8 +82,6 @@ void k005289_device::device_start()
/* build the mixer table */
make_mixer_table(2);
- m_sound_prom = m_region->base();
-
/* reset all the voices */
for (int i = 0; i < 2; i++)
{
@@ -119,7 +117,7 @@ void k005289_device::sound_stream_update(sound_stream &stream, stream_sample_t *
f=m_frequency[0];
if (v && f)
{
- const unsigned char *w = m_sound_prom + m_waveform[0];
+ const unsigned char *w = &m_sound_prom[m_waveform[0]];
int c = m_counter[0];
mix = m_mixer_buffer.get();
@@ -142,7 +140,7 @@ void k005289_device::sound_stream_update(sound_stream &stream, stream_sample_t *
f=m_frequency[1];
if (v && f)
{
- const unsigned char *w = m_sound_prom + m_waveform[1];
+ const unsigned char *w = &m_sound_prom[m_waveform[1]];
int c = m_counter[1];
mix = m_mixer_buffer.get();
diff --git a/src/devices/sound/k005289.h b/src/devices/sound/k005289.h
index 24f84638263..ad085ba9482 100644
--- a/src/devices/sound/k005289.h
+++ b/src/devices/sound/k005289.h
@@ -43,7 +43,7 @@ public:
private:
void make_mixer_table(int voices);
- const unsigned char *m_sound_prom;
+ required_region_ptr<UINT8> m_sound_prom;
sound_stream *m_stream;
int m_rate;
diff --git a/src/devices/sound/k007232.cpp b/src/devices/sound/k007232.cpp
index cc25519e4b9..1272f7b579b 100644
--- a/src/devices/sound/k007232.cpp
+++ b/src/devices/sound/k007232.cpp
@@ -162,7 +162,7 @@ k007232_device::k007232_device(const machine_config &mconfig, const char *tag, d
void k007232_device::device_start()
{
/* Set up the chips */
- m_pcmlimit = region()->bytes();
+ m_pcmlimit = m_rom.bytes();
m_port_write_handler.resolve();
diff --git a/src/devices/sound/k053260.cpp b/src/devices/sound/k053260.cpp
index f3ebc4b2445..01d70d0f676 100644
--- a/src/devices/sound/k053260.cpp
+++ b/src/devices/sound/k053260.cpp
@@ -76,10 +76,8 @@ const device_type K053260 = &device_creator<k053260_device>;
k053260_device::k053260_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, K053260, "K053260 KDSC", tag, owner, clock, "k053260", __FILE__),
device_sound_interface(mconfig, *this),
- m_rgnoverride(nullptr),
m_stream(nullptr),
- m_rom(nullptr),
- m_rom_size(0),
+ m_rom(*this, DEVICE_SELF),
m_keyon(0),
m_mode(0)
{
@@ -93,10 +91,6 @@ k053260_device::k053260_device(const machine_config &mconfig, const char *tag, d
void k053260_device::device_start()
{
- memory_region *ROM = (m_rgnoverride) ? owner()->memregion(m_rgnoverride) : region();
- m_rom = ROM->base();
- m_rom_size = ROM->bytes();
-
m_stream = stream_alloc( 0, 2, clock() / CLOCKS_PER_SAMPLE );
/* register with the save state system */
@@ -381,10 +375,10 @@ void k053260_device::KDSC_Voice::update_pan_volume()
void k053260_device::KDSC_Voice::key_on()
{
- if (m_start >= m_device->m_rom_size)
+ if (m_start >= m_device->m_rom.bytes())
m_device->logerror("K053260: Attempting to start playing past the end of the ROM ( start = %06x, length = %06x )\n", m_start, m_length);
- else if (m_start + m_length >= m_device->m_rom_size)
+ else if (m_start + m_length >= m_device->m_rom.bytes())
m_device->logerror("K053260: Attempting to play past the end of the ROM ( start = %06x, length = %06x )\n",
m_start, m_length);
@@ -462,10 +456,10 @@ UINT8 k053260_device::KDSC_Voice::read_rom()
m_position = (m_position + 1) & 0xffff;
- if (offs >= m_device->m_rom_size)
+ if (offs >= m_device->m_rom.bytes())
{
m_device->logerror("%s: K053260: Attempting to read past the end of the ROM (offs = %06x, size = %06x)\n",
- m_device->machine().describe_context(), offs, m_device->m_rom_size);
+ m_device->machine().describe_context(), offs, m_device->m_rom.bytes());
return 0;
}
diff --git a/src/devices/sound/k053260.h b/src/devices/sound/k053260.h
index ace87855740..e80a2da87d7 100644
--- a/src/devices/sound/k053260.h
+++ b/src/devices/sound/k053260.h
@@ -22,7 +22,7 @@
MCFG_DEVICE_REPLACE(_tag, K053260, _clock)
#define MCFG_K053260_REGION(_tag) \
- k053260_device::set_region_tag(*device, _tag);
+ k053260_device::set_region_tag(*device, "^" _tag);
//**************************************************************************
@@ -38,7 +38,7 @@ public:
k053260_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~k053260_device() { }
- static void set_region_tag(device_t &device, const char *tag) { downcast<k053260_device &>(device).m_rgnoverride = tag; }
+ static void set_region_tag(device_t &device, const char *tag) { downcast<k053260_device &>(device).m_rom.set_tag(tag); }
DECLARE_READ8_MEMBER( main_read );
DECLARE_WRITE8_MEMBER( main_write );
@@ -55,11 +55,8 @@ protected:
private:
// configuration
- const char * m_rgnoverride;
-
sound_stream * m_stream;
- UINT8 * m_rom;
- UINT32 m_rom_size;
+ required_region_ptr<UINT8> m_rom;
// live state
UINT8 m_portdata[4];
diff --git a/src/devices/sound/k054539.cpp b/src/devices/sound/k054539.cpp
index 5270f5b80d6..41a2161569b 100644
--- a/src/devices/sound/k054539.cpp
+++ b/src/devices/sound/k054539.cpp
@@ -19,10 +19,19 @@ const device_type K054539 = &device_creator<k054539_device>;
k054539_device::k054539_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, K054539, "K054539 ADPCM", tag, owner, clock, "k054539", __FILE__),
- device_sound_interface(mconfig, *this), flags(0), ram(nullptr), reverb_pos(0), cur_ptr(0), cur_limit(0),
- cur_zone(nullptr), rom(nullptr), rom_size(0), rom_mask(0), stream(nullptr), m_timer(nullptr), m_timer_state(0),
- m_timer_handler(*this),
- m_rgnoverride(nullptr)
+ device_sound_interface(mconfig, *this),
+ flags(0),
+ ram(nullptr),
+ reverb_pos(0),
+ cur_ptr(0),
+ cur_limit(0),
+ cur_zone(nullptr),
+ m_rom(*this, DEVICE_SELF),
+ rom_mask(0),
+ stream(nullptr),
+ m_timer(nullptr),
+ m_timer_state(0),
+ m_timer_handler(*this)
{
}
@@ -190,10 +199,10 @@ void k054539_device::sound_stream_update(sound_stream &stream, stream_sample_t *
cur_pos += pdelta;
cur_pval = cur_val;
- cur_val = (INT16)(rom[cur_pos] << 8);
+ cur_val = (INT16)(m_rom[cur_pos] << 8);
if(cur_val == (INT16)0x8000 && (base2[1] & 1)) {
cur_pos = (base1[0x08] | (base1[0x09] << 8) | (base1[0x0a] << 16)) & rom_mask;
- cur_val = (INT16)(rom[cur_pos] << 8);
+ cur_val = (INT16)(m_rom[cur_pos] << 8);
}
if(cur_val == (INT16)0x8000) {
keyoff(ch);
@@ -213,10 +222,10 @@ void k054539_device::sound_stream_update(sound_stream &stream, stream_sample_t *
cur_pos += pdelta;
cur_pval = cur_val;
- cur_val = (INT16)(rom[cur_pos] | rom[cur_pos+1]<<8);
+ cur_val = (INT16)(m_rom[cur_pos] | m_rom[cur_pos+1]<<8);
if(cur_val == (INT16)0x8000 && (base2[1] & 1)) {
cur_pos = (base1[0x08] | (base1[0x09] << 8) | (base1[0x0a] << 16)) & rom_mask;
- cur_val = (INT16)(rom[cur_pos] | rom[cur_pos+1]<<8);
+ cur_val = (INT16)(m_rom[cur_pos] | m_rom[cur_pos+1]<<8);
}
if(cur_val == (INT16)0x8000) {
keyoff(ch);
@@ -241,10 +250,10 @@ void k054539_device::sound_stream_update(sound_stream &stream, stream_sample_t *
cur_pos += pdelta;
cur_pval = cur_val;
- cur_val = rom[cur_pos>>1];
+ cur_val = m_rom[cur_pos>>1];
if(cur_val == 0x88 && (base2[1] & 1)) {
cur_pos = ((base1[0x08] | (base1[0x09] << 8) | (base1[0x0a] << 16)) & rom_mask) << 1;
- cur_val = rom[cur_pos>>1];
+ cur_val = m_rom[cur_pos>>1];
}
if(cur_val == 0x88) {
keyoff(ch);
@@ -311,12 +320,9 @@ void k054539_device::init_chip()
cur_ptr = 0;
memset(ram.get(), 0, 0x4000);
- memory_region *reg = (m_rgnoverride != nullptr) ? owner()->memregion(m_rgnoverride) : region();
- rom = reg->base();
- rom_size = reg->bytes();
rom_mask = 0xffffffffU;
for(int i=0; i<32; i++)
- if((1U<<i) >= rom_size) {
+ if((1U<<i) >= m_rom.bytes()) {
rom_mask = (1U<<i) - 1;
break;
}
@@ -429,7 +435,7 @@ WRITE8_MEMBER(k054539_device::write)
case 0x22e:
cur_zone =
data == 0x80 ? ram.get() :
- rom + 0x20000*data;
+ &m_rom[0x20000*data];
cur_limit = data == 0x80 ? 0x4000 : 0x20000;
cur_ptr = 0;
break;
@@ -466,7 +472,7 @@ WRITE8_MEMBER(k054539_device::write)
void k054539_device::device_post_load()
{
int data = regs[0x22e];
- cur_zone = data == 0x80 ? ram.get() : rom + 0x20000*data;
+ cur_zone = data == 0x80 ? ram.get() : &m_rom[0x20000*data];
cur_limit = data == 0x80 ? 0x4000 : 0x20000;
}
diff --git a/src/devices/sound/k054539.h b/src/devices/sound/k054539.h
index fd196d306b8..a035f941f2b 100644
--- a/src/devices/sound/k054539.h
+++ b/src/devices/sound/k054539.h
@@ -18,7 +18,7 @@ typedef device_delegate<void (double left, double right)> k054539_cb_delegate;
k054539_device::set_analog_callback(*device, k054539_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
#define MCFG_K054539_REGION_OVERRRIDE(_region) \
- k054539_device::set_override(*device, _region);
+ k054539_device::set_override(*device, "^" _region);
#define MCFG_K054539_TIMER_HANDLER(_devcb) \
devcb = &k054539_device::set_timer_handler(*device, DEVCB_##_devcb);
@@ -46,7 +46,7 @@ public:
// static configuration helpers
static void set_analog_callback(device_t &device, k054539_cb_delegate callback) { downcast<k054539_device &>(device).m_apan_cb = callback; }
- static void set_override(device_t &device, const char *rgnoverride) { downcast<k054539_device &>(device).m_rgnoverride = rgnoverride; }
+ static void set_override(device_t &device, const char *rgnoverride) { downcast<k054539_device &>(device).m_rom.set_tag(rgnoverride); }
template<class _Object> static devcb_base &set_timer_handler(device_t &device, _Object object) { return downcast<k054539_device &>(device).m_timer_handler.set_callback(object); }
@@ -100,8 +100,7 @@ private:
INT32 cur_ptr;
int cur_limit;
unsigned char *cur_zone;
- unsigned char *rom;
- UINT32 rom_size;
+ required_region_ptr<UINT8> m_rom;
UINT32 rom_mask;
channel channels[8];
@@ -110,7 +109,6 @@ private:
emu_timer *m_timer;
UINT32 m_timer_state;
devcb_write_line m_timer_handler;
- const char *m_rgnoverride;
k054539_cb_delegate m_apan_cb;
bool regupdate();
diff --git a/src/devices/sound/l7a1045_l6028_dsp_a.cpp b/src/devices/sound/l7a1045_l6028_dsp_a.cpp
index ca30c79e5fc..526cbda9d9e 100644
--- a/src/devices/sound/l7a1045_l6028_dsp_a.cpp
+++ b/src/devices/sound/l7a1045_l6028_dsp_a.cpp
@@ -105,8 +105,7 @@ l7a1045_sound_device::l7a1045_sound_device(const machine_config &mconfig, const
device_sound_interface(mconfig, *this),
m_stream(nullptr),
m_key(0),
- m_rom(nullptr),
- m_rom_size(0)
+ m_rom(*this, DEVICE_SELF)
{
}
@@ -119,9 +118,6 @@ void l7a1045_sound_device::device_start()
{
/* Allocate the stream */
m_stream = stream_alloc(0, 2, 66150); //clock() / 384);
-
- m_rom = m_region->base();
- m_rom_size = m_region->bytes();
}
@@ -171,7 +167,7 @@ void l7a1045_sound_device::sound_stream_update(sound_stream &stream, stream_samp
}
- data = m_rom[(start + pos) & (m_rom_size-1)];
+ data = m_rom[(start + pos) & m_rom.mask()];
sample = ((INT8)(data & 0xfc)) << (3 - (data & 3));
frac += step;
@@ -252,7 +248,7 @@ WRITE16_MEMBER(l7a1045_sound_device::sound_data_w)
vptr->start |= (m_audiodat[m_audioregister][m_audiochannel].dat[1] & 0xffff) << (4);
vptr->start |= (m_audiodat[m_audioregister][m_audiochannel].dat[0] & 0xf000) >> (12);
- vptr->start &= m_rom_size - 1;
+ vptr->start &= m_rom.mask();
break;
case 0x01:
@@ -267,7 +263,7 @@ WRITE16_MEMBER(l7a1045_sound_device::sound_data_w)
vptr->end += vptr->start;
vptr->mode = false;
// hopefully it'll never happen? Maybe assert here?
- vptr->end &= m_rom_size - 1;
+ vptr->end &= m_rom.mask();
}
else // absolute
@@ -277,7 +273,7 @@ WRITE16_MEMBER(l7a1045_sound_device::sound_data_w)
vptr->end |= (m_audiodat[m_audioregister][m_audiochannel].dat[0] & 0xf000) >> (12);
vptr->mode = true;
- vptr->end &= m_rom_size - 1;
+ vptr->end &= m_rom.mask();
}
break;
diff --git a/src/devices/sound/l7a1045_l6028_dsp_a.h b/src/devices/sound/l7a1045_l6028_dsp_a.h
index e97edefc814..49c5670263d 100644
--- a/src/devices/sound/l7a1045_l6028_dsp_a.h
+++ b/src/devices/sound/l7a1045_l6028_dsp_a.h
@@ -48,8 +48,7 @@ private:
sound_stream *m_stream;
l7a1045_voice m_voice[32];
UINT32 m_key;
- UINT8 *m_rom;
- INT32 m_rom_size;
+ required_region_ptr<UINT8> m_rom;
UINT8 m_audiochannel;
UINT8 m_audioregister;
diff --git a/src/devices/sound/nile.cpp b/src/devices/sound/nile.cpp
index 3a21b1c6415..ecb193d005a 100644
--- a/src/devices/sound/nile.cpp
+++ b/src/devices/sound/nile.cpp
@@ -56,7 +56,7 @@ nile_device::nile_device(const machine_config &mconfig, const char *tag, device_
: device_t(mconfig, NILE, "NiLe", tag, owner, clock, "nile", __FILE__),
device_sound_interface(mconfig, *this),
m_stream(nullptr),
- m_sound_ram(nullptr),
+ m_sound_ram(*this, DEVICE_SELF),
m_ctrl(0)
{
}
@@ -68,7 +68,6 @@ nile_device::nile_device(const machine_config &mconfig, const char *tag, device_
void nile_device::device_start()
{
- m_sound_ram = region()->base();
m_stream = stream_alloc(0, 2, 44100);
}
@@ -80,7 +79,7 @@ void nile_device::device_start()
void nile_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
- UINT8 *sound_ram = m_sound_ram;
+ UINT8 *sound_ram = &m_sound_ram[0];
int v, i, snum;
UINT16 *slot;
INT32 mix[48000*2];
diff --git a/src/devices/sound/nile.h b/src/devices/sound/nile.h
index 4265f439813..0a298d6b9b8 100644
--- a/src/devices/sound/nile.h
+++ b/src/devices/sound/nile.h
@@ -46,7 +46,7 @@ public:
private:
sound_stream *m_stream;
- UINT8 *m_sound_ram;
+ required_region_ptr<UINT8> m_sound_ram;
UINT16 m_sound_regs[0x80];
int m_vpos[NILE_VOICES];
int m_frac[NILE_VOICES];
diff --git a/src/devices/sound/okim6295.cpp b/src/devices/sound/okim6295.cpp
index 7e97d04e916..d7af7157792 100644
--- a/src/devices/sound/okim6295.cpp
+++ b/src/devices/sound/okim6295.cpp
@@ -91,6 +91,7 @@ okim6295_device::okim6295_device(const machine_config &mconfig, const char *tag,
device_sound_interface(mconfig, *this),
device_memory_interface(mconfig, *this),
m_space_config("samples", ENDIANNESS_LITTLE, 8, 18, 0, nullptr, *ADDRESS_MAP_NAME(okim6295)),
+ m_region(*this, DEVICE_SELF),
m_command(-1),
m_bank_installed(false),
m_bank_offs(0),
diff --git a/src/devices/sound/okim6295.h b/src/devices/sound/okim6295.h
index 36be5b3a084..4fb85839f5c 100644
--- a/src/devices/sound/okim6295.h
+++ b/src/devices/sound/okim6295.h
@@ -103,6 +103,7 @@ protected:
// configuration state
const address_space_config m_space_config;
+ optional_memory_region m_region;
// internal state
static const int OKIM6295_VOICES = 4;
diff --git a/src/devices/sound/tc8830f.cpp b/src/devices/sound/tc8830f.cpp
index 06759146d93..1db6ab5bad4 100644
--- a/src/devices/sound/tc8830f.cpp
+++ b/src/devices/sound/tc8830f.cpp
@@ -37,7 +37,8 @@ tc8830f_device::tc8830f_device(const machine_config &mconfig, const char *tag, d
m_output(0),
m_command(0),
m_cmd_rw(0),
- m_phrase(0), m_mem_base(nullptr), m_mem_mask(0)
+ m_phrase(0),
+ m_mem(*this, DEVICE_SELF)
{
}
@@ -47,9 +48,6 @@ void tc8830f_device::device_start()
// create the stream
m_stream = stream_alloc(0, 1, clock() / 0x10);
- m_mem_base = region()->base();
- m_mem_mask = region()->bytes() - 1;
-
// register for savestates
save_item(NAME(m_playing));
save_item(NAME(m_address));
@@ -90,11 +88,11 @@ void tc8830f_device::sound_stream_update(sound_stream &stream, stream_sample_t *
if (m_playing)
{
// get bit
- int bit = m_mem_base[m_address] >> m_bitcount & 1;
+ int bit = m_mem[m_address] >> m_bitcount & 1;
m_bitcount = (m_bitcount + 1) & 7;
if (m_bitcount == 0)
{
- m_address = (m_address + 1) & m_mem_mask;
+ m_address = (m_address + 1) & m_mem.mask();
if (m_address == m_stop_address)
m_playing = false;
}
@@ -199,7 +197,7 @@ void tc8830f_device::write_p(UINT8 data)
m_address = (m_address & ~(0xf << (m_cmd_rw*4))) | (data << (m_cmd_rw*4));
if (m_cmd_rw == 5)
{
- m_address &= m_mem_mask;
+ m_address &= m_mem.mask();
m_bitcount = 0;
m_cmd_rw = -1;
}
@@ -210,7 +208,7 @@ void tc8830f_device::write_p(UINT8 data)
m_stop_address = (m_stop_address & ~(0xf << (m_cmd_rw*4))) | (data << (m_cmd_rw*4));
if (m_cmd_rw == 5)
{
- m_stop_address &= m_mem_mask;
+ m_stop_address &= m_mem.mask();
m_cmd_rw = -1;
}
break;
@@ -234,9 +232,9 @@ void tc8830f_device::write_p(UINT8 data)
// update addresses and start
UINT8 offs = m_phrase * 4;
- m_address = (m_mem_base[offs] | m_mem_base[offs|1]<<8 | m_mem_base[offs|2]<<16) & m_mem_mask;
+ m_address = (m_mem[offs] | m_mem[offs|1]<<8 | m_mem[offs|2]<<16) & m_mem.mask();
offs += 4;
- m_stop_address = (m_mem_base[offs] | m_mem_base[offs|1]<<8 | m_mem_base[offs|2]<<16) & m_mem_mask;
+ m_stop_address = (m_mem[offs] | m_mem[offs|1]<<8 | m_mem[offs|2]<<16) & m_mem.mask();
m_bitcount = 0;
m_prevbits = 0;
diff --git a/src/devices/sound/tc8830f.h b/src/devices/sound/tc8830f.h
index 655e83167a6..7b7059152ca 100644
--- a/src/devices/sound/tc8830f.h
+++ b/src/devices/sound/tc8830f.h
@@ -60,8 +60,7 @@ private:
int m_cmd_rw;
UINT8 m_phrase;
- UINT8 *m_mem_base;
- UINT32 m_mem_mask;
+ required_region_ptr<UINT8> m_mem;
};
diff --git a/src/devices/sound/tms5110.cpp b/src/devices/sound/tms5110.cpp
index aa98b69697a..6e7de3e445c 100644
--- a/src/devices/sound/tms5110.cpp
+++ b/src/devices/sound/tms5110.cpp
@@ -1184,7 +1184,7 @@ void tms5110_device::device_reset()
m_RNG = 0x1FFF;
memset(m_u, 0, sizeof(m_u));
memset(m_x, 0, sizeof(m_x));
- if (m_table != nullptr)
+ if (m_table.found())
{
/* legacy interface */
m_schedule_dummy_read = TRUE;
@@ -1454,11 +1454,6 @@ void tmsprom_device::device_start()
m_pdc_cb.resolve_safe();
m_ctl_cb.resolve_safe();
- m_rom = region()->base();
- assert_always(m_rom != nullptr, "Error creating TMSPROM chip: No rom region found");
- m_prom = owner()->memregion(m_prom_region)->base();
- assert_always(m_prom != nullptr, "Error creating TMSPROM chip: No prom region found");
-
m_romclk_timer = timer_alloc(0);
m_romclk_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
@@ -1614,7 +1609,8 @@ const device_type TMSPROM = &device_creator<tmsprom_device>;
tmsprom_device::tmsprom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, TMSPROM, "TMSPROM", tag, owner, clock, "tmsprom", __FILE__),
- m_prom_region(""),
+ m_rom(*this, DEVICE_SELF),
+ m_prom(*this, 0x20),
m_rom_size(0),
m_pdc_bit(0),
m_ctl1_bit(0),
diff --git a/src/devices/sound/tms5110.h b/src/devices/sound/tms5110.h
index 8eb5306eaf9..8cba11e64f3 100644
--- a/src/devices/sound/tms5110.h
+++ b/src/devices/sound/tms5110.h
@@ -298,7 +298,7 @@ class tmsprom_device : public device_t
public:
tmsprom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- static void set_region(device_t &device, const char *region) { downcast<tmsprom_device &>(device).m_prom_region = region; }
+ static void set_region(device_t &device, const char *region) { downcast<tmsprom_device &>(device).m_prom.set_tag(region); }
static void set_rom_size(device_t &device, UINT32 rom_size) { downcast<tmsprom_device &>(device).m_rom_size = rom_size; }
static void set_pdc_bit(device_t &device, UINT8 pdc_bit) { downcast<tmsprom_device &>(device).m_pdc_bit = pdc_bit; }
static void set_ctl1_bit(device_t &device, UINT8 ctl1_bit) { downcast<tmsprom_device &>(device).m_ctl1_bit = ctl1_bit; }
@@ -339,7 +339,8 @@ private:
int m_prom_cnt;
- const char *m_prom_region; /* prom memory region - sound region is automatically assigned */
+ required_region_ptr<UINT8> m_rom;
+ required_region_ptr<UINT8> m_prom;
UINT32 m_rom_size; /* individual rom_size */
UINT8 m_pdc_bit; /* bit # of pdc line */
/* virtual bit 8: constant 0, virtual bit 9:constant 1 */
@@ -353,14 +354,12 @@ private:
devcb_write8 m_ctl_cb; /* tms ctl func */
emu_timer *m_romclk_timer;
- const UINT8 *m_rom;
- const UINT8 *m_prom;
};
extern const device_type TMSPROM;
#define MCFG_TMSPROM_REGION(_region) \
- tmsprom_device::set_region(*device, _region);
+ tmsprom_device::set_region(*device, "^" _region);
#define MCFG_TMSPROM_ROM_SIZE(_size) \
tmsprom_device::set_rom_size(*device, _size);
diff --git a/src/devices/sound/vlm5030.cpp b/src/devices/sound/vlm5030.cpp
index 836a0de7eac..3bd8928e3e5 100644
--- a/src/devices/sound/vlm5030.cpp
+++ b/src/devices/sound/vlm5030.cpp
@@ -164,6 +164,7 @@ vlm5030_device::vlm5030_device(const machine_config &mconfig, const char *tag, d
device_sound_interface(mconfig, *this),
m_channel(nullptr),
m_coeff(nullptr),
+ m_region(*this, DEVICE_SELF),
m_rom(nullptr),
m_address_mask(0),
m_address(0),
@@ -215,8 +216,8 @@ void vlm5030_device::device_start()
device_reset();
m_phase = PH_IDLE;
- m_rom = region()->base();
- m_address_mask = (region()->bytes() - 1) & 0xffff;
+ m_rom = m_region->base();
+ m_address_mask = (m_region->bytes() - 1) & 0xffff;
m_channel = machine().sound().stream_alloc(*this, 0, 1, clock() / 440);
@@ -388,6 +389,7 @@ void vlm5030_device::restore_state()
}
/* set speech rom address */
+// TO DO: rewrite using device_memory_interface to get rid of this ridiculous hack
void vlm5030_device::set_rom(void *speech_rom)
{
m_rom = (UINT8 *)speech_rom;
diff --git a/src/devices/sound/vlm5030.h b/src/devices/sound/vlm5030.h
index cf2c620f13f..00264e4710c 100644
--- a/src/devices/sound/vlm5030.h
+++ b/src/devices/sound/vlm5030.h
@@ -47,6 +47,7 @@ private:
/* need to save state */
+ required_memory_region m_region;
UINT8 *m_rom;
int m_address_mask;
UINT16 m_address;
diff --git a/src/devices/sound/ymf278b.cpp b/src/devices/sound/ymf278b.cpp
index af186ff0100..67db79498e7 100644
--- a/src/devices/sound/ymf278b.cpp
+++ b/src/devices/sound/ymf278b.cpp
@@ -646,7 +646,7 @@ void ymf278b_device::C_w(UINT8 reg, UINT8 data)
case 0x06:
// memory data
- m_addrspace[0]->write_byte(m_memadr, data);
+ space(AS_0).write_byte(m_memadr, data);
m_memadr = (m_memadr + 1) & 0x3fffff;
break;
diff --git a/src/devices/sound/ymz280b.cpp b/src/devices/sound/ymz280b.cpp
index fad4f1b7558..9809c110c7a 100644
--- a/src/devices/sound/ymz280b.cpp
+++ b/src/devices/sound/ymz280b.cpp
@@ -583,11 +583,12 @@ void ymz280b_device::device_start()
m_master_clock = (double)clock() / 384.0;
m_irq_handler.resolve();
- if (region() != NULL)
+ memory_region *region = memregion(DEVICE_SELF);
+ if (region != nullptr)
{
/* Some systems (e.g. Konami Firebeat) have a YMZ280B on-board that isn't hooked up to ROM, so be safe. */
- m_mem_base = region()->base();
- m_mem_size = region()->bytes();
+ m_mem_base = region->base();
+ m_mem_size = region->bytes();
}
for (int i = 0; i < 8; i++)
diff --git a/src/devices/sound/ymz770.cpp b/src/devices/sound/ymz770.cpp
index 6456c346ffd..f6a9c17c0b0 100644
--- a/src/devices/sound/ymz770.cpp
+++ b/src/devices/sound/ymz770.cpp
@@ -38,7 +38,8 @@ ymz770_device::ymz770_device(const machine_config &mconfig, const char *tag, dev
m_doen(0),
m_vlma(0),
m_bsl(0),
- m_cpl(0), m_rom_base(nullptr), m_rom_limit(0)
+ m_cpl(0),
+ m_rom(*this, DEVICE_SELF)
{
}
@@ -51,14 +52,12 @@ void ymz770_device::device_start()
{
// create the stream
m_stream = machine().sound().stream_alloc(*this, 0, 2, 16000);
- m_rom_base = region()->base();
- m_rom_limit = region()->bytes() * 8;
for (auto & elem : m_channels)
{
elem.is_playing = false;
elem.is_seq_playing = false;
- elem.decoder = new mpeg_audio(m_rom_base, mpeg_audio::AMM, false, 0);
+ elem.decoder = new mpeg_audio(&m_rom[0], mpeg_audio::AMM, false, 0);
}
// register for save states
@@ -147,8 +146,8 @@ void ymz770_device::sound_stream_update(sound_stream &stream, stream_sample_t **
{
// loop sequence
UINT8 sqn = elem.sequence;
- UINT32 pptr = m_rom_base[(4*sqn)+1+0x400]<<16 | m_rom_base[(4*sqn)+2+0x400]<<8 | m_rom_base[(4*sqn)+3+0x400];
- elem.seqdata = &m_rom_base[pptr];
+ UINT32 pptr = m_rom[(4*sqn)+1+0x400]<<16 | m_rom[(4*sqn)+2+0x400]<<8 | m_rom[(4*sqn)+3+0x400];
+ elem.seqdata = &m_rom[pptr];
}
else
{
@@ -190,8 +189,8 @@ retry:
{
// loop sample
UINT8 phrase = elem.phrase;
- elem.atbl = m_rom_base[(4*phrase)+0] >> 4 & 7;
- elem.pptr = 8*(m_rom_base[(4*phrase)+1]<<16 | m_rom_base[(4*phrase)+2]<<8 | m_rom_base[(4*phrase)+3]);
+ elem.atbl = m_rom[(4*phrase)+0] >> 4 & 7;
+ elem.pptr = 8*(m_rom[(4*phrase)+1]<<16 | m_rom[(4*phrase)+2]<<8 | m_rom[(4*phrase)+3]);
}
else
{
@@ -205,7 +204,7 @@ retry:
{
// next block
int sample_rate, channel_count;
- if (!elem.decoder->decode_buffer(elem.pptr, m_rom_limit, elem.output_data, elem.output_remaining, sample_rate, channel_count) || elem.output_remaining == 0)
+ if (!elem.decoder->decode_buffer(elem.pptr, m_rom.bytes()*8, elem.output_data, elem.output_remaining, sample_rate, channel_count) || elem.output_remaining == 0)
{
elem.is_playing = !elem.last_block; // detect infinite retry loop
elem.last_block = true;
@@ -295,8 +294,8 @@ void ymz770_device::internal_reg_write(UINT8 reg, UINT8 data)
if (data & 6)
{
UINT8 phrase = m_channels[ch].phrase;
- m_channels[ch].atbl = m_rom_base[(4*phrase)+0] >> 4 & 7;
- m_channels[ch].pptr = 8*(m_rom_base[(4*phrase)+1]<<16 | m_rom_base[(4*phrase)+2]<<8 | m_rom_base[(4*phrase)+3]);
+ m_channels[ch].atbl = m_rom[(4*phrase)+0] >> 4 & 7;
+ m_channels[ch].pptr = 8*(m_rom[(4*phrase)+1]<<16 | m_rom[(4*phrase)+2]<<8 | m_rom[(4*phrase)+3]);
m_channels[ch].last_block = false;
m_channels[ch].is_playing = true;
@@ -325,8 +324,8 @@ void ymz770_device::internal_reg_write(UINT8 reg, UINT8 data)
if (data & 6)
{
UINT8 sqn = m_channels[ch].sequence;
- UINT32 pptr = m_rom_base[(4*sqn)+1+0x400]<<16 | m_rom_base[(4*sqn)+2+0x400]<<8 | m_rom_base[(4*sqn)+3+0x400];
- m_channels[ch].seqdata = &m_rom_base[pptr];
+ UINT32 pptr = m_rom[(4*sqn)+1+0x400]<<16 | m_rom[(4*sqn)+2+0x400]<<8 | m_rom[(4*sqn)+3+0x400];
+ m_channels[ch].seqdata = &m_rom[pptr];
m_channels[ch].seqdelay = 0;
m_channels[ch].is_seq_playing = true;
}
diff --git a/src/devices/sound/ymz770.h b/src/devices/sound/ymz770.h
index ddcd72e7bfa..a52dbba8e3a 100644
--- a/src/devices/sound/ymz770.h
+++ b/src/devices/sound/ymz770.h
@@ -86,8 +86,7 @@ protected:
UINT8 m_vlma; // overall AAM volume
UINT8 m_bsl; // boost level
UINT8 m_cpl; // clip limiter
- UINT8 *m_rom_base;
- int m_rom_limit;
+ required_region_ptr<UINT8> m_rom;
ymz_channel m_channels[8];
};
diff --git a/src/devices/video/bufsprite.h b/src/devices/video/bufsprite.h
index 3a75f5a14f6..7e8606f454b 100644
--- a/src/devices/video/bufsprite.h
+++ b/src/devices/video/bufsprite.h
@@ -55,7 +55,7 @@ public:
// construction
buffered_spriteram_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, type, "Buffered Sprite RAM", tag, owner, clock, "buffered_spriteram", __FILE__),
- m_spriteram(*owner, tag) { }
+ m_spriteram(*this, DEVICE_SELF) { }
// getters
_Type *live() const { return m_spriteram; }
diff --git a/src/devices/video/ef9345.cpp b/src/devices/video/ef9345.cpp
index a46e32a34b7..057550d794b 100644
--- a/src/devices/video/ef9345.cpp
+++ b/src/devices/video/ef9345.cpp
@@ -101,6 +101,7 @@ ef9345_device::ef9345_device(const machine_config &mconfig, const char *tag, dev
device_memory_interface(mconfig, *this),
device_video_interface(mconfig, *this),
m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, nullptr, *ADDRESS_MAP_NAME(ef9345)),
+ m_charset(*this, DEVICE_SELF),
m_palette(*this)
{
}
@@ -125,7 +126,6 @@ void ef9345_device::device_start()
m_blink_timer = timer_alloc(BLINKING_TIMER);
m_videoram = &space(0);
- m_charset = region();
m_screen_out.allocate(496, m_screen->height());
@@ -266,7 +266,7 @@ void ef9345_device::init_accented_chars(void)
UINT16 i, j;
for(j = 0; j < 0x10; j++)
for(i = 0; i < 0x200; i++)
- m_acc_char[(j << 9) + i] = m_charset->u8(0x0600 + i);
+ m_acc_char[(j << 9) + i] = m_charset[0x0600 + i];
for(j = 0; j < 0x200; j += 0x40)
for(i = 0; i < 4; i++)
@@ -299,7 +299,7 @@ void ef9345_device::init_accented_chars(void)
UINT8 ef9345_device::read_char(UINT8 index, UINT16 addr)
{
if (index < 0x04)
- return m_charset->u8(0x0800*index + addr);
+ return m_charset[0x0800*index + addr];
else if (index < 0x08)
return m_acc_char[0x0800*(index&3) + addr];
else if (index < 0x0c)
@@ -860,7 +860,7 @@ void ef9345_device::ef9345_exec(UINT8 cmd)
set_busy_flag(3.5);
switch(cmd&7)
{
- case 0: m_registers[1] = m_charset->u8(indexrom(7) & 0x1fff); break;
+ case 0: m_registers[1] = m_charset[indexrom(7) & 0x1fff]; break;
case 1: m_registers[1] = m_tgs; break;
case 2: m_registers[1] = m_mat; break;
case 3: m_registers[1] = m_pat; break;
diff --git a/src/devices/video/ef9345.h b/src/devices/video/ef9345.h
index 9179e01ab03..c6790b00a39 100644
--- a/src/devices/video/ef9345.h
+++ b/src/devices/video/ef9345.h
@@ -84,7 +84,7 @@ private:
static const device_timer_id BUSY_TIMER = 0;
static const device_timer_id BLINKING_TIMER = 1;
- memory_region *m_charset;
+ required_region_ptr<UINT8> m_charset;
address_space *m_videoram;
UINT8 m_bf; //busy flag
diff --git a/src/devices/video/ef9364.cpp b/src/devices/video/ef9364.cpp
index 5b683b15e09..e7266e88b49 100644
--- a/src/devices/video/ef9364.cpp
+++ b/src/devices/video/ef9364.cpp
@@ -61,6 +61,7 @@ ef9364_device::ef9364_device(const machine_config &mconfig, const char *tag, dev
device_memory_interface(mconfig, *this),
device_video_interface(mconfig, *this),
m_space_config("textram", ENDIANNESS_LITTLE, 8, 12, 0, nullptr, *ADDRESS_MAP_NAME(ef9364)),
+ m_charset(*this, DEVICE_SELF),
m_palette(*this)
{
clock_freq = clock;
@@ -112,7 +113,6 @@ void ef9364_device::set_color_entry( int index, UINT8 r, UINT8 g, UINT8 b )
void ef9364_device::device_start()
{
m_textram = &space(0);
- m_charset = region();
bitplane_xres = EF9364_NB_OF_COLUMNS*8;
bitplane_yres = EF9364_NB_OF_ROWS*(8+4);
@@ -206,7 +206,7 @@ UINT32 ef9364_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
{
c = m_textram->read_byte( ( r * EF9364_NB_OF_COLUMNS ) + ( x>>3 ) );
- if( m_charset->u8(((c&0x7F)<<3) + y ) & (0x80>>(x&7)) )
+ if( m_charset[((c&0x7F)<<3) + y] & (0x80>>(x&7)) )
m_screen_out.pix32((r*12)+y, x) = palette[1];
else
m_screen_out.pix32((r*12)+y, x) = palette[0];
diff --git a/src/devices/video/ef9364.h b/src/devices/video/ef9364.h
index 4c5f57bb211..9d18942429d 100644
--- a/src/devices/video/ef9364.h
+++ b/src/devices/video/ef9364.h
@@ -75,7 +75,7 @@ private:
// internal state
- memory_region *m_charset;
+ required_region_ptr<UINT8> m_charset;
address_space *m_textram;
UINT8 x_curs_pos;
diff --git a/src/devices/video/ef9365.cpp b/src/devices/video/ef9365.cpp
index 5f81d7f45b5..db278ce24bb 100644
--- a/src/devices/video/ef9365.cpp
+++ b/src/devices/video/ef9365.cpp
@@ -160,6 +160,7 @@ ef9365_device::ef9365_device(const machine_config &mconfig, const char *tag, dev
device_memory_interface(mconfig, *this),
device_video_interface(mconfig, *this),
m_space_config("videoram", ENDIANNESS_LITTLE, 8, 18, 0, nullptr, *ADDRESS_MAP_NAME(ef9365)),
+ m_charset(*this, DEVICE_SELF),
m_palette(*this),
m_irq_handler(*this)
{
@@ -283,7 +284,6 @@ void ef9365_device::device_start()
m_busy_timer = timer_alloc(BUSY_TIMER);
m_videoram = &space(0);
- m_charset = region();
m_current_color = 0x0F;
m_irq_vb = 0;
@@ -729,7 +729,7 @@ int ef9365_device::get_char_pix( unsigned char c, int x, int y )
char_base = c * 5;
char_pix = ( y * 5 ) + x;
- if ( m_charset->u8(char_base + (char_pix>>3) ) & ( 0x80 >> (char_pix&7)) )
+ if ( m_charset[char_base + (char_pix>>3)] & ( 0x80 >> (char_pix&7)) )
return 1;
else
return 0;
diff --git a/src/devices/video/ef9365.h b/src/devices/video/ef9365.h
index e29b3adca33..957a5047325 100644
--- a/src/devices/video/ef9365.h
+++ b/src/devices/video/ef9365.h
@@ -95,7 +95,7 @@ private:
// internal state
static const device_timer_id BUSY_TIMER = 0;
- memory_region *m_charset;
+ required_region_ptr<UINT8> m_charset;
address_space *m_videoram;
UINT8 m_irq_state;
diff --git a/src/devices/video/hd44352.cpp b/src/devices/video/hd44352.cpp
index 8b30b0afd9b..c13cf80f818 100644
--- a/src/devices/video/hd44352.cpp
+++ b/src/devices/video/hd44352.cpp
@@ -36,7 +36,8 @@ const device_type HD44352 = &device_creator<hd44352_device>;
hd44352_device::hd44352_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock):
device_t(mconfig, HD44352, "hd44352", tag, owner, clock, "hd44352", __FILE__),
- m_on_cb(*this)
+ m_on_cb(*this),
+ m_char_rom(*this, DEVICE_SELF)
{
}
@@ -216,7 +217,7 @@ UINT8 hd44352_device::get_char(UINT16 pos)
case 0xff:
return m_custom_char[3][pos%8];
default:
- return region()->u8(pos);
+ return m_char_rom[pos];
}
}
diff --git a/src/devices/video/hd44352.h b/src/devices/video/hd44352.h
index dda32fa7111..0974ed90a9d 100644
--- a/src/devices/video/hd44352.h
+++ b/src/devices/video/hd44352.h
@@ -73,6 +73,7 @@ private:
UINT8 m_cursor_lcd;
devcb_write_line m_on_cb; // ON line callback
+ required_region_ptr<UINT8> m_char_rom;
};
// device type definition
diff --git a/src/devices/video/hd44780.cpp b/src/devices/video/hd44780.cpp
index 00c75e3cd2a..0f8647ced55 100644
--- a/src/devices/video/hd44780.cpp
+++ b/src/devices/video/hd44780.cpp
@@ -47,14 +47,16 @@ ROM_END
hd44780_device::hd44780_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, HD44780, "HD44780 A00", tag, owner, clock, "hd44780_a00", __FILE__),
- m_pixel_update_func(nullptr)
+ m_pixel_update_func(nullptr),
+ m_cgrom(*this, DEVICE_SELF)
{
set_charset_type(CHARSET_HD44780_A00);
}
hd44780_device::hd44780_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- m_pixel_update_func(nullptr)
+ m_pixel_update_func(nullptr),
+ m_cgrom(*this, DEVICE_SELF)
{
}
@@ -86,10 +88,8 @@ const rom_entry *hd44780_device::device_rom_region() const
void hd44780_device::device_start()
{
- if (region())
- m_cgrom = region()->base();
- else
- m_cgrom = memregion("cgrom")->base();
+ if (!m_cgrom.found())
+ m_cgrom.set_target(memregion("cgrom")->base(), 0x1000);
m_busy_timer = timer_alloc(TIMER_BUSY);
m_blink_timer = timer_alloc(TIMER_BLINKING);
diff --git a/src/devices/video/hd44780.h b/src/devices/video/hd44780.h
index 637056d9505..b1210fbd47d 100644
--- a/src/devices/video/hd44780.h
+++ b/src/devices/video/hd44780.h
@@ -105,7 +105,7 @@ private:
bool m_busy_flag; // busy flag
UINT8 m_ddram[0x80]; // internal display data RAM
UINT8 m_cgram[0x40]; // internal chargen RAM
- UINT8 * m_cgrom; // internal chargen ROM
+ optional_region_ptr<UINT8> m_cgrom; // internal chargen ROM
int m_ac; // address counter
UINT8 m_dr; // data register
UINT8 m_ir; // instruction register
diff --git a/src/devices/video/msm6222b.cpp b/src/devices/video/msm6222b.cpp
index efa82d7c119..17ee6897400 100644
--- a/src/devices/video/msm6222b.cpp
+++ b/src/devices/video/msm6222b.cpp
@@ -22,18 +22,22 @@ ROM_START( msm6222b_01 )
ROM_END
msm6222b_device::msm6222b_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
- device_t(mconfig, type, name, tag, owner, clock, shortname, source), cursor_direction(false), cursor_blinking(false), two_line(false), shift_on_write(false), double_height(false), cursor_on(false), display_on(false), adc(0), shift(0), cgrom(nullptr)
+ device_t(mconfig, type, name, tag, owner, clock, shortname, source), cursor_direction(false), cursor_blinking(false), two_line(false), shift_on_write(false), double_height(false), cursor_on(false), display_on(false), adc(0), shift(0),
+ m_cgrom(*this)
{
}
msm6222b_device::msm6222b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- device_t(mconfig, MSM6222B, "msm6222b-xx", tag, owner, clock, "msm6222b", __FILE__), cursor_direction(false), cursor_blinking(false), two_line(false), shift_on_write(false), double_height(false), cursor_on(false), display_on(false), adc(0), shift(0), cgrom(nullptr)
+ device_t(mconfig, MSM6222B, "msm6222b-xx", tag, owner, clock, "msm6222b", __FILE__), cursor_direction(false), cursor_blinking(false), two_line(false), shift_on_write(false), double_height(false), cursor_on(false), display_on(false), adc(0), shift(0),
+ m_cgrom(*this, DEVICE_SELF)
{
}
msm6222b_01_device::msm6222b_01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
msm6222b_device(mconfig, MSM6222B_01, "msm6222b-01", tag, owner, clock, "msm6222b", __FILE__)
{
+ // load the fixed cgrom
+ m_cgrom.set_tag("cgrom");
}
const rom_entry *msm6222b_01_device::device_rom_region() const
@@ -43,13 +47,6 @@ const rom_entry *msm6222b_01_device::device_rom_region() const
void msm6222b_device::device_start()
{
- if(memregion("cgrom"))
- cgrom = memregion("cgrom")->base();
- else if(m_region)
- cgrom = m_region->base();
- else
- cgrom = nullptr;
-
memset(cgram, 0, sizeof(cgram));
memset(ddram, 0x20, sizeof(ddram));
@@ -218,8 +215,8 @@ const UINT8 *msm6222b_device::render()
UINT8 c = ddram[(i+shift) % 80];
if(c < 16)
memcpy(render_buf + 16*i, double_height ? cgram + 8*(c & 6) : cgram + 8*(c & 7), char_height);
- else if(cgrom)
- memcpy(render_buf + 16*i, cgrom + 16*c, char_height);
+ else if (m_cgrom.found())
+ memcpy(render_buf + 16*i, &m_cgrom[16*c], char_height);
}
if(cursor_on) {
diff --git a/src/devices/video/msm6222b.h b/src/devices/video/msm6222b.h
index d86bcd63629..3324dda3b06 100644
--- a/src/devices/video/msm6222b.h
+++ b/src/devices/video/msm6222b.h
@@ -41,7 +41,8 @@ private:
UINT8 render_buf[80*16];
bool cursor_direction, cursor_blinking, two_line, shift_on_write, double_height, cursor_on, display_on;
UINT8 adc, shift;
- const UINT8 *cgrom;
+protected:
+ optional_region_ptr<UINT8> m_cgrom;
void cursor_step(bool direction);
void shift_step(bool direction);
diff --git a/src/devices/video/tms9927.cpp b/src/devices/video/tms9927.cpp
index 9c45dab00ca..e571499a399 100644
--- a/src/devices/video/tms9927.cpp
+++ b/src/devices/video/tms9927.cpp
@@ -39,7 +39,7 @@ tms9927_device::tms9927_device(const machine_config &mconfig, const char *tag, d
device_video_interface(mconfig, *this),
m_write_vsyn(*this),
m_hpixels_per_column(0),
- m_selfload_region(nullptr),
+ m_selfload(*this),
m_reset(0)
{
memset(m_reg, 0x00, sizeof(m_reg));
@@ -50,7 +50,7 @@ tms9927_device::tms9927_device(const machine_config &mconfig, device_type type,
device_video_interface(mconfig, *this),
m_write_vsyn(*this),
m_hpixels_per_column(0),
- m_selfload_region(nullptr),
+ m_selfload(*this),
m_reset(0)
{
memset(m_reg, 0x00, sizeof(m_reg));
@@ -84,13 +84,6 @@ void tms9927_device::device_start()
/* copy the initial parameters */
m_clock = clock();
- /* get the self-load PROM */
- if (m_selfload_region != nullptr)
- {
- m_selfload = machine().root_device().memregion(m_selfload_region)->base();
- assert(m_selfload != nullptr);
- }
-
// resolve callbacks
m_write_vsyn.resolve_safe();
@@ -166,7 +159,7 @@ void tms9927_device::generic_access(address_space &space, offs_t offset)
{
case 0x07: /* Processor Self Load */
case 0x0f: /* Non-processor self-load */
- if (m_selfload != nullptr)
+ if (m_selfload.found())
{
for (int cur = 0; cur < 7; cur++)
write(space, cur, m_selfload[cur]);
diff --git a/src/devices/video/tms9927.h b/src/devices/video/tms9927.h
index 40181d16cbc..ba8e25f9e79 100644
--- a/src/devices/video/tms9927.h
+++ b/src/devices/video/tms9927.h
@@ -17,7 +17,7 @@
tms9927_device::set_char_width(*device, _pixels);
#define MCFG_TMS9927_REGION(_tag) \
- tms9927_device::set_region_tag(*device, _tag);
+ tms9927_device::set_region_tag(*device, "^" _tag);
class tms9927_device : public device_t,
@@ -31,7 +31,7 @@ public:
template<class _Object> static devcb_base &set_vsyn_wr_callback(device_t &device, _Object object) { return downcast<tms9927_device &>(device).m_write_vsyn.set_callback(object); }
static void set_char_width(device_t &device, int pixels) { downcast<tms9927_device &>(device).m_hpixels_per_column = pixels; }
- static void set_region_tag(device_t &device, const char *tag) { downcast<tms9927_device &>(device).m_selfload_region = tag; }
+ static void set_region_tag(device_t &device, const char *tag) { downcast<tms9927_device &>(device).m_selfload.set_tag(tag); }
DECLARE_WRITE8_MEMBER(write);
DECLARE_READ8_MEMBER(read);
@@ -59,10 +59,9 @@ private:
devcb_write_line m_write_vsyn;
int m_hpixels_per_column; /* number of pixels per video memory address */
- const char *m_selfload_region; /* name of the region with self-load data */
// internal state
- const UINT8 *m_selfload;
+ optional_region_ptr<UINT8> m_selfload;
/* live state */
UINT32 m_clock;