diff options
| author | 2018-04-30 23:32:41 +1000 | |
|---|---|---|
| committer | 2018-04-30 23:32:41 +1000 | |
| commit | b60c852f119db04564731fa86d73e0a986771258 (patch) | |
| tree | f3f48148a13484a407b7054c78239258708c5a18 /src/emu/divideo.cpp | |
| parent | 89b356a0f5d874f2cabe2e0a96ccfb611b735109 (diff) | |
Set finder tag relative to current device being configured rather than
the finder's owner. This meand you no longer need to care about the
your relationship to the object being configured and a lot of ^ and :
can disappear. There's a bit reduction in string pasting in macros from
this.
Yes, I have to make this apply to devcb etc. as well, but that's a job
for another day.
There's probably at least one thing broken by this where optional
objects are involved. Most things can be solved by just getting rid of
the now-problematic ^ and : prefixes.
Diffstat (limited to 'src/emu/divideo.cpp')
| -rw-r--r-- | src/emu/divideo.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/emu/divideo.cpp b/src/emu/divideo.cpp index 6a06aa3e857..66cbd6105e9 100644 --- a/src/emu/divideo.cpp +++ b/src/emu/divideo.cpp @@ -25,10 +25,11 @@ const char device_video_interface::s_unconfigured_screen_tag[] = "!!UNCONFIGURED //------------------------------------------------- device_video_interface::device_video_interface(const machine_config &mconfig, device_t &device, bool screen_required) - : device_interface(device, "video"), - m_screen_required(screen_required), - m_screen_tag(s_unconfigured_screen_tag), - m_screen(nullptr) + : device_interface(device, "video") + , m_screen_required(screen_required) + , m_screen_base(&device) + , m_screen_tag(s_unconfigured_screen_tag) + , m_screen(nullptr) { } @@ -42,6 +43,13 @@ device_video_interface::~device_video_interface() } +void device_video_interface::set_screen(const char *tag) +{ + m_screen_base = &device().mconfig().current_device(); + m_screen_tag = tag; +} + + //------------------------------------------------- // interface_validity_check - validation for a // device after the configuration has been @@ -52,19 +60,18 @@ void device_video_interface::interface_validity_check(validity_checker &valid) c { // only look up screens if we haven't explicitly requested no screen screen_device *screen = nullptr; - if (m_screen_tag != nullptr) + if (m_screen_tag) { - // find the screen device if explicitly configured if (strcmp(m_screen_tag, s_unconfigured_screen_tag) != 0) { - screen = device().siblingdevice<screen_device>(m_screen_tag); - if (screen == nullptr) + // find the screen device if explicitly configured + screen = m_screen_base->subdevice<screen_device>(m_screen_tag); + if (!screen) osd_printf_error("Screen '%s' not found, explicitly set for device '%s'\n", m_screen_tag, device().tag()); } - - // otherwise, look for a single match else { + // otherwise, look for a single match screen_device_iterator iter(device().mconfig().root_device()); screen = iter.first(); if (iter.count() > 1) @@ -73,7 +80,7 @@ void device_video_interface::interface_validity_check(validity_checker &valid) c } // error if no screen is found - if (screen == nullptr && m_screen_required) + if (!screen && m_screen_required) osd_printf_error("Device '%s' requires a screen\n", device().tag()); } @@ -86,19 +93,18 @@ void device_video_interface::interface_validity_check(validity_checker &valid) c void device_video_interface::interface_pre_start() { // only look up screens if we haven't explicitly requested no screen - if (m_screen_tag != nullptr) + if (m_screen_tag) { - // find the screen device if explicitly configured if (strcmp(m_screen_tag, s_unconfigured_screen_tag) != 0) { - m_screen = device().siblingdevice<screen_device>(m_screen_tag); - if (m_screen == nullptr) + // find the screen device if explicitly configured + m_screen = m_screen_base->subdevice<screen_device>(m_screen_tag); + if (!m_screen) throw emu_fatalerror("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag()); } - - // otherwise, look for a single match else { + // otherwise, look for a single match screen_device_iterator iter(device().machine().root_device()); m_screen = iter.first(); if (iter.count() > 1) @@ -107,21 +113,19 @@ void device_video_interface::interface_pre_start() } // fatal error if no screen is found - if (m_screen == nullptr && m_screen_required) + if (!m_screen) throw emu_fatalerror("Device '%s' requires a screen", device().tag()); // if we have a screen and it's not started, wait for it device_palette_interface *palintf; - if (m_screen != nullptr && !m_screen->started()) + if (m_screen && !m_screen->started()) { // avoid circular dependency if we are also a palette device if (!device().interface(palintf)) throw device_missing_dependencies(); - else - { - // no other palette may be specified - if (m_screen->has_palette() && palintf != &m_screen->palette()) - throw emu_fatalerror("Device '%s' cannot control screen '%s' with palette '%s'", device().tag(), m_screen_tag, m_screen->palette().device().tag()); - } + + // no other palette may be specified + if (m_screen->has_palette() && palintf != &m_screen->palette()) + throw emu_fatalerror("Device '%s' cannot control screen '%s' with palette '%s'", device().tag(), m_screen_tag, m_screen->palette().device().tag()); } } |
