diff options
author | Aaron Giles <aaron@aarongiles.com> | 2010-09-10 23:33:36 +0000 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2010-09-10 23:33:36 +0000 |
commit | 958c161bccdd1f785c0760b3125db616bc60717c (patch) | |
tree | fe5f45f96babff1f1f83fd84b09bcec83a0d1c41 /src/emu/timer.c | |
parent | fdc0db7e2683a803e91cff1790730bbdf4b83f21 (diff) |
Made the mc146818 a proper device, modernized it, and added an NVRAM interface
so that drivers don't have to ask it to be manually saved.
Diffstat (limited to 'src/emu/timer.c')
-rw-r--r-- | src/emu/timer.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/emu/timer.c b/src/emu/timer.c index aadeb4f6a47..55231d3ee24 100644 --- a/src/emu/timer.c +++ b/src/emu/timer.c @@ -56,6 +56,7 @@ public: attotime period; /* the repeat frequency of the timer */ attotime start; /* time when the timer was started */ attotime expire; /* time when the timer will expire */ + device_t * device; /* for device timers, a pointer to the device */ }; @@ -368,12 +369,17 @@ void timer_execute_timers(running_machine *machine) global->callback_timer_expire_time = timer->expire; /* call the callback */ - if (was_enabled && timer->callback != NULL) + if (was_enabled) { - LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9))); - g_profiler.start(PROFILER_TIMER_CALLBACK); - (*timer->callback)(machine, timer->ptr, timer->param); - g_profiler.stop(); + if (timer->device != NULL) + timer->device->timer_fired(*timer, timer->param, timer->ptr); + else if (timer->callback != NULL) + { + LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9))); + g_profiler.start(PROFILER_TIMER_CALLBACK); + (*timer->callback)(machine, timer->ptr, timer->param); + g_profiler.stop(); + } } /* clear the callback timer global */ @@ -603,6 +609,7 @@ INLINE emu_timer *_timer_alloc_common(running_machine *machine, timer_fired_func timer->file = file; timer->line = line; timer->func = func; + timer->device = NULL; /* compute the time of the next firing and insert into the list */ timer->start = time; @@ -626,6 +633,14 @@ emu_timer *_timer_alloc_internal(running_machine *machine, timer_fired_func call return _timer_alloc_common(machine, callback, ptr, file, line, func, FALSE); } +emu_timer *device_timer_alloc(device_t &device, void *ptr, int param) +{ + emu_timer *timer = _timer_alloc_common(device.machine, NULL, ptr, __FILE__, __LINE__, device.tag(), FALSE); + timer->param = param; + timer->device = &device; + return timer; +} + /*------------------------------------------------- timer_remove - remove a timer from the |