summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2016-04-07 18:59:38 -0400
committer AJR <ajrhacker@users.noreply.github.com>2016-04-07 18:59:38 -0400
commitc0f366c61374775f8f8b7661e84705b568134dea (patch)
tree626e95fa31e6e8480983abbe305c0415ded783d2 /src/mame
parent5933d47ed740fd08c2f66f37fdca4f95e08df3d4 (diff)
Devfind revision phase 1, cleaning out some legacy stuff
- Eliminate the cached device_t::m_region pointer and its region() getter method. Devices that need to bind to a region with the same tag should use optional/required_memory_region or optional/required_region_ptr with DEVICE_SELF as the subtag; this improves error checking. (DEVICE_SELF has been moved to device.h for greater visibility in the source.) - Allow required/optional_region_ptr to specify a specific length which must match that of the region found. - Implement finder_base::finder_tag() getter for diagnostic purposes. - Perform some (not very efficient) validity checks on memory region finders instead of allowing them to automatically pass. - Privatize device_memory_interface::m_addrspace.
Diffstat (limited to 'src/mame')
-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
65 files changed, 286 insertions, 359 deletions
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);