trunk/src/emu/schedule.c
| r31185 | r31186 | |
| 174 | 174 | // firings |
| 175 | 175 | //------------------------------------------------- |
| 176 | 176 | |
| 177 | | void emu_timer::adjust(attotime start_delay, INT32 param, attotime period) |
| 177 | void emu_timer::adjust(attotime start_delay, INT32 param, const attotime &period) |
| 178 | 178 | { |
| 179 | 179 | // if this is the callback timer, mark it modified |
| 180 | 180 | device_scheduler &scheduler = machine().scheduler(); |
| r31185 | r31186 | |
| 532 | 532 | // trigger - generate a global trigger |
| 533 | 533 | //------------------------------------------------- |
| 534 | 534 | |
| 535 | | void device_scheduler::trigger(int trigid, attotime after) |
| 535 | void device_scheduler::trigger(int trigid, const attotime &after) |
| 536 | 536 | { |
| 537 | 537 | // ensure we have a list of executing devices |
| 538 | 538 | if (m_execute_list == NULL) |
| r31185 | r31186 | |
| 554 | 554 | // interleave factor |
| 555 | 555 | //------------------------------------------------- |
| 556 | 556 | |
| 557 | | void device_scheduler::boost_interleave(attotime timeslice_time, attotime boost_duration) |
| 557 | void device_scheduler::boost_interleave(const attotime ×lice_time, const attotime &boost_duration) |
| 558 | 558 | { |
| 559 | 559 | // ignore timeslices > 1 second |
| 560 | 560 | if (timeslice_time.seconds > 0) |
| r31185 | r31186 | |
| 580 | 580 | // amount of time |
| 581 | 581 | //------------------------------------------------- |
| 582 | 582 | |
| 583 | | void device_scheduler::timer_set(attotime duration, timer_expired_delegate callback, int param, void *ptr) |
| 583 | void device_scheduler::timer_set(const attotime &duration, timer_expired_delegate callback, int param, void *ptr) |
| 584 | 584 | { |
| 585 | 585 | m_timer_allocator.alloc()->init(machine(), callback, ptr, true).adjust(duration, param); |
| 586 | 586 | } |
| r31185 | r31186 | |
| 592 | 592 | // frequency |
| 593 | 593 | //------------------------------------------------- |
| 594 | 594 | |
| 595 | | void device_scheduler::timer_pulse(attotime period, timer_expired_delegate callback, int param, void *ptr) |
| 595 | void device_scheduler::timer_pulse(const attotime &period, timer_expired_delegate callback, int param, void *ptr) |
| 596 | 596 | { |
| 597 | 597 | m_timer_allocator.alloc()->init(machine(), callback, ptr, false).adjust(period, param, period); |
| 598 | 598 | } |
| r31185 | r31186 | |
| 615 | 615 | // time |
| 616 | 616 | //------------------------------------------------- |
| 617 | 617 | |
| 618 | | void device_scheduler::timer_set(attotime duration, device_t &device, device_timer_id id, int param, void *ptr) |
| 618 | void device_scheduler::timer_set(const attotime &duration, device_t &device, device_timer_id id, int param, void *ptr) |
| 619 | 619 | { |
| 620 | 620 | m_timer_allocator.alloc()->init(device, id, ptr, true).adjust(duration, param); |
| 621 | 621 | } |
| r31185 | r31186 | |
| 931 | 931 | // that is in use |
| 932 | 932 | //------------------------------------------------- |
| 933 | 933 | |
| 934 | | void device_scheduler::add_scheduling_quantum(attotime quantum, attotime duration) |
| 934 | void device_scheduler::add_scheduling_quantum(const attotime &quantum, const attotime &duration) |
| 935 | 935 | { |
| 936 | 936 | assert(quantum.seconds == 0); |
| 937 | 937 | |
trunk/src/emu/schedule.h
| r31185 | r31186 | |
| 79 | 79 | void set_ptr(void *ptr) { m_ptr = ptr; } |
| 80 | 80 | |
| 81 | 81 | // control |
| 82 | | void reset(attotime duration = attotime::never) { adjust(duration, m_param, m_period); } |
| 83 | | void adjust(attotime duration, INT32 param = 0, attotime periodicity = attotime::never); |
| 82 | void reset(const attotime &duration = attotime::never) { adjust(duration, m_param, m_period); } |
| 83 | void adjust(attotime start_delay, INT32 param = 0, const attotime &periodicity = attotime::never); |
| 84 | 84 | |
| 85 | 85 | // timing queries |
| 86 | 86 | attotime elapsed() const; |
| r31185 | r31186 | |
| 133 | 133 | // execution |
| 134 | 134 | void timeslice(); |
| 135 | 135 | void abort_timeslice(); |
| 136 | | void trigger(int trigid, attotime after = attotime::zero); |
| 137 | | void boost_interleave(attotime timeslice_time, attotime boost_duration); |
| 136 | void trigger(int trigid, const attotime &after = attotime::zero); |
| 137 | void boost_interleave(const attotime ×lice_time, const attotime &boost_duration); |
| 138 | 138 | void suspend_resume_changed() { m_suspend_changes_pending = true; } |
| 139 | 139 | |
| 140 | 140 | // timers, specified by callback/name |
| 141 | 141 | emu_timer *timer_alloc(timer_expired_delegate callback, void *ptr = NULL); |
| 142 | | void timer_set(attotime duration, timer_expired_delegate callback, int param = 0, void *ptr = NULL); |
| 143 | | void timer_pulse(attotime period, timer_expired_delegate callback, int param = 0, void *ptr = NULL); |
| 142 | void timer_set(const attotime &duration, timer_expired_delegate callback, int param = 0, void *ptr = NULL); |
| 143 | void timer_pulse(const attotime &period, timer_expired_delegate callback, int param = 0, void *ptr = NULL); |
| 144 | 144 | void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, param, ptr); } |
| 145 | 145 | |
| 146 | 146 | // timers with old-skool callbacks |
| 147 | 147 | emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = NULL) { return timer_alloc(timer_expired_delegate(callback, name, &machine()), ptr); } |
| 148 | | void timer_set(attotime duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_set(duration, timer_expired_delegate(callback, name, &machine()), param, ptr); } |
| 149 | | void timer_pulse(attotime period, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_pulse(period, timer_expired_delegate(callback, name, &machine()), param, ptr); } |
| 148 | void timer_set(const attotime &duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_set(duration, timer_expired_delegate(callback, name, &machine()), param, ptr); } |
| 149 | void timer_pulse(const attotime &period, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_pulse(period, timer_expired_delegate(callback, name, &machine()), param, ptr); } |
| 150 | 150 | void synchronize(timer_expired_func callback, const char *name = NULL, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, name, param, ptr); } |
| 151 | 151 | |
| 152 | 152 | // timers, specified by device/id; generally devices should use the device_t methods instead |
| 153 | 153 | emu_timer *timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = NULL); |
| 154 | | void timer_set(attotime duration, device_t &device, device_timer_id id = 0, int param = 0, void *ptr = NULL); |
| 154 | void timer_set(const attotime &duration, device_t &device, device_timer_id id = 0, int param = 0, void *ptr = NULL); |
| 155 | 155 | |
| 156 | 156 | // debugging |
| 157 | 157 | void dump_timers() const; |
| r31185 | r31186 | |
| 169 | 169 | void compute_perfect_interleave(); |
| 170 | 170 | void rebuild_execute_list(); |
| 171 | 171 | void apply_suspend_changes(); |
| 172 | | void add_scheduling_quantum(attotime quantum, attotime duration); |
| 172 | void add_scheduling_quantum(const attotime &quantum, const attotime &duration); |
| 173 | 173 | |
| 174 | 174 | // timer helpers |
| 175 | 175 | emu_timer &timer_list_insert(emu_timer &timer); |