Now setting NULL explicitly for the screen tag will prevent the video

interface from auto-finding the target screen.
This commit is contained in:
Aaron Giles 2013-07-26 08:35:00 +00:00
parent ec07fb1022
commit d1ddcb34c4
2 changed files with 48 additions and 31 deletions

View File

@ -40,6 +40,9 @@
#include "emu.h"
const char device_video_interface::s_unconfigured_screen_tag[] = "!!UNCONFIGURED!!";
//**************************************************************************
// DEVICE VIDEO INTERFACE
@ -52,7 +55,7 @@
device_video_interface::device_video_interface(const machine_config &mconfig, device_t &device, bool screen_required)
: device_interface(device),
m_screen_required(screen_required),
m_screen_tag(NULL),
m_screen_tag(s_unconfigured_screen_tag),
m_screen(NULL)
{
}
@ -90,25 +93,31 @@ void device_video_interface::static_set_screen(device_t &device, const char *tag
void device_video_interface::interface_validity_check(validity_checker &valid) const
{
// find the screen device
// only look up screens if we haven't explicitly requested no screen
screen_device *screen = NULL;
if (m_screen_tag != NULL)
{
screen = device().siblingdevice<screen_device>(m_screen_tag);
if (screen == NULL)
mame_printf_error("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag());
}
// if no device, look for a single match
if (screen == NULL)
{
screen_device_iterator iter(device().mconfig().root_device());
screen = iter.first();
if (screen == NULL && m_screen_required)
mame_printf_error("Device '%s' requires a screen", device().tag());
if (iter.next() != NULL)
mame_printf_error("No screen specified for device '%s', but multiple screens found", device().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 == NULL)
mame_printf_error("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag());
}
// otherwise, look for a single match
else
{
screen_device_iterator iter(device().mconfig().root_device());
screen = iter.first();
if (iter.next() != NULL)
mame_printf_error("No screen specified for device '%s', but multiple screens found", device().tag());
}
}
// error if no screen is found
if (screen == NULL && m_screen_required)
mame_printf_error("Device '%s' requires a screen", device().tag());
}
@ -119,25 +128,31 @@ void device_video_interface::interface_validity_check(validity_checker &valid) c
void device_video_interface::interface_pre_start()
{
// find the screen device
// only look up screens if we haven't explicitly requested no screen
if (m_screen_tag != NULL)
{
m_screen = device().siblingdevice<screen_device>(m_screen_tag);
if (m_screen == NULL)
throw emu_fatalerror("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag());
}
// if no device, look for a single match
if (m_screen == NULL)
{
screen_device_iterator iter(device().machine().root_device());
m_screen = iter.first();
if (m_screen == NULL && m_screen_required)
throw emu_fatalerror("Device '%s' requires a screen", device().tag());
if (iter.next() != NULL)
throw emu_fatalerror("No screen specified for device '%s', but multiple screens found", device().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 == NULL)
throw emu_fatalerror("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag());
}
// otherwise, look for a single match
else
{
screen_device_iterator iter(device().machine().root_device());
m_screen = iter.first();
if (iter.next() != NULL)
throw emu_fatalerror("No screen specified for device '%s', but multiple screens found", device().tag());
}
}
// fatal error if no screen is found
if (m_screen == NULL && m_screen_required)
throw emu_fatalerror("Device '%s' requires a screen", device().tag());
// if we have a screen and it's not started, wait for it
if (m_screen != NULL && !m_screen->started())
throw device_missing_dependencies();

View File

@ -64,6 +64,8 @@
class device_video_interface : public device_interface
{
static const char s_unconfigured_screen_tag[];
public:
// construction/destruction
device_video_interface(const machine_config &mconfig, device_t &device, bool screen_required = true);