diff options
author | Aaron Giles <aaron@aarongiles.com> | 2021-03-23 17:13:14 -0700 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2021-03-23 17:13:14 -0700 |
commit | bf29ca5075d62178863eb1c72fe29abe96f0d7a9 (patch) | |
tree | c7626821fe452f3ea4cb20617c6d7fc976e843ec | |
parent | ab35bc38737da5f47277afd6aabaa5bb7d6146b5 (diff) |
Remove some old-school synchronize calls. Add an optional unique ID pointer to enregistration to help differentiate in non-device cases.
25 files changed, 102 insertions, 34 deletions
diff --git a/src/devices/machine/aic565.cpp b/src/devices/machine/aic565.cpp index 34da7f4fd14..1ef7bc2044f 100644 --- a/src/devices/machine/aic565.cpp +++ b/src/devices/machine/aic565.cpp @@ -75,6 +75,9 @@ void aic565_device::device_start() save_item(NAME(m_local_status)); save_item(NAME(m_aux_status)); save_item(NAME(m_interrupt_flags)); + + m_host_sync_w.enregister(*this, FUNC(aic565_device::host_sync_w)); + m_local_sync_w.enregister(*this, FUNC(aic565_device::local_sync_w)); } @@ -130,7 +133,7 @@ u8 aic565_device::host_r(offs_t offset) void aic565_device::host_w(offs_t offset, u8 data) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(aic565_device::host_sync_w), this), (offset & 3) << 8 | data); + m_host_sync_w.synchronize((offset & 3) << 8 | data); } @@ -214,7 +217,7 @@ u8 aic565_device::local_r(offs_t offset) void aic565_device::local_w(offs_t offset, u8 data) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(aic565_device::local_sync_w), this), (offset & 3) << 8 | data); + m_local_sync_w.synchronize((offset & 3) << 8 | data); } diff --git a/src/devices/machine/aic565.h b/src/devices/machine/aic565.h index 581a595d77c..5c8c7f5f2ad 100644 --- a/src/devices/machine/aic565.h +++ b/src/devices/machine/aic565.h @@ -45,7 +45,9 @@ protected: private: // synchronization helpers TIMER_CALLBACK_MEMBER(host_sync_w); + emu_timer_cb m_host_sync_w; TIMER_CALLBACK_MEMBER(local_sync_w); + emu_timer_cb m_local_sync_w; // callback objects devcb_write_line m_hrst_callback; diff --git a/src/devices/machine/am9513.cpp b/src/devices/machine/am9513.cpp index 9e6a661b18b..bab1b24b8d4 100644 --- a/src/devices/machine/am9513.cpp +++ b/src/devices/machine/am9513.cpp @@ -83,6 +83,8 @@ void am9513_device::device_start() m_out_cb.resolve_all_safe(); m_fout_cb.resolve(); + m_clear_outputs.enregister(*this, FUNC(am9513_device::clear_outputs)); + // Power-on reset m_dpr = 0x1f; m_mmr = 0; @@ -144,7 +146,7 @@ void am9513_device::device_start() save_item(NAME(m_fout_counter)); // Synchronize clearing of OUT n - machine().scheduler().synchronize(timer_expired_delegate(FUNC(am9513_device::clear_outputs), this)); + m_clear_outputs.synchronize(); } diff --git a/src/devices/machine/am9513.h b/src/devices/machine/am9513.h index 0ea22285b4e..c34ad042405 100644 --- a/src/devices/machine/am9513.h +++ b/src/devices/machine/am9513.h @@ -98,6 +98,7 @@ protected: private: // internal helpers TIMER_CALLBACK_MEMBER(clear_outputs); + emu_timer_cb m_clear_outputs; void master_reset(); void init_freq_timer(int f); void select_freq_timer(int f, int c, bool selected, bool cycle); diff --git a/src/devices/machine/at_keybc.cpp b/src/devices/machine/at_keybc.cpp index a166ff234cb..3b53f857cc4 100644 --- a/src/devices/machine/at_keybc.cpp +++ b/src/devices/machine/at_keybc.cpp @@ -167,7 +167,7 @@ uint8_t at_kbc_device_base::status_r() void at_kbc_device_base::data_w(uint8_t data) { LOG("data_w 0x%02x (%s)\n", data, machine().describe_context()); - machine().scheduler().synchronize(timer_expired_delegate(FUNC(at_kbc_device_base::write_data), this), unsigned(data)); + m_write_data.synchronize(unsigned(data)); } void at_kbc_device_base::command_w(uint8_t data) @@ -269,17 +269,17 @@ void at_kbc_device_base::command_w(uint8_t data) else LOG("command_w 0x%02x (%s)\n", data, machine().describe_context()); - machine().scheduler().synchronize(timer_expired_delegate(FUNC(at_kbc_device_base::write_command), this), unsigned(data)); + m_write_command.synchronize(unsigned(data)); } WRITE_LINE_MEMBER(at_kbc_device_base::kbd_clk_w) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(at_kbc_device_base::set_kbd_clk_in), this), state); + m_set_kbd_clk_in.synchronize(state); } WRITE_LINE_MEMBER(at_kbc_device_base::kbd_data_w) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(at_kbc_device_base::set_kbd_data_in), this), state); + m_set_kbd_data_in.synchronize(state); } at_kbc_device_base::at_kbc_device_base(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock) @@ -311,6 +311,11 @@ void at_kbc_device_base::device_start() save_item(NAME(m_kbd_data_in)); save_item(NAME(m_kbd_data_out)); + m_write_data.enregister(*this, FUNC(at_kbc_device_base::write_data)); + m_write_command.enregister(*this, FUNC(at_kbc_device_base::write_command)); + m_set_kbd_clk_in.enregister(*this, FUNC(at_kbc_device_base::set_kbd_clk_in)); + m_set_kbd_data_in.enregister(*this, FUNC(at_kbc_device_base::set_kbd_data_in)); + m_hot_res = m_gate_a20 = m_kbd_irq = 0U; m_kbd_clk_in = m_kbd_clk_out = 1U; m_kbd_data_in = m_kbd_data_out = 1U; @@ -444,12 +449,12 @@ uint8_t ps2_keyboard_controller_device::status_r() WRITE_LINE_MEMBER(ps2_keyboard_controller_device::aux_clk_w) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(ps2_keyboard_controller_device::set_aux_clk_in), this), state); + m_set_aux_clk_in.synchronize(state); } WRITE_LINE_MEMBER(ps2_keyboard_controller_device::aux_data_w) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(ps2_keyboard_controller_device::set_aux_data_in), this), state); + m_set_aux_data_in.synchronize(state); } ps2_keyboard_controller_device::ps2_keyboard_controller_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock) @@ -491,6 +496,9 @@ void ps2_keyboard_controller_device::device_start() { at_kbc_device_base::device_start(); + m_set_aux_clk_in.enregister(*this, FUNC(ps2_keyboard_controller_device::set_aux_clk_in)); + m_set_aux_data_in.enregister(*this, FUNC(ps2_keyboard_controller_device::set_aux_data_in)); + save_item(NAME(m_aux_irq)); save_item(NAME(m_aux_clk_in)); save_item(NAME(m_aux_clk_out)); diff --git a/src/devices/machine/at_keybc.h b/src/devices/machine/at_keybc.h index 9e769416cb2..6ffe7b24254 100644 --- a/src/devices/machine/at_keybc.h +++ b/src/devices/machine/at_keybc.h @@ -63,9 +63,13 @@ protected: private: // internal sync helpers TIMER_CALLBACK_MEMBER(write_data); + emu_timer_cb m_write_data; TIMER_CALLBACK_MEMBER(write_command); + emu_timer_cb m_write_command; TIMER_CALLBACK_MEMBER(set_kbd_clk_in); + emu_timer_cb m_set_kbd_clk_in; TIMER_CALLBACK_MEMBER(set_kbd_data_in); + emu_timer_cb m_set_kbd_data_in; devcb_write_line m_hot_res_cb, m_gate_a20_cb, m_kbd_irq_cb; devcb_write_line m_kbd_clk_cb, m_kbd_data_cb; @@ -141,7 +145,9 @@ private: // internal sync helpers TIMER_CALLBACK_MEMBER(set_aux_clk_in); + emu_timer_cb m_set_aux_clk_in; TIMER_CALLBACK_MEMBER(set_aux_data_in); + emu_timer_cb m_set_aux_data_in; // MCU I/O handlers uint8_t p1_r(); diff --git a/src/devices/machine/chessmachine.cpp b/src/devices/machine/chessmachine.cpp index ce0d358f183..570fcb3a162 100644 --- a/src/devices/machine/chessmachine.cpp +++ b/src/devices/machine/chessmachine.cpp @@ -60,6 +60,8 @@ void chessmachine_device::device_start() { // resolve callbacks m_data_out.resolve_safe(); + m_sync0_callback.enregister(*this, FUNC(chessmachine_device::sync0_callback)); + m_sync1_callback.enregister(*this, FUNC(chessmachine_device::sync1_callback)); // zerofill m_bootstrap_enabled = false; @@ -83,7 +85,7 @@ void chessmachine_device::sync0_callback(void *ptr, s32 param) void chessmachine_device::data0_w(int state) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(chessmachine_device::sync0_callback), this), state ? 1 : 0); + m_sync0_callback.synchronize(state ? 1 : 0); } void chessmachine_device::sync1_callback(void *ptr, s32 param) @@ -96,7 +98,7 @@ void chessmachine_device::sync1_callback(void *ptr, s32 param) void chessmachine_device::data1_w(int state) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(chessmachine_device::sync1_callback), this), state ? 0x80 : 0); + m_sync1_callback.synchronize(state ? 0x80 : 0); } void chessmachine_device::reset_w(int state) diff --git a/src/devices/machine/chessmachine.h b/src/devices/machine/chessmachine.h index 4d589fc97c3..1845034eb21 100644 --- a/src/devices/machine/chessmachine.h +++ b/src/devices/machine/chessmachine.h @@ -47,7 +47,9 @@ private: u8 m_latch[2]; void sync0_callback(void *ptr, s32 param); + emu_timer_cb m_sync0_callback; void sync1_callback(void *ptr, s32 param); + emu_timer_cb m_sync1_callback; bool m_bootstrap_enabled; TIMER_DEVICE_CALLBACK_MEMBER(disable_bootstrap) { m_bootstrap_enabled = false; } diff --git a/src/devices/machine/gen_latch.cpp b/src/devices/machine/gen_latch.cpp index 2e3929b108a..6a7edeb33c1 100644 --- a/src/devices/machine/gen_latch.cpp +++ b/src/devices/machine/gen_latch.cpp @@ -49,7 +49,8 @@ void generic_latch_base_device::device_start() save_item(NAME(m_latch_written)); // synchronization is needed since other devices may not be initialized yet - machine().scheduler().synchronize(timer_expired_delegate(FUNC(generic_latch_base_device::init_callback), this)); + m_init_callback.enregister(*this, FUNC(generic_latch_base_device::init_callback)); + m_init_callback.synchronize(); } //------------------------------------------------- @@ -125,7 +126,7 @@ u8 generic_latch_8_device::read() void generic_latch_8_device::write(u8 data) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(generic_latch_8_device::sync_callback), this), data); + m_sync_callback.synchronize(data); } void generic_latch_8_device::preset_w(u8 data) @@ -174,6 +175,7 @@ void generic_latch_8_device::device_start() { // register for state saving generic_latch_base_device::device_start(); + m_sync_callback.enregister(*this, FUNC(generic_latch_8_device::sync_callback)); save_item(NAME(m_latched_value)); } @@ -196,7 +198,7 @@ u16 generic_latch_16_device::read() void generic_latch_16_device::write(u16 data) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(generic_latch_16_device::sync_callback), this), data); + m_sync_callback.synchronize(data); } void generic_latch_16_device::preset_w(u16 data) @@ -245,5 +247,6 @@ void generic_latch_16_device::device_start() { // register for state saving generic_latch_base_device::device_start(); + m_sync_callback.enregister(*this, FUNC(generic_latch_16_device::sync_callback)); save_item(NAME(m_latched_value)); } diff --git a/src/devices/machine/gen_latch.h b/src/devices/machine/gen_latch.h index 4080cbebe8d..2a19eec3ef0 100644 --- a/src/devices/machine/gen_latch.h +++ b/src/devices/machine/gen_latch.h @@ -52,6 +52,7 @@ protected: private: void init_callback(void *ptr, s32 param); + emu_timer_cb m_init_callback; bool m_separate_acknowledge; bool m_latch_written; @@ -79,6 +80,7 @@ protected: virtual void device_start() override; void sync_callback(void *ptr, s32 param); + emu_timer_cb m_sync_callback; private: u8 m_latched_value; @@ -105,6 +107,7 @@ protected: virtual void device_start() override; void sync_callback(void *ptr, s32 param); + emu_timer_cb m_sync_callback; private: u16 m_latched_value; diff --git a/src/devices/machine/input_merger.cpp b/src/devices/machine/input_merger.cpp index 28652cdb66f..d7927486d4f 100644 --- a/src/devices/machine/input_merger.cpp +++ b/src/devices/machine/input_merger.cpp @@ -70,6 +70,7 @@ input_merger_device::~input_merger_device() void input_merger_device::device_start() { m_output_handler.resolve_safe(); + m_update_state.enregister(*this, FUNC(input_merger_device::update_state)); save_item(NAME(m_state)); m_state = m_initval; } diff --git a/src/devices/machine/input_merger.h b/src/devices/machine/input_merger.h index 10c400b4a74..0ad4b3c10a4 100644 --- a/src/devices/machine/input_merger.h +++ b/src/devices/machine/input_merger.h @@ -26,7 +26,7 @@ public: auto output_handler() { return m_output_handler.bind(); } // input lines - template <unsigned Bit> DECLARE_WRITE_LINE_MEMBER(in_w) { static_assert(Bit < 32, "invalid bit"); machine().scheduler().synchronize(timer_expired_delegate(FUNC(input_merger_device::update_state), this), (Bit << 1) | (state ? 1U : 0U)); } + template <unsigned Bit> DECLARE_WRITE_LINE_MEMBER(in_w) { static_assert(Bit < 32, "invalid bit"); m_update_state.synchronize((Bit << 1) | (state ? 1U : 0U)); } template <unsigned Bit> void in_set(u8 data) { in_w<Bit>(1); } template <unsigned Bit> void in_clear(u8 data) { in_w<Bit>(0); } @@ -53,6 +53,7 @@ protected: u32 const m_initval, m_xorval; int const m_active; u32 m_state; + emu_timer_cb m_update_state; }; diff --git a/src/devices/machine/latch8.cpp b/src/devices/machine/latch8.cpp index 4db3d302195..a73b94c464f 100644 --- a/src/devices/machine/latch8.cpp +++ b/src/devices/machine/latch8.cpp @@ -60,7 +60,7 @@ void latch8_device::write(offs_t offset, uint8_t data) assert(offset == 0); if (m_nosync != 0xff) - machine().scheduler().synchronize(timer_expired_delegate(FUNC(latch8_device::timerproc),this), (0xFF << 8) | data); + m_timerproc.synchronize((0xFF << 8) | data); else update(data, 0xFF); } @@ -87,7 +87,7 @@ void latch8_device::bitx_w(int bit, offs_t offset, uint8_t data) if (m_nosync & mask) update(masked_data, mask); else - machine().scheduler().synchronize(timer_expired_delegate(FUNC(latch8_device::timerproc),this), (mask << 8) | masked_data); + m_timerproc.synchronize((mask << 8) | masked_data); } void latch8_device::bit0_w(offs_t offset, uint8_t data) { bitx_w(0, offset, data); } @@ -133,6 +133,8 @@ void latch8_device::device_validity_check(validity_checker &valid) const void latch8_device::device_start() { + m_timerproc.enregister(*this, FUNC(latch8_device::timerproc)); + /* setup nodemap */ for (auto &cb : m_write_cb) { diff --git a/src/devices/machine/latch8.h b/src/devices/machine/latch8.h index 750a9c752b5..0612fdc1a0a 100644 --- a/src/devices/machine/latch8.h +++ b/src/devices/machine/latch8.h @@ -90,6 +90,7 @@ protected: virtual void device_validity_check(validity_checker &valid) const override; TIMER_CALLBACK_MEMBER( timerproc ); + emu_timer_cb m_timerproc; void update(uint8_t new_val, uint8_t mask); inline void bitx_w(int bit, offs_t offset, uint8_t data); diff --git a/src/devices/machine/rstbuf.cpp b/src/devices/machine/rstbuf.cpp index 9e13d72743a..db8f510c70b 100644 --- a/src/devices/machine/rstbuf.cpp +++ b/src/devices/machine/rstbuf.cpp @@ -117,6 +117,9 @@ void rst_buffer_device::device_resolve_objects() void rst_buffer_device::device_start() { + m_sync_set_input.enregister(*this, FUNC(rst_pos_buffer_device::sync_set_input)); + m_sync_clear_input.enregister(*this, FUNC(rst_pos_buffer_device::sync_clear_input)); + // save input state save_item(NAME(m_input_buffer)); } @@ -163,9 +166,9 @@ TIMER_CALLBACK_MEMBER(rst_buffer_device::sync_clear_input) void rst_buffer_device::sync_input(bool state, u8 mask) { if (state) - machine().scheduler().synchronize(timer_expired_delegate(FUNC(rst_pos_buffer_device::sync_set_input), this), mask); + m_sync_set_input.synchronize(mask); else - machine().scheduler().synchronize(timer_expired_delegate(FUNC(rst_pos_buffer_device::sync_clear_input), this), mask); + m_sync_clear_input.synchronize(mask); } diff --git a/src/devices/machine/rstbuf.h b/src/devices/machine/rstbuf.h index 718a96f4861..abcfc234b66 100644 --- a/src/devices/machine/rstbuf.h +++ b/src/devices/machine/rstbuf.h @@ -39,7 +39,9 @@ protected: // synchronization helpers void sync_input(bool state, u8 mask); TIMER_CALLBACK_MEMBER(sync_set_input); + emu_timer_cb m_sync_set_input; TIMER_CALLBACK_MEMBER(sync_clear_input); + emu_timer_cb m_sync_clear_input; // interrupt output callback devcb_write_line m_int_cb; diff --git a/src/devices/machine/z80dma.cpp b/src/devices/machine/z80dma.cpp index 1a347cc2f24..c892200514f 100644 --- a/src/devices/machine/z80dma.cpp +++ b/src/devices/machine/z80dma.cpp @@ -182,6 +182,7 @@ void z80dma_device::device_start() // allocate timer m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z80dma_device::timerproc), this)); + m_rdy_write_callback.enregister(*this, FUNC(z80dma_device::rdy_write_callback)); // register for state saving save_item(NAME(m_regs)); @@ -866,7 +867,7 @@ TIMER_CALLBACK_MEMBER(z80dma_device::rdy_write_callback) WRITE_LINE_MEMBER(z80dma_device::rdy_w) { LOG("Z80DMA RDY: %d Active High: %d\n", state, READY_ACTIVE_HIGH); - machine().scheduler().synchronize(timer_expired_delegate(FUNC(z80dma_device::rdy_write_callback),this), state); + m_rdy_write_callback.synchronize(state); } diff --git a/src/devices/machine/z80dma.h b/src/devices/machine/z80dma.h index 14725329bd0..acaa689dfd9 100644 --- a/src/devices/machine/z80dma.h +++ b/src/devices/machine/z80dma.h @@ -92,6 +92,7 @@ private: void update_status(); TIMER_CALLBACK_MEMBER(rdy_write_callback); + emu_timer_cb m_rdy_write_callback; // internal state devcb_write_line m_out_busreq_cb; diff --git a/src/devices/sound/qsound.cpp b/src/devices/sound/qsound.cpp index 29b2661add5..7cf2876a816 100644 --- a/src/devices/sound/qsound.cpp +++ b/src/devices/sound/qsound.cpp @@ -209,6 +209,8 @@ void qsound_device::device_start() // hope we get good synchronisation between the DSP and the sound system m_stream = stream_alloc(0, 2, clock() / 2 / 1248); + m_set_dsp_ready.enregister(*this, FUNC(qsound_device::set_dsp_ready)); + // save DSP communication state save_item(NAME(m_rom_bank)); save_item(NAME(m_rom_offset)); @@ -349,7 +351,7 @@ u16 qsound_device::dsp_pio_r() { m_cmd_pending = 0U; m_dsp->set_input_line(DSP16_INT_LINE, CLEAR_LINE); - machine().scheduler().synchronize(timer_expired_delegate(FUNC(qsound_device::set_dsp_ready), this)); + m_set_dsp_ready.synchronize(); return m_cmd_addr; } else diff --git a/src/devices/sound/qsound.h b/src/devices/sound/qsound.h index 6a9be5dfbc2..2c108e13db6 100644 --- a/src/devices/sound/qsound.h +++ b/src/devices/sound/qsound.h @@ -48,6 +48,7 @@ private: DECLARE_WRITE_LINE_MEMBER(dsp_ock_w); u16 dsp_pio_r(); void set_dsp_ready(void *ptr, s32 param); + emu_timer_cb m_set_dsp_ready; void set_cmd(void *ptr, s32 param); // MAME resources diff --git a/src/devices/sound/ymfm.cpp b/src/devices/sound/ymfm.cpp index 2931b62ebbe..0bf70cea995 100644 --- a/src/devices/sound/ymfm.cpp +++ b/src/devices/sound/ymfm.cpp @@ -1291,6 +1291,10 @@ void ymfm_engine_base<RegisterType>::save(device_t &device) // resolve the IRQ handler while we're here m_irq_handler.resolve(); + // register timer callbacks + m_synced_mode_w.enregister(device.machine().scheduler(), device.tag(), timer_expired_delegate(FUNC(ymfm_engine_base<RegisterType>::synced_mode_w), this)); + m_check_interrupts.enregister(device.machine().scheduler(), device.tag(), timer_expired_delegate(FUNC(ymfm_engine_base<RegisterType>::check_interrupts), this)); + // save our data device.save_item(YMFM_NAME(m_env_counter)); device.save_item(YMFM_NAME(m_lfo_counter)); @@ -1399,7 +1403,7 @@ void ymfm_engine_base<RegisterType>::write(u16 regnum, u8 data) // schedule these writes to ensure ordering with timers if (regnum == RegisterType::REG_MODE) { - m_device.machine().scheduler().synchronize(timer_expired_delegate(FUNC(ymfm_engine_base<RegisterType>::synced_mode_w), this), data); + m_synced_mode_w.synchronize(data); return; } @@ -1637,7 +1641,7 @@ void ymfm_engine_base<RegisterType>::schedule_check_interrupts() // otherwise, do it directly auto &scheduler = m_device.machine().scheduler(); if (scheduler.currently_executing()) - scheduler.synchronize(timer_expired_delegate(FUNC(ymfm_engine_base<RegisterType>::check_interrupts), this), 0); + m_check_interrupts.synchronize(0); else check_interrupts(nullptr, 0); } diff --git a/src/devices/sound/ymfm.h b/src/devices/sound/ymfm.h index 33e307ed16f..058c6af356d 100644 --- a/src/devices/sound/ymfm.h +++ b/src/devices/sound/ymfm.h @@ -789,9 +789,11 @@ private: // check interrupts TIMER_CALLBACK_MEMBER(check_interrupts); + emu_timer_cb m_check_interrupts; // handle a mode register write TIMER_CALLBACK_MEMBER(synced_mode_w); + emu_timer_cb m_synced_mode_w; // internal state device_t &m_device; // reference to the owning device diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp index 07ac1e35a28..15a7e0d43e3 100644 --- a/src/emu/schedule.cpp +++ b/src/emu/schedule.cpp @@ -55,17 +55,22 @@ emu_timer_cb::emu_timer_cb() : { } -void emu_timer_cb::enregister(device_scheduler &scheduler, timer_expired_delegate callback) +void emu_timer_cb::enregister(device_scheduler &scheduler, char const *unique, timer_expired_delegate callback) { if (m_next != nullptr) throw emu_fatalerror("Attempted to re-enregister a emu_timer_cb"); m_callback = callback; m_scheduler = &scheduler; m_unique_id = m_callback.name(); + if (unique != nullptr) + { + m_unique_id += "/"; + m_unique_id += unique; + } m_scheduler->register_timer_expired(*this); } -void emu_timer_cb::enregister(device_t &device, timer_expired_delegate callback) +void emu_timer_cb::enregister(device_t &device, char const *unique, timer_expired_delegate callback) { if (m_next != nullptr) throw emu_fatalerror("Attempted to re-enregister a emu_timer_cb"); @@ -74,10 +79,15 @@ void emu_timer_cb::enregister(device_t &device, timer_expired_delegate callback) m_unique_id = device.tag(); m_unique_id += "/"; m_unique_id += m_callback.name(); + if (unique != nullptr) + { + m_unique_id += "/"; + m_unique_id += unique; + } m_scheduler->register_timer_expired(*this); } -void emu_timer_cb::interface_enregister(device_interface &intf, timer_expired_delegate callback) +void emu_timer_cb::interface_enregister(device_interface &intf, char const *unique, timer_expired_delegate callback) { if (m_next != nullptr) throw emu_fatalerror("Attempted to re-enregister a emu_timer_cb"); @@ -86,6 +96,11 @@ void emu_timer_cb::interface_enregister(device_interface &intf, timer_expired_de m_unique_id = intf.device().tag(); m_unique_id += "/"; m_unique_id += m_callback.name(); + if (unique != nullptr) + { + m_unique_id += "/"; + m_unique_id += unique; + } m_scheduler->register_timer_expired(*this); } diff --git a/src/emu/schedule.h b/src/emu/schedule.h index bdfc9afa978..cbfd39fa21e 100644 --- a/src/emu/schedule.h +++ b/src/emu/schedule.h @@ -44,20 +44,20 @@ public: emu_timer_cb(); // registration - void enregister(device_scheduler &scheduler, timer_expired_delegate callback); - void enregister(device_t &device, timer_expired_delegate callback); - void interface_enregister(device_interface &device, timer_expired_delegate callback); + void enregister(device_scheduler &scheduler, char const *unique, timer_expired_delegate callback); + void enregister(device_t &device, char const *unique, timer_expired_delegate callback); + void interface_enregister(device_interface &device, char const *unique, timer_expired_delegate callback); // direct registration for device's and device interfaces template<typename DeviceType, typename FuncType> - void enregister(DeviceType &device, FuncType callback, char const *string) + void enregister(DeviceType &device, FuncType callback, char const *string, char const *unique = nullptr) { - return enregister(device, timer_expired_delegate(callback, string, &device)); + enregister(device, unique, timer_expired_delegate(callback, string, &device)); } template<typename IntfType, typename FuncType> - void interface_enregister(IntfType &intf, FuncType callback, char const *string) + void interface_enregister(IntfType &intf, FuncType callback, char const *string, char const *unique = nullptr) { - return enregister(intf, timer_expired_delegate(callback, string, &intf)); + interface_enregister(intf, unique, timer_expired_delegate(callback, string, &intf)); } // call the delegate after a set amount of time, with the given parameter diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 2ed3a088a26..2439c944d1f 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -637,7 +637,7 @@ bool lua_engine::on_missing_mandatory_image(const std::string &instance_name) void lua_engine::attach_notifiers() { - m_resume.enregister(machine().scheduler(), timer_expired_delegate(FUNC(lua_engine::resume), this)); + m_resume.enregister(machine().scheduler(), nullptr, timer_expired_delegate(FUNC(lua_engine::resume), this)); machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(&lua_engine::on_machine_prestart, this), true); machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(&lua_engine::on_machine_start, this)); |