mirror of
https://github.com/holub/mame
synced 2025-06-02 02:49:44 +03:00
Added the ability to specify member function driver callbacks for
machine/sound/video_start/reset. Changed liberatr as an example. If a callback is specified, it is called in place of the corresponding virtual method. Not entirely sure I like this, so consider the example open for discussion.
This commit is contained in:
parent
4e01c83775
commit
06f296a55a
@ -148,8 +148,6 @@ void driver_device::driver_start()
|
||||
|
||||
void driver_device::machine_start()
|
||||
{
|
||||
if (!m_callbacks[CB_MACHINE_START].isnull())
|
||||
m_callbacks[CB_MACHINE_START]();
|
||||
}
|
||||
|
||||
|
||||
@ -160,8 +158,6 @@ void driver_device::machine_start()
|
||||
|
||||
void driver_device::sound_start()
|
||||
{
|
||||
if (!m_callbacks[CB_SOUND_START].isnull())
|
||||
m_callbacks[CB_SOUND_START]();
|
||||
}
|
||||
|
||||
|
||||
@ -172,8 +168,6 @@ void driver_device::sound_start()
|
||||
|
||||
void driver_device::video_start()
|
||||
{
|
||||
if (!m_callbacks[CB_VIDEO_START].isnull())
|
||||
m_callbacks[CB_VIDEO_START]();
|
||||
}
|
||||
|
||||
|
||||
@ -194,8 +188,6 @@ void driver_device::driver_reset()
|
||||
|
||||
void driver_device::machine_reset()
|
||||
{
|
||||
if (!m_callbacks[CB_MACHINE_RESET].isnull())
|
||||
m_callbacks[CB_MACHINE_RESET]();
|
||||
}
|
||||
|
||||
|
||||
@ -206,8 +198,6 @@ void driver_device::machine_reset()
|
||||
|
||||
void driver_device::sound_reset()
|
||||
{
|
||||
if (!m_callbacks[CB_SOUND_RESET].isnull())
|
||||
m_callbacks[CB_SOUND_RESET]();
|
||||
}
|
||||
|
||||
|
||||
@ -218,8 +208,6 @@ void driver_device::sound_reset()
|
||||
|
||||
void driver_device::video_reset()
|
||||
{
|
||||
if (!m_callbacks[CB_VIDEO_RESET].isnull())
|
||||
m_callbacks[CB_VIDEO_RESET]();
|
||||
}
|
||||
|
||||
|
||||
@ -276,9 +264,21 @@ void driver_device::device_start()
|
||||
|
||||
// start the various pieces
|
||||
driver_start();
|
||||
machine_start();
|
||||
sound_start();
|
||||
video_start();
|
||||
|
||||
if (!m_callbacks[CB_MACHINE_START].isnull())
|
||||
m_callbacks[CB_MACHINE_START]();
|
||||
else
|
||||
machine_start();
|
||||
|
||||
if (!m_callbacks[CB_SOUND_START].isnull())
|
||||
m_callbacks[CB_SOUND_START]();
|
||||
else
|
||||
sound_start();
|
||||
|
||||
if (!m_callbacks[CB_VIDEO_START].isnull())
|
||||
m_callbacks[CB_VIDEO_START]();
|
||||
else
|
||||
video_start();
|
||||
|
||||
// save generic states
|
||||
save_item(NAME(m_flip_screen_x));
|
||||
@ -296,9 +296,21 @@ void driver_device::device_reset_after_children()
|
||||
{
|
||||
// reset each piece
|
||||
driver_reset();
|
||||
machine_reset();
|
||||
sound_reset();
|
||||
video_reset();
|
||||
|
||||
if (!m_callbacks[CB_MACHINE_RESET].isnull())
|
||||
m_callbacks[CB_MACHINE_RESET]();
|
||||
else
|
||||
machine_reset();
|
||||
|
||||
if (!m_callbacks[CB_SOUND_RESET].isnull())
|
||||
m_callbacks[CB_SOUND_RESET]();
|
||||
else
|
||||
sound_reset();
|
||||
|
||||
if (!m_callbacks[CB_VIDEO_RESET].isnull())
|
||||
m_callbacks[CB_VIDEO_RESET]();
|
||||
else
|
||||
video_reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -270,17 +270,29 @@ ATTR_COLD device_t *MACHINE_CONFIG_NAME(_name)(machine_config &config, device_t
|
||||
#define MCFG_MACHINE_START(_func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_MACHINE_START, MACHINE_START_NAME(_func)); \
|
||||
|
||||
#define MCFG_MACHINE_START_DRIVER(_class, _func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_MACHINE_START, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(&config.root_device())));
|
||||
|
||||
#define MCFG_MACHINE_RESET(_func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_MACHINE_RESET, MACHINE_RESET_NAME(_func)); \
|
||||
|
||||
#define MCFG_MACHINE_RESET_DRIVER(_class, _func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_MACHINE_RESET, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(&config.root_device())));
|
||||
|
||||
|
||||
// core sound functions
|
||||
#define MCFG_SOUND_START(_func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_SOUND_START, SOUND_START_NAME(_func)); \
|
||||
|
||||
#define MCFG_SOUND_START_DRIVER(_class, _func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_SOUND_START, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(&config.root_device())));
|
||||
|
||||
#define MCFG_SOUND_RESET(_func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_SOUND_RESET, SOUND_RESET_NAME(_func)); \
|
||||
|
||||
#define MCFG_SOUND_RESET_DRIVER(_class, _func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_SOUND_RESET, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(&config.root_device())));
|
||||
|
||||
|
||||
// core video functions
|
||||
#define MCFG_PALETTE_INIT(_func) \
|
||||
@ -289,9 +301,15 @@ ATTR_COLD device_t *MACHINE_CONFIG_NAME(_name)(machine_config &config, device_t
|
||||
#define MCFG_VIDEO_START(_func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_VIDEO_START, VIDEO_START_NAME(_func)); \
|
||||
|
||||
#define MCFG_VIDEO_START_DRIVER(_class, _func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_VIDEO_START, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(&config.root_device())));
|
||||
|
||||
#define MCFG_VIDEO_RESET(_func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_VIDEO_RESET, VIDEO_RESET_NAME(_func)); \
|
||||
|
||||
#define MCFG_VIDEO_RESET_DRIVER(_class, _func) \
|
||||
driver_device::static_set_callback(*owner, driver_device::CB_VIDEO_RESET, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(&config.root_device())));
|
||||
|
||||
|
||||
// add/remove devices
|
||||
#define MCFG_DEVICE_ADD(_tag, _type, _clock) \
|
||||
|
@ -140,7 +140,7 @@
|
||||
#define MASTER_CLOCK 20000000 /* 20Mhz Main Clock Xtal */
|
||||
|
||||
|
||||
void liberatr_state::machine_start()
|
||||
void liberatr_state::machine_start_liberatr()
|
||||
{
|
||||
atarigen_state::machine_start();
|
||||
|
||||
@ -392,8 +392,11 @@ static MACHINE_CONFIG_START( liberatr, liberatr_state )
|
||||
MCFG_CPU_PERIODIC_INT(irq0_line_hold,4*60)
|
||||
|
||||
MCFG_ER2055_ADD("earom")
|
||||
|
||||
MCFG_MACHINE_START_DRIVER(liberatr_state, machine_start_liberatr)
|
||||
|
||||
/* video hardware */
|
||||
MCFG_VIDEO_START_DRIVER(liberatr_state, video_start_liberatr)
|
||||
MCFG_SCREEN_ADD("screen", RASTER)
|
||||
MCFG_SCREEN_REFRESH_RATE(60)
|
||||
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
|
||||
|
@ -21,6 +21,9 @@ public:
|
||||
m_bitmapram(*this, "bitmapram"),
|
||||
m_colorram(*this, "colorram") { }
|
||||
|
||||
void machine_start_liberatr();
|
||||
void video_start_liberatr();
|
||||
|
||||
DECLARE_WRITE8_MEMBER( led_w );
|
||||
DECLARE_WRITE8_MEMBER( coin_counter_w );
|
||||
|
||||
@ -36,10 +39,6 @@ public:
|
||||
protected:
|
||||
struct planet;
|
||||
|
||||
virtual void machine_start();
|
||||
|
||||
virtual void video_start();
|
||||
|
||||
void init_planet(planet &liberatr_planet, UINT8 *planet_rom);
|
||||
void get_pens(pen_t *pens);
|
||||
void draw_planet(bitmap_rgb32 &bitmap, pen_t *pens);
|
||||
|
@ -209,7 +209,7 @@ void liberatr_state::init_planet(planet &liberatr_planet, UINT8 *planet_rom)
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
void liberatr_state::video_start()
|
||||
void liberatr_state::video_start_liberatr()
|
||||
{
|
||||
// for each planet in the planet ROMs
|
||||
init_planet(m_planets[0], &machine().region("gfx1")->base()[0x2000]);
|
||||
|
Loading…
Reference in New Issue
Block a user