summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/timer.h')
-rw-r--r--src/emu/timer.h117
1 files changed, 46 insertions, 71 deletions
diff --git a/src/emu/timer.h b/src/emu/timer.h
index c8c38152031..fff33be5ad4 100644
--- a/src/emu/timer.h
+++ b/src/emu/timer.h
@@ -64,30 +64,30 @@
#define MCFG_TIMER_ADD(_tag, _callback) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
- timer_device_config::static_configure_generic(device, _callback); \
+ timer_device::static_configure_generic(*device, _callback); \
#define MCFG_TIMER_ADD_PERIODIC(_tag, _callback, _period) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
- timer_device_config::static_configure_periodic(device, _callback, _period); \
+ timer_device::static_configure_periodic(*device, _callback, _period); \
#define MCFG_TIMER_ADD_SCANLINE(_tag, _callback, _screen, _first_vpos, _increment) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
- timer_device_config::static_configure_scanline(device, _callback, _screen, _first_vpos, _increment); \
+ timer_device::static_configure_scanline(*device, _callback, _screen, _first_vpos, _increment); \
#define MCFG_TIMER_MODIFY(_tag) \
MCFG_DEVICE_MODIFY(_tag)
#define MCFG_TIMER_CALLBACK(_callback) \
- timer_device_config::static_set_callback(device, _callback); \
+ timer_device::static_set_callback(*device, _callback); \
#define MCFG_TIMER_START_DELAY(_start_delay) \
- timer_device_config::static_set_start_delay(device, _start_delay); \
+ timer_device::static_set_start_delay(*device, _start_delay); \
#define MCFG_TIMER_PARAM(_param) \
- timer_device_config::static_set_param(device, _param); \
+ timer_device::static_set_param(*device, _param); \
#define MCFG_TIMER_PTR(_ptr) \
- timer_device_config::static_set_ptr(device, (void *)(_ptr)); \
+ timer_device::static_set_ptr(*device, (void *)(_ptr)); \
@@ -103,81 +103,36 @@ class timer_device;
typedef void (*timer_device_fired_func)(timer_device &timer, void *ptr, INT32 param);
-// ======================> timer_device_config
-
-class timer_device_config : public device_config
-{
- friend class timer_device;
-
- // construction/destruction
- timer_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
-
-public:
- // allocators
- static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
- virtual device_t *alloc_device(running_machine &machine) const;
-
- // inline configuration helpers
- static void static_configure_generic(device_config *device, timer_device_fired_func callback);
- static void static_configure_periodic(device_config *device, timer_device_fired_func callback, attotime period);
- static void static_configure_scanline(device_config *device, timer_device_fired_func callback, const char *screen, int first_vpos, int increment);
- static void static_set_callback(device_config *device, timer_device_fired_func callback);
- static void static_set_start_delay(device_config *device, attotime delay);
- static void static_set_param(device_config *device, int param);
- static void static_set_ptr(device_config *device, void *ptr);
-
-private:
- // device_config overrides
- virtual bool device_validity_check(emu_options &options, const game_driver &driver) const;
-
- // timer types
- enum timer_type
- {
- TIMER_TYPE_PERIODIC,
- TIMER_TYPE_SCANLINE,
- TIMER_TYPE_GENERIC
- };
-
- // configuration data
- timer_type m_type; // type of timer
- timer_device_fired_func m_callback; // the timer's callback function
- void * m_ptr; // the pointer parameter passed to the timer callback
-
- // periodic timers only
- attotime m_start_delay; // delay before the timer fires for the first time
- attotime m_period; // period of repeated timer firings
- INT32 m_param; // the integer parameter passed to the timer callback
-
- // scanline timers only
- const char * m_screen; // the name of the screen this timer tracks
- UINT32 m_first_vpos; // the first vertical scanline position the timer fires on
- UINT32 m_increment; // the number of scanlines between firings
-};
-
-
// ======================> timer_device
class timer_device : public device_t
{
- friend class timer_device_config;
-
+public:
// construction/destruction
- timer_device(running_machine &_machine, const timer_device_config &config);
+ 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_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);
-public:
// property getters
int param() const { return m_timer->param(); }
void *ptr() const { return m_ptr; }
bool enabled() const { return m_timer->enabled(); }
// property setters
- void set_param(int param) { assert(m_config.m_type == timer_device_config::TIMER_TYPE_GENERIC); m_timer->set_param(param); }
+ void set_param(int param) { assert(m_type == TIMER_TYPE_GENERIC); m_timer->set_param(param); }
void set_ptr(void *ptr) { m_ptr = ptr; }
void enable(bool enable = true) { m_timer->enable(enable); }
// adjustments
void reset() { adjust(attotime::never, 0, attotime::never); }
- void adjust(attotime duration, INT32 param = 0, attotime period = attotime::never) { assert(m_config.m_type == timer_device_config::TIMER_TYPE_GENERIC); m_timer->adjust(duration, param, period); }
+ void adjust(attotime duration, INT32 param = 0, attotime period = attotime::never) { assert(m_type == TIMER_TYPE_GENERIC); m_timer->adjust(duration, param, period); }
// timing information
attotime time_elapsed() const { return m_timer->elapsed(); }
@@ -187,18 +142,38 @@ public:
private:
// device-level overrides
+ virtual bool device_validity_check(emu_options &options, const game_driver &driver) const;
virtual void device_start();
virtual void device_reset();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
- // internal state
- const timer_device_config & m_config;
- emu_timer * m_timer; // the backing timer
- void * m_ptr; // the pointer parameter passed to the timer callback
+ // timer types
+ enum timer_type
+ {
+ TIMER_TYPE_PERIODIC,
+ TIMER_TYPE_SCANLINE,
+ TIMER_TYPE_GENERIC
+ };
+
+ // configuration data
+ timer_type m_type; // type of timer
+ timer_device_fired_func m_callback; // the timer's callback function
+ void * m_ptr; // the pointer parameter passed to the timer callback
+
+ // periodic timers only
+ attotime m_start_delay; // delay before the timer fires for the first time
+ attotime m_period; // period of repeated timer firings
+ INT32 m_param; // the integer parameter passed to the timer callback
// scanline timers only
- screen_device * m_screen; // pointer to the screen
- bool m_first_time; // indicates that the system is starting
+ const char * m_screen_tag; // the tag of the screen this timer tracks
+ screen_device * m_screen; // pointer to the screen device
+ UINT32 m_first_vpos; // the first vertical scanline position the timer fires on
+ UINT32 m_increment; // the number of scanlines between firings
+
+ // internal state
+ emu_timer * m_timer; // the backing timer
+ bool m_first_time; // indicates that the system is starting (scanline timers only)
};