summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/timer.h')
-rw-r--r--src/devices/machine/timer.h51
1 files changed, 33 insertions, 18 deletions
diff --git a/src/devices/machine/timer.h b/src/devices/machine/timer.h
index b6a7ea33025..44a7582bec7 100644
--- a/src/devices/machine/timer.h
+++ b/src/devices/machine/timer.h
@@ -28,36 +28,36 @@
#define MCFG_TIMER_ADD_NONE(_tag) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
- timer_device::static_configure_generic(*device, timer_device::expired_delegate());
+ downcast<timer_device &>(*device).configure_generic(timer_device::expired_delegate());
#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, nullptr, (_class *)nullptr));
+ 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) \
- timer_device::static_configure_generic(*device, timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)nullptr));
+ 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) \
- timer_device::static_configure_periodic(*device, timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, nullptr, (_class *)nullptr), _period);
+ 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) \
- timer_device::static_configure_periodic(*device, timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)nullptr), _period);
+ 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) \
- timer_device::static_configure_scanline(*device, timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, nullptr, (_class *)nullptr), _screen, _first_vpos, _increment);
+ 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) \
- timer_device::static_configure_scanline(*device, timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)nullptr), _screen, _first_vpos, _increment);
+ 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) \
- timer_device::static_set_callback(*device, timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, nullptr, (_class *)nullptr));
+ downcast<timer_device &>(*device).set_callback(timer_device::expired_delegate(&_class::_callback, #_class "::" #_callback, nullptr, (_class *)nullptr));
#define MCFG_TIMER_START_DELAY(_start_delay) \
- timer_device::static_set_start_delay(*device, _start_delay);
+ downcast<timer_device &>(*device).set_start_delay(_start_delay);
#define MCFG_TIMER_PARAM(_param) \
- timer_device::static_set_param(*device, _param);
+ downcast<timer_device &>(*device).config_param(_param);
#define MCFG_TIMER_PTR(_ptr) \
- timer_device::static_set_ptr(*device, (void *)(_ptr));
+ downcast<timer_device &>(*device).set_ptr((void *)(_ptr));
//**************************************************************************
@@ -76,13 +76,28 @@ public:
timer_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
// inline configuration helpers
- static void static_configure_generic(device_t &device, expired_delegate callback);
- static void static_configure_periodic(device_t &device, expired_delegate callback, const attotime &period);
- static void static_configure_scanline(device_t &device, expired_delegate callback, const char *screen, int first_vpos, int increment);
- static void static_set_callback(device_t &device, expired_delegate callback);
- static void static_set_start_delay(device_t &device, const attotime &delay);
- static void static_set_param(device_t &device, int param);
- static void static_set_ptr(device_t &device, void *ptr);
+ template <typename Object> void configure_generic(Object &&cb)
+ {
+ m_type = TIMER_TYPE_GENERIC;
+ m_callback = std::forward<Object>(cb);
+ }
+ template <typename Object> void configure_periodic(Object &&cb, const attotime &period)
+ {
+ m_type = TIMER_TYPE_PERIODIC;
+ m_callback = std::forward<Object>(cb);
+ m_period = period;
+ }
+ template <typename Object> void configure_scanline(Object &&cb, const char *screen, int first_vpos, int increment)
+ {
+ m_type = TIMER_TYPE_SCANLINE;
+ m_callback = std::forward<Object>(cb);
+ m_screen_tag = screen;
+ m_first_vpos = first_vpos;
+ m_increment = increment;
+ }
+ template <typename Object> void set_callback(Object &&cb) { m_callback = std::forward<Object>(cb); }
+ void set_start_delay(const attotime &delay) { m_start_delay = delay; }
+ void config_param(int param) { m_param = param; }
// property getters
int param() const { return m_timer->param(); }