Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created new device_video_interface. Right now its sole purpose is to
house a screen tag and to find the screen at startup, providing an m_screen object that can be used. One nice feature is that if there is only one screen and no screen has been specified, it will auto configure to that screen. This removes the need to explicitly specify a screen in the configuration for a large chunk of drivers (though doing so never hurts). A new macro MCFG_VIDEO_SET_SCREEN is provided, though devices are encouraged to define their own that maps there so it is obvious which device is being targeted. The device_video_interface's validation function will error if an invalid screen is specified or if no screen is provided but there are multiple screens present. Updated all devices that currently had an m_screen in them to use the device_video_interface instead. This also has the nice benefit of flagging video-related devices for categorization purposes. It also means all these devices inherit the same screen-finding behaviors. For devices that had interfaces that specified a screen tag, those have been removed and all existing structs updated. Added an optional_device<screen_device> m_screen to the base driver_device. If you name your screen "screen" (as most drivers do), you will have free access to your screen this way. Future updates include: * Updating all devices referencing machine.primary_screen to use the device_video_interface instead * Updating all drivers referencing machine.primary_screen to use the m_screen instead * Removing machine.primary_screen entirely
- Loading branch information
1 parent
4719b97
commit 25a100d
Showing
428 changed files
with
820 additions
and
1,361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/*************************************************************************** | ||
divideo.c | ||
Device video interfaces. | ||
**************************************************************************** | ||
Copyright Aaron Giles | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the | ||
distribution. | ||
* Neither the name 'MAME' nor the names of its contributors may be | ||
used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
***************************************************************************/ | ||
|
||
#include "emu.h" | ||
|
||
|
||
|
||
//************************************************************************** | ||
// DEVICE VIDEO INTERFACE | ||
//************************************************************************** | ||
|
||
//------------------------------------------------- | ||
// device_video_interface - constructor | ||
//------------------------------------------------- | ||
|
||
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(NULL) | ||
{ | ||
} | ||
|
||
|
||
//------------------------------------------------- | ||
// ~device_video_interface - destructor | ||
//------------------------------------------------- | ||
|
||
device_video_interface::~device_video_interface() | ||
{ | ||
} | ||
|
||
|
||
//------------------------------------------------- | ||
// static_add_route - configuration helper to add | ||
// a new route to the device | ||
//------------------------------------------------- | ||
|
||
void device_video_interface::static_set_screen(device_t &device, const char *tag) | ||
{ | ||
// find our video interface | ||
device_video_interface *video; | ||
if (!device.interface(video)) | ||
throw emu_fatalerror("MCFG_VIDEO_SET_SCREEN called on device '%s' with no video interface", device.tag()); | ||
video->m_screen_tag = tag; | ||
} | ||
|
||
|
||
//------------------------------------------------- | ||
// interface_validity_check - validation for a | ||
// device after the configuration has been | ||
// constructed | ||
//------------------------------------------------- | ||
|
||
void device_video_interface::interface_validity_check(validity_checker &valid) const | ||
{ | ||
// find the screen device | ||
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()); | ||
} | ||
} | ||
|
||
|
||
//------------------------------------------------- | ||
// interface_pre_start - make sure all our input | ||
// devices are started | ||
//------------------------------------------------- | ||
|
||
void device_video_interface::interface_pre_start() | ||
{ | ||
// find the screen device | ||
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()); | ||
} | ||
|
||
// if we have a screen and it's not started, wait for it | ||
if (m_screen != NULL && !m_screen->started()) | ||
throw device_missing_dependencies(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/*************************************************************************** | ||
divideo.h | ||
Device video interfaces. | ||
**************************************************************************** | ||
Copyright Aaron Giles | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the | ||
distribution. | ||
* Neither the name 'MAME' nor the names of its contributors may be | ||
used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
***************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#ifndef __EMU_H__ | ||
#error Dont include this file directly; include emu.h instead. | ||
#endif | ||
|
||
#ifndef __DIVIDEO_H__ | ||
#define __DIVIDEO_H__ | ||
|
||
|
||
//************************************************************************** | ||
// INTERFACE CONFIGURATION MACROS | ||
//************************************************************************** | ||
|
||
#define MCFG_VIDEO_SET_SCREEN(_tag) \ | ||
device_video_interface::static_set_screen(*device, _tag); | ||
|
||
|
||
|
||
//************************************************************************** | ||
// TYPE DEFINITIONS | ||
//************************************************************************** | ||
|
||
// ======================> device_video_interface | ||
|
||
class device_video_interface : public device_interface | ||
{ | ||
public: | ||
// construction/destruction | ||
device_video_interface(const machine_config &mconfig, device_t &device, bool screen_required = true); | ||
virtual ~device_video_interface(); | ||
|
||
// static configuration | ||
static void static_set_screen(device_t &device, const char *tag); | ||
|
||
// getters | ||
screen_device &screen() const { return *m_screen; } | ||
|
||
protected: | ||
// optional operation overrides | ||
virtual void interface_validity_check(validity_checker &valid) const; | ||
virtual void interface_pre_start(); | ||
|
||
// configuration state | ||
bool m_screen_required; // is a screen required? | ||
const char * m_screen_tag; // configured tag for the target screen | ||
|
||
// internal state | ||
screen_device * m_screen; // pointer to the screen device | ||
}; | ||
|
||
// iterator | ||
typedef device_interface_iterator<device_video_interface> video_interface_iterator; | ||
|
||
|
||
#endif /* __DIVIDEO_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.