diff options
author | 2012-09-25 07:30:11 +0000 | |
---|---|---|
committer | 2012-09-25 07:30:11 +0000 | |
commit | a68624339fd92b85cc8bd519d37d5108da9a1fae (patch) | |
tree | 7737c9ac869dcb33b6466f8438fe2189ff1ecd71 | |
parent | 34835ae4a556985130c4a09c2f812f78cbb42be0 (diff) |
Made timer_device use delegates (no whatsnew)
-rw-r--r-- | src/emu/timer.c | 16 | ||||
-rw-r--r-- | src/emu/timer.h | 48 | ||||
-rw-r--r-- | src/mame/drivers/midvunit.c | 4 | ||||
-rw-r--r-- | src/mame/drivers/segas24.c | 2 | ||||
-rw-r--r-- | src/mame/drivers/viper.c | 2 | ||||
-rw-r--r-- | src/mame/machine/balsente.c | 2 | ||||
-rw-r--r-- | src/mame/machine/megacd.c | 2 |
7 files changed, 46 insertions, 30 deletions
diff --git a/src/emu/timer.c b/src/emu/timer.c index 191377610fd..e92cf0ba0af 100644 --- a/src/emu/timer.c +++ b/src/emu/timer.c @@ -64,7 +64,7 @@ const device_type TIMER = &device_creator<timer_device>; timer_device::timer_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, TIMER, "Timer", tag, owner, clock), m_type(TIMER_TYPE_GENERIC), - m_callback(NULL), + m_callback(timer_device_expired_delegate()), m_ptr(NULL), m_start_delay(attotime::zero), m_period(attotime::zero), @@ -84,7 +84,7 @@ timer_device::timer_device(const machine_config &mconfig, const char *tag, devic // helper to set up a generic timer //------------------------------------------------- -void timer_device::static_configure_generic(device_t &device, timer_device_fired_func callback) +void timer_device::static_configure_generic(device_t &device, timer_device_expired_delegate callback) { timer_device &timer = downcast<timer_device &>(device); timer.m_type = TIMER_TYPE_GENERIC; @@ -97,7 +97,7 @@ void timer_device::static_configure_generic(device_t &device, timer_device_fired // helper to set up a periodic timer //------------------------------------------------- -void timer_device::static_configure_periodic(device_t &device, timer_device_fired_func callback, attotime period) +void timer_device::static_configure_periodic(device_t &device, timer_device_expired_delegate callback, attotime period) { timer_device &timer = downcast<timer_device &>(device); timer.m_type = TIMER_TYPE_PERIODIC; @@ -111,7 +111,7 @@ void timer_device::static_configure_periodic(device_t &device, timer_device_fire // helper to set up a scanline timer //------------------------------------------------- -void timer_device::static_configure_scanline(device_t &device, timer_device_fired_func callback, const char *screen, int first_vpos, int increment) +void timer_device::static_configure_scanline(device_t &device, timer_device_expired_delegate callback, const char *screen, int first_vpos, int increment) { timer_device &timer = downcast<timer_device &>(device); timer.m_type = TIMER_TYPE_SCANLINE; @@ -127,7 +127,7 @@ void timer_device::static_configure_scanline(device_t &device, timer_device_fire // to set the callback //------------------------------------------------- -void timer_device::static_set_callback(device_t &device, timer_device_fired_func callback) +void timer_device::static_set_callback(device_t &device, timer_device_expired_delegate callback) { timer_device &timer = downcast<timer_device &>(device); timer.m_callback = callback; @@ -283,8 +283,8 @@ void timer_device::device_timer(emu_timer &timer, device_timer_id id, int param, // general periodic timers just call through case TIMER_TYPE_GENERIC: case TIMER_TYPE_PERIODIC: - if (m_callback != NULL) - (*m_callback)(*this, m_ptr, param); + if (!m_callback.isnull()) + (m_callback)(*this, m_ptr, param); break; @@ -299,7 +299,7 @@ void timer_device::device_timer(emu_timer &timer, device_timer_id id, int param, { // call the real callback int vpos = m_screen->vpos(); - (*m_callback)(*this, m_ptr, vpos); + (m_callback)(*this, m_ptr, vpos); // advance by the increment only if we will still be within the screen bounds if (m_increment != 0 && (vpos + m_increment) < m_screen->height()) diff --git a/src/emu/timer.h b/src/emu/timer.h index 7c01feb0375..87c8b3845ea 100644 --- a/src/emu/timer.h +++ b/src/emu/timer.h @@ -53,10 +53,8 @@ //************************************************************************** // macros for a timer callback functions -#define TIMER_DEVICE_CALLBACK(name) void name(timer_device &timer, void *ptr, INT32 param) - - - +#define TIMER_DEVICE_CALLBACK(name) void name(device_t *, timer_device &timer, void *ptr, INT32 param) +#define TIMER_DEVICE_CALLBACK_MEMBER(name) void name(timer_device &timer, void *ptr, INT32 param) //************************************************************************** // TIMER DEVICE CONFIGURATION MACROS @@ -64,21 +62,40 @@ #define MCFG_TIMER_ADD(_tag, _callback) \ MCFG_DEVICE_ADD(_tag, TIMER, 0) \ - timer_device::static_configure_generic(*device, _callback); \ + timer_device::static_configure_generic(*device, timer_device_expired_delegate(&_callback, #_callback)); \ + +#define MCFG_TIMER_ADD_NONE(_tag) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + timer_device::static_configure_generic(*device, timer_device_expired_delegate()); \ #define MCFG_TIMER_ADD_PERIODIC(_tag, _callback, _period) \ MCFG_DEVICE_ADD(_tag, TIMER, 0) \ - timer_device::static_configure_periodic(*device, _callback, _period); \ + timer_device::static_configure_periodic(*device, timer_device_expired_delegate(&_callback, #_callback), _period); \ #define MCFG_TIMER_ADD_SCANLINE(_tag, _callback, _screen, _first_vpos, _increment) \ MCFG_DEVICE_ADD(_tag, TIMER, 0) \ - timer_device::static_configure_scanline(*device, _callback, _screen, _first_vpos, _increment); \ + timer_device::static_configure_scanline(*device, timer_device_expired_delegate(&_callback, #_callback), _screen, _first_vpos, _increment); \ + +#define MCFG_TIMER_DRIVER_ADD(_tag, _class, _callback) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + timer_device::static_configure_generic(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, NULL)); \ + +#define MCFG_TIMER_DRIVER_ADD_PERIODIC(_tag, _class, _callback, _period) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + timer_device::static_configure_periodic(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, NULL), _period); \ + +#define MCFG_TIMER_DRIVER_ADD_SCANLINE(_tag, _class, _callback, _screen, _first_vpos, _increment) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + timer_device::static_configure_scanline(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, NULL), _screen, _first_vpos, _increment); \ #define MCFG_TIMER_MODIFY(_tag) \ MCFG_DEVICE_MODIFY(_tag) #define MCFG_TIMER_CALLBACK(_callback) \ - timer_device::static_set_callback(*device, _callback); \ + timer_device::static_set_callback(*device, timer_device_expired_delegate(&_callback, #_callback)); \ + +#define MCFG_TIMER_DRIVER_CALLBACK(_class, _callback) \ + timer_device::static_set_callback(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, NULL)); \ #define MCFG_TIMER_START_DELAY(_start_delay) \ timer_device::static_set_start_delay(*device, _start_delay); \ @@ -99,9 +116,8 @@ class emu_timer; class timer_device; -// a timer callback looks like this -typedef void (*timer_device_fired_func)(timer_device &timer, void *ptr, INT32 param); - +// a timer callbacks look like this +typedef device_delegate<void (timer_device &, void *, INT32)> timer_device_expired_delegate; // ======================> timer_device @@ -112,10 +128,10 @@ public: timer_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); // inline configuration helpers - static void static_configure_generic(device_t &device, timer_device_fired_func callback); - static void static_configure_periodic(device_t &device, timer_device_fired_func callback, attotime period); - static void static_configure_scanline(device_t &device, timer_device_fired_func callback, const char *screen, int first_vpos, int increment); - static void static_set_callback(device_t &device, timer_device_fired_func callback); + static void static_configure_generic(device_t &device, timer_device_expired_delegate callback); + static void static_configure_periodic(device_t &device, timer_device_expired_delegate callback, attotime period); + static void static_configure_scanline(device_t &device, timer_device_expired_delegate callback, const char *screen, int first_vpos, int increment); + static void static_set_callback(device_t &device, timer_device_expired_delegate callback); static void static_set_start_delay(device_t &device, attotime delay); static void static_set_param(device_t &device, int param); static void static_set_ptr(device_t &device, void *ptr); @@ -157,7 +173,7 @@ private: // configuration data timer_type m_type; // type of timer - timer_device_fired_func m_callback; // the timer's callback function + timer_device_expired_delegate m_callback; // the timer's callback function void * m_ptr; // the pointer parameter passed to the timer callback // periodic timers only diff --git a/src/mame/drivers/midvunit.c b/src/mame/drivers/midvunit.c index 659429e0a97..32cd170021f 100644 --- a/src/mame/drivers/midvunit.c +++ b/src/mame/drivers/midvunit.c @@ -1018,8 +1018,8 @@ static MACHINE_CONFIG_START( midvcommon, midvunit_state ) MCFG_NVRAM_ADD_1FILL("nvram") - MCFG_TIMER_ADD("timer0", NULL) - MCFG_TIMER_ADD("timer1", NULL) + MCFG_TIMER_ADD_NONE("timer0") + MCFG_TIMER_ADD_NONE("timer1") /* video hardware */ MCFG_PALETTE_LENGTH(32768) diff --git a/src/mame/drivers/segas24.c b/src/mame/drivers/segas24.c index d46954b2c25..1926bd41072 100644 --- a/src/mame/drivers/segas24.c +++ b/src/mame/drivers/segas24.c @@ -1956,7 +1956,7 @@ static MACHINE_CONFIG_START( system24, segas24_state ) MCFG_TIMER_ADD("irq_timer", irq_timer_cb) MCFG_TIMER_ADD("irq_timer_clear", irq_timer_clear_cb) - MCFG_TIMER_ADD("frc_timer", NULL) + MCFG_TIMER_ADD_NONE("frc_timer") MCFG_TIMER_ADD_PERIODIC("irq_frc", irq_frc_cb, attotime::from_hz(FRC_CLOCK_MODE1)) MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK) diff --git a/src/mame/drivers/viper.c b/src/mame/drivers/viper.c index c152acba73f..98a98e250d1 100644 --- a/src/mame/drivers/viper.c +++ b/src/mame/drivers/viper.c @@ -2039,7 +2039,7 @@ static MACHINE_CONFIG_START( viper, viper_state ) MCFG_SCREEN_UPDATE_DRIVER(viper_state, screen_update_viper) - MCFG_TIMER_ADD("ds2430_timer2", NULL) + MCFG_TIMER_ADD_NONE("ds2430_timer2") /* sound hardware */ MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") diff --git a/src/mame/machine/balsente.c b/src/mame/machine/balsente.c index 8f7977480e2..f6fff92035b 100644 --- a/src/mame/machine/balsente.c +++ b/src/mame/machine/balsente.c @@ -867,7 +867,7 @@ static void set_counter_0_ff(timer_device &timer, int newstate) { state->m_counter[0].count--; if (state->m_counter[0].count == 0) - balsente_counter_callback(timer, NULL, 0); + balsente_counter_callback(state, timer, NULL, 0); } } diff --git a/src/mame/machine/megacd.c b/src/mame/machine/megacd.c index 4627cd4973c..f4b2f849a82 100644 --- a/src/mame/machine/megacd.c +++ b/src/mame/machine/megacd.c @@ -48,7 +48,7 @@ static MACHINE_CONFIG_FRAGMENT( segacd_fragment ) MCFG_DEVICE_ADD("cdc", LC89510, 0) // cd controller - MCFG_TIMER_ADD("sw_timer", NULL) //stopwatch timer + MCFG_TIMER_ADD_NONE("sw_timer") //stopwatch timer MCFG_DEFAULT_LAYOUT( layout_megacd ) |