diff options
Diffstat (limited to 'src/devices/machine/timer.h')
-rw-r--r-- | src/devices/machine/timer.h | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/src/devices/machine/timer.h b/src/devices/machine/timer.h index 944db93c1e5..e27c8a8cc53 100644 --- a/src/devices/machine/timer.h +++ b/src/devices/machine/timer.h @@ -23,6 +23,44 @@ #define TIMER_DEVICE_CALLBACK_MEMBER(name) void name(timer_device &timer, void *ptr, s32 param) //************************************************************************** +// TIMER DEVICE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_TIMER_ADD_NONE(_tag) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + downcast<timer_device &>(*device).configure_generic(timer_device::expired_delegate()); +#define MCFG_TIMER_DRIVER_ADD(_tag, _class, _callback) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + downcast<timer_device &>(*device).configure_generic(timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, nullptr, (_class *)nullptr)); +#define MCFG_TIMER_DEVICE_ADD(_tag, _devtag, _class, _callback) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + downcast<timer_device &>(*device).configure_generic(timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)nullptr)); +#define MCFG_TIMER_DRIVER_ADD_PERIODIC(_tag, _class, _callback, _period) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + downcast<timer_device &>(*device).configure_periodic(timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, nullptr, (_class *)nullptr), _period); +#define MCFG_TIMER_DEVICE_ADD_PERIODIC(_tag, _devtag, _class, _callback, _period) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + downcast<timer_device &>(*device).configure_periodic(timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)nullptr), _period); +#define MCFG_TIMER_DRIVER_ADD_SCANLINE(_tag, _class, _callback, _screen, _first_vpos, _increment) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + downcast<timer_device &>(*device).configure_scanline(timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, nullptr, (_class *)nullptr), _screen, _first_vpos, _increment); +#define MCFG_TIMER_DEVICE_ADD_SCANLINE(_tag, _devtag, _class, _callback, _screen, _first_vpos, _increment) \ + MCFG_DEVICE_ADD(_tag, TIMER, 0) \ + downcast<timer_device &>(*device).configure_scanline(timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)nullptr), _screen, _first_vpos, _increment); +#define MCFG_TIMER_MODIFY(_tag) \ + MCFG_DEVICE_MODIFY(_tag) + +#define MCFG_TIMER_DRIVER_CALLBACK(_class, _callback) \ + downcast<timer_device &>(*device).set_callback(timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, nullptr, (_class *)nullptr)); +#define MCFG_TIMER_START_DELAY(_start_delay) \ + downcast<timer_device &>(*device).set_start_delay(_start_delay); +#define MCFG_TIMER_PARAM(_param) \ + downcast<timer_device &>(*device).config_param(_param); +#define MCFG_TIMER_PTR(_ptr) \ + downcast<timer_device &>(*device).set_ptr((void *)(_ptr)); + + +//************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -48,11 +86,6 @@ public: configure_generic(expired_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); } - template <class FunctionClass> void configure_generic(const char *devname, void (FunctionClass::*callback)(timer_device &, void *, s32), const char *name) - { - configure_generic(expired_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - template <typename Object> void configure_periodic(Object &&cb, const attotime &period) { m_type = TIMER_TYPE_PERIODIC; @@ -65,12 +98,6 @@ public: configure_periodic(expired_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr)), period); } - template <class FunctionClass> void configure_periodic(const char *devname, void (FunctionClass::*callback)(timer_device &, void *, s32), - const char *name, const attotime &period) - { - configure_periodic(expired_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr)), period); - } - template <typename Object> void configure_scanline(Object &&cb, const char *screen, int first_vpos, int increment) { m_type = TIMER_TYPE_SCANLINE; @@ -111,18 +138,13 @@ public: // adjustments void reset() { adjust(attotime::never, 0, attotime::never); } - void adjust(const attotime &duration, s32 param = 0, const attotime &period = attotime::never) const - { - assert(m_type == TIMER_TYPE_GENERIC); - m_timer->adjust(duration, param, period); - } + void adjust(const attotime &duration, s32 param = 0, const attotime &period = attotime::never) const { assert(m_type == TIMER_TYPE_GENERIC); m_timer->adjust(duration, param, period); } // timing information attotime time_elapsed() const { return m_timer->elapsed(); } attotime time_left() const { return m_timer->remaining(); } attotime start_time() const { return m_timer->start(); } attotime fire_time() const { return m_timer->expire(); } - attotime period() const { return m_timer ? m_timer->period() : m_period; } private: // device-level overrides @@ -141,7 +163,7 @@ private: // configuration data timer_type m_type; // type of timer - expired_delegate m_callback; // the timer's callback function + expired_delegate m_callback; // the timer's callback function void * m_ptr; // the pointer parameter passed to the timer callback // periodic timers only |