summaryrefslogtreecommitdiffstatshomepage
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
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.
-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
-rw-r--r--src/emu/addrmap.h11
-rw-r--r--src/emu/devfind.cpp55
-rw-r--r--src/emu/devfind.h37
-rw-r--r--src/emu/device.cpp23
-rw-r--r--src/emu/device.h13
-rw-r--r--src/emu/dimemory.h3
-rw-r--r--src/mame/audio/atarijsa.cpp25
-rw-r--r--src/mame/audio/atarijsa.h7
-rw-r--r--src/mame/audio/seibu.cpp28
-rw-r--r--src/mame/audio/seibu.h13
-rw-r--r--src/mame/audio/wpcsnd.cpp8
-rw-r--r--src/mame/audio/wpcsnd.h3
-rw-r--r--src/mame/drivers/artmagic.cpp2
-rw-r--r--src/mame/drivers/cabal.cpp10
-rw-r--r--src/mame/drivers/chihiro.cpp2
-rw-r--r--src/mame/drivers/deadang.cpp8
-rw-r--r--src/mame/drivers/harddriv.cpp5
-rw-r--r--src/mame/drivers/naomi.cpp12
-rw-r--r--src/mame/drivers/segas18.cpp2
-rw-r--r--src/mame/drivers/segasp.cpp2
-rw-r--r--src/mame/drivers/triforce.cpp2
-rw-r--r--src/mame/includes/artmagic.h2
-rw-r--r--src/mame/includes/harddriv.h5
-rw-r--r--src/mame/includes/nb1414m4.h2
-rw-r--r--src/mame/includes/segas18.h2
-rw-r--r--src/mame/machine/awboard.cpp26
-rw-r--r--src/mame/machine/awboard.h7
-rw-r--r--src/mame/machine/decocass_tape.cpp17
-rw-r--r--src/mame/machine/decocass_tape.h1
-rw-r--r--src/mame/machine/fd1089.cpp17
-rw-r--r--src/mame/machine/fd1089.h3
-rw-r--r--src/mame/machine/fd1094.cpp36
-rw-r--r--src/mame/machine/fd1094.h7
-rw-r--r--src/mame/machine/harddriv.cpp16
-rw-r--r--src/mame/machine/naomibd.cpp5
-rw-r--r--src/mame/machine/naomibd.h3
-rw-r--r--src/mame/machine/naomigd.h2
-rw-r--r--src/mame/machine/naomim1.cpp7
-rw-r--r--src/mame/machine/naomim1.h2
-rw-r--r--src/mame/machine/naomim2.cpp5
-rw-r--r--src/mame/machine/naomim2.h1
-rw-r--r--src/mame/machine/naomim4.cpp22
-rw-r--r--src/mame/machine/naomim4.h7
-rw-r--r--src/mame/machine/naomirom.cpp3
-rw-r--r--src/mame/machine/naomirom.h1
-rw-r--r--src/mame/machine/pc9801_118.cpp2
-rw-r--r--src/mame/machine/pc9801_26.cpp2
-rw-r--r--src/mame/machine/segaic16.cpp22
-rw-r--r--src/mame/machine/segaic16.h6
-rw-r--r--src/mame/machine/zs01.cpp3
-rw-r--r--src/mame/machine/zs01.h1
-rw-r--r--src/mame/video/atarirle.cpp13
-rw-r--r--src/mame/video/atarirle.h3
-rw-r--r--src/mame/video/k051316.cpp14
-rw-r--r--src/mame/video/k051316.h3
-rw-r--r--src/mame/video/k051960.cpp16
-rw-r--r--src/mame/video/k051960.h10
-rw-r--r--src/mame/video/k052109.cpp26
-rw-r--r--src/mame/video/k052109.h9
-rw-r--r--src/mame/video/k053244_k053245.cpp7
-rw-r--r--src/mame/video/k053244_k053245.h3
-rw-r--r--src/mame/video/k053250.cpp19
-rw-r--r--src/mame/video/k053250.h1
-rw-r--r--src/mame/video/k054156_k054157_k056832.cpp67
-rw-r--r--src/mame/video/k054156_k054157_k056832.h10
-rw-r--r--src/mame/video/sega16sp.cpp37
-rw-r--r--src/mame/video/sega16sp.h17
-rw-r--r--src/mame/video/tc0150rod.cpp5
-rw-r--r--src/mame/video/tc0150rod.h2
-rw-r--r--src/mame/video/vtvideo.cpp11
-rw-r--r--src/mame/video/vtvideo.h8
180 files changed, 774 insertions, 885 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;
diff --git a/src/emu/addrmap.h b/src/emu/addrmap.h
index 492ad21b03b..56e9fde3e8f 100644
--- a/src/emu/addrmap.h
+++ b/src/emu/addrmap.h
@@ -499,15 +499,4 @@ void _class :: _name(::address_map &map, device_t &device) \
#define AM_RAM_DEVWRITE(_tag, _class, _write) AM_READONLY AM_DEVWRITE(_tag, _class, _write)
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// use this to refer to the owning device when providing a device tag
-static const char DEVICE_SELF[] = "";
-
-// use this to refer to the owning device's owner when providing a device tag
-static const char DEVICE_SELF_OWNER[] = "^";
-
-
#endif /* __ADDRMAP_H__ */
diff --git a/src/emu/devfind.cpp b/src/emu/devfind.cpp
index d251e56ce0b..7669b331832 100644
--- a/src/emu/devfind.cpp
+++ b/src/emu/devfind.cpp
@@ -45,27 +45,76 @@ void *finder_base::find_memregion(UINT8 width, size_t &length, bool required) co
// look up the region and return NULL if not found
memory_region *region = m_base.memregion(m_tag);
if (region == nullptr)
+ {
+ length = 0;
return nullptr;
+ }
// check the width and warn if not correct
if (region->bytewidth() != width)
{
if (required)
osd_printf_warning("Region '%s' found but is width %d, not %d as requested\n", m_tag, region->bitwidth(), width*8);
+ length = 0;
+ return nullptr;
+ }
+
+ // check the length and warn if other than specified
+ size_t length_found = region->bytes() / width;
+ if (length != 0 && length != length_found)
+ {
+ if (required)
+ osd_printf_warning("Region '%s' found but has %d bytes, not %d as requested\n", m_tag, region->bytes(), (int)length*width);
+ length = 0;
return nullptr;
}
// return results
- length = region->bytes() / width;
+ length = length_found;
return region->base();
}
//-------------------------------------------------
+// validate_memregion - find memory region
+//-------------------------------------------------
+
+bool finder_base::validate_memregion(size_t bytes, bool required) const
+{
+ // make sure we can resolve the full path to the region
+ size_t bytes_found = 0;
+ std::string region_fulltag = m_base.subtag(m_tag);
+
+ // look for the region
+ device_iterator deviter(m_base.mconfig().root_device());
+ for (device_t *dev = deviter.first(); dev != nullptr && bytes_found == 0; dev = deviter.next())
+ for (const rom_entry *romp = rom_first_region(*dev); romp != nullptr; romp = rom_next_region(romp))
+ {
+ if (rom_region_name(*dev, romp) == region_fulltag)
+ {
+ bytes_found = ROMREGION_GETLENGTH(romp);
+ break;
+ }
+ }
+
+ if (bytes_found != 0)
+ {
+ // check the length and warn if other than specified
+ if (bytes != 0 && bytes != bytes_found)
+ {
+ osd_printf_warning("Region '%s' found but has %d bytes, not %d as requested\n", m_tag, (int)bytes_found, (int)bytes);
+ bytes_found = 0;
+ }
+ }
+ return report_missing(bytes_found != 0, "memory region", required);
+}
+
+
+//-------------------------------------------------
// find_memshare - find memory share
//-------------------------------------------------
-void *finder_base::find_memshare(UINT8 width, size_t &bytes, bool required)
+void *finder_base::find_memshare(UINT8 width, size_t &bytes, bool required) const
{
// look up the share and return NULL if not found
memory_share *share = m_base.memshare(m_tag);
@@ -91,7 +140,7 @@ void *finder_base::find_memshare(UINT8 width, size_t &bytes, bool required)
// return true if it's ok
//-------------------------------------------------
-bool finder_base::report_missing(bool found, const char *objname, bool required)
+bool finder_base::report_missing(bool found, const char *objname, bool required) const
{
if (required && strcmp(m_tag, FINDER_DUMMY_TAG)==0)
{
diff --git a/src/emu/devfind.h b/src/emu/devfind.h
index 44a5532b6a8..98599e4a6e9 100644
--- a/src/emu/devfind.h
+++ b/src/emu/devfind.h
@@ -47,6 +47,7 @@ public:
// getters
virtual bool findit(bool isvalidation = false) = 0;
+ const char *finder_tag() const { return m_tag; }
// setter for setting the object
void set_tag(const char *tag) { m_tag = tag; }
@@ -54,8 +55,9 @@ public:
protected:
// helpers
void *find_memregion(UINT8 width, size_t &length, bool required) const;
- void *find_memshare(UINT8 width, size_t &bytes, bool required);
- bool report_missing(bool found, const char *objname, bool required);
+ bool validate_memregion(size_t bytes, bool required) const;
+ void *find_memshare(UINT8 width, size_t &bytes, bool required) const;
+ bool report_missing(bool found, const char *objname, bool required) const;
void printf_warning(const char *format, ...) ATTR_PRINTF(2,3);
@@ -104,7 +106,7 @@ class device_finder : public object_finder_base<_DeviceClass>
{
public:
// construction/destruction
- device_finder(device_t &base, const char *tag)
+ device_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG)
: object_finder_base<_DeviceClass>(base, tag) { }
// make reference use transparent as well
@@ -148,7 +150,7 @@ class memory_region_finder : public object_finder_base<memory_region>
{
public:
// construction/destruction
- memory_region_finder(device_t &base, const char *tag)
+ memory_region_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG)
: object_finder_base<memory_region>(base, tag) { }
// make reference use transparent as well
@@ -157,7 +159,7 @@ public:
// finder
virtual bool findit(bool isvalidation = false) override
{
- if (isvalidation) return true;
+ if (isvalidation) return this->validate_memregion(0, _Required);
m_target = m_base.memregion(m_tag);
return this->report_missing(m_target != nullptr, "memory region", _Required);
}
@@ -186,7 +188,7 @@ class memory_bank_finder : public object_finder_base<memory_bank>
{
public:
// construction/destruction
- memory_bank_finder(device_t &base, const char *tag)
+ memory_bank_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG)
: object_finder_base<memory_bank>(base, tag) { }
// make reference use transparent as well
@@ -224,7 +226,7 @@ class ioport_finder : public object_finder_base<ioport_port>
{
public:
// construction/destruction
- ioport_finder(device_t &base, const char *tag)
+ ioport_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG)
: object_finder_base<ioport_port>(base, tag) { }
// make reference use transparent as well
@@ -319,14 +321,20 @@ class region_ptr_finder : public object_finder_base<_PointerType>
{
public:
// construction/destruction
- region_ptr_finder(device_t &base, const char *tag)
+ region_ptr_finder(device_t &base, const char *tag, size_t length = 0)
: object_finder_base<_PointerType>(base, tag),
- m_length(0) { }
+ m_length(length) { }
+ region_ptr_finder(device_t &base, size_t length = 0)
+ : object_finder_base<_PointerType>(base, FINDER_DUMMY_TAG),
+ m_length(length) { }
// operators to make use transparent
_PointerType operator[](int index) const { assert(index < m_length); return this->m_target[index]; }
_PointerType &operator[](int index) { assert(index < m_length); return this->m_target[index]; }
+ // setter for setting the object and its length
+ void set_target(_PointerType *target, size_t length) { this->m_target = target; m_length = length; }
+
// getter for explicit fetching
UINT32 length() const { return m_length; }
UINT32 bytes() const { return m_length * sizeof(_PointerType); }
@@ -335,7 +343,7 @@ public:
// finder
virtual bool findit(bool isvalidation = false) override
{
- if (isvalidation) return true;
+ if (isvalidation) return this->validate_memregion(sizeof(_PointerType) * m_length, _Required);
this->m_target = reinterpret_cast<_PointerType *>(this->find_memregion(sizeof(_PointerType), m_length, _Required));
return this->report_missing(this->m_target != nullptr, "memory region", _Required);
}
@@ -350,7 +358,8 @@ template<class _PointerType>
class optional_region_ptr : public region_ptr_finder<_PointerType, false>
{
public:
- optional_region_ptr(device_t &base, const char *tag = FINDER_DUMMY_TAG) : region_ptr_finder<_PointerType, false>(base, tag) { }
+ optional_region_ptr(device_t &base, const char *tag, size_t length = 0) : region_ptr_finder<_PointerType, false>(base, tag, length) { }
+ optional_region_ptr(device_t &base, size_t length = 0) : region_ptr_finder<_PointerType, false>(base, FINDER_DUMMY_TAG, length) { }
};
// required region pointer finder
@@ -358,10 +367,12 @@ template<class _PointerType>
class required_region_ptr : public region_ptr_finder<_PointerType, true>
{
public:
- required_region_ptr(device_t &base, const char *tag = FINDER_DUMMY_TAG) : region_ptr_finder<_PointerType, true>(base, tag) { }
+ required_region_ptr(device_t &base, const char *tag, size_t length = 0) : region_ptr_finder<_PointerType, true>(base, tag, length) { }
+ required_region_ptr(device_t &base, size_t length = 0) : region_ptr_finder<_PointerType, true>(base, FINDER_DUMMY_TAG, length) { }
};
+
// ======================> shared_ptr_finder
// shared pointer finder template
@@ -370,7 +381,7 @@ class shared_ptr_finder : public object_finder_base<_PointerType>
{
public:
// construction/destruction
- shared_ptr_finder(device_t &base, const char *tag, UINT8 width = sizeof(_PointerType) * 8)
+ shared_ptr_finder(device_t &base, const char *tag = FINDER_DUMMY_TAG, UINT8 width = sizeof(_PointerType) * 8)
: object_finder_base<_PointerType>(base, tag),
m_bytes(0),
m_width(width) { }
diff --git a/src/emu/device.cpp b/src/emu/device.cpp
index 59e4162314c..64fe6fede58 100644
--- a/src/emu/device.cpp
+++ b/src/emu/device.cpp
@@ -39,7 +39,6 @@ device_t::device_t(const machine_config &mconfig, device_type type, const char *
m_clock_scale(1.0),
m_attoseconds_per_clock((clock == 0) ? 0 : HZ_TO_ATTOSECONDS(clock)),
- m_region(nullptr),
m_machine_config(mconfig),
m_static_config(nullptr),
m_input_defaults(nullptr),
@@ -308,7 +307,26 @@ bool device_t::findit(bool isvalidation) const
{
bool allfound = true;
for (finder_base *autodev = m_auto_finder_list; autodev != nullptr; autodev = autodev->m_next)
+ {
+ if (isvalidation)
+ {
+ // sanity checking
+ const char *tag = autodev->finder_tag();
+ if (tag == nullptr)
+ {
+ osd_printf_error("Finder tag is null!\n");
+ allfound = false;
+ continue;
+ }
+ if (tag[0] == '^' && tag[1] == ':')
+ {
+ osd_printf_error("Malformed finder tag: %s\n", tag);
+ allfound = false;
+ continue;
+ }
+ }
allfound &= autodev->findit(isvalidation);
+ }
return allfound;
}
@@ -318,9 +336,6 @@ bool device_t::findit(bool isvalidation) const
void device_t::start()
{
- // populate the machine and the region field
- m_region = machine().root_device().memregion(tag());
-
// find all the registered devices
if (!findit(false))
throw emu_fatalerror("Missing some required objects, unable to proceed");
diff --git a/src/emu/device.h b/src/emu/device.h
index 9681e43943c..c098b2c337b 100644
--- a/src/emu/device.h
+++ b/src/emu/device.h
@@ -48,6 +48,17 @@
//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// use this to refer to the owning device when providing a device tag
+static const char DEVICE_SELF[] = "";
+
+// use this to refer to the owning device's owner when providing a device tag
+static const char DEVICE_SELF_OWNER[] = "^";
+
+
+//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@@ -199,7 +210,6 @@ public:
UINT8 default_bios() const { return m_default_bios; }
UINT8 system_bios() const { return m_system_bios; }
std::string default_bios_tag() const { return m_default_bios_tag; }
- memory_region *region() const { return m_region; }
// interface helpers
interface_list &interfaces() { return m_interfaces; }
@@ -334,7 +344,6 @@ protected:
attoseconds_t m_attoseconds_per_clock;// period in attoseconds
std::unique_ptr<device_debug> m_debug;
- memory_region * m_region; // our device-local region
const machine_config & m_machine_config; // reference to the machine's configuration
const void * m_static_config; // static device configuration
const input_device_default *m_input_defaults; // devices input ports default overrides
diff --git a/src/emu/dimemory.h b/src/emu/dimemory.h
index 0998fd4ae9a..941a8c87729 100644
--- a/src/emu/dimemory.h
+++ b/src/emu/dimemory.h
@@ -123,6 +123,9 @@ protected:
// configuration
address_map_constructor m_address_map[ADDRESS_SPACES]; // address maps for each address space
+
+private:
+ // internal state
address_space * m_addrspace[ADDRESS_SPACES]; // reported address spaces
};
diff --git a/src/mame/audio/atarijsa.cpp b/src/mame/audio/atarijsa.cpp
index 26581c21550..0ad49a64295 100644
--- a/src/mame/audio/atarijsa.cpp
+++ b/src/mame/audio/atarijsa.cpp
@@ -291,6 +291,7 @@ atari_jsa_base_device::atari_jsa_base_device(const machine_config &mconfig, devi
m_soundcomm(*this, "soundcomm"),
m_jsacpu(*this, "cpu"),
m_ym2151(*this, "ym2151"),
+ m_cpu_region(*this, "cpu"),
m_cpu_bank(*this, "cpubank"),
m_test_read_cb(*this),
m_main_int_cb(*this),
@@ -308,7 +309,7 @@ atari_jsa_base_device::atari_jsa_base_device(const machine_config &mconfig, devi
void atari_jsa_base_device::device_start()
{
// configure CPU bank
- m_cpu_bank->configure_entries(0, 4, m_jsacpu->region()->base(), 0x1000);
+ m_cpu_bank->configure_entries(0, 4, m_cpu_region->base(), 0x1000);
// resolve devices
m_test_read_cb.resolve_safe(0);
@@ -415,6 +416,8 @@ atari_jsa_oki_base_device::atari_jsa_oki_base_device(const machine_config &mconf
: atari_jsa_base_device(mconfig, devtype, name, tag, owner, clock, shortname, channels),
m_oki1(*this, "oki1"),
m_oki2(*this, "oki2"),
+ m_oki1_region(*this, "oki1"),
+ m_oki2_region(*this, "oki2"),
m_oki1_banklo(*this, "oki1lo"),
m_oki1_bankhi(*this, "oki1hi"),
m_oki2_banklo(*this, "oki2lo"),
@@ -568,19 +571,19 @@ void atari_jsa_oki_base_device::device_start()
save_item(NAME(m_overall_volume));
// configure JSA III ADPCM banking
- if (m_oki1_banklo != nullptr && m_oki1_bankhi != nullptr && m_oki1->region()->bytes() >= 0x80000)
+ if (m_oki1_banklo.found() && m_oki1_bankhi.found() && m_oki1_region->bytes() >= 0x80000)
{
- m_oki1_banklo->configure_entries(0, 2, m_oki1->region()->base() + 0x00000, 0x00000);
- m_oki1_banklo->configure_entries(2, 2, m_oki1->region()->base() + 0x20000, 0x20000);
- m_oki1_bankhi->set_base(m_oki1->region()->base() + 0x60000);
+ m_oki1_banklo->configure_entries(0, 2, m_oki1_region->base() + 0x00000, 0x00000);
+ m_oki1_banklo->configure_entries(2, 2, m_oki1_region->base() + 0x20000, 0x20000);
+ m_oki1_bankhi->set_base(m_oki1_region->base() + 0x60000);
}
// configure JSA IIIs ADPCM banking
- if (m_oki2_banklo != nullptr && m_oki2_bankhi != nullptr && m_oki2->region()->bytes() >= 0x80000)
+ if (m_oki2_banklo.found() && m_oki2_bankhi.found() && m_oki2_region->bytes() >= 0x80000)
{
- m_oki2_banklo->configure_entries(0, 2, m_oki2->region()->base() + 0x00000, 0x00000);
- m_oki2_banklo->configure_entries(2, 2, m_oki2->region()->base() + 0x20000, 0x20000);
- m_oki2_bankhi->set_base(m_oki2->region()->base() + 0x60000);
+ m_oki2_banklo->configure_entries(0, 2, m_oki2_region->base() + 0x00000, 0x00000);
+ m_oki2_banklo->configure_entries(2, 2, m_oki2_region->base() + 0x20000, 0x20000);
+ m_oki2_bankhi->set_base(m_oki2_region->base() + 0x60000);
}
}
@@ -608,9 +611,9 @@ void atari_jsa_oki_base_device::device_reset()
void atari_jsa_oki_base_device::update_all_volumes()
{
- if (m_oki1 != nullptr)
+ if (m_oki1.found())
m_oki1->set_output_gain(ALL_OUTPUTS, m_overall_volume * m_oki6295_volume * m_ym2151_ct1);
- if (m_oki2 != nullptr)
+ if (m_oki2.found())
m_oki2->set_output_gain(ALL_OUTPUTS, m_overall_volume * m_oki6295_volume * m_ym2151_ct1);
m_ym2151->set_output_gain(ALL_OUTPUTS, m_overall_volume * m_ym2151_volume);
}
diff --git a/src/mame/audio/atarijsa.h b/src/mame/audio/atarijsa.h
index 38ce437b4d2..dd47ada0c34 100644
--- a/src/mame/audio/atarijsa.h
+++ b/src/mame/audio/atarijsa.h
@@ -117,6 +117,9 @@ protected:
required_device<m6502_device> m_jsacpu;
required_device<ym2151_device> m_ym2151;
+ // memory regions
+ required_memory_region m_cpu_region;
+
// memory banks
required_memory_bank m_cpu_bank;
@@ -159,6 +162,10 @@ protected:
optional_device<okim6295_device> m_oki1;
optional_device<okim6295_device> m_oki2; // JSA IIIs only
+ // memory regions
+ optional_memory_region m_oki1_region;
+ optional_memory_region m_oki2_region;
+
// memory banks
optional_memory_bank m_oki1_banklo; // JSA III(s) only
optional_memory_bank m_oki1_bankhi; // JSA III(s)
diff --git a/src/mame/audio/seibu.cpp b/src/mame/audio/seibu.cpp
index 9883e9b9a25..c6b4c6b654d 100644
--- a/src/mame/audio/seibu.cpp
+++ b/src/mame/audio/seibu.cpp
@@ -78,6 +78,7 @@ const device_type SEIBU_SOUND = &device_creator<seibu_sound_device>;
seibu_sound_device::seibu_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, SEIBU_SOUND, "Seibu Sound System", tag, owner, clock, "seibu_sound", __FILE__),
+ m_sound_rom(*this, ":audiocpu"),
m_main2sub_pending(0),
m_sub2main_pending(0),
m_rst10_irq(0xff),
@@ -98,16 +99,14 @@ void seibu_sound_device::set_encryption(int mode)
void seibu_sound_device::device_start()
{
- int length = memregion(":audiocpu")->bytes();
- UINT8 *rom = memregion(":audiocpu")->base();
- if (length > 0x10000)
+ if (m_sound_rom.length() > 0x10000)
{
- membank(":seibu_bank1")->configure_entries(0, (length - 0x10000) / 0x8000, rom + 0x10000, 0x8000);
+ membank(":seibu_bank1")->configure_entries(0, (m_sound_rom.length() - 0x10000) / 0x8000, &m_sound_rom[0x10000], 0x8000);
/* Denjin Makai definitely needs this at start-up, it never writes to the bankswitch */
membank(":seibu_bank1")->set_entry(0);
} else
- membank(":seibu_bank1")->set_base(rom + 0x8000);
+ membank(":seibu_bank1")->set_base(&m_sound_rom[0x8000]);
switch(m_encryption_mode) {
case 0: break;
@@ -115,13 +114,13 @@ void seibu_sound_device::device_start()
case 1:
get_custom_decrypt();
- memcpy(m_decrypted_opcodes.get(), rom, length);
- apply_decrypt(rom, m_decrypted_opcodes.get(), 0x2000);
+ memcpy(m_decrypted_opcodes.get(), &m_sound_rom[0], m_sound_rom.length());
+ apply_decrypt(&m_sound_rom[0], m_decrypted_opcodes.get(), 0x2000);
break;
case 2:
get_custom_decrypt();
- apply_decrypt(rom, m_decrypted_opcodes.get(), length);
+ apply_decrypt(&m_sound_rom[0], m_decrypted_opcodes.get(), m_sound_rom.length());
break;
}
@@ -514,8 +513,7 @@ seibu_adpcm_device::seibu_adpcm_device(const machine_config &mconfig, const char
m_end(0),
m_nibble(0),
m_playing(0),
- m_rom_tag(nullptr),
- m_base(nullptr)
+ m_base(*this, DEVICE_SELF)
{
}
@@ -527,7 +525,6 @@ void seibu_adpcm_device::device_start()
{
m_playing = 0;
m_stream = machine().sound().stream_alloc(*this, 0, 1, clock());
- m_base = machine().root_device().memregion(m_rom_tag)->base();
m_adpcm.reset();
save_item(NAME(m_current));
@@ -540,14 +537,11 @@ void seibu_adpcm_device::device_start()
// simplify PCB layout/routing rather than intentional protection, but it
// still fits, especially since the Z80s for all these games are truly encrypted.
-void seibu_adpcm_device::decrypt(const char *region)
+void seibu_adpcm_device::decrypt()
{
- UINT8 *ROM = machine().root_device().memregion(region)->base();
- int len = machine().root_device().memregion(region)->bytes();
-
- for (int i = 0; i < len; i++)
+ for (int i = 0; i < m_base.length(); i++)
{
- ROM[i] = BITSWAP8(ROM[i], 7, 5, 3, 1, 6, 4, 2, 0);
+ m_base[i] = BITSWAP8(m_base[i], 7, 5, 3, 1, 6, 4, 2, 0);
}
}
diff --git a/src/mame/audio/seibu.h b/src/mame/audio/seibu.h
index 732ab5af314..450febcf665 100644
--- a/src/mame/audio/seibu.h
+++ b/src/mame/audio/seibu.h
@@ -76,6 +76,7 @@ protected:
// internal state
device_t *m_sound_cpu;
+ required_region_ptr<UINT8> m_sound_rom;
UINT8 m_main2sub[2];
UINT8 m_sub2main[2];
int m_main2sub_pending;
@@ -105,9 +106,7 @@ public:
seibu_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~seibu_adpcm_device() {}
- static void set_adpcm_rom_tag(device_t &device, const char *tag) { downcast<seibu_adpcm_device &>(device).m_rom_tag = tag; }
-
- void decrypt(const char *region);
+ void decrypt();
DECLARE_WRITE8_MEMBER( adr_w );
DECLARE_WRITE8_MEMBER( ctl_w );
@@ -126,17 +125,13 @@ protected:
UINT32 m_end;
UINT8 m_nibble;
UINT8 m_playing;
- const char *m_rom_tag;
- UINT8 *m_base;
+ required_region_ptr<UINT8> m_base;
};
extern const device_type SEIBU_ADPCM;
/**************************************************************************/
-#define MCFG_SEIBU_ADPCM_ROMREGION(_tag) \
- seibu_adpcm_device::set_adpcm_rom_tag(*device, _tag);
-
#define SEIBU_COIN_INPUTS \
PORT_START("COIN") \
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(4) \
@@ -278,11 +273,9 @@ extern const device_type SEIBU_ADPCM;
#define SEIBU_SOUND_SYSTEM_ADPCM_INTERFACE \
MCFG_SOUND_ADD("adpcm1", SEIBU_ADPCM, 8000) \
- MCFG_SEIBU_ADPCM_ROMREGION("adpcm1") \
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) \
\
MCFG_SOUND_ADD("adpcm2", SEIBU_ADPCM, 8000) \
- MCFG_SEIBU_ADPCM_ROMREGION("adpcm2") \
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
/**************************************************************************/
diff --git a/src/mame/audio/wpcsnd.cpp b/src/mame/audio/wpcsnd.cpp
index 134456fe19b..4aec641b3ac 100644
--- a/src/mame/audio/wpcsnd.cpp
+++ b/src/mame/audio/wpcsnd.cpp
@@ -21,6 +21,7 @@ wpcsnd_device::wpcsnd_device(const machine_config &mconfig, const char *tag, dev
m_dac(*this,"dac"),
m_cpubank(*this,"rombank"),
m_fixedbank(*this,"fixed"),
+ m_rom(*this),
m_reply_cb(*this)
{
}
@@ -92,10 +93,7 @@ void wpcsnd_device::device_start()
void wpcsnd_device::device_reset()
{
- UINT8* ROM;
-
- m_rom = memregion(m_regiontag);
- ROM = m_rom->base();
+ UINT8* ROM = m_rom->base();
m_cpubank->configure_entries(0, 0x80, &ROM[0], 0x8000);
m_cpubank->set_entry(0);
m_fixedbank->configure_entries(0, 1, &ROM[0x17c000], 0x4000);
@@ -110,7 +108,7 @@ void wpcsnd_device::device_reset()
void wpcsnd_device::static_set_gfxregion(device_t &device, const char *tag)
{
wpcsnd_device &cpuboard = downcast<wpcsnd_device &>(device);
- cpuboard.m_regiontag = tag;
+ cpuboard.m_rom.set_tag(tag);
}
WRITE_LINE_MEMBER( wpcsnd_device::ym2151_irq_w)
diff --git a/src/mame/audio/wpcsnd.h b/src/mame/audio/wpcsnd.h
index 36c418bd9bf..0975b2d584a 100644
--- a/src/mame/audio/wpcsnd.h
+++ b/src/mame/audio/wpcsnd.h
@@ -34,7 +34,7 @@ public:
required_device<dac_device> m_dac;
required_memory_bank m_cpubank;
required_memory_bank m_fixedbank;
- memory_region* m_rom;
+ required_memory_region m_rom;
DECLARE_WRITE8_MEMBER(bg_speech_clock_w);
DECLARE_WRITE8_MEMBER(bg_speech_digit_w);
@@ -61,7 +61,6 @@ protected:
virtual machine_config_constructor device_mconfig_additions() const override;
private:
- const char* m_regiontag;
UINT8 m_latch;
UINT8 m_reply;
bool m_reply_available;
diff --git a/src/mame/drivers/artmagic.cpp b/src/mame/drivers/artmagic.cpp
index dba800e1a3d..3c23a78051d 100644
--- a/src/mame/drivers/artmagic.cpp
+++ b/src/mame/drivers/artmagic.cpp
@@ -99,7 +99,7 @@ WRITE16_MEMBER(artmagic_state::control_w)
/* OKI banking here */
if (offset == 0)
{
- m_oki->set_bank_base((((data >> 4) & 1) * 0x40000) % m_oki->region()->bytes());
+ m_oki->set_bank_base((((data >> 4) & 1) * 0x40000) % m_oki_region->bytes());
}
logerror("%06X:control_w(%d) = %04X\n", space.device().safe_pc(), offset, data);
diff --git a/src/mame/drivers/cabal.cpp b/src/mame/drivers/cabal.cpp
index 9f41c09a89a..b14eeb7e6f8 100644
--- a/src/mame/drivers/cabal.cpp
+++ b/src/mame/drivers/cabal.cpp
@@ -503,11 +503,9 @@ static MACHINE_CONFIG_START( cabal_base, cabal_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS,"mono", 0.80)
MCFG_SOUND_ADD("adpcm1", SEIBU_ADPCM, 8000) /* it should use the msm5205 */
- MCFG_SEIBU_ADPCM_ROMREGION("adpcm1")
MCFG_SOUND_ROUTE(ALL_OUTPUTS,"mono", 0.40)
MCFG_SOUND_ADD("adpcm2", SEIBU_ADPCM, 8000) /* it should use the msm5205 */
- MCFG_SEIBU_ADPCM_ROMREGION("adpcm2")
MCFG_SOUND_ROUTE(ALL_OUTPUTS,"mono", 0.40)
MACHINE_CONFIG_END
@@ -873,8 +871,8 @@ ROM_END
DRIVER_INIT_MEMBER(cabal_state,cabal)
{
- m_adpcm1->decrypt("adpcm1");
- m_adpcm2->decrypt("adpcm2");
+ m_adpcm1->decrypt();
+ m_adpcm2->decrypt();
}
DRIVER_INIT_MEMBER(cabal_state,cabalbl2)
@@ -882,8 +880,8 @@ DRIVER_INIT_MEMBER(cabal_state,cabalbl2)
UINT8 *decrypt = m_seibu_sound->get_custom_decrypt();
memcpy(decrypt, memregion("audiocpu")->base()+0x2000, 0x2000);
memcpy(decrypt+0x8000, memregion("audiocpu")->base()+0x8000, 0x8000);
- m_adpcm1->decrypt("adpcm1");
- m_adpcm2->decrypt("adpcm2");
+ m_adpcm1->decrypt();
+ m_adpcm2->decrypt();
}
diff --git a/src/mame/drivers/chihiro.cpp b/src/mame/drivers/chihiro.cpp
index c421161c9d8..f7961417637 100644
--- a/src/mame/drivers/chihiro.cpp
+++ b/src/mame/drivers/chihiro.cpp
@@ -1083,7 +1083,7 @@ static MACHINE_CONFIG_DERIVED_CLASS(chihiro_base, xbox_base, chihiro_state)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED(chihirogd, chihiro_base)
- MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", ":pic", nullptr, NOOP)
+ MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "pic", nullptr, NOOP)
MACHINE_CONFIG_END
#define ROM_LOAD16_WORD_SWAP_BIOS(bios,name,offset,length,hash) \
diff --git a/src/mame/drivers/deadang.cpp b/src/mame/drivers/deadang.cpp
index b73bc01e7ed..62f785fdf2d 100644
--- a/src/mame/drivers/deadang.cpp
+++ b/src/mame/drivers/deadang.cpp
@@ -463,14 +463,14 @@ ROM_END
DRIVER_INIT_MEMBER(deadang_state,deadang)
{
- m_adpcm1->decrypt("adpcm1");
- m_adpcm2->decrypt("adpcm2");
+ m_adpcm1->decrypt();
+ m_adpcm2->decrypt();
}
DRIVER_INIT_MEMBER(deadang_state,ghunter)
{
- m_adpcm1->decrypt("adpcm1");
- m_adpcm2->decrypt("adpcm2");
+ m_adpcm1->decrypt();
+ m_adpcm2->decrypt();
m_maincpu->space(AS_PROGRAM).install_read_handler(0x80000, 0x80001, read16_delegate(FUNC(deadang_state::ghunter_trackball_low_r),this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0xb0000, 0xb0001, read16_delegate(FUNC(deadang_state::ghunter_trackball_high_r),this));
diff --git a/src/mame/drivers/harddriv.cpp b/src/mame/drivers/harddriv.cpp
index 7b47dc59c7c..d895bedb7ff 100644
--- a/src/mame/drivers/harddriv.cpp
+++ b/src/mame/drivers/harddriv.cpp
@@ -351,6 +351,8 @@ harddriv_state::harddriv_state(const machine_config &mconfig, const char *tag, d
m_dsp32(*this, "dsp32"),
m_ds3sdsp(*this, "ds3sdsp"),
m_ds3xdsp(*this, "ds3xdsp"),
+ m_ds3sdsp_region(*this, "ds3sdsp"),
+ m_ds3xdsp_region(*this, "ds3xdsp"),
m_ds3dac1(*this, "ds3dac1"),
m_ds3dac2(*this, "ds3dac2"),
m_harddriv_sound(*this, "harddriv_sound"),
@@ -407,8 +409,7 @@ harddriv_state::harddriv_state(const machine_config &mconfig, const char *tag, d
m_adsp_sim_address(0),
m_adsp_som_address(0),
m_adsp_eprom_base(0),
- m_sim_memory(nullptr),
- m_sim_memory_size(0),
+ m_sim_memory(*this, "user1"),
m_adsp_pgm_memory_word(nullptr),
m_ds3_sdata_memory(*this, "ds3sdsp_data"),
m_ds3_sdata_memory_size(0),
diff --git a/src/mame/drivers/naomi.cpp b/src/mame/drivers/naomi.cpp
index 4bd679f4dfe..b727012f2ef 100644
--- a/src/mame/drivers/naomi.cpp
+++ b/src/mame/drivers/naomi.cpp
@@ -2712,7 +2712,7 @@ MACHINE_CONFIG_END
*/
static MACHINE_CONFIG_DERIVED( naomi, naomi_base )
- MCFG_NAOMI_ROM_BOARD_ADD("rom_board", "naomibd_eeprom", ":boardid", WRITE8(dc_state, g1_irq))
+ MCFG_NAOMI_ROM_BOARD_ADD("rom_board", "naomibd_eeprom", "boardid", WRITE8(dc_state, g1_irq))
MACHINE_CONFIG_END
/*
@@ -2720,7 +2720,7 @@ MACHINE_CONFIG_END
*/
static MACHINE_CONFIG_DERIVED( naomigd, naomi_base )
- MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", ":pic", "naomibd_eeprom", WRITE8(dc_state, g1_irq))
+ MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "pic", "naomibd_eeprom", WRITE8(dc_state, g1_irq))
MACHINE_CONFIG_END
/*
@@ -2728,7 +2728,7 @@ MACHINE_CONFIG_END
*/
static MACHINE_CONFIG_DERIVED( naomim1, naomi_base )
- MCFG_NAOMI_M1_BOARD_ADD("rom_board", "naomibd_eeprom", ":boardid", WRITE8(dc_state, g1_irq))
+ MCFG_NAOMI_M1_BOARD_ADD("rom_board", "naomibd_eeprom", "boardid", WRITE8(dc_state, g1_irq))
MACHINE_CONFIG_END
/*
@@ -2736,7 +2736,7 @@ MACHINE_CONFIG_END
*/
static MACHINE_CONFIG_DERIVED( naomim2, naomi_base )
- MCFG_NAOMI_M2_BOARD_ADD("rom_board", "naomibd_eeprom", ":boardid", WRITE8(dc_state, g1_irq))
+ MCFG_NAOMI_M2_BOARD_ADD("rom_board", "naomibd_eeprom", "boardid", WRITE8(dc_state, g1_irq))
MACHINE_CONFIG_END
/*
@@ -2744,7 +2744,7 @@ MACHINE_CONFIG_END
*/
static MACHINE_CONFIG_DERIVED( naomim4, naomi_base )
- MCFG_NAOMI_M4_BOARD_ADD("rom_board", ":pic_readout", "naomibd_eeprom", ":boardid", WRITE8(dc_state, g1_irq))
+ MCFG_NAOMI_M4_BOARD_ADD("rom_board", "pic_readout", "naomibd_eeprom", "boardid", WRITE8(dc_state, g1_irq))
MACHINE_CONFIG_END
/*
@@ -2791,7 +2791,7 @@ static MACHINE_CONFIG_DERIVED( aw_base, naomi_aw_base )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(aw_map)
MCFG_MACRONIX_29L001MC_ADD("awflash")
- MCFG_AW_ROM_BOARD_ADD("rom_board", ":rom_key", WRITE8(dc_state, g1_irq))
+ MCFG_AW_ROM_BOARD_ADD("rom_board", "rom_key", WRITE8(dc_state, g1_irq))
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( aw1c, aw_base )
diff --git a/src/mame/drivers/segas18.cpp b/src/mame/drivers/segas18.cpp
index c78c37f04c7..0dbb04eb3cf 100644
--- a/src/mame/drivers/segas18.cpp
+++ b/src/mame/drivers/segas18.cpp
@@ -45,7 +45,7 @@
void segas18_state::memory_mapper(sega_315_5195_mapper_device &mapper, UINT8 index)
{
- UINT32 romsize = m_maincpu->region()->bytes();
+ UINT32 romsize = m_maincpu_region->bytes();
switch (index)
{
case 7:
diff --git a/src/mame/drivers/segasp.cpp b/src/mame/drivers/segasp.cpp
index ea4482ec04a..51c54c98c3c 100644
--- a/src/mame/drivers/segasp.cpp
+++ b/src/mame/drivers/segasp.cpp
@@ -301,7 +301,7 @@ static MACHINE_CONFIG_DERIVED_CLASS( segasp, naomi_aw_base, segasp_state )
// todo, not exactly NaomiM4 (see notes at top of driver) use custom board type here instead
MCFG_X76F100_ADD("naomibd_eeprom") // actually not present
- MCFG_NAOMI_M4_BOARD_ADD("rom_board", ":pic_readout", "naomibd_eeprom", ":boardid", WRITE8(dc_state, g1_irq))
+ MCFG_NAOMI_M4_BOARD_ADD("rom_board", "pic_readout", "naomibd_eeprom", "boardid", WRITE8(dc_state, g1_irq))
MACHINE_CONFIG_END
#define ROM_LOAD16_WORD_SWAP_BIOS(bios,name,offset,length,hash) \
diff --git a/src/mame/drivers/triforce.cpp b/src/mame/drivers/triforce.cpp
index 3823f27179c..15bc9e48f20 100644
--- a/src/mame/drivers/triforce.cpp
+++ b/src/mame/drivers/triforce.cpp
@@ -583,7 +583,7 @@ static MACHINE_CONFIG_START( triforce_base, triforce_state )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( triforcegd, triforce_base )
- MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", ":pic", nullptr, NOOP)
+ MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "pic", nullptr, NOOP)
MACHINE_CONFIG_END
diff --git a/src/mame/includes/artmagic.h b/src/mame/includes/artmagic.h
index 32f56fd2747..575c90b15cf 100644
--- a/src/mame/includes/artmagic.h
+++ b/src/mame/includes/artmagic.h
@@ -20,6 +20,7 @@ public:
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_oki(*this, "oki"),
+ m_oki_region(*this, "oki"),
m_tms(*this, "tms"),
m_tlc34076(*this, "tlc34076"),
m_control(*this, "control"),
@@ -28,6 +29,7 @@ public:
required_device<cpu_device> m_maincpu;
required_device<okim6295_device> m_oki;
+ required_memory_region m_oki_region;
required_device<tms34010_device> m_tms;
required_device<tlc34076_device> m_tlc34076;
diff --git a/src/mame/includes/harddriv.h b/src/mame/includes/harddriv.h
index 01fad97eb95..669cc95b4ca 100644
--- a/src/mame/includes/harddriv.h
+++ b/src/mame/includes/harddriv.h
@@ -257,6 +257,8 @@ protected:
optional_device<dsp32c_device> m_dsp32;
optional_device<adsp2105_device> m_ds3sdsp;
optional_device<adsp2105_device> m_ds3xdsp;
+ optional_memory_region m_ds3sdsp_region;
+ optional_memory_region m_ds3xdsp_region;
optional_device<dac_device> m_ds3dac1;
optional_device<dac_device> m_ds3dac2;
optional_device<harddriv_sound_board_device> m_harddriv_sound;
@@ -339,8 +341,7 @@ protected:
UINT16 m_adsp_som_address;
UINT32 m_adsp_eprom_base;
- UINT16 * m_sim_memory;
- UINT32 m_sim_memory_size;
+ required_region_ptr<UINT16> m_sim_memory;
UINT16 m_som_memory[0x8000/2];
UINT16 * m_adsp_pgm_memory_word;
diff --git a/src/mame/includes/nb1414m4.h b/src/mame/includes/nb1414m4.h
index b00bdf6ae2e..2832d6a38b2 100644
--- a/src/mame/includes/nb1414m4.h
+++ b/src/mame/includes/nb1414m4.h
@@ -24,7 +24,7 @@ private:
void _0600(UINT8 is2p, UINT8 *vram);
void _0e00(UINT16 mcu_cmd, UINT8 *vram);
- optional_region_ptr<UINT8> m_data;
+ required_region_ptr<UINT8> m_data;
};
diff --git a/src/mame/includes/segas18.h b/src/mame/includes/segas18.h
index 5efbcfea648..79726c3c253 100644
--- a/src/mame/includes/segas18.h
+++ b/src/mame/includes/segas18.h
@@ -27,6 +27,7 @@ public:
: sega_16bit_common_base(mconfig, type, tag),
m_mapper(*this, "mapper"),
m_maincpu(*this, "maincpu"),
+ m_maincpu_region(*this, "maincpu"),
m_soundcpu(*this, "soundcpu"),
m_mcu(*this, "mcu"),
m_vdp(*this, "gen_vdp"),
@@ -128,6 +129,7 @@ protected:
// devices
required_device<sega_315_5195_mapper_device> m_mapper;
required_device<m68000_device> m_maincpu;
+ required_memory_region m_maincpu_region;
required_device<z80_device> m_soundcpu;
optional_device<i8751_device> m_mcu;
required_device<sega315_5313_device> m_vdp;
diff --git a/src/mame/machine/awboard.cpp b/src/mame/machine/awboard.cpp
index 7ec0c5b6c3a..1a364d8a1a2 100644
--- a/src/mame/machine/awboard.cpp
+++ b/src/mame/machine/awboard.cpp
@@ -166,15 +166,16 @@ DEVICE_ADDRESS_MAP_START(submap, 16, aw_rom_board)
ADDRESS_MAP_END
aw_rom_board::aw_rom_board(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : naomi_g1_device(mconfig, AW_ROM_BOARD, "Sammy Atomiswave ROM Board", tag, owner, clock, "aw_rom_board", __FILE__)
+ : naomi_g1_device(mconfig, AW_ROM_BOARD, "Sammy Atomiswave ROM Board", tag, owner, clock, "aw_rom_board", __FILE__),
+ m_region(*this, DEVICE_SELF),
+ m_keyregion(*this)
{
- keyregion = nullptr;
}
-void aw_rom_board::static_set_keyregion(device_t &device, const char *_keyregion)
+void aw_rom_board::static_set_keyregion(device_t &device, const char *keyregion)
{
aw_rom_board &dev = downcast<aw_rom_board &>(device);
- dev.keyregion = _keyregion;
+ dev.m_keyregion.set_tag(keyregion);
}
@@ -256,20 +257,13 @@ UINT16 aw_rom_board::decrypt(UINT16 cipherText, UINT32 address, const UINT32 key
void aw_rom_board::set_key()
{
- if(!m_region)
- throw emu_fatalerror("AW-ROM-BOARD: region %s is missing\n", tag());
-
- if(!keyregion)
- return;
-
- memory_region *kr = memregion(keyregion);
- if(!kr)
+ if (!m_keyregion.found())
return;
- if(kr->bytes() != 4)
- throw emu_fatalerror("AW-ROM-BOARD: key region %s has incorrect size (%d, expected 4)\n", keyregion, kr->bytes());
+ if (m_keyregion->bytes() != 4)
+ throw emu_fatalerror("AW-ROM-BOARD: key region %s has incorrect size (%d, expected 4)\n", m_keyregion.finder_tag(), m_keyregion->bytes());
- const UINT8 *krp = kr->base();
+ const UINT8 *krp = m_keyregion->base();
rombd_key = (krp[0] << 24) | (krp[1] << 16) | (krp[2] << 8) | krp[3];
}
@@ -307,7 +301,7 @@ READ16_MEMBER(aw_rom_board::pio_r)
UINT32 roffset = epr_offset & 0x3ffffff;
if (roffset >= (mpr_offset / 2))
roffset += mpr_bank * 0x4000000;
- UINT16 retval = (m_region->bytes() > roffset) ? m_region->u16(roffset) : 0;
+ UINT16 retval = (m_region->bytes() > roffset) ? m_region->u16(roffset) : 0; // not endian-safe?
return retval;
}
diff --git a/src/mame/machine/awboard.h b/src/mame/machine/awboard.h
index 4e531523856..5ae885079c1 100644
--- a/src/mame/machine/awboard.h
+++ b/src/mame/machine/awboard.h
@@ -7,14 +7,14 @@
#define MCFG_AW_ROM_BOARD_ADD(_tag, _keyregion, _irq_cb) \
MCFG_NAOMI_G1_ADD(_tag, AW_ROM_BOARD, _irq_cb) \
- aw_rom_board::static_set_keyregion(*device, _keyregion);
+ aw_rom_board::static_set_keyregion(*device, "^" _keyregion);
class aw_rom_board : public naomi_g1_device
{
public:
aw_rom_board(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- static void static_set_keyregion(device_t &device, const char *_keyregion);
+ static void static_set_keyregion(device_t &device, const char *keyregion);
DECLARE_ADDRESS_MAP(submap, 16);
@@ -37,7 +37,8 @@ protected:
private:
enum { EPR, MPR_RECORD, MPR_FILE };
- const char *keyregion;
+ required_memory_region m_region;
+ optional_memory_region m_keyregion;
UINT32 rombd_key;
UINT32 mpr_offset, mpr_bank;
UINT32 epr_offset, mpr_file_offset;
diff --git a/src/mame/machine/decocass_tape.cpp b/src/mame/machine/decocass_tape.cpp
index 8b3f2785032..982cd9018aa 100644
--- a/src/mame/machine/decocass_tape.cpp
+++ b/src/mame/machine/decocass_tape.cpp
@@ -65,7 +65,8 @@ decocass_tape_device::decocass_tape_device(const machine_config &mconfig, const
m_region(REGION_LEADER),
m_bitnum(0),
m_clockpos(0),
- m_numclocks(0)
+ m_numclocks(0),
+ m_tape_data(*this, DEVICE_SELF)
{
for (auto & elem : m_crc16)
elem = 0;
@@ -91,13 +92,12 @@ void decocass_tape_device::device_start()
/* fetch the data pointer */
m_tape_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(decocass_tape_device::tape_clock_callback), this));
- if (region() == nullptr)
+ if (!m_tape_data.found())
return;
- UINT8 *regionbase = region()->base();
/* scan for the first non-empty block in the image */
- for (offs = region()->bytes() - 1; offs >= 0; offs--)
- if (regionbase[offs] != 0)
+ for (offs = m_tape_data.bytes() - 1; offs >= 0; offs--)
+ if (m_tape_data[offs] != 0)
break;
numblocks = ((offs | 0xff) + 1) / 256;
assert(numblocks < ARRAY_LENGTH(m_crc16));
@@ -113,7 +113,7 @@ void decocass_tape_device::device_start()
/* first CRC the 256 bytes of data */
for (offs = 256 * curblock; offs < 256 * curblock + 256; offs++)
- crc = tape_crc16_byte(crc, regionbase[offs]);
+ crc = tape_crc16_byte(crc, m_tape_data[offs]);
/* then find a pair of bytes that will bring the CRC to 0 (any better way than brute force?) */
for (testval = 0; testval < 0x10000; testval++)
@@ -292,7 +292,6 @@ TIMER_CALLBACK_MEMBER( decocass_tape_device::tape_clock_callback )
UINT8 decocass_tape_device::get_status_bits()
{
UINT8 tape_bits = 0;
- UINT8 *tape_data = region()->base();
/* bit 0x20 is the BOT/EOT signal, which is also set in the leader/trailer area */
if (m_region == REGION_LEADER || m_region == REGION_BOT || m_region == REGION_EOT || m_region == REGION_TRAILER)
@@ -325,7 +324,7 @@ UINT8 decocass_tape_device::get_status_bits()
/* data block bytes are data */
else if (m_bytenum >= BYTE_DATA_0 && m_bytenum <= BYTE_DATA_255)
- byteval = tape_data[blocknum * 256 + (m_bytenum - BYTE_DATA_0)];
+ byteval = m_tape_data[blocknum * 256 + (m_bytenum - BYTE_DATA_0)];
/* CRC MSB */
else if (m_bytenum == BYTE_CRC16_MSB)
@@ -350,7 +349,7 @@ UINT8 decocass_tape_device::get_status_bits()
UINT8 decocass_tape_device::is_present()
{
- return region() != nullptr;
+ return m_tape_data.found();
}
diff --git a/src/mame/machine/decocass_tape.h b/src/mame/machine/decocass_tape.h
index 0b4909f34bd..4d7f03ada4a 100644
--- a/src/mame/machine/decocass_tape.h
+++ b/src/mame/machine/decocass_tape.h
@@ -64,6 +64,7 @@ private:
UINT32 m_clockpos; /* the current clock position of the tape */
UINT32 m_numclocks; /* total number of clocks on the entire tape */
UINT16 m_crc16[256]; /* CRC16 for each block */
+ optional_region_ptr<UINT8> m_tape_data;
const char *describe_state();
TIMER_CALLBACK_MEMBER( tape_clock_callback );
diff --git a/src/mame/machine/fd1089.cpp b/src/mame/machine/fd1089.cpp
index 5f8df8b0b3d..f786bf29c2d 100644
--- a/src/mame/machine/fd1089.cpp
+++ b/src/mame/machine/fd1089.cpp
@@ -223,6 +223,8 @@ ADDRESS_MAP_END
fd1089_base_device::fd1089_base_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)
: m68000_device(mconfig, tag, owner, clock, shortname, source),
+ m_region(*this, DEVICE_SELF),
+ m_key(*this, "key"),
m_decrypted_opcodes(*this, ":fd1089_decrypted_opcodes")
{
// override the name after the m68000 initializes
@@ -251,18 +253,11 @@ void fd1089_base_device::device_start()
// start the base device
m68000_device::device_start();
- // find the key
- m_key = memregion("key")->base();
- if (m_key == nullptr)
- throw emu_fatalerror("FD1089 key region not found!");
-
// get a pointer to the ROM region
- UINT16 *rombase = reinterpret_cast<UINT16 *>(region()->base());
- if (rombase == nullptr)
- throw emu_fatalerror("FD1089 found no ROM data to decrypt!");
+ UINT16 *rombase = reinterpret_cast<UINT16 *>(m_region->base());
// determine length and resize our internal buffers
- UINT32 romsize = region()->bytes();
+ UINT32 romsize = m_region->bytes();
m_plaintext.resize(romsize/2);
// copy the plaintext
@@ -493,7 +488,7 @@ void fd1089_base_device::decrypt(offs_t baseaddr, UINT32 size, const UINT16 *src
for (offs_t offset = 0; offset < size; offset += 2)
{
UINT16 src = srcptr[offset / 2];
- opcodesptr[offset / 2] = decrypt_one(baseaddr + offset, src, m_key, true);
- dataptr[offset / 2] = decrypt_one(baseaddr + offset, src, m_key, false);
+ opcodesptr[offset / 2] = decrypt_one(baseaddr + offset, src, &m_key[0], true);
+ dataptr[offset / 2] = decrypt_one(baseaddr + offset, src, &m_key[0], false);
}
}
diff --git a/src/mame/machine/fd1089.h b/src/mame/machine/fd1089.h
index 71fcc361d7a..0bf37ba75b9 100644
--- a/src/mame/machine/fd1089.h
+++ b/src/mame/machine/fd1089.h
@@ -55,7 +55,8 @@ protected:
void decrypt(offs_t baseaddr, UINT32 size, const UINT16 *srcptr, UINT16 *opcodesptr, UINT16 *dataptr);
// internal state
- const UINT8 * m_key;
+ required_memory_region m_region;
+ required_region_ptr<UINT8> m_key;
std::vector<UINT16> m_plaintext;
required_shared_ptr<UINT16> m_decrypted_opcodes;
diff --git a/src/mame/machine/fd1094.cpp b/src/mame/machine/fd1094.cpp
index 9dc3009cd31..7616adcd0b9 100644
--- a/src/mame/machine/fd1094.cpp
+++ b/src/mame/machine/fd1094.cpp
@@ -558,9 +558,8 @@ fd1094_device::fd1094_device(const machine_config &mconfig, const char *tag, dev
m_state(0x00),
m_irqmode(false),
m_cache(*this),
- m_srcbase(nullptr),
- m_srcbytes(0),
- m_key(nullptr)
+ m_srcbase(*this, DEVICE_SELF),
+ m_key(*this, "key")
{
// override the name after the m68000 initializes
m_name.assign("FD1094");
@@ -634,35 +633,18 @@ void fd1094_device::change_state(int newstate)
void fd1094_device::device_start()
{
- // find the key
- m_key = memregion("key")->base();
- if (m_key == nullptr)
- throw emu_fatalerror("FD1094 key region not found!");
-
- // get a pointer to the ROM region
- if (region() != nullptr)
- {
- m_srcbase = reinterpret_cast<UINT16 *>(region()->base());
- m_srcbytes = region()->bytes();
- }
-
// if no ROM region, see if there's a memory share with our name
- else
+ if (!m_srcbase.found())
{
- memory_share *share = owner()->memshare(tag());
+ memory_share *share = memshare(DEVICE_SELF);
if (share != nullptr)
- {
- m_srcbase = reinterpret_cast<UINT16 *>(share->ptr());
- m_srcbytes = share->bytes();
- }
+ m_srcbase.set_target(reinterpret_cast<UINT16 *>(share->ptr()), share->bytes() / 2);
+ else
+ throw emu_fatalerror("FD1094 found no data to decrypt!");
}
- // if we got nothing, error
- if (m_srcbase == nullptr)
- throw emu_fatalerror("FD1094 found no data to decrypt!");
-
// determine length and configure our cache
- m_cache.configure(0x000000, m_srcbytes, 0x000000);
+ m_cache.configure(0x000000, m_srcbase.bytes(), 0x000000);
change_state(STATE_RESET);
// start the base device
@@ -907,7 +889,7 @@ UINT16 fd1094_device::decrypt_one(offs_t address, UINT16 val, const UINT8 *main_
void fd1094_device::decrypt(offs_t baseaddr, UINT32 size, const UINT16 *srcptr, UINT16 *opcodesptr, UINT8 state)
{
for (offs_t offset = 0; offset < size; offset += 2)
- opcodesptr[offset / 2] = decrypt_one((baseaddr + offset) / 2, srcptr[offset / 2], m_key, state, (baseaddr + offset) < 8);
+ opcodesptr[offset / 2] = decrypt_one((baseaddr + offset) / 2, srcptr[offset / 2], &m_key[0], state, (baseaddr + offset) < 8);
}
diff --git a/src/mame/machine/fd1094.h b/src/mame/machine/fd1094.h
index 737f3b81e1c..a72fc6f5df1 100644
--- a/src/mame/machine/fd1094.h
+++ b/src/mame/machine/fd1094.h
@@ -72,7 +72,7 @@ public:
fd1094_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// explicit decryption helpers
- void decrypt(offs_t baseaddr, UINT32 size, offs_t regionoffs, UINT16 *opcodesptr, UINT8 state) { decrypt(baseaddr, size, m_srcbase + regionoffs/2, opcodesptr, state); }
+ void decrypt(offs_t baseaddr, UINT32 size, offs_t regionoffs, UINT16 *opcodesptr, UINT8 state) { decrypt(baseaddr, size, &m_srcbase[regionoffs/2], opcodesptr, state); }
// live state management
UINT8 state() const { return m_irqmode ? m_key[0] : m_state; }
@@ -110,9 +110,8 @@ protected:
bool m_irqmode;
state_change_delegate m_state_change;
fd1094_decryption_cache m_cache;
- UINT16 * m_srcbase;
- UINT32 m_srcbytes;
- const UINT8 * m_key;
+ optional_region_ptr<UINT16> m_srcbase;
+ required_region_ptr<UINT8> m_key;
UINT8 m_masked_opcodes_lookup[2][65536/8/2];
// static tables
diff --git a/src/mame/machine/harddriv.cpp b/src/mame/machine/harddriv.cpp
index a9653cf34ea..5d8dc40966b 100644
--- a/src/mame/machine/harddriv.cpp
+++ b/src/mame/machine/harddriv.cpp
@@ -41,8 +41,6 @@ void harddriv_state::device_start()
//atarigen_state::machine_start();
/* predetermine memory regions */
- m_sim_memory = (UINT16 *)memregion("user1")->base();
- m_sim_memory_size = memregion("user1")->bytes() / 2;
m_adsp_pgm_memory_word = (UINT16 *)(reinterpret_cast<UINT8 *>(m_adsp_pgm_memory.target()) + 1);
init_video();
@@ -74,14 +72,14 @@ void harddriv_state::device_reset()
if (m_ds3sdsp.found())
{
- m_ds3sdsp->load_boot_data(m_ds3sdsp->region()->base(), m_ds3sdsp_pgm_memory);
+ m_ds3sdsp->load_boot_data(m_ds3sdsp_region->base(), m_ds3sdsp_pgm_memory);
m_ds3sdsp_timer_en = 0;
m_ds3sdsp_internal_timer->adjust(attotime::never);
}
if (m_ds3xdsp.found())
{
- m_ds3xdsp->load_boot_data(m_ds3xdsp->region()->base(), m_ds3xdsp_pgm_memory);
+ m_ds3xdsp->load_boot_data(m_ds3xdsp_region->base(), m_ds3xdsp_pgm_memory);
m_ds3xdsp_timer_en = 0;
m_ds3xdsp_internal_timer->adjust(attotime::never);
}
@@ -760,7 +758,7 @@ READ16_MEMBER( harddriv_state::hdadsp_special_r )
switch (offset & 7)
{
case 0: /* /SIMBUF */
- if (m_adsp_eprom_base + m_adsp_sim_address < m_sim_memory_size)
+ if (m_adsp_eprom_base + m_adsp_sim_address < m_sim_memory.length())
return m_sim_memory[m_adsp_eprom_base + m_adsp_sim_address++];
else
return 0xff;
@@ -862,7 +860,7 @@ WRITE16_MEMBER( harddriv_state::hd68k_ds3_control_w )
if (m_ds3sdsp.found())
{
m_ds3sdsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
- m_ds3sdsp->load_boot_data(m_ds3sdsp->region()->base(), m_ds3sdsp_pgm_memory);
+ m_ds3sdsp->load_boot_data(m_ds3sdsp_region->base(), m_ds3sdsp_pgm_memory);
if (val && !m_ds3_sreset)
{
@@ -882,7 +880,7 @@ WRITE16_MEMBER( harddriv_state::hd68k_ds3_control_w )
if (m_ds3xdsp.found())
{
m_ds3xdsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
- m_ds3xdsp->load_boot_data(m_ds3xdsp->region()->base(), m_ds3xdsp_pgm_memory);
+ m_ds3xdsp->load_boot_data(m_ds3xdsp_region->base(), m_ds3xdsp_pgm_memory);
}
break;
@@ -1190,7 +1188,7 @@ WRITE16_MEMBER( harddriv_state::hdds3_sdsp_control_w )
if (data & 0x200)
{
UINT32 page = (data >> 6) & 7;
- m_ds3sdsp->load_boot_data(m_ds3sdsp->region()->base() + (0x2000 * page), m_ds3sdsp_pgm_memory);
+ m_ds3sdsp->load_boot_data(m_ds3sdsp_region->base() + (0x2000 * page), m_ds3sdsp_pgm_memory);
m_ds3sdsp->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
data &= ~0x200;
}
@@ -1374,7 +1372,7 @@ READ16_MEMBER( harddriv_state::hdds3_special_r )
case 6:
logerror("ADSP r @ %04x\n", m_ds3_sim_address);
- if (m_ds3_sim_address < m_sim_memory_size)
+ if (m_ds3_sim_address < m_sim_memory.length())
return m_sim_memory[m_ds3_sim_address];
else
return 0xff;
diff --git a/src/mame/machine/naomibd.cpp b/src/mame/machine/naomibd.cpp
index 704c357d70f..f90c3d35077 100644
--- a/src/mame/machine/naomibd.cpp
+++ b/src/mame/machine/naomibd.cpp
@@ -3,7 +3,6 @@
#include "emu.h"
#include "naomibd.h"
-#include "machine/x76f100.h"
/*
Naomi ROM board info from ElSemi:
@@ -91,8 +90,8 @@ void naomi_board::device_start()
save_item(NAME(pio_ready));
save_item(NAME(dma_ready));
- if(eeprom_tag)
- eeprom = machine().device<x76f100_device>(eeprom_tag);
+ if (eeprom_tag != nullptr)
+ eeprom = owner()->subdevice<x76f100_device>(eeprom_tag);
else
eeprom = nullptr;
}
diff --git a/src/mame/machine/naomibd.h b/src/mame/machine/naomibd.h
index 1b4d2b705c0..8f0c07d3c09 100644
--- a/src/mame/machine/naomibd.h
+++ b/src/mame/machine/naomibd.h
@@ -4,6 +4,7 @@
#define _NAOMIBD_H_
#include "machine/naomig1.h"
+#include "machine/x76f100.h"
#define MCFG_NAOMI_BOARD_ADD(_tag, type, _eeprom_tag, _actel_tag, _irq_cb) \
MCFG_NAOMI_G1_ADD(_tag, type, _irq_cb) \
@@ -55,7 +56,7 @@ private:
bool pio_ready, dma_ready;
const char *eeprom_tag;
- class x76f100_device *eeprom;
+ x76f100_device *eeprom;
};
#endif
diff --git a/src/mame/machine/naomigd.h b/src/mame/machine/naomigd.h
index 6f9e434ec13..84a3225abb0 100644
--- a/src/mame/machine/naomigd.h
+++ b/src/mame/machine/naomigd.h
@@ -7,7 +7,7 @@
#define MCFG_NAOMI_GDROM_BOARD_ADD(_tag, _image_tag, _pic_tag, _eeprom_tag, _irq_cb) \
MCFG_NAOMI_BOARD_ADD(_tag, NAOMI_GDROM_BOARD, _eeprom_tag, NULL, _irq_cb) \
- naomi_gdrom_board::static_set_tags(*device, _image_tag, _pic_tag);
+ naomi_gdrom_board::static_set_tags(*device, "^" _image_tag, "^" _pic_tag);
class naomi_gdrom_board : public naomi_board
{
diff --git a/src/mame/machine/naomim1.cpp b/src/mame/machine/naomim1.cpp
index 7e205ce1ee7..a456bc8cdb8 100644
--- a/src/mame/machine/naomim1.cpp
+++ b/src/mame/machine/naomim1.cpp
@@ -13,15 +13,16 @@ DEVICE_ADDRESS_MAP_START(submap, 16, naomi_m1_board)
ADDRESS_MAP_END
naomi_m1_board::naomi_m1_board(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : naomi_board(mconfig, NAOMI_M1_BOARD, "Sega NAOMI M1 Board", tag, owner, clock, "naomi_m1_board", __FILE__)
+ : naomi_board(mconfig, NAOMI_M1_BOARD, "Sega NAOMI M1 Board", tag, owner, clock, "naomi_m1_board", __FILE__),
+ m_region(*this, DEVICE_SELF)
{
}
READ16_MEMBER(naomi_m1_board::actel_id_r)
{
- if (rombdid_tag && memregion(rombdid_tag) != nullptr)
+ if (rombdid_tag && owner()->memregion(rombdid_tag) != nullptr)
{
- const UINT8 *bdid = memregion(rombdid_tag)->base();
+ const UINT8 *bdid = owner()->memregion(rombdid_tag)->base();
return bdid[0] | (bdid[1] << 8);
}
diff --git a/src/mame/machine/naomim1.h b/src/mame/machine/naomim1.h
index 37c5a58739b..0e1730eee80 100644
--- a/src/mame/machine/naomim1.h
+++ b/src/mame/machine/naomim1.h
@@ -35,6 +35,8 @@ private:
UINT32 rom_cur_address, buffer_actual_size, avail_bits;
bool encryption, stream_ended, has_history;
+ required_memory_region m_region;
+
void gb_reset();
UINT32 lookb(int bits);
void skipb(int bits);
diff --git a/src/mame/machine/naomim2.cpp b/src/mame/machine/naomim2.cpp
index 516da16435e..e74da6573fd 100644
--- a/src/mame/machine/naomim2.cpp
+++ b/src/mame/machine/naomim2.cpp
@@ -113,7 +113,8 @@ const device_type NAOMI_M2_BOARD = &device_creator<naomi_m2_board>;
naomi_m2_board::naomi_m2_board(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: naomi_board(mconfig, NAOMI_M2_BOARD, "Sega NAOMI M2 Board", tag, owner, clock, "naomi_m2_board", __FILE__),
- m_cryptdevice(*this, "segam2crypt")
+ m_cryptdevice(*this, "segam2crypt"),
+ m_region(*this, DEVICE_SELF)
{
}
@@ -194,7 +195,7 @@ UINT16 naomi_m2_board::read_callback(UINT32 addr)
}
else {
- const UINT8 *base = m_region->base() + 2*addr;
+ const UINT8 *base = &m_region->u8(2*addr);
return base[1] | (base[0] << 8);
}
}
diff --git a/src/mame/machine/naomim2.h b/src/mame/machine/naomim2.h
index ae1bdf3fed8..8196e7e4ba7 100644
--- a/src/mame/machine/naomim2.h
+++ b/src/mame/machine/naomim2.h
@@ -32,6 +32,7 @@ protected:
private:
required_device<sega_315_5881_crypt_device> m_cryptdevice;
+ required_memory_region m_region;
};
extern const device_type NAOMI_M2_BOARD;
diff --git a/src/mame/machine/naomim4.cpp b/src/mame/machine/naomim4.cpp
index 40ced99ea5a..89d61ce08c3 100644
--- a/src/mame/machine/naomim4.cpp
+++ b/src/mame/machine/naomim4.cpp
@@ -47,24 +47,24 @@ DEVICE_ADDRESS_MAP_START(submap, 16, naomi_m4_board)
ADDRESS_MAP_END
naomi_m4_board::naomi_m4_board(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : naomi_board(mconfig, NAOMI_M4_BOARD, "Sega NAOMI M4 Board", tag, owner, clock, "naomi_m4_board", __FILE__)
+ : naomi_board(mconfig, NAOMI_M4_BOARD, "Sega NAOMI M4 Board", tag, owner, clock, "naomi_m4_board", __FILE__),
+ m_region(*this, DEVICE_SELF),
+ m_key_data(*this)
{
- key_tag = nullptr;
}
-void naomi_m4_board::static_set_tags(device_t &device, const char *_key_tag)
+void naomi_m4_board::static_set_tags(device_t &device, const char *key_tag)
{
naomi_m4_board &dev = downcast<naomi_m4_board &>(device);
- dev.key_tag = _key_tag;
+ dev.m_key_data.set_tag(key_tag);
}
void naomi_m4_board::device_start()
{
naomi_board::device_start();
- const UINT8 *key_data = memregion(key_tag)->base();
- subkey1 = (key_data[0x5e2] << 8) | key_data[0x5e0];
- subkey2 = (key_data[0x5e6] << 8) | key_data[0x5e4];
+ subkey1 = (m_key_data[0x5e2] << 8) | m_key_data[0x5e0];
+ subkey2 = (m_key_data[0x5e6] << 8) | m_key_data[0x5e4];
buffer = std::make_unique<UINT8[]>(BUFFER_SIZE);
enc_init();
@@ -134,9 +134,9 @@ void naomi_m4_board::board_get_buffer(UINT8 *&base, UINT32 &limit)
if (cfi_mode) {
int fpr_num = 0;
- if (rombdid_tag && memregion(rombdid_tag) != nullptr)
+ if (rombdid_tag && owner()->memregion(rombdid_tag) != nullptr)
{
- fpr_num = *memregion(rombdid_tag)->base() & 0x7f;
+ fpr_num = *owner()->memregion(rombdid_tag)->base() & 0x7f;
}
@@ -217,9 +217,9 @@ READ16_MEMBER(naomi_m4_board::m4_id_r)
{
UINT16 epr_flag = 0;
- if (rombdid_tag && memregion(rombdid_tag) != nullptr)
+ if (rombdid_tag != nullptr && owner()->memregion(rombdid_tag) != nullptr)
{
- epr_flag = *memregion(rombdid_tag)->base() & 0x80;
+ epr_flag = *owner()->memregion(rombdid_tag)->base() & 0x80;
}
diff --git a/src/mame/machine/naomim4.h b/src/mame/machine/naomim4.h
index 650ed901c24..461fa1779a5 100644
--- a/src/mame/machine/naomim4.h
+++ b/src/mame/machine/naomim4.h
@@ -7,14 +7,14 @@
#define MCFG_NAOMI_M4_BOARD_ADD(_tag, _key_tag, _eeprom_tag, _actel_tag, _irq_cb) \
MCFG_NAOMI_BOARD_ADD(_tag, NAOMI_M4_BOARD, _eeprom_tag, _actel_tag, _irq_cb) \
- naomi_m4_board::static_set_tags(*device, _key_tag);
+ naomi_m4_board::static_set_tags(*device, "^" _key_tag);
class naomi_m4_board : public naomi_board
{
public:
naomi_m4_board(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- static void static_set_tags(device_t &device, const char *_key_tag);
+ static void static_set_tags(device_t &device, const char *key_tag);
virtual DECLARE_ADDRESS_MAP(submap, 16) override;
@@ -33,7 +33,8 @@ private:
static const UINT8 k_sboxes[4][16];
- const char *key_tag;
+ required_memory_region m_region;
+ required_region_ptr<UINT8> m_key_data;
UINT16 subkey1, subkey2;
std::unique_ptr<UINT16[]> one_round;
diff --git a/src/mame/machine/naomirom.cpp b/src/mame/machine/naomirom.cpp
index 5f074d16ec6..ad356dd46e6 100644
--- a/src/mame/machine/naomirom.cpp
+++ b/src/mame/machine/naomirom.cpp
@@ -6,7 +6,8 @@
const device_type NAOMI_ROM_BOARD = &device_creator<naomi_rom_board>;
naomi_rom_board::naomi_rom_board(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : naomi_board(mconfig, NAOMI_ROM_BOARD, "Sega NAOMI ROM Board", tag, owner, clock, "naomi_rom_board", __FILE__)
+ : naomi_board(mconfig, NAOMI_ROM_BOARD, "Sega NAOMI ROM Board", tag, owner, clock, "naomi_rom_board", __FILE__),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/mame/machine/naomirom.h b/src/mame/machine/naomirom.h
index f23268cfa32..11f692200db 100644
--- a/src/mame/machine/naomirom.h
+++ b/src/mame/machine/naomirom.h
@@ -23,6 +23,7 @@ protected:
private:
UINT32 rom_cur_address;
+ required_memory_region m_region;
};
extern const device_type NAOMI_ROM_BOARD;
diff --git a/src/mame/machine/pc9801_118.cpp b/src/mame/machine/pc9801_118.cpp
index ee3a189b338..9b7191c40da 100644
--- a/src/mame/machine/pc9801_118.cpp
+++ b/src/mame/machine/pc9801_118.cpp
@@ -119,7 +119,7 @@ const rom_entry *pc9801_118_device::device_rom_region() const
pc9801_118_device::pc9801_118_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, PC9801_118, "pc9801_118", tag, owner, clock, "pc9801_118", __FILE__),
-// m_maincpu(*owner, "maincpu"),
+// m_maincpu(*this, "^maincpu"),
m_opn3(*this, "opn3")
{
}
diff --git a/src/mame/machine/pc9801_26.cpp b/src/mame/machine/pc9801_26.cpp
index 2f0b0351c7c..8eb8e0f7413 100644
--- a/src/mame/machine/pc9801_26.cpp
+++ b/src/mame/machine/pc9801_26.cpp
@@ -111,7 +111,7 @@ ioport_constructor pc9801_26_device::device_input_ports() const
pc9801_26_device::pc9801_26_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, PC9801_26, "pc9801_26", tag, owner, clock, "pc9801_26", __FILE__),
-// m_maincpu(*owner, "maincpu"),
+// m_maincpu(*this, "^maincpu"),
m_opn(*this, "opn")
{
}
diff --git a/src/mame/machine/segaic16.cpp b/src/mame/machine/segaic16.cpp
index 3cb068c70e6..611d8568a96 100644
--- a/src/mame/machine/segaic16.cpp
+++ b/src/mame/machine/segaic16.cpp
@@ -200,8 +200,8 @@ WRITE16_MEMBER( sega_16bit_common_base::philko_paletteram_w )
sega_315_5195_mapper_device::sega_315_5195_mapper_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, SEGA_315_5195_MEM_MAPPER, "Sega 315-5195 Memory Mapper", tag, owner, clock, "sega_315_5195", __FILE__),
- m_cputag(nullptr),
- m_cpu(nullptr),
+ m_cpu(*this),
+ m_cpuregion(*this),
m_space(nullptr),
m_decrypted_space(nullptr),
m_curregion(0)
@@ -217,7 +217,8 @@ sega_315_5195_mapper_device::sega_315_5195_mapper_device(const machine_config &m
void sega_315_5195_mapper_device::static_set_cputag(device_t &device, const char *cpu)
{
sega_315_5195_mapper_device &mapper = downcast<sega_315_5195_mapper_device &>(device);
- mapper.m_cputag = cpu;
+ mapper.m_cpu.set_tag(cpu);
+ mapper.m_cpuregion.set_tag(cpu);
}
@@ -392,7 +393,7 @@ void sega_315_5195_mapper_device::map_as_rom(UINT32 offset, UINT32 length, offs_
}
// don't map if the start is past the end of the ROM region
- offs_t romsize = m_cpu->region()->bytes();
+ offs_t romsize = m_cpuregion->bytes();
if (rgnoffset < romsize)
{
// clamp the end to the ROM size
@@ -408,7 +409,7 @@ void sega_315_5195_mapper_device::map_as_rom(UINT32 offset, UINT32 length, offs_
// configure the bank
memory_bank *bank = owner()->membank(bank_name);
memory_bank *decrypted_bank = owner()->membank(decrypted_bank_name);
- UINT8 *memptr = m_cpu->region()->base() + rgnoffset;
+ UINT8 *memptr = m_cpuregion->base() + rgnoffset;
bank->set_base(memptr);
// remember this bank, and decrypt if necessary
@@ -527,19 +528,14 @@ void sega_315_5195_mapper_device::device_start()
m_sound_read.bind_relative_to(*owner());
m_sound_write.bind_relative_to(*owner());
- // find our CPU
- m_cpu = siblingdevice<m68000_device>(m_cputag);
- if (m_cpu == nullptr)
- throw emu_fatalerror("Unable to find sibling device '%s'", m_cputag);
-
// if we are mapping an FD1089, tell all the banks
- fd1089_base_device *fd1089 = dynamic_cast<fd1089_base_device *>(m_cpu);
+ fd1089_base_device *fd1089 = dynamic_cast<fd1089_base_device *>(m_cpu.target());
if (fd1089 != nullptr)
for (auto & elem : m_banks)
elem.set_decrypt(fd1089);
// if we are mapping an FD1094, register for state change notifications and tell all the banks
- fd1094_device *fd1094 = dynamic_cast<fd1094_device *>(m_cpu);
+ fd1094_device *fd1094 = dynamic_cast<fd1094_device *>(m_cpu.target());
if (fd1094 != nullptr)
{
fd1094->notify_state_change(fd1094_device::state_change_delegate(FUNC(sega_315_5195_mapper_device::fd1094_state_change), this));
@@ -550,7 +546,7 @@ void sega_315_5195_mapper_device::device_start()
// find the address space that is to be mapped
m_space = &m_cpu->space(AS_PROGRAM);
if (m_space == nullptr)
- throw emu_fatalerror("Unable to find program address space on device '%s'", m_cputag);
+ throw emu_fatalerror("Unable to find program address space on device '%s'", m_cpu.finder_tag());
m_decrypted_space = m_cpu->has_space(AS_DECRYPTED_OPCODES) ? &m_cpu->space(AS_DECRYPTED_OPCODES) : nullptr;
diff --git a/src/mame/machine/segaic16.h b/src/mame/machine/segaic16.h
index 5b4b4812bd4..b647d1012a0 100644
--- a/src/mame/machine/segaic16.h
+++ b/src/mame/machine/segaic16.h
@@ -22,7 +22,7 @@
#define MCFG_SEGA_315_5195_MAPPER_ADD(_tag, _cputag, _class, _mapper, _read, _write) \
MCFG_DEVICE_ADD(_tag, SEGA_315_5195_MEM_MAPPER, 0) \
- sega_315_5195_mapper_device::static_set_cputag(*device, _cputag); \
+ sega_315_5195_mapper_device::static_set_cputag(*device, "^" _cputag); \
sega_315_5195_mapper_device::static_set_mapper(*device, sega_315_5195_mapper_device::mapper_delegate(&_class::_mapper, #_class "::" #_mapper, NULL, (_class *)0)); \
sega_315_5195_mapper_device::static_set_sound_readwrite(*device, sega_315_5195_mapper_device::sound_read_delegate(&_class::_read, #_class "::" #_read, NULL, (_class *)0), sega_315_5195_mapper_device::sound_write_delegate(&_class::_write, #_class "::" #_write, NULL, (_class *)0));
@@ -162,13 +162,13 @@ private:
void fd1094_state_change(UINT8 state);
// configuration
- const char * m_cputag;
+ required_device<m68000_device> m_cpu;
+ required_memory_region m_cpuregion;
mapper_delegate m_mapper;
sound_read_delegate m_sound_read;
sound_write_delegate m_sound_write;
// internal state
- m68000_device * m_cpu;
address_space * m_space;
address_space * m_decrypted_space;
UINT8 m_regs[0x20];
diff --git a/src/mame/machine/zs01.cpp b/src/mame/machine/zs01.cpp
index 613a3cdcc1a..2816d865ee0 100644
--- a/src/mame/machine/zs01.cpp
+++ b/src/mame/machine/zs01.cpp
@@ -32,6 +32,7 @@ const device_type ZS01 = &device_creator<zs01_device>;
zs01_device::zs01_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
: device_t( mconfig, ZS01, "Konami ZS01 PIC", tag, owner, clock, "zs01", __FILE__ ),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_cs( 0 ),
m_rst( 0 ),
m_scl( 0 ),
@@ -581,7 +582,7 @@ void zs01_device::nvram_default()
int expected_bytes = sizeof( m_response_to_reset ) + sizeof( m_command_key ) + sizeof( m_data_key ) + sizeof( m_data );
- if( !m_region )
+ if (!m_region.found())
{
logerror( "zs01(%s) region not found\n", tag() );
}
diff --git a/src/mame/machine/zs01.h b/src/mame/machine/zs01.h
index 2606cb5341e..b7266a20cbd 100644
--- a/src/mame/machine/zs01.h
+++ b/src/mame/machine/zs01.h
@@ -74,6 +74,7 @@ private:
// internal state
const char *m_ds2401_tag;
+ optional_memory_region m_region;
int m_cs;
int m_rst;
diff --git a/src/mame/video/atarirle.cpp b/src/mame/video/atarirle.cpp
index 05a3fe4737d..897e300533a 100644
--- a/src/mame/video/atarirle.cpp
+++ b/src/mame/video/atarirle.cpp
@@ -68,7 +68,8 @@ inline int atari_rle_objects_device::round_to_powerof2(int value)
atari_rle_objects_device::atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, ATARI_RLE_OBJECTS, "Atari RLE Motion Objects", tag, owner, clock, "atari_rle", __FILE__),
- device_video_interface(mconfig, *this)
+ device_video_interface(mconfig, *this),
+ m_rombase(*this, DEVICE_SELF)
{
}
@@ -218,8 +219,6 @@ void atari_rle_objects_device::device_start()
m_bitmapymask = m_bitmapheight - 1;
// set up the graphics ROM
- m_rombase = reinterpret_cast<UINT16 *>(m_region->base());
- m_romlength = m_region->bytes();
m_objectcount = count_objects();
// set up a cliprect
@@ -232,7 +231,7 @@ void atari_rle_objects_device::device_start()
// compute the checksums
memset(m_checksums, 0, sizeof(m_checksums));
- for (int sumchunk = 0; sumchunk < m_romlength / 0x20000; sumchunk++)
+ for (int sumchunk = 0; sumchunk < m_rombase.bytes() / 0x20000; sumchunk++)
{
const UINT16 *csbase = &m_rombase[0x10000 * sumchunk];
int cursum = 0;
@@ -345,7 +344,7 @@ void atari_rle_objects_device::build_rle_tables()
int atari_rle_objects_device::count_objects()
{
// first determine the lowest address of all objects
- int lowest_address = m_romlength;
+ int lowest_address = m_rombase.length();
for (int objoffset = 0; objoffset < lowest_address; objoffset += 4)
{
int offset = ((m_rombase[objoffset + 2] & 0xff) << 16) | m_rombase[objoffset + 3];
@@ -370,7 +369,7 @@ void atari_rle_objects_device::prescan_rle(int which)
// look up the offset
UINT16 *base = (UINT16 *)&m_rombase[which * 4];
- const UINT16 *end = m_rombase + m_romlength / 2;
+ const UINT16 *end = &m_rombase[0] + m_rombase.length();
info.xoffs = (INT16)base[0];
info.yoffs = (INT16)base[1];
@@ -384,7 +383,7 @@ void atari_rle_objects_device::prescan_rle(int which)
info.data = base = (UINT16 *)&m_rombase[offset];
// make sure it's valid
- if (offset < which * 4 || offset >= m_romlength)
+ if (offset < which * 4 || offset >= m_rombase.length())
{
info.data = nullptr;
return;
diff --git a/src/mame/video/atarirle.h b/src/mame/video/atarirle.h
index 5cf65931d04..86b07c598a9 100644
--- a/src/mame/video/atarirle.h
+++ b/src/mame/video/atarirle.h
@@ -159,8 +159,7 @@ private:
sprite_parameter m_vrammask; // mask for the VRAM target
// ROM information
- const UINT16 * m_rombase; // pointer to the base of the GFX ROM
- int m_romlength; // length of the GFX ROM
+ required_region_ptr<UINT16> m_rombase; // pointer to the base of the GFX ROM
int m_objectcount; // number of objects in the ROM
std::vector<object_info> m_info; // list of info records
diff --git a/src/mame/video/k051316.cpp b/src/mame/video/k051316.cpp
index 29493e7e69c..2bad3d043f9 100644
--- a/src/mame/video/k051316.cpp
+++ b/src/mame/video/k051316.cpp
@@ -106,8 +106,7 @@ GFXDECODE_END
k051316_device::k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, K051316, "K051316 PSAC", tag, owner, clock, "k051316", __FILE__),
device_gfx_interface(mconfig, *this, gfxinfo),
- m_zoom_rom(nullptr),
- m_zoom_size(0),
+ m_zoom_rom(*this, DEVICE_SELF),
m_dx(0),
m_dy(0),
m_wrap(0),
@@ -151,13 +150,6 @@ void k051316_device::set_bpp(device_t &device, int bpp)
void k051316_device::device_start()
{
- memory_region *ROM = region();
- if (ROM != nullptr)
- {
- m_zoom_rom = ROM->base();
- m_zoom_size = ROM->bytes();
- }
-
decode_gfx();
gfx(0)->set_colors(palette().entries() / gfx(0)->depth());
@@ -209,13 +201,13 @@ WRITE8_MEMBER( k051316_device::write )
READ8_MEMBER( k051316_device::rom_r )
{
- assert (m_zoom_size != 0);
+ assert (m_zoom_rom.found());
if ((m_ctrlram[0x0e] & 0x01) == 0)
{
int addr = offset + (m_ctrlram[0x0c] << 11) + (m_ctrlram[0x0d] << 19);
addr /= m_pixels_per_byte;
- addr &= m_zoom_size - 1;
+ addr &= m_zoom_rom.mask();
// popmessage("%s: offset %04x addr %04x", space.machine().describe_context(), offset, addr);
diff --git a/src/mame/video/k051316.h b/src/mame/video/k051316.h
index fc51fdb95fb..3363cfbdc41 100644
--- a/src/mame/video/k051316.h
+++ b/src/mame/video/k051316.h
@@ -84,8 +84,7 @@ private:
UINT8 m_ctrlram[16];
tilemap_t *m_tmap;
- UINT8 *m_zoom_rom;
- UINT32 m_zoom_size;
+ optional_region_ptr<UINT8> m_zoom_rom;
int m_dx, m_dy;
int m_wrap;
diff --git a/src/mame/video/k051960.cpp b/src/mame/video/k051960.cpp
index ae93ec9cb01..d5c899c3386 100644
--- a/src/mame/video/k051960.cpp
+++ b/src/mame/video/k051960.cpp
@@ -129,10 +129,8 @@ k051960_device::k051960_device(const machine_config &mconfig, const char *tag, d
: device_t(mconfig, K051960, "K051960 Sprite Generator", tag, owner, clock, "k051960", __FILE__),
device_gfx_interface(mconfig, *this, gfxinfo),
m_ram(nullptr),
- m_sprite_rom(nullptr),
- m_sprite_size(0),
- m_screen_tag(nullptr),
- m_screen(nullptr),
+ m_sprite_rom(*this, DEVICE_SELF),
+ m_screen(*this),
m_scanline_timer(nullptr),
m_irq_handler(*this),
m_firq_handler(*this),
@@ -171,10 +169,10 @@ void k051960_device::set_plane_order(device_t &device, int order)
// set_screen_tag - set screen we are attached to
//-------------------------------------------------
-void k051960_device::set_screen_tag(device_t &device, device_t *owner, const char *tag)
+void k051960_device::set_screen_tag(device_t &device, const char *tag)
{
k051960_device &dev = dynamic_cast<k051960_device &>(device);
- dev.m_screen_tag = tag;
+ dev.m_screen.set_tag(tag);
}
//-------------------------------------------------
@@ -184,7 +182,6 @@ void k051960_device::set_screen_tag(device_t &device, device_t *owner, const cha
void k051960_device::device_start()
{
// make sure our screen is started
- m_screen = m_owner->subdevice<screen_device>(m_screen_tag);
if (!m_screen->started())
throw device_missing_dependencies();
@@ -192,9 +189,6 @@ void k051960_device::device_start()
m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(k051960_device::scanline_callback), this));
m_scanline_timer->adjust(m_screen->time_until_pos(0));
- m_sprite_rom = region()->base();
- m_sprite_size = region()->bytes();
-
decode_gfx();
gfx(0)->set_colors(palette().entries() / gfx(0)->depth());
@@ -271,7 +265,7 @@ int k051960_device::k051960_fetchromdata( int byte )
m_k051960_cb(&code, &color, &pri, &shadow);
addr = (code << 7) | (off1 << 2) | byte;
- addr &= m_sprite_size - 1;
+ addr &= m_sprite_rom.mask();
// popmessage("%s: addr %06x", machine().describe_context(), addr);
diff --git a/src/mame/video/k051960.h b/src/mame/video/k051960.h
index 069f0f48440..a5b4939153b 100644
--- a/src/mame/video/k051960.h
+++ b/src/mame/video/k051960.h
@@ -22,7 +22,7 @@ typedef device_delegate<void (int *code, int *color, int *priority, int *shadow)
k051960_device::set_plane_order(*device, _order);
#define MCFG_K051960_SCREEN_TAG(_tag) \
- k051960_device::set_screen_tag(*device, owner, _tag);
+ k051960_device::set_screen_tag(*device, "^" _tag);
#define MCFG_K051960_IRQ_HANDLER(_devcb) \
devcb = &k051960_device::set_irq_handler(*device, DEVCB_##_devcb);
@@ -54,7 +54,7 @@ public:
// static configuration
static void set_k051960_callback(device_t &device, k051960_cb_delegate callback) { downcast<k051960_device &>(device).m_k051960_cb = callback; }
static void set_plane_order(device_t &device, int order);
- static void set_screen_tag(device_t &device, device_t *owner, const char *tag);
+ static void set_screen_tag(device_t &device, const char *tag);
/*
The callback is passed:
@@ -89,11 +89,9 @@ private:
// internal state
std::unique_ptr<UINT8[]> m_ram;
- UINT8 *m_sprite_rom;
- UINT32 m_sprite_size;
+ required_region_ptr<UINT8> m_sprite_rom;
- const char *m_screen_tag;
- screen_device *m_screen;
+ required_device<screen_device> m_screen;
emu_timer *m_scanline_timer;
k051960_cb_delegate m_k051960_cb;
diff --git a/src/mame/video/k052109.cpp b/src/mame/video/k052109.cpp
index 08e781da0f8..6530afb113a 100644
--- a/src/mame/video/k052109.cpp
+++ b/src/mame/video/k052109.cpp
@@ -178,9 +178,8 @@ k052109_device::k052109_device(const machine_config &mconfig, const char *tag, d
m_irq_enabled(0),
m_romsubbank(0),
m_scrollctrl(0),
- m_char_rom(nullptr),
- m_char_size(0),
- m_screen_tag(nullptr),
+ m_char_rom(*this, DEVICE_SELF),
+ m_screen(*this),
m_irq_handler(*this),
m_firq_handler(*this),
m_nmi_handler(*this)
@@ -205,21 +204,14 @@ void k052109_device::set_ram(device_t &device, bool ram)
void k052109_device::device_start()
{
- if (m_screen_tag != nullptr)
+ if (m_screen.found())
{
// make sure our screen is started
- screen_device *screen = m_owner->subdevice<screen_device>(m_screen_tag);
- if (!screen->started())
+ if (!m_screen->started())
throw device_missing_dependencies();
// and register a callback for vblank state
- screen->register_vblank_callback(vblank_state_delegate(FUNC(k052109_device::vblank_callback), this));
- }
-
- if (region() != nullptr)
- {
- m_char_rom = region()->base();
- m_char_size = region()->bytes();
+ m_screen->register_vblank_callback(vblank_state_delegate(FUNC(k052109_device::vblank_callback), this));
}
decode_gfx();
@@ -288,10 +280,10 @@ void k052109_device::device_reset()
// set_screen_tag - set screen we are attached to
//-------------------------------------------------
-void k052109_device::set_screen_tag(device_t &device, device_t *owner, const char *tag)
+void k052109_device::set_screen_tag(device_t &device, const char *tag)
{
k052109_device &dev = dynamic_cast<k052109_device &>(device);
- dev.m_screen_tag = tag;
+ dev.m_screen.set_tag(tag);
}
@@ -329,7 +321,7 @@ READ8_MEMBER( k052109_device::read )
}
else /* Punk Shot and TMNT read from 0000-1fff, Aliens from 2000-3fff */
{
- assert (m_char_size != 0);
+ assert (m_char_rom.found());
int code = (offset & 0x1fff) >> 5;
int color = m_romsubbank;
@@ -346,7 +338,7 @@ READ8_MEMBER( k052109_device::read )
m_k052109_cb(0, bank, &code, &color, &flags, &priority);
addr = (code << 5) + (offset & 0x1f);
- addr &= m_char_size - 1;
+ addr &= m_char_rom.mask();
// logerror("%04x: off = %04x sub = %02x (bnk = %x) adr = %06x\n", space.device().safe_pc(), offset, m_romsubbank, bank, addr);
diff --git a/src/mame/video/k052109.h b/src/mame/video/k052109.h
index 96f25882fa4..78156365838 100644
--- a/src/mame/video/k052109.h
+++ b/src/mame/video/k052109.h
@@ -14,7 +14,7 @@ typedef device_delegate<void (int layer, int bank, int *code, int *color, int *f
k052109_device::set_ram(*device, _ram);
#define MCFG_K052109_SCREEN_TAG(_tag) \
- k052109_device::set_screen_tag(*device, owner, _tag);
+ k052109_device::set_screen_tag(*device, "^" _tag);
#define MCFG_K052109_IRQ_HANDLER(_devcb) \
devcb = &k052109_device::set_irq_handler(*device, DEVCB_##_devcb);
@@ -36,7 +36,7 @@ public:
static void set_k052109_callback(device_t &device, k052109_cb_delegate callback) { downcast<k052109_device &>(device).m_k052109_cb = callback; }
static void set_ram(device_t &device, bool ram);
- static void set_screen_tag(device_t &device, device_t *owner, const char *tag);
+ static void set_screen_tag(device_t &device, const char *tag);
/*
The callback is passed:
@@ -96,10 +96,9 @@ private:
UINT8 m_irq_enabled;
UINT8 m_romsubbank, m_scrollctrl;
- UINT8 *m_char_rom;
- UINT32 m_char_size;
+ optional_region_ptr<UINT8> m_char_rom;
- const char *m_screen_tag;
+ optional_device<screen_device> m_screen;
k052109_cb_delegate m_k052109_cb;
diff --git a/src/mame/video/k053244_k053245.cpp b/src/mame/video/k053244_k053245.cpp
index 796eff8a3ec..59295af4227 100644
--- a/src/mame/video/k053244_k053245.cpp
+++ b/src/mame/video/k053244_k053245.cpp
@@ -86,7 +86,7 @@ k05324x_device::k05324x_device(const machine_config &mconfig, const char *tag, d
device_gfx_interface(mconfig, *this, gfxinfo),
m_ram(nullptr),
m_buffer(nullptr),
- m_sprite_rom(nullptr),
+ m_sprite_rom(*this, DEVICE_SELF),
m_dx(0),
m_dy(0),
m_rombank(0),
@@ -118,9 +118,6 @@ void k05324x_device::set_bpp(device_t &device, int bpp)
void k05324x_device::device_start()
{
- m_sprite_rom = region()->base();
- m_sprite_size = region()->bytes();
-
/* decode the graphics */
decode_gfx();
gfx(0)->set_colors(palette().entries() / gfx(0)->depth());
@@ -209,7 +206,7 @@ READ8_MEMBER( k05324x_device::k053244_r )
addr = (m_rombank << 19) | ((m_regs[11] & 0x7) << 18)
| (m_regs[8] << 10) | (m_regs[9] << 2)
| ((offset & 3) ^ 1);
- addr &= m_sprite_size - 1;
+ addr &= m_sprite_rom.mask();
// popmessage("%s: offset %02x addr %06x", machine().describe_context(), offset & 3, addr);
diff --git a/src/mame/video/k053244_k053245.h b/src/mame/video/k053244_k053245.h
index 924edc2a37f..47644806bb9 100644
--- a/src/mame/video/k053244_k053245.h
+++ b/src/mame/video/k053244_k053245.h
@@ -66,8 +66,7 @@ private:
// internal state
std::unique_ptr<UINT16[]> m_ram;
std::unique_ptr<UINT16[]> m_buffer;
- UINT8 *m_sprite_rom;
- UINT32 m_sprite_size;
+ required_region_ptr<UINT8> m_sprite_rom;
int m_dx, m_dy;
k05324x_cb_delegate m_k05324x_cb;
diff --git a/src/mame/video/k053250.cpp b/src/mame/video/k053250.cpp
index 09b59b99718..55896f2e9b6 100644
--- a/src/mame/video/k053250.cpp
+++ b/src/mame/video/k053250.cpp
@@ -7,7 +7,8 @@ const device_type K053250 = &device_creator<k053250_device>;
k053250_device::k053250_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, K053250, "K053250 LVC", tag, owner, clock, "k053250", __FILE__),
device_gfx_interface(mconfig, *this),
- device_video_interface(mconfig, *this)
+ device_video_interface(mconfig, *this),
+ m_rom(*this, DEVICE_SELF)
{
}
@@ -20,18 +21,12 @@ void k053250_device::static_set_offsets(device_t &device, int offx, int offy)
void k053250_device::unpack_nibbles()
{
- if(!m_region)
- throw emu_fatalerror("k053250 %s: no associated region found\n", tag());
+ m_unpacked_rom.resize(m_rom.length()*2);
- const UINT8 *base = m_region->base();
- int size = m_region->bytes();
-
- m_unpacked_rom.resize(size*2);
-
- for(int i=0; i<size; i++)
+ for (int i = 0; i < m_rom.length(); i++)
{
- m_unpacked_rom[2*i] = base[i] >> 4;
- m_unpacked_rom[2*i+1] = base[i] & 0xf;
+ m_unpacked_rom[2*i] = m_rom[i] >> 4;
+ m_unpacked_rom[2*i+1] = m_rom[i] & 0xf;
}
}
@@ -461,5 +456,5 @@ WRITE16_MEMBER(k053250_device::ram_w)
READ16_MEMBER(k053250_device::rom_r)
{
- return m_region->base()[0x80000 * m_regs[6] + 0x800 * m_regs[7] + offset/2];
+ return m_rom[0x80000 * m_regs[6] + 0x800 * m_regs[7] + offset/2];
}
diff --git a/src/mame/video/k053250.h b/src/mame/video/k053250.h
index 610c8577507..2e5e956aa4b 100644
--- a/src/mame/video/k053250.h
+++ b/src/mame/video/k053250.h
@@ -42,6 +42,7 @@ private:
int m_offx, m_offy;
// internal state
+ required_region_ptr<UINT8> m_rom;
dynamic_buffer m_unpacked_rom;
std::vector<UINT16> m_ram;
UINT16 *m_buffer[2];
diff --git a/src/mame/video/k054156_k054157_k056832.cpp b/src/mame/video/k054156_k054157_k056832.cpp
index b5dc7fd67fa..0511b8b8913 100644
--- a/src/mame/video/k054156_k054157_k056832.cpp
+++ b/src/mame/video/k054156_k054157_k056832.cpp
@@ -188,10 +188,9 @@ k056832_device::k056832_device(const machine_config &mconfig, const char *tag, d
//*m_pixmap[K056832_PAGE_COUNT],
//m_regs[0x20],
//m_regsb[4],
- m_rombase(nullptr),
+ m_rombase(*this),
m_num_gfx_banks(0),
m_cur_gfx_banks(0),
- m_gfx_memory_region(nullptr),
m_gfx_num(0),
m_bpp(-1),
m_big(0),
@@ -349,7 +348,7 @@ void k056832_device::device_start()
/* TODO: understand which elements MUST be init here (to keep correct layer
associations) and which ones can can be init at RESET, if any */
- create_gfx(m_gfx_memory_region, m_bpp, m_big);
+ create_gfx();
create_tilemaps();
@@ -610,11 +609,8 @@ void k056832_device::SetExtLinescroll( )
/* generic helper routine for ROM checksumming */
int k056832_device::rom_read_b( int offset, int blksize, int blksize2, int zerosec )
{
- UINT8 *rombase;
int base, ret;
- rombase = (UINT8 *)machine().root_device().memregion(m_gfx_memory_region)->base();
-
if ((m_rom_half) && (zerosec))
{
return 0;
@@ -631,11 +627,11 @@ int k056832_device::rom_read_b( int offset, int blksize, int blksize2, int zeros
if (m_rom_half)
{
- ret = rombase[base + 1];
+ ret = m_rombase[base + 1];
}
else
{
- ret = rombase[base];
+ ret = m_rombase[base];
m_rom_half = 1;
}
@@ -697,9 +693,6 @@ READ16_MEMBER( k056832_device::rom_word_r )
{
int addr = 0x2000 * m_cur_gfx_banks + 2 * offset;
- if (!m_rombase)
- m_rombase = space.machine().root_device().memregion(m_gfx_memory_region)->base();
-
return m_rombase[addr + 1] | (m_rombase[addr] << 8);
}
@@ -710,9 +703,6 @@ READ16_MEMBER( k056832_device::mw_rom_word_r )
int bank = 10240 * m_cur_gfx_banks;
int addr;
- if (!m_rombase)
- m_rombase = space.machine().root_device().memregion(m_gfx_memory_region)->base();
-
if (m_regsb[2] & 0x8)
{
// we want only the 2s
@@ -772,9 +762,6 @@ READ16_MEMBER( k056832_device::bishi_rom_word_r )
{
int addr = 0x4000 * m_cur_gfx_banks + offset;
- if (!m_rombase)
- m_rombase = space.machine().root_device().memregion(m_gfx_memory_region)->base();
-
return m_rombase[addr + 2] | (m_rombase[addr] << 8);
}
@@ -782,9 +769,6 @@ READ16_MEMBER( k056832_device::rom_word_8000_r )
{
int addr = 0x8000 * m_cur_gfx_banks + 2 * offset;
- if (!m_rombase)
- m_rombase = space.machine().root_device().memregion(m_gfx_memory_region)->base();
-
return m_rombase[addr + 2] | (m_rombase[addr] << 8);
}
@@ -792,9 +776,6 @@ READ16_MEMBER( k056832_device::old_rom_word_r )
{
int addr = 0x2000 * m_cur_gfx_banks + 2 * offset;
- if (!m_rombase)
- m_rombase = space.machine().root_device().memregion(m_gfx_memory_region)->base();
-
return m_rombase[addr + 1] | (m_rombase[addr] << 8);
}
@@ -1997,7 +1978,7 @@ READ16_MEMBER( k056832_device::b_word_r )
/***************************************************************************/
-void k056832_device::create_gfx(const char *gfx_memory_region, int bpp, int big)
+void k056832_device::create_gfx()
{
int gfx_index = 0;
int i;
@@ -2065,47 +2046,45 @@ void k056832_device::create_gfx(const char *gfx_memory_region, int bpp, int big)
8*8*4
};
- m_bpp = bpp;
-
/* handle the various graphics formats */
- i = (big) ? 8 : 16;
+ i = (m_big) ? 8 : 16;
/* decode the graphics */
- switch (bpp)
+ switch (m_bpp)
{
case K056832_BPP_4:
- total = machine().root_device().memregion(gfx_memory_region)->bytes() / (i*4);
- konami_decode_gfx(*this, gfx_index, machine().root_device().memregion(gfx_memory_region)->base(), total, &charlayout4, 4);
+ total = m_rombase.bytes() / (i*4);
+ konami_decode_gfx(*this, gfx_index, &m_rombase[0], total, &charlayout4, 4);
break;
case K056832_BPP_5:
- total = machine().root_device().memregion(gfx_memory_region)->bytes() / (i*5);
- konami_decode_gfx(*this, gfx_index, machine().root_device().memregion(gfx_memory_region)->base(), total, &charlayout5, 5);
+ total = m_rombase.bytes() / (i*5);
+ konami_decode_gfx(*this, gfx_index, &m_rombase[0], total, &charlayout5, 5);
break;
case K056832_BPP_6:
- total = machine().root_device().memregion(gfx_memory_region)->bytes() / (i*6);
- konami_decode_gfx(*this, gfx_index, machine().root_device().memregion(gfx_memory_region)->base(), total, &charlayout6, 6);
+ total = m_rombase.bytes() / (i*6);
+ konami_decode_gfx(*this, gfx_index, &m_rombase[0], total, &charlayout6, 6);
break;
case K056832_BPP_8:
- total = machine().root_device().memregion(gfx_memory_region)->bytes() / (i*8);
- konami_decode_gfx(*this, gfx_index, machine().root_device().memregion(gfx_memory_region)->base(), total, &charlayout8, 8);
+ total = m_rombase.bytes() / (i*8);
+ konami_decode_gfx(*this, gfx_index, &m_rombase[0], total, &charlayout8, 8);
break;
case K056832_BPP_8LE:
- total = machine().root_device().memregion(gfx_memory_region)->bytes() / (i*8);
- konami_decode_gfx(*this, gfx_index, machine().root_device().memregion(gfx_memory_region)->base(), total, &charlayout8le, 8);
+ total = m_rombase.bytes() / (i*8);
+ konami_decode_gfx(*this, gfx_index, &m_rombase[0], total, &charlayout8le, 8);
break;
case K056832_BPP_8TASMAN:
- total = machine().root_device().memregion(gfx_memory_region)->bytes() / (i*8);
- konami_decode_gfx(*this, gfx_index, machine().root_device().memregion(gfx_memory_region)->base(), total, &charlayout8, 8);
+ total = m_rombase.bytes() / (i*8);
+ konami_decode_gfx(*this, gfx_index, &m_rombase[0], total, &charlayout8, 8);
break;
case K056832_BPP_4dj:
- total = machine().root_device().memregion(gfx_memory_region)->bytes() / (i*4);
- konami_decode_gfx(*this, gfx_index, machine().root_device().memregion(gfx_memory_region)->base(), total, &charlayout4dj, 4);
+ total = m_rombase.bytes() / (i*4);
+ konami_decode_gfx(*this, gfx_index, &m_rombase[0], total, &charlayout4dj, 4);
break;
default:
@@ -2115,11 +2094,9 @@ void k056832_device::create_gfx(const char *gfx_memory_region, int bpp, int big)
gfx(gfx_index)->set_granularity(16); /* override */
gfx(gfx_index)->set_colors(palette().entries() / 16);
- m_gfx_memory_region = gfx_memory_region;
m_gfx_num = gfx_index;
- m_rombase = machine().root_device().memregion(gfx_memory_region)->base();
- m_num_gfx_banks = machine().root_device().memregion(gfx_memory_region)->bytes() / 0x2000;
+ m_num_gfx_banks = m_rombase.bytes() / 0x2000;
m_cur_gfx_banks = 0;
m_use_ext_linescroll = 0;
m_uses_tile_banks = 0;
diff --git a/src/mame/video/k054156_k054157_k056832.h b/src/mame/video/k054156_k054157_k056832.h
index e0c6e87b3f4..ce6ed1945d5 100644
--- a/src/mame/video/k054156_k054157_k056832.h
+++ b/src/mame/video/k054156_k054157_k056832.h
@@ -17,7 +17,7 @@ typedef device_delegate<void (int layer, int *code, int *color, int *flags)> k05
k056832_device::set_k056832_callback(*device, k056832_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
#define MCFG_K056832_CONFIG(_gfx_reg, _bpp, _big, _djmain_hack, _k055555) \
- k056832_device::set_config(*device, _gfx_reg, _bpp, _big, _djmain_hack, _k055555);
+ k056832_device::set_config(*device, "^" _gfx_reg, _bpp, _big, _djmain_hack, _k055555);
#define K056832_PAGE_COUNT 16
@@ -48,7 +48,7 @@ public:
static void set_config(device_t &device, const char *gfx_reg, int bpp, int big, int djmain_hack, const char *k055555)
{
k056832_device &dev = downcast<k056832_device &>(device);
- dev.m_gfx_memory_region = gfx_reg;
+ dev.m_rombase.set_tag(gfx_reg);
dev.m_bpp = bpp;
dev.m_big = big;
dev.m_djmain_hack = djmain_hack;
@@ -127,15 +127,13 @@ private:
UINT16 m_regs[0x20]; // 157/832 regs group 1
UINT16 m_regsb[4]; // 157/832 regs group 2, board dependent
- UINT8 * m_rombase; // pointer to tile gfx data
+ required_region_ptr<UINT8> m_rombase; // pointer to tile gfx data
int m_num_gfx_banks; // depends on size of graphics ROMs
int m_cur_gfx_banks; // cached info for K056832_regs[0x1a]
k056832_cb_delegate m_k056832_cb;
- //FIXME: device should be updated to use device_gfx_interface to get rid of most of these!
- const char *m_gfx_memory_region;
int m_gfx_num;
int m_bpp;
int m_big;
@@ -210,7 +208,7 @@ private:
template<class _BitmapClass>
void tilemap_draw_common(screen_device &screen, _BitmapClass &bitmap, const rectangle &cliprect, int layer, UINT32 flags, UINT32 priority);
- void create_gfx(const char *gfx_memory_region, int bpp, int big);
+ void create_gfx();
void create_tilemaps();
void finalize_init();
diff --git a/src/mame/video/sega16sp.cpp b/src/mame/video/sega16sp.cpp
index 3629072e2e5..8f5e8e6de75 100644
--- a/src/mame/video/sega16sp.cpp
+++ b/src/mame/video/sega16sp.cpp
@@ -96,6 +96,7 @@ WRITE16_MEMBER( sega_16bit_sprite_device::draw_write )
sega_hangon_sprite_device::sega_hangon_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: sega_16bit_sprite_device(mconfig, SEGA_HANGON_SPRITES, "Sega Custom Sprites (Hang On)", tag, owner, "sega_hangon_sprite", __FILE__)
+ , m_sprite_region_ptr(*this, DEVICE_SELF)
{
set_local_origin(189, -1);
}
@@ -141,8 +142,8 @@ void sega_hangon_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
//
// render the sprites in order
- const UINT16 *spritebase = reinterpret_cast<const UINT16 *>(region()->base());
- UINT8 numbanks = region()->bytes() / 0x10000;
+ const UINT16 *spritebase = &m_sprite_region_ptr[0];
+ UINT8 numbanks = m_sprite_region_ptr.bytes() / 0x10000;
const UINT8 *zoom = memregion("zoom")->base();
UINT16 *ramend = spriteram() + spriteram_elements();
for (UINT16 *data = spriteram(); data < ramend; data += 8)
@@ -272,6 +273,7 @@ void sega_hangon_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
sega_sharrier_sprite_device::sega_sharrier_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: sega_16bit_sprite_device(mconfig, SEGA_SHARRIER_SPRITES, "Sega Custom Sprites (Space Harrier)", tag, owner, "sega_sharrier_sprite", __FILE__)
+ , m_sprite_region_ptr(*this, DEVICE_SELF)
{
set_local_origin(189, -1);
}
@@ -320,8 +322,8 @@ void sega_sharrier_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &cl
//
// render the sprites in order
- const UINT32 *spritebase = reinterpret_cast<const UINT32 *>(region()->base());
- UINT8 numbanks = region()->bytes() / 0x20000;
+ const UINT32 *spritebase = &m_sprite_region_ptr[0];
+ UINT8 numbanks = m_sprite_region_ptr.bytes() / 0x20000;
const UINT8 *zoom = memregion("zoom")->base();
UINT16 *ramend = spriteram() + spriteram_elements();
for (UINT16 *data = spriteram(); data < ramend; data += 8)
@@ -459,6 +461,7 @@ void sega_sharrier_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &cl
sega_sys16a_sprite_device::sega_sys16a_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: sega_16bit_sprite_device(mconfig, SEGA_SYS16A_SPRITES, "Sega System 16A Sprites", tag, owner, "sega_sys16a_sprite", __FILE__)
+ , m_sprite_region_ptr(*this, DEVICE_SELF)
{
set_local_origin(189, -1, -189, -1);
}
@@ -503,8 +506,8 @@ void sega_sys16a_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
//
// render the sprites in order
- const UINT16 *spritebase = reinterpret_cast<const UINT16 *>(region()->base());
- UINT8 numbanks = region()->bytes() / 0x10000;
+ const UINT16 *spritebase = &m_sprite_region_ptr[0];
+ UINT8 numbanks = m_sprite_region_ptr.bytes() / 0x10000;
UINT16 *ramend = spriteram() + spriteram_elements();
for (UINT16 *data = spriteram(); data < ramend; data += 8)
{
@@ -638,6 +641,7 @@ void sega_sys16a_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
bootleg_sys16a_sprite_device::bootleg_sys16a_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: sega_16bit_sprite_device(mconfig, BOOTLEG_SYS16A_SPRITES, "Sega System 16A Sprites (Bootleg)", tag, owner, "bootleg_sys16a_sprite", __FILE__)
+ , m_sprite_region_ptr(*this, DEVICE_SELF)
{
m_addrmap[0] = 0;
m_addrmap[1] = 1;
@@ -689,8 +693,8 @@ void bootleg_sys16a_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &c
//
// render the sprites in order
- const UINT16 *spritebase = reinterpret_cast<const UINT16 *>(region()->base());
- UINT8 numbanks = region()->bytes() / 0x10000;
+ const UINT16 *spritebase = &m_sprite_region_ptr[0];
+ UINT8 numbanks = m_sprite_region_ptr.bytes() / 0x10000;
UINT16 *ramend = spriteram() + spriteram_elements();
for (UINT16 *data = spriteram(); data < ramend; data += 8)
{
@@ -826,7 +830,7 @@ void bootleg_sys16a_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &c
sega_sys16b_sprite_device::sega_sys16b_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: sega_16bit_sprite_device(mconfig, SEGA_SYS16B_SPRITES, "Sega System 16B Sprites", tag, owner, "sega_16bit_sprite", __FILE__)
- , m_sprite_region_ptr(*this, ":sprites")
+ , m_sprite_region_ptr(*this, DEVICE_SELF)
{
set_local_origin(184, 0x00, -184, 0);
}
@@ -1022,14 +1026,16 @@ void sega_sys16b_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
sega_outrun_sprite_device::sega_outrun_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: sega_16bit_sprite_device(mconfig, SEGA_OUTRUN_SPRITES, "Sega Custom Sprites (Out Run)", tag, owner, "sega_outrun_sprite", __FILE__),
- m_is_xboard(false)
+ m_is_xboard(false),
+ m_sprite_region_ptr(*this, DEVICE_SELF)
{
set_local_origin(189, 0x00);
}
sega_outrun_sprite_device::sega_outrun_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, bool xboard_variant, const char *shortname, const char *source)
: sega_16bit_sprite_device(mconfig, SEGA_XBOARD_SPRITES, "Sega X-Board Sprites", tag, owner, shortname, source),
- m_is_xboard(true)
+ m_is_xboard(true),
+ m_sprite_region_ptr(*this, DEVICE_SELF)
{
set_local_origin(190, 0x00);
}
@@ -1090,8 +1096,8 @@ void sega_outrun_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
set_origin(m_xoffs, m_yoffs);
// render the sprites in order
- const UINT32 *spritebase = reinterpret_cast<const UINT32 *>(region()->base());
- UINT8 numbanks = region()->bytes() / 0x40000;
+ const UINT32 *spritebase = &m_sprite_region_ptr[0];
+ UINT8 numbanks = m_sprite_region_ptr.bytes() / 0x40000;
UINT16 *ramend = buffer() + spriteram_elements();
for (UINT16 *data = buffer(); data < ramend; data += 8)
{
@@ -1235,6 +1241,7 @@ void sega_outrun_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
sega_yboard_sprite_device::sega_yboard_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: sega_16bit_sprite_device(mconfig, SEGA_YBOARD_SPRITES, "Sega Y-Board Sprites", tag, owner, "sega_yboard_sprite", __FILE__)
+ , m_sprite_region_ptr(*this, DEVICE_SELF)
{
set_local_origin(0x600, 0x600);
}
@@ -1293,8 +1300,8 @@ void sega_yboard_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
memset(visited, 0, sizeof(visited));
// render the sprites in order
- const UINT64 *spritebase = reinterpret_cast<const UINT64 *>(region()->base());
- UINT8 numbanks = region()->bytes() / 0x80000;
+ const UINT64 *spritebase = &m_sprite_region_ptr[0];
+ UINT8 numbanks = m_sprite_region_ptr.bytes() / 0x80000;
int next = 0;
for (UINT16 *data = spriteram(); !(data[0] & 0x8000) && !visited[next]; data = spriteram() + next * 8)
{
diff --git a/src/mame/video/sega16sp.h b/src/mame/video/sega16sp.h
index ed758b1299f..e5f50143ba1 100644
--- a/src/mame/video/sega16sp.h
+++ b/src/mame/video/sega16sp.h
@@ -130,6 +130,9 @@ public:
protected:
// subclass overrides
virtual void draw(bitmap_ind16 &bitmap, const rectangle &cliprect) override;
+
+ // memory regions
+ required_region_ptr<UINT16> m_sprite_region_ptr;
};
@@ -144,6 +147,9 @@ public:
protected:
// subclass overrides
virtual void draw(bitmap_ind16 &bitmap, const rectangle &cliprect) override;
+
+ // memory regions
+ required_region_ptr<UINT32> m_sprite_region_ptr;
};
@@ -157,11 +163,13 @@ public:
protected:
sega_outrun_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, bool xboard_variant, const char *shortname, const char *source);
+protected:
// subclass overrides
virtual void draw(bitmap_ind16 &bitmap, const rectangle &cliprect) override;
// configuration
bool m_is_xboard;
+ required_region_ptr<UINT32> m_sprite_region_ptr;
};
class sega_xboard_sprite_device : public sega_outrun_sprite_device
@@ -183,6 +191,9 @@ public:
protected:
// subclass overrides
virtual void draw(bitmap_ind16 &bitmap, const rectangle &cliprect) override;
+
+ // memory regions
+ required_region_ptr<UINT16> m_sprite_region_ptr;
};
@@ -201,6 +212,9 @@ protected:
// subclass overrides
virtual void draw(bitmap_ind16 &bitmap, const rectangle &cliprect) override;
+ // memory regions
+ required_region_ptr<UINT16> m_sprite_region_ptr;
+
// internal state
UINT8 m_addrmap[8];
};
@@ -236,7 +250,8 @@ protected:
// subclass overrides
virtual void draw(bitmap_ind16 &bitmap, const rectangle &cliprect) override;
- rotate_info* m_segaic16_rotate;
+ required_region_ptr<UINT64> m_sprite_region_ptr;
+ rotate_info* m_segaic16_rotate;
};
diff --git a/src/mame/video/tc0150rod.cpp b/src/mame/video/tc0150rod.cpp
index 6077df445e3..c6bcd8512af 100644
--- a/src/mame/video/tc0150rod.cpp
+++ b/src/mame/video/tc0150rod.cpp
@@ -16,7 +16,7 @@ const device_type TC0150ROD = &device_creator<tc0150rod_device>;
tc0150rod_device::tc0150rod_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, TC0150ROD, "Taito TC0150ROD", tag, owner, clock, "tc0150rod", __FILE__),
- m_roadgfx(nullptr)
+ m_roadgfx(*this, DEVICE_SELF, 0x40000)
{
}
@@ -29,9 +29,6 @@ void tc0150rod_device::device_start()
m_ram.resize(TC0150ROD_RAM_SIZE / 2);
memset(&m_ram[0], 0, TC0150ROD_RAM_SIZE);
save_item(NAME(m_ram));
-
- m_roadgfx = (UINT16 *)region()->base();
- assert(m_roadgfx);
}
diff --git a/src/mame/video/tc0150rod.h b/src/mame/video/tc0150rod.h
index 723e97dea7c..a6c2b653a64 100644
--- a/src/mame/video/tc0150rod.h
+++ b/src/mame/video/tc0150rod.h
@@ -20,7 +20,7 @@ protected:
private:
// internal state
std::vector<UINT16> m_ram;
- UINT16 *m_roadgfx;
+ required_region_ptr<UINT16> m_roadgfx;
};
extern const device_type TC0150ROD;
diff --git a/src/mame/video/vtvideo.cpp b/src/mame/video/vtvideo.cpp
index 45bcfe5da79..c182bd05bb0 100644
--- a/src/mame/video/vtvideo.cpp
+++ b/src/mame/video/vtvideo.cpp
@@ -78,7 +78,7 @@ vt100_video_device::vt100_video_device(const machine_config &mconfig, device_typ
device_video_interface(mconfig, *this),
m_read_ram(*this),
m_write_clear_video_interrupt(*this),
-m_char_rom_tag(""),
+m_char_rom(*this),
m_palette(*this, "palette")
{
}
@@ -89,7 +89,7 @@ vt100_video_device::vt100_video_device(const machine_config &mconfig, const char
device_video_interface(mconfig, *this),
m_read_ram(*this),
m_write_clear_video_interrupt(*this),
-m_char_rom_tag(""),
+m_char_rom(*this),
m_palette(*this, "palette")
{
}
@@ -111,9 +111,6 @@ void vt100_video_device::device_start()
m_read_ram.resolve_safe(0);
m_write_clear_video_interrupt.resolve_safe();
- m_gfx = machine().root_device().memregion(m_char_rom_tag)->base();
- assert(m_gfx != nullptr);
-
// LBA7 is scan line frequency update
machine().scheduler().timer_pulse(attotime::from_nsec(31778), timer_expired_delegate(FUNC(vt100_video_device::lba7_change), this));
@@ -425,7 +422,7 @@ void vt100_video_device::display_char(bitmap_ind16 &bitmap, UINT8 code, int x, i
// modify line since that is how it is stored in rom
if (j == 0) j = 15; else j = j - 1;
- line = m_gfx[(code & 0x7f) * 16 + j];
+ line = m_char_rom[(code & 0x7f) * 16 + j];
if (m_basic_attribute == 1)
{
@@ -659,7 +656,7 @@ void rainbow_video_device::display_char(bitmap_ind16 &bitmap, UINT8 code, int x,
// modify line since that is how it is stored in rom
if (j == 0) j = 15; else j = j - 1;
- line = m_gfx[(code << 4) + j]; // code * 16
+ line = m_char_rom[(code << 4) + j]; // code * 16
// UNDERLINED CHARACTERS (CASE 5 - different in 1 line):
back_intensity = back_default_intensity; // 0, 1, 2
diff --git a/src/mame/video/vtvideo.h b/src/mame/video/vtvideo.h
index 0c29e0637e8..981e271b103 100644
--- a/src/mame/video/vtvideo.h
+++ b/src/mame/video/vtvideo.h
@@ -25,7 +25,7 @@ public:
template<class _Object> static devcb_base &set_ram_rd_callback(device_t &device, _Object object) { return downcast<vt100_video_device &>(device).m_read_ram.set_callback(object); }
template<class _Object> static devcb_base &set_clear_video_irq_wr_callback(device_t &device, _Object object) { return downcast<vt100_video_device &>(device).m_write_clear_video_interrupt.set_callback(object); }
- static void set_chargen_tag(device_t &device, const char *tag) { downcast<vt100_video_device &>(device).m_char_rom_tag = tag; }
+ static void set_chargen_tag(device_t &device, const char *tag) { downcast<vt100_video_device &>(device).m_char_rom.set_tag(tag); }
DECLARE_READ8_MEMBER(lba7_r);
DECLARE_WRITE8_MEMBER(dc012_w);
@@ -47,8 +47,6 @@ protected:
devcb_read8 m_read_ram;
devcb_write8 m_write_clear_video_interrupt;
- UINT8 *m_gfx; /* content of char rom */
-
int m_lba7;
bool MHFU_FLAG;
@@ -68,7 +66,7 @@ protected:
UINT8 m_frequency;
UINT8 m_interlaced;
- const char *m_char_rom_tag; /* character rom region */
+ required_region_ptr<UINT8> m_char_rom; /* character rom region */
required_device<palette_device> m_palette;
bool m_notify_vblank;
@@ -102,7 +100,7 @@ extern const device_type RAINBOW_VIDEO;
#define MCFG_VT_SET_SCREEN MCFG_VIDEO_SET_SCREEN
#define MCFG_VT_CHARGEN(_tag) \
- vt100_video_device::set_chargen_tag(*device, _tag);
+ vt100_video_device::set_chargen_tag(*device, "^" _tag);
#define MCFG_VT_VIDEO_RAM_CALLBACK(_read) \
devcb = &vt100_video_device::set_ram_rd_callback(*device, DEVCB_##_read);