From 58fed9839ff65d69a81014fd1134aa92c34d3fc2 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 12 Jun 2023 03:14:42 +1000 Subject: emu/devfind.h: Added a lookup() member function to device finders. This simplifies looking up the target device during configuration. It is useful when configuring child devices in things like CPUs with integrated peripherals. emu/device.h: Allow templated subdevice() and siblingdevice() to work with classes that don't derive from device_t (e.g. classes that derive from device_interface). util/delegate.h: Added more noexcept. Won't make much difference as most of the affected member functions are inline anyway. --- src/devices/bus/imi7000/imi7000.h | 8 +-- src/devices/bus/isa/gus.cpp | 8 ++- src/devices/bus/ti99/colorbus/colorbus.cpp | 10 ++-- src/devices/cpu/h8/h8.h | 2 +- src/devices/cpu/nec/v5x.h | 40 +++++++-------- src/devices/cpu/psx/psx.h | 1 - src/devices/cpu/psx/rcnt.cpp | 30 +++++------ src/devices/cpu/psx/sio.cpp | 26 +++++----- src/devices/cpu/upd7725/upd7725.cpp | 34 ++++++------- src/devices/cpu/z180/z180.h | 14 +++--- src/devices/cpu/z80/tmpz84c015.h | 4 +- src/devices/machine/40105.cpp | 22 ++++---- src/devices/machine/74123.cpp | 22 ++++---- src/devices/machine/74148.cpp | 2 +- src/devices/machine/am53cf96.cpp | 12 ++--- src/devices/machine/at.h | 4 +- src/devices/machine/cdp1879.cpp | 8 +-- src/devices/machine/dp8573.cpp | 6 ++- src/devices/machine/ds1315.cpp | 4 +- src/devices/machine/ds75160a.cpp | 14 +++--- src/devices/machine/ds75161a.cpp | 56 ++++++++++----------- src/devices/machine/e05a30.cpp | 4 +- src/devices/machine/genpc.h | 4 +- src/devices/machine/i80130.cpp | 20 ++++---- src/devices/machine/i82357.h | 2 +- src/devices/machine/ie15_kbd.cpp | 3 +- src/devices/machine/ie15_kbd.h | 5 +- src/devices/machine/ripple_counter.cpp | 20 ++++---- src/devices/machine/z80ctc.h | 2 +- src/devices/sound/t6721a.cpp | 16 +++--- src/devices/sound/ymz280b.cpp | 6 ++- src/devices/video/decsfb.cpp | 4 +- src/devices/video/tms34061.cpp | 4 +- src/devices/video/tms9927.cpp | 4 +- src/devices/video/vic4567.cpp | 1 - src/emu/devfind.h | 6 +++ src/emu/device.h | 46 ++++++++++++++--- src/lib/util/delegate.h | 80 +++++++++++++++--------------- src/mame/apple/macrtc.cpp | 22 ++++---- src/mame/atari/gtia.cpp | 2 +- src/mame/konami/k573fpga.h | 2 +- src/mame/pinball/wpc.cpp | 26 +++++----- src/mame/sgi/sgi_gr1.h | 13 +++-- src/mame/shared/megacdcd.h | 2 +- src/mame/shared/xbox_pci.h | 8 +-- src/mame/sunelectronics/ikki.cpp | 18 +++---- src/mame/vsystem/vsystem_gga.cpp | 8 +-- 47 files changed, 348 insertions(+), 307 deletions(-) diff --git a/src/devices/bus/imi7000/imi7000.h b/src/devices/bus/imi7000/imi7000.h index c1cf590091c..ce76033f30a 100644 --- a/src/devices/bus/imi7000/imi7000.h +++ b/src/devices/bus/imi7000/imi7000.h @@ -80,10 +80,10 @@ public: template void set_slot_default_options(T &&def1, U &&def2, V &&def3, W &&def4) { - subdevice(m_units[0].finder_tag())->set_default_option(std::forward(def1)); - subdevice(m_units[1].finder_tag())->set_default_option(std::forward(def2)); - subdevice(m_units[2].finder_tag())->set_default_option(std::forward(def3)); - subdevice(m_units[3].finder_tag())->set_default_option(std::forward(def4)); + m_units[0].lookup()->set_default_option(std::forward(def1)); + m_units[1].lookup()->set_default_option(std::forward(def2)); + m_units[2].lookup()->set_default_option(std::forward(def3)); + m_units[3].lookup()->set_default_option(std::forward(def4)); } protected: diff --git a/src/devices/bus/isa/gus.cpp b/src/devices/bus/isa/gus.cpp index becce41d29a..6ad155a5db5 100644 --- a/src/devices/bus/isa/gus.cpp +++ b/src/devices/bus/isa/gus.cpp @@ -380,9 +380,6 @@ void gf1_device::device_start() { acia6850_device::device_start(); - int i; - double out = (double)(1 << 13); - m_txirq_handler.resolve_safe(); m_rxirq_handler.resolve_safe(); m_wave_irq_handler.resolve_safe(); @@ -416,9 +413,10 @@ void gf1_device::device_start() m_gf1_irq = 0; m_midi_irq = 0; - for (i=4095;i>=0;i--) + double out = double(1 << 13); + for (int i = 4095; i >= 0; i--) { - m_volume_table[i] = (int16_t)out; + m_volume_table[i] = int16_t(out); out /= 1.002709201; /* 0.0235 dB Steps */ } diff --git a/src/devices/bus/ti99/colorbus/colorbus.cpp b/src/devices/bus/ti99/colorbus/colorbus.cpp index e3decb6ba61..df6767cf65e 100644 --- a/src/devices/bus/ti99/colorbus/colorbus.cpp +++ b/src/devices/bus/ti99/colorbus/colorbus.cpp @@ -25,11 +25,11 @@ DEFINE_DEVICE_TYPE(V9938_COLORBUS, bus::ti99::colorbus::v9938_colorbus_device, " namespace bus::ti99::colorbus { -v9938_colorbus_device::v9938_colorbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, V9938_COLORBUS, tag, owner, clock), - device_single_card_slot_interface(mconfig, *this), - m_v9938(*owner, TIGEN_V9938_TAG), - m_extra_button(*this) +v9938_colorbus_device::v9938_colorbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, V9938_COLORBUS, tag, owner, clock), + device_single_card_slot_interface(mconfig, *this), + m_v9938(*owner, TIGEN_V9938_TAG), + m_extra_button(*this) { } diff --git a/src/devices/cpu/h8/h8.h b/src/devices/cpu/h8/h8.h index 2d92da051c6..07375cc4df3 100644 --- a/src/devices/cpu/h8/h8.h +++ b/src/devices/cpu/h8/h8.h @@ -42,7 +42,7 @@ public: template void sci_clk_w(int state) { m_sci[sci]->do_clk_w(state); } void sci_set_external_clock_period(int sci, const attotime &period) { - m_sci[sci].finder_target().first.subdevice(m_sci[sci].finder_target().second)->do_set_external_clock_period(period); + m_sci[sci].lookup()->do_set_external_clock_period(period); } void internal_update(); diff --git a/src/devices/cpu/nec/v5x.h b/src/devices/cpu/nec/v5x.h index 5e766bc77d1..d30bb5fdb4a 100644 --- a/src/devices/cpu/nec/v5x.h +++ b/src/devices/cpu/nec/v5x.h @@ -22,26 +22,26 @@ public: void tclk_w(int state); // DMAU - auto out_hreq_cb() { return device().subdevice("dmau")->out_hreq_callback(); } - auto out_eop_cb() { return device().subdevice("dmau")->out_eop_callback(); } - auto in_memr_cb() { return device().subdevice("dmau")->in_memr_callback(); } - auto in_mem16r_cb() { return device().subdevice("dmau")->in_mem16r_callback(); } - auto out_memw_cb() { return device().subdevice("dmau")->out_memw_callback(); } - auto out_mem16w_cb() { return device().subdevice("dmau")->out_mem16w_callback(); } - template auto in_ior_cb() { return device().subdevice("dmau")->in_ior_callback(); } - template auto in_io16r_cb() { return device().subdevice("dmau")->in_io16r_callback(); } - template auto out_iow_cb() { return device().subdevice("dmau")->out_iow_callback(); } - template auto out_io16w_cb() { return device().subdevice("dmau")->out_io16w_callback(); } - template auto out_dack_cb() { return device().subdevice("dmau")->out_dack_callback(); } + auto out_hreq_cb() { return m_dmau.lookup()->out_hreq_callback(); } + auto out_eop_cb() { return m_dmau.lookup()->out_eop_callback(); } + auto in_memr_cb() { return m_dmau.lookup()->in_memr_callback(); } + auto in_mem16r_cb() { return m_dmau.lookup()->in_mem16r_callback(); } + auto out_memw_cb() { return m_dmau.lookup()->out_memw_callback(); } + auto out_mem16w_cb() { return m_dmau.lookup()->out_mem16w_callback(); } + template auto in_ior_cb() { return m_dmau.lookup()->in_ior_callback(); } + template auto in_io16r_cb() { return m_dmau.lookup()->in_io16r_callback(); } + template auto out_iow_cb() { return m_dmau.lookup()->out_iow_callback(); } + template auto out_io16w_cb() { return m_dmau.lookup()->out_io16w_callback(); } + template auto out_dack_cb() { return m_dmau.lookup()->out_dack_callback(); } // SCU - auto txd_handler_cb() { return device().subdevice("scu")->txd_handler(); } - auto dtr_handler_cb() { return device().subdevice("scu")->dtr_handler(); } - auto rts_handler_cb() { return device().subdevice("scu")->rts_handler(); } - auto rxrdy_handler_cb() { return device().subdevice("scu")->rxrdy_handler(); } - auto txrdy_handler_cb() { return device().subdevice("scu")->txrdy_handler(); } - auto txempty_handler_cb() { return device().subdevice("scu")->txempty_handler(); } - auto syndet_handler_cb() { return device().subdevice("scu")->syndet_handler(); } + auto txd_handler_cb() { return m_scu.lookup()->txd_handler(); } + auto dtr_handler_cb() { return m_scu.lookup()->dtr_handler(); } + auto rts_handler_cb() { return m_scu.lookup()->rts_handler(); } + auto rxrdy_handler_cb() { return m_scu.lookup()->rxrdy_handler(); } + auto txrdy_handler_cb() { return m_scu.lookup()->txrdy_handler(); } + auto txempty_handler_cb() { return m_scu.lookup()->txempty_handler(); } + auto syndet_handler_cb() { return m_scu.lookup()->syndet_handler(); } protected: device_v5x_interface(const machine_config &mconfig, nec_common_device &device, bool is_16bit); @@ -146,7 +146,7 @@ public: void tctl2_w(int state) { m_tcu->write_gate2(state); } auto tout1_cb() { return m_tout1_callback.bind(); } - auto tout2_cb() { return subdevice("tcu")->out_handler<2>(); } + auto tout2_cb() { return m_tcu.lookup()->out_handler<2>(); } auto icu_slave_ack_cb() { return m_icu_slave_ack.bind(); } @@ -237,7 +237,7 @@ public: } void hack_w(int state); - template auto tout_handler() { return subdevice("tcu")->out_handler(); } + template auto tout_handler() { return m_tcu.lookup()->out_handler(); } protected: v53_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); diff --git a/src/devices/cpu/psx/psx.h b/src/devices/cpu/psx/psx.h index 4ab779d9139..f2ce1ed59d3 100644 --- a/src/devices/cpu/psx/psx.h +++ b/src/devices/cpu/psx/psx.h @@ -160,7 +160,6 @@ public: void com_delay_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); uint32_t com_delay_r(offs_t offset, uint32_t mem_mask = ~0); - static psxcpu_device *getcpu( device_t &device, const char *cputag ) { return downcast( device.subdevice( cputag ) ); } void set_disable_rom_berr(bool mode); void psxcpu_internal_map(address_map &map); diff --git a/src/devices/cpu/psx/rcnt.cpp b/src/devices/cpu/psx/rcnt.cpp index cdca5953509..c31c9464f8e 100644 --- a/src/devices/cpu/psx/rcnt.cpp +++ b/src/devices/cpu/psx/rcnt.cpp @@ -29,32 +29,28 @@ void psxrcnt_device::device_reset() void psxrcnt_device::device_post_load() { - int n; - for( n = 0; n < 3; n++ ) - { - root_timer_adjust( n ); - } + for (int n = 0; n < 3; n++) + root_timer_adjust(n); } void psxrcnt_device::device_start() { - int n; - m_irq0_handler.resolve_safe(); m_irq1_handler.resolve_safe(); m_irq2_handler.resolve_safe(); - for( n = 0; n < 3; n++ ) + save_item(STRUCT_MEMBER(root_counter, n_count)); + save_item(STRUCT_MEMBER(root_counter, n_mode)); + save_item(STRUCT_MEMBER(root_counter, n_target)); + save_item(STRUCT_MEMBER(root_counter, n_start)); + + for (int n = 0; n < 3; n++) { - root_counter[ n ].timer = timer_alloc( FUNC( psxrcnt_device::timer_update ), this ); - save_item(NAME(root_counter[ n ].n_count), n); - save_item(NAME(root_counter[ n ].n_mode), n); - save_item(NAME(root_counter[ n ].n_target), n); - save_item(NAME(root_counter[ n ].n_start), n); - root_counter[ n ].n_count = 0; - root_counter[ n ].n_mode = 0; - root_counter[ n ].n_target = 0; - root_counter[ n ].n_start = 0; + root_counter[n].timer = timer_alloc(FUNC(psxrcnt_device::timer_update ), this); + root_counter[n].n_count = 0; + root_counter[n].n_mode = 0; + root_counter[n].n_target = 0; + root_counter[n].n_start = 0; } } diff --git a/src/devices/cpu/psx/sio.cpp b/src/devices/cpu/psx/sio.cpp index 25d9a693252..120fa395d41 100644 --- a/src/devices/cpu/psx/sio.cpp +++ b/src/devices/cpu/psx/sio.cpp @@ -53,7 +53,7 @@ void psxsio_device::device_start() m_dtr_handler.resolve_safe(); m_rts_handler.resolve_safe(); - m_timer = timer_alloc( FUNC( psxsio_device::sio_tick ), this ); + m_timer = timer_alloc(FUNC( psxsio_device::sio_tick ), this); m_mode = 0; m_control = 0; m_baud = 0; @@ -64,22 +64,22 @@ void psxsio_device::device_start() m_rx_bits = 0; m_tx_bits = 0; - save_item( NAME( m_status ) ); - save_item( NAME( m_mode ) ); - save_item( NAME( m_control ) ); - save_item( NAME( m_baud ) ); - save_item( NAME( m_rxd ) ); - save_item( NAME( m_rx_data ) ); - save_item( NAME( m_tx_data ) ); - save_item( NAME( m_rx_shift ) ); - save_item( NAME( m_tx_shift ) ); - save_item( NAME( m_rx_bits ) ); - save_item( NAME( m_tx_bits ) ); + save_item(NAME(m_status)); + save_item(NAME(m_mode)); + save_item(NAME(m_control)); + save_item(NAME(m_baud)); + save_item(NAME(m_rxd)); + save_item(NAME(m_rx_data)); + save_item(NAME(m_tx_data)); + save_item(NAME(m_rx_shift)); + save_item(NAME(m_tx_shift)); + save_item(NAME(m_rx_bits)); + save_item(NAME(m_tx_bits)); } void psxsio_device::sio_interrupt() { - LOG( "sio_interrupt\n" ); + LOG("sio_interrupt\n"); m_status |= SIO_STATUS_IRQ; m_irq_handler(1); } diff --git a/src/devices/cpu/upd7725/upd7725.cpp b/src/devices/cpu/upd7725/upd7725.cpp index 51c2faf3b6a..31cf876eb8b 100644 --- a/src/devices/cpu/upd7725/upd7725.cpp +++ b/src/devices/cpu/upd7725/upd7725.cpp @@ -24,23 +24,23 @@ DEFINE_DEVICE_TYPE(UPD7725, upd7725_device, "upd7725", "NEC uPD7725") DEFINE_DEVICE_TYPE(UPD96050, upd96050_device, "upd96050", "NEC uPD96050") -necdsp_device::necdsp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t abits, uint32_t dbits) - : cpu_device(mconfig, type, tag, owner, clock), - m_program_config("program", ENDIANNESS_BIG, 32, abits, -2), // data bus width, address bus width, -2 means DWORD-addressable - m_data_config("data", ENDIANNESS_BIG, 16, dbits, -1), m_icount(0), // -1 for WORD-addressable - m_irq(0), - m_irq_firing(0), - m_in_int_cb(*this), - //m_in_si_cb(*this), - //m_in_sck_cb(*this), - //m_in_sien_cb(*this), - //m_in_soen_cb(*this), - //m_in_dack_cb(*this), - m_out_p0_cb(*this), - m_out_p1_cb(*this) - //m_out_so_cb(*this), - //m_out_sorq_cb(*this), - //m_out_drq_cb(*this) +necdsp_device::necdsp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t abits, uint32_t dbits) : + cpu_device(mconfig, type, tag, owner, clock), + m_program_config("program", ENDIANNESS_BIG, 32, abits, -2), // data bus width, address bus width, -2 means DWORD-addressable + m_data_config("data", ENDIANNESS_BIG, 16, dbits, -1), m_icount(0), // -1 for WORD-addressable + m_irq(0), + m_irq_firing(0), + m_in_int_cb(*this), + //m_in_si_cb(*this), + //m_in_sck_cb(*this), + //m_in_sien_cb(*this), + //m_in_soen_cb(*this), + //m_in_dack_cb(*this), + m_out_p0_cb(*this), + m_out_p1_cb(*this) + //m_out_so_cb(*this), + //m_out_sorq_cb(*this), + //m_out_drq_cb(*this) { } diff --git a/src/devices/cpu/z180/z180.h b/src/devices/cpu/z180/z180.h index 62c701a1234..1ce1ee61f57 100644 --- a/src/devices/cpu/z180/z180.h +++ b/src/devices/cpu/z180/z180.h @@ -110,13 +110,13 @@ class z180_device : public cpu_device, public z80_daisy_chain_interface public: auto tend0_wr_callback() { return m_tend0_cb.bind(); } auto tend1_wr_callback() { return m_tend1_cb.bind(); } - auto txa0_wr_callback() { return subdevice("asci_0")->txa_handler(); } - auto txa1_wr_callback() { return subdevice("asci_1")->txa_handler(); } - auto rts0_wr_callback() { return subdevice("asci_0")->rts_handler(); } - auto cka0_wr_callback() { return subdevice("asci_0")->cka_handler(); } - auto cka1_wr_callback() { return subdevice("asci_1")->cka_handler(); } - auto cks_wr_callback() { return subdevice("csio")->cks_handler(); } - auto txs_wr_callback() { return subdevice("csio")->txs_handler(); } + auto txa0_wr_callback() { return m_asci[0].lookup()->txa_handler(); } + auto txa1_wr_callback() { return m_asci[1].lookup()->txa_handler(); } + auto rts0_wr_callback() { return m_asci[0].lookup()->rts_handler(); } + auto cka0_wr_callback() { return m_asci[0].lookup()->cka_handler(); } + auto cka1_wr_callback() { return m_asci[1].lookup()->cka_handler(); } + auto cks_wr_callback() { return m_csio.lookup()->cks_handler(); } + auto txs_wr_callback() { return m_csio.lookup()->txs_handler(); } bool get_tend0(); bool get_tend1(); diff --git a/src/devices/cpu/z80/tmpz84c015.h b/src/devices/cpu/z80/tmpz84c015.h index 0888fe631ef..449b9cd2725 100644 --- a/src/devices/cpu/z80/tmpz84c015.h +++ b/src/devices/cpu/z80/tmpz84c015.h @@ -28,8 +28,8 @@ public: tmpz84c015_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // configuration helpers - template void set_clk_trg(u32 clock) { subdevice(m_ctc.finder_tag())->set_clk(clock); } - template void set_clk_trg(const XTAL &xtal) { subdevice(m_ctc.finder_tag())->set_clk(xtal); } + template void set_clk_trg(u32 clock) { m_ctc.lookup()->set_clk(clock); } + template void set_clk_trg(const XTAL &xtal) { m_ctc.lookup()->set_clk(xtal); } // SIO callbacks auto out_txda_callback() { return m_out_txda_cb.bind(); } diff --git a/src/devices/machine/40105.cpp b/src/devices/machine/40105.cpp index a05e3587c87..032fc62521d 100644 --- a/src/devices/machine/40105.cpp +++ b/src/devices/machine/40105.cpp @@ -43,17 +43,17 @@ DEFINE_DEVICE_TYPE(CD40105, cmos_40105_device, "cd40105", "CD40105B FIFO Registe // cmos_40105_device - constructor //------------------------------------------------- -cmos_40105_device::cmos_40105_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, CD40105, tag, owner, clock), - m_write_dir(*this), - m_write_dor(*this), - m_write_q(*this), - m_d(0), - m_q(0), - m_dir(false), - m_dor(false), - m_si(false), - m_so(false) +cmos_40105_device::cmos_40105_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, CD40105, tag, owner, clock), + m_write_dir(*this), + m_write_dor(*this), + m_write_q(*this), + m_d(0), + m_q(0), + m_dir(false), + m_dor(false), + m_si(false), + m_so(false) { } diff --git a/src/devices/machine/74123.cpp b/src/devices/machine/74123.cpp index 4dd56f98b92..fb238ee01a8 100644 --- a/src/devices/machine/74123.cpp +++ b/src/devices/machine/74123.cpp @@ -27,17 +27,17 @@ DEFINE_DEVICE_TYPE(TTL74123, ttl74123_device, "ttl74123", "74123 TTL") // ttl74123_device - constructor //------------------------------------------------- -ttl74123_device::ttl74123_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, TTL74123, tag, owner, clock), - m_clear_timer(nullptr), - m_output_timer(nullptr), - m_connection_type(TTL74123_NOT_GROUNDED_NO_DIODE), - m_res(1.0), - m_cap(1.0), - m_a(0), - m_b(0), - m_clear(0), - m_output_changed_cb(*this) +ttl74123_device::ttl74123_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, TTL74123, tag, owner, clock), + m_clear_timer(nullptr), + m_output_timer(nullptr), + m_connection_type(TTL74123_NOT_GROUNDED_NO_DIODE), + m_res(1.0), + m_cap(1.0), + m_a(0), + m_b(0), + m_clear(0), + m_output_changed_cb(*this) { } diff --git a/src/devices/machine/74148.cpp b/src/devices/machine/74148.cpp index 45ce281ed51..61097815db3 100644 --- a/src/devices/machine/74148.cpp +++ b/src/devices/machine/74148.cpp @@ -58,7 +58,7 @@ ttl74148_device::ttl74148_device(const machine_config &mconfig, const char *tag, , m_last_output_valid(0) , m_last_enable_output(0) { - for (auto & elem : m_input_lines) + for (auto &elem : m_input_lines) elem = 0; } diff --git a/src/devices/machine/am53cf96.cpp b/src/devices/machine/am53cf96.cpp index 41b62e145f0..4c70bcb79e7 100644 --- a/src/devices/machine/am53cf96.cpp +++ b/src/devices/machine/am53cf96.cpp @@ -163,13 +163,13 @@ void am53cf96_device::device_start() xfer_state = 0; last_id = -1; - save_item( NAME( scsi_regs ) ); - save_item( NAME( fifo ) ); - save_item( NAME( fptr ) ); - save_item( NAME( xfer_state ) ); - save_item( NAME( last_id ) ); + save_item(NAME(scsi_regs)); + save_item(NAME(fifo)); + save_item(NAME(fptr)); + save_item(NAME(xfer_state)); + save_item(NAME(last_id)); - m_transfer_timer = timer_alloc( FUNC( am53cf96_device::irq_timer_tick ), this ); + m_transfer_timer = timer_alloc(FUNC(am53cf96_device::irq_timer_tick), this); } // retrieve data from the SCSI controller diff --git a/src/devices/machine/at.h b/src/devices/machine/at.h index 41a83f7ead1..d41e9448401 100644 --- a/src/devices/machine/at.h +++ b/src/devices/machine/at.h @@ -19,8 +19,8 @@ public: void map(address_map &map); - auto kbd_clk() { return subdevice("keybc")->kbd_clk(); } - auto kbd_data() { return subdevice("keybc")->kbd_data(); } + auto kbd_clk() { return m_keybc.lookup()->kbd_clk(); } + auto kbd_data() { return m_keybc.lookup()->kbd_data(); } uint8_t page8_r(offs_t offset); void page8_w(offs_t offset, uint8_t data); diff --git a/src/devices/machine/cdp1879.cpp b/src/devices/machine/cdp1879.cpp index f6687f73226..e8230b5b33b 100644 --- a/src/devices/machine/cdp1879.cpp +++ b/src/devices/machine/cdp1879.cpp @@ -21,10 +21,10 @@ DEFINE_DEVICE_TYPE(CDP1879, cdp1879_device, "cdp1879", "RCA CDP1879 RTC") // cdp1879_device - constructor //------------------------------------------------- -cdp1879_device::cdp1879_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, CDP1879, tag, owner, clock), - device_rtc_interface(mconfig, *this), - m_irq_w(*this) +cdp1879_device::cdp1879_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, CDP1879, tag, owner, clock), + device_rtc_interface(mconfig, *this), + m_irq_w(*this) { } diff --git a/src/devices/machine/dp8573.cpp b/src/devices/machine/dp8573.cpp index d74dc7c77c5..487a4985ca4 100644 --- a/src/devices/machine/dp8573.cpp +++ b/src/devices/machine/dp8573.cpp @@ -8,8 +8,12 @@ #include "emu.h" #include "machine/dp8573.h" + #include "machine/timehelp.h" +#include +#include + #define LOG_TICKS (1U << 1) #define LOG_ALL (LOG_GENERAL | LOG_TICKS) @@ -41,7 +45,7 @@ void dp8573_device::device_start() m_intr_cb.resolve_safe(); m_mfo_cb.resolve_safe(); - memset(m_ram, 0, 32); + std::fill(std::begin(m_ram), std::end(m_ram), 0); m_tscr = 0; diff --git a/src/devices/machine/ds1315.cpp b/src/devices/machine/ds1315.cpp index 2a574dca399..283503c21d8 100644 --- a/src/devices/machine/ds1315.cpp +++ b/src/devices/machine/ds1315.cpp @@ -32,8 +32,8 @@ DEFINE_DEVICE_TYPE(DS1315, ds1315_device, "ds1315", "Dallas DS1315 Phantom Time Chip") -ds1315_device::ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, DS1315, tag, owner, clock), +ds1315_device::ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, DS1315, tag, owner, clock), m_backing_read(*this), m_mode(), m_count(0) diff --git a/src/devices/machine/ds75160a.cpp b/src/devices/machine/ds75160a.cpp index e376b96606a..6caf1fcc046 100644 --- a/src/devices/machine/ds75160a.cpp +++ b/src/devices/machine/ds75160a.cpp @@ -27,13 +27,13 @@ DEFINE_DEVICE_TYPE(DS75160A, ds75160a_device, "ds75160a", "DS75160A GPIB Transce // ds75160a_device - constructor //------------------------------------------------- -ds75160a_device::ds75160a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, DS75160A, tag, owner, clock), - m_read(*this), - m_write(*this), - m_data(0xff), - m_te(0), - m_pe(0) +ds75160a_device::ds75160a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, DS75160A, tag, owner, clock), + m_read(*this), + m_write(*this), + m_data(0xff), + m_te(0), + m_pe(0) { } diff --git a/src/devices/machine/ds75161a.cpp b/src/devices/machine/ds75161a.cpp index 19535dec193..2b54d43b266 100644 --- a/src/devices/machine/ds75161a.cpp +++ b/src/devices/machine/ds75161a.cpp @@ -27,34 +27,34 @@ DEFINE_DEVICE_TYPE(DS75161A, ds75161a_device, "ds75161a", "DS75161A GPIB Transce // ds75161a_device - constructor //------------------------------------------------- -ds75161a_device::ds75161a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, DS75161A, tag, owner, clock), - m_in_ren_cb(*this), - m_in_ifc_cb(*this), - m_in_ndac_cb(*this), - m_in_nrfd_cb(*this), - m_in_dav_cb(*this), - m_in_eoi_cb(*this), - m_in_atn_cb(*this), - m_in_srq_cb(*this), - m_out_ren_cb(*this), - m_out_ifc_cb(*this), - m_out_ndac_cb(*this), - m_out_nrfd_cb(*this), - m_out_dav_cb(*this), - m_out_eoi_cb(*this), - m_out_atn_cb(*this), - m_out_srq_cb(*this), - m_ren(1), - m_ifc(1), - m_ndac(1), - m_nrfd(1), - m_dav(1), - m_eoi(1), - m_atn(1), - m_srq(1), - m_te(0), - m_dc(0) +ds75161a_device::ds75161a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, DS75161A, tag, owner, clock), + m_in_ren_cb(*this), + m_in_ifc_cb(*this), + m_in_ndac_cb(*this), + m_in_nrfd_cb(*this), + m_in_dav_cb(*this), + m_in_eoi_cb(*this), + m_in_atn_cb(*this), + m_in_srq_cb(*this), + m_out_ren_cb(*this), + m_out_ifc_cb(*this), + m_out_ndac_cb(*this), + m_out_nrfd_cb(*this), + m_out_dav_cb(*this), + m_out_eoi_cb(*this), + m_out_atn_cb(*this), + m_out_srq_cb(*this), + m_ren(1), + m_ifc(1), + m_ndac(1), + m_nrfd(1), + m_dav(1), + m_eoi(1), + m_atn(1), + m_srq(1), + m_te(0), + m_dc(0) { } diff --git a/src/devices/machine/e05a30.cpp b/src/devices/machine/e05a30.cpp index eece1540855..a9fc241ebcb 100644 --- a/src/devices/machine/e05a30.cpp +++ b/src/devices/machine/e05a30.cpp @@ -18,8 +18,8 @@ DEFINE_DEVICE_TYPE(E05A30, e05a30_device, "e05a30", "Epson E05A30 Gate Array") -e05a30_device::e05a30_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, E05A30, tag, owner, clock), +e05a30_device::e05a30_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, E05A30, tag, owner, clock), m_write_printhead(*this), m_write_pf_stepper(*this), m_write_cr_stepper(*this), diff --git a/src/devices/machine/genpc.h b/src/devices/machine/genpc.h index f7b5631b830..bc938e22697 100644 --- a/src/devices/machine/genpc.h +++ b/src/devices/machine/genpc.h @@ -33,8 +33,8 @@ public: template void set_cputag(T &&tag) { m_maincpu.set_tag(std::forward(tag)); - subdevice("isa")->set_memspace(std::forward(tag), AS_PROGRAM); - subdevice("isa")->set_iospace(std::forward(tag), AS_IO); + m_isabus.lookup()->set_memspace(std::forward(tag), AS_PROGRAM); + m_isabus.lookup()->set_iospace(std::forward(tag), AS_IO); } auto int_callback() { return m_int_callback.bind(); } diff --git a/src/devices/machine/i80130.cpp b/src/devices/machine/i80130.cpp index b9b632b93e1..38fcda0dfa0 100644 --- a/src/devices/machine/i80130.cpp +++ b/src/devices/machine/i80130.cpp @@ -124,16 +124,16 @@ void i80130_device::device_add_mconfig(machine_config &config) // i80130_device - constructor //------------------------------------------------- -i80130_device::i80130_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, I80130, tag, owner, clock), - m_pic(*this, "pic"), - m_pit(*this, "pit"), - m_write_irq(*this), - m_write_ack(*this), - m_write_lir(*this), - m_write_systick(*this), - m_write_delay(*this), - m_write_baud(*this) +i80130_device::i80130_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, I80130, tag, owner, clock), + m_pic(*this, "pic"), + m_pit(*this, "pit"), + m_write_irq(*this), + m_write_ack(*this), + m_write_lir(*this), + m_write_systick(*this), + m_write_delay(*this), + m_write_baud(*this) { } diff --git a/src/devices/machine/i82357.h b/src/devices/machine/i82357.h index 8df66abdd8e..9f8a31cdfc3 100644 --- a/src/devices/machine/i82357.h +++ b/src/devices/machine/i82357.h @@ -16,7 +16,7 @@ public: i82357_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); auto out_rtc_cb() { return m_out_rtc.bind(); } - auto out_int_cb() { return subdevice("pic0")->out_int_callback(); } + auto out_int_cb() { return m_pic[0].lookup()->out_int_callback(); } auto out_nmi_cb() { return m_out_nmi.bind(); } auto out_spkr_cb() { return m_out_spkr.bind(); } diff --git a/src/devices/machine/ie15_kbd.cpp b/src/devices/machine/ie15_kbd.cpp index 169f4be18aa..dea705a60c2 100644 --- a/src/devices/machine/ie15_kbd.cpp +++ b/src/devices/machine/ie15_kbd.cpp @@ -22,6 +22,7 @@ ie15_keyboard_device::ie15_keyboard_device(const machine_config &mconfig, device : device_t(mconfig, type, tag, owner, clock) , device_matrix_keyboard_interface(mconfig, *this, "TERM_LINE0", "TERM_LINE1", "TERM_LINE2", "TERM_LINE3") , m_io_kbdc(*this, "TERM_LINEC") + , m_rom(*this, "ie15kbd") , m_keyboard_cb(*this) , m_sdv_cb(*this) { @@ -84,8 +85,6 @@ void ie15_keyboard_device::device_start() { m_keyboard_cb.resolve_safe(); m_sdv_cb.resolve_safe(); - - m_rom = (uint8_t *)memregion("ie15kbd")->base(); } void ie15_keyboard_device::device_reset() diff --git a/src/devices/machine/ie15_kbd.h b/src/devices/machine/ie15_kbd.h index 3302bbda8a2..f8ff57e963e 100644 --- a/src/devices/machine/ie15_kbd.h +++ b/src/devices/machine/ie15_kbd.h @@ -52,11 +52,10 @@ protected: required_ioport m_io_kbdc; private: - bool m_ruslat; - uint8_t *m_rom; - + required_region_ptr m_rom; devcb_write16 m_keyboard_cb; devcb_write_line m_sdv_cb; + bool m_ruslat; }; DECLARE_DEVICE_TYPE(IE15_KEYBOARD, ie15_keyboard_device) diff --git a/src/devices/machine/ripple_counter.cpp b/src/devices/machine/ripple_counter.cpp index 6f3fde41f94..3c446d8a82c 100644 --- a/src/devices/machine/ripple_counter.cpp +++ b/src/devices/machine/ripple_counter.cpp @@ -33,16 +33,16 @@ DEFINE_DEVICE_TYPE(RIPPLE_COUNTER, ripple_counter_device, "ripple_counter", "Gen // ripple_counter_device - constructor //------------------------------------------------- -ripple_counter_device::ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, RIPPLE_COUNTER, tag, owner, clock), - device_rom_interface(mconfig, *this), - m_count_out_cb(*this), - m_rom_out_cb(*this), - m_count_timer(nullptr), - m_count_mask(0), - m_count(1), - m_clk(false), - m_reset(false) +ripple_counter_device::ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, RIPPLE_COUNTER, tag, owner, clock), + device_rom_interface(mconfig, *this), + m_count_out_cb(*this), + m_rom_out_cb(*this), + m_count_timer(nullptr), + m_count_mask(0), + m_count(1), + m_clk(false), + m_reset(false) { } diff --git a/src/devices/machine/z80ctc.h b/src/devices/machine/z80ctc.h index 82aab7d230e..62ac96d1a90 100644 --- a/src/devices/machine/z80ctc.h +++ b/src/devices/machine/z80ctc.h @@ -115,7 +115,7 @@ private: // internal helpers void interrupt_check(); - z80ctc_channel_device &channel_config(int ch) { return *subdevice(m_channel[ch].finder_tag()); } + z80ctc_channel_device &channel_config(int ch) { return *m_channel[ch].lookup(); } // internal state devcb_write_line m_intr_cb; // interrupt callback diff --git a/src/devices/sound/t6721a.cpp b/src/devices/sound/t6721a.cpp index e011796cb9a..6ab00ac10b6 100644 --- a/src/devices/sound/t6721a.cpp +++ b/src/devices/sound/t6721a.cpp @@ -31,14 +31,14 @@ DEFINE_DEVICE_TYPE(T6721A, t6721a_device, "t6721a", "Toshiba T6721A") // t6721a_device - constructor //------------------------------------------------- -t6721a_device::t6721a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, T6721A, tag, owner, clock), - device_sound_interface(mconfig, *this), - m_write_eos(*this), - m_write_phi2(*this), - m_write_dtrd(*this), - m_write_apd(*this), - m_stream(nullptr) +t6721a_device::t6721a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, T6721A, tag, owner, clock), + device_sound_interface(mconfig, *this), + m_write_eos(*this), + m_write_phi2(*this), + m_write_dtrd(*this), + m_write_apd(*this), + m_stream(nullptr) { } diff --git a/src/devices/sound/ymz280b.cpp b/src/devices/sound/ymz280b.cpp index ef4e9bf1190..82fd7ed9c77 100644 --- a/src/devices/sound/ymz280b.cpp +++ b/src/devices/sound/ymz280b.cpp @@ -69,14 +69,16 @@ void ymz280b_device::update_irq_state() m_irq_state = 1; if (!m_irq_handler.isnull()) m_irq_handler(1); - else logerror("YMZ280B: IRQ generated, but no callback specified!\n"); + else + logerror("YMZ280B: IRQ generated, but no callback specified!\n"); } else if (!irq_bits && m_irq_state) { m_irq_state = 0; if (!m_irq_handler.isnull()) m_irq_handler(0); - else logerror("YMZ280B: IRQ generated, but no callback specified!\n"); + else + logerror("YMZ280B: IRQ generated, but no callback specified!\n"); } } diff --git a/src/devices/video/decsfb.cpp b/src/devices/video/decsfb.cpp index 1a94ba1a694..716941d18cc 100644 --- a/src/devices/video/decsfb.cpp +++ b/src/devices/video/decsfb.cpp @@ -35,8 +35,8 @@ DEFINE_DEVICE_TYPE(DECSFB, decsfb_device, "decsfb", "Digital Equipment Corporation Smart Frame Buffer") -decsfb_device::decsfb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, DECSFB, tag, owner, clock), +decsfb_device::decsfb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, DECSFB, tag, owner, clock), m_int_cb(*this) { } diff --git a/src/devices/video/tms34061.cpp b/src/devices/video/tms34061.cpp index 8d987b06701..8fe8daa9112 100644 --- a/src/devices/video/tms34061.cpp +++ b/src/devices/video/tms34061.cpp @@ -32,8 +32,8 @@ DEFINE_DEVICE_TYPE(TMS34061, tms34061_device, "tms34061", "TI TMS34061 VSC") -tms34061_device::tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, TMS34061, tag, owner, clock), +tms34061_device::tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, TMS34061, tag, owner, clock), device_video_interface(mconfig, *this), m_rowshift(0), m_vramsize(0), diff --git a/src/devices/video/tms9927.cpp b/src/devices/video/tms9927.cpp index 6ae31a1a9d5..ef765fc40b4 100644 --- a/src/devices/video/tms9927.cpp +++ b/src/devices/video/tms9927.cpp @@ -351,7 +351,9 @@ void tms9927_device::recompute_parameters(bool postload) attotime refresh = clocks_to_attotime(HCOUNT * m_total_vpix); - osd_printf_debug("TMS9927: Total = %dx%d, Visible = %dx%d, HSync = %d-%d, VSync = %d-%d, Skew=%d, Upscroll=%d, Period=%f Hz\n", m_total_hpix, m_total_vpix, m_visible_hpix, m_visible_vpix, m_hsyn_start, m_hsyn_end, m_vsyn_start, m_vsyn_end, SKEW_BITS, m_start_datarow, refresh.as_hz()); + osd_printf_debug( + "TMS9927(%s): Total = %dx%d, Visible = %dx%d, HSync = %d-%d, VSync = %d-%d, Skew=%d, Upscroll=%d, Period=%f Hz\n", + tag(), m_total_hpix, m_total_vpix, m_visible_hpix, m_visible_vpix, m_hsyn_start, m_hsyn_end, m_vsyn_start, m_vsyn_end, SKEW_BITS, m_start_datarow, refresh.as_hz()); screen().configure(m_total_hpix, m_total_vpix, visarea, refresh.as_attoseconds()); diff --git a/src/devices/video/vic4567.cpp b/src/devices/video/vic4567.cpp index 5f1c756c50d..ead044f387c 100644 --- a/src/devices/video/vic4567.cpp +++ b/src/devices/video/vic4567.cpp @@ -1460,7 +1460,6 @@ void vic3_device::port_w(offs_t offset, uint8_t data) if (!m_port_changed_cb.isnull()) { DBG_LOG(2, "vic write", ("%.2x:%.2x\n", offset, data)); - m_reg[offset] = data; m_port_changed_cb((offs_t)0,data); } break; diff --git a/src/emu/devfind.h b/src/emu/devfind.h index 6e8b078bc56..20a555a8784 100644 --- a/src/emu/devfind.h +++ b/src/emu/devfind.h @@ -600,6 +600,12 @@ public: return device; } + /// \brief Look up target during configuration + /// Look up the current target device during configuration, before + /// resolution. + /// \return Pointer to target device if found, or nullptr otherwise. + DeviceClass *lookup() const { return this->m_base.get().template subdevice(this->m_tag); } + private: /// \brief Check that device implementation has expected tag /// \param [in] device Reference to device. diff --git a/src/emu/device.h b/src/emu/device.h index 4cf972a4825..0142b9e665e 100644 --- a/src/emu/device.h +++ b/src/emu/device.h @@ -634,8 +634,8 @@ public: // interface helpers interface_list &interfaces() { return m_interfaces; } const interface_list &interfaces() const { return m_interfaces; } - template bool interface(DeviceClass *&intf) { intf = dynamic_cast(this); return (intf != nullptr); } - template bool interface(DeviceClass *&intf) const { intf = dynamic_cast(this); return (intf != nullptr); } + template bool interface(DeviceClass *&intf) { intf = dynamic_cast(this); return (intf != nullptr); } + template bool interface(DeviceClass *&intf) const { intf = dynamic_cast(this); return (intf != nullptr); } // specialized helpers for common core interfaces bool interface(device_execute_interface *&intf) { intf = m_interfaces.m_execute; return (intf != nullptr); } @@ -658,8 +658,42 @@ public: ioport_port *ioport(std::string_view tag) const; device_t *subdevice(std::string_view tag) const; device_t *siblingdevice(std::string_view tag) const; - template DeviceClass *subdevice(std::string_view tag) const { return downcast(subdevice(tag)); } - template DeviceClass *siblingdevice(std::string_view tag) const { return downcast(siblingdevice(tag)); } + template + DeviceClass *subdevice(std::string_view tag) const + { + device_t *const found = subdevice(tag); + if constexpr (std::is_base_of_v) + { + return downcast(found); + } + else + { + auto const result = dynamic_cast(found); +#if defined(MAME_DEBUG) + if (found && !result) + report_bad_device_cast(found, typeid(device_t), typeid(DeviceClass)); +#endif + return result; + } + } + template + DeviceClass *siblingdevice(std::string_view tag) const + { + device_t *const found = siblingdevice(tag); + if constexpr (std::is_base_of_v) + { + return downcast(found); + } + else + { + auto const result = dynamic_cast(found); +#if defined(MAME_DEBUG) + if (found && !result) + report_bad_device_cast(found, typeid(device_t), typeid(DeviceClass)); +#endif + return result; + } + } std::string parameter(std::string_view tag) const; // configuration helpers @@ -758,7 +792,7 @@ public: /// \param [in] index A numeric value to distinguish between saved /// items with the same name. /// \sa save_item - template + template void ATTR_COLD save_pointer(ItemType &&value, const char *valname, u32 count, int index = 0) { assert(m_save); @@ -787,7 +821,7 @@ public: /// \param [in] index A numeric value to distinguish between saved /// items with the same name. /// \sa save_item - template + template void ATTR_COLD save_pointer(ItemType &&value, ElementType StructType::*element, const char *valname, u32 count, int index = 0) { assert(m_save); diff --git a/src/lib/util/delegate.h b/src/lib/util/delegate.h index 3c0745bf0c5..b4681b04758 100644 --- a/src/lib/util/delegate.h +++ b/src/lib/util/delegate.h @@ -245,18 +245,18 @@ class delegate_mfp_compatible { public: // default constructor - delegate_mfp_compatible() + delegate_mfp_compatible() noexcept : m_rawdata(s_null_mfp) , m_realobject(nullptr) , m_stubfunction(nullptr) { } // copy constructor - delegate_mfp_compatible(const delegate_mfp_compatible &src) = default; + delegate_mfp_compatible(const delegate_mfp_compatible &src) noexcept = default; // construct from any member function pointer template - delegate_mfp_compatible(MemberFunctionType mfp, MemberFunctionClass *, ReturnType *, StaticFunctionType) + delegate_mfp_compatible(MemberFunctionType mfp, MemberFunctionClass *, ReturnType *, StaticFunctionType) noexcept : m_rawdata(s_null_mfp) , m_realobject(nullptr) , m_stubfunction(make_generic(&delegate_mfp_compatible::method_stub)) @@ -266,21 +266,21 @@ public: } // comparison helpers - bool operator==(const delegate_mfp_compatible &rhs) const { return m_rawdata == rhs.m_rawdata; } - bool isnull() const { return m_rawdata == s_null_mfp; } + bool operator==(const delegate_mfp_compatible &rhs) const noexcept { return m_rawdata == rhs.m_rawdata; } + bool isnull() const noexcept { return m_rawdata == s_null_mfp; } // getters - delegate_generic_class *real_object(delegate_generic_class *original) const + delegate_generic_class *real_object(delegate_generic_class *original) const noexcept { return m_realobject; } // binding helpers template - void update_after_bind(FunctionType &funcptr, delegate_generic_class *&object); + void update_after_bind(FunctionType &funcptr, delegate_generic_class *&object) noexcept; template - void update_after_copy(FunctionType &funcptr, delegate_generic_class *&object); + void update_after_copy(FunctionType &funcptr, delegate_generic_class *&object) noexcept; private: // helper stubs for calling encased member function pointers @@ -290,7 +290,7 @@ private: // helper to convert a function of a given type to a generic function, forcing template // instantiation to match the source type template - static delegate_generic_function make_generic(SourceType funcptr) + static delegate_generic_function make_generic(SourceType funcptr) noexcept { return reinterpret_cast(funcptr); } @@ -303,7 +303,7 @@ private: #else // all other cases - for MSVC maximum size is one pointer, plus 3 ints; all other implementations seem to be smaller int data[((sizeof(void *) + 3 * sizeof(int)) + (sizeof(int) - 1)) / sizeof(int)]; #endif - bool operator==(const raw_mfp_data &rhs) const { return !std::memcmp(data, rhs.data, sizeof(data)); } + bool operator==(const raw_mfp_data &rhs) const noexcept { return !std::memcmp(data, rhs.data, sizeof(data)); } }; // internal state @@ -316,7 +316,7 @@ private: template -void delegate_mfp_compatible::update_after_bind(FunctionType &funcptr, delegate_generic_class *&object) +void delegate_mfp_compatible::update_after_bind(FunctionType &funcptr, delegate_generic_class *&object) noexcept { m_realobject = object; object = reinterpret_cast(this); @@ -325,7 +325,7 @@ void delegate_mfp_compatible::update_after_bind(FunctionType &funcptr, delegate_ template -void delegate_mfp_compatible::update_after_copy(FunctionType &funcptr, delegate_generic_class *&object) +void delegate_mfp_compatible::update_after_copy(FunctionType &funcptr, delegate_generic_class *&object) noexcept { assert(reinterpret_cast(m_stubfunction) == funcptr); object = reinterpret_cast(this); @@ -375,26 +375,26 @@ class delegate_mfp_itanium { public: // default constructor - delegate_mfp_itanium() = default; + delegate_mfp_itanium() noexcept = default; // copy constructor - delegate_mfp_itanium(const delegate_mfp_itanium &src) = default; + delegate_mfp_itanium(const delegate_mfp_itanium &src) noexcept = default; // construct from any member function pointer template - delegate_mfp_itanium(MemberFunctionType mfp, MemberFunctionClass *, ReturnType *, StaticFunctionType) + delegate_mfp_itanium(MemberFunctionType mfp, MemberFunctionClass *, ReturnType *, StaticFunctionType) noexcept { static_assert(sizeof(mfp) == sizeof(*this), "Unsupported member function pointer size"); *reinterpret_cast(this) = mfp; } // comparison helpers - bool operator==(const delegate_mfp_itanium &rhs) const + bool operator==(const delegate_mfp_itanium &rhs) const noexcept { return (isnull() && rhs.isnull()) || ((m_function == rhs.m_function) && (m_this_delta == rhs.m_this_delta)); } - bool isnull() const + bool isnull() const noexcept { if (MAME_ABI_CXX_ITANIUM_MFP_TYPE == MAME_ABI_CXX_ITANIUM_MFP_ARM) return !reinterpret_cast(m_function) && !(m_this_delta & 1); @@ -403,7 +403,7 @@ public: } // getters - static delegate_generic_class *real_object(delegate_generic_class *original) + static delegate_generic_class *real_object(delegate_generic_class *original) noexcept { return original; } @@ -416,7 +416,7 @@ public: } template - void update_after_copy(FunctionType &funcptr, delegate_generic_class *&object) + void update_after_copy(FunctionType &funcptr, delegate_generic_class *&object) noexcept { } @@ -465,14 +465,14 @@ class delegate_mfp_msvc public: // default constructor - delegate_mfp_msvc() = default; + delegate_mfp_msvc() noexcept = default; // copy constructor - delegate_mfp_msvc(const delegate_mfp_msvc &src) = default; + delegate_mfp_msvc(const delegate_mfp_msvc &src) noexcept = default; // construct from any member function pointer template - delegate_mfp_msvc(MemberFunctionType mfp, MemberFunctionClass *, ReturnType *, StaticFunctionType) + delegate_mfp_msvc(MemberFunctionType mfp, MemberFunctionClass *, ReturnType *, StaticFunctionType) noexcept { // FIXME: this doesn't actually catch the unsupported virtual inheritance case on 64-bit targets // alignment of the pointer means sizeof gives the same value for multiple inheritance and virtual inheritance cases @@ -485,7 +485,7 @@ public: } // comparison helpers - bool operator==(const delegate_mfp_msvc &rhs) const + bool operator==(const delegate_mfp_msvc &rhs) const noexcept { if (m_function != rhs.m_function) { @@ -512,13 +512,13 @@ public: } } - bool isnull() const + bool isnull() const noexcept { return !reinterpret_cast(m_function); } // getters - static delegate_generic_class *real_object(delegate_generic_class *original) { return original; } + static delegate_generic_class *real_object(delegate_generic_class *original) noexcept { return original; } // binding helpers template @@ -528,7 +528,7 @@ public: } template - void update_after_copy(FunctionType &funcptr, delegate_generic_class *&object) + void update_after_copy(FunctionType &funcptr, delegate_generic_class *&object) noexcept { } @@ -630,14 +630,14 @@ class delegate_late_bind_helper { public: // make it default constructible and copyable - delegate_late_bind_helper() = default; - delegate_late_bind_helper(delegate_late_bind_helper const &) = default; - delegate_late_bind_helper(delegate_late_bind_helper &&) = default; - delegate_late_bind_helper &operator=(delegate_late_bind_helper const &) = default; - delegate_late_bind_helper &operator=(delegate_late_bind_helper &&) = default; + delegate_late_bind_helper() noexcept = default; + delegate_late_bind_helper(delegate_late_bind_helper const &) noexcept = default; + delegate_late_bind_helper(delegate_late_bind_helper &&) noexcept = default; + delegate_late_bind_helper &operator=(delegate_late_bind_helper const &) noexcept = default; + delegate_late_bind_helper &operator=(delegate_late_bind_helper &&) noexcept = default; template - delegate_late_bind_helper(FunctionClass *) + delegate_late_bind_helper(FunctionClass *) noexcept : m_latebinder(&delegate_late_bind_helper::late_bind_helper) { } @@ -647,7 +647,7 @@ public: explicit operator bool() const noexcept { return bool(m_latebinder); } private: - using late_bind_func = delegate_generic_class*(*)(LateBindBase &object); + using late_bind_func = delegate_generic_class *(*)(LateBindBase &object); template static delegate_generic_class *late_bind_helper(LateBindBase &object); @@ -681,7 +681,7 @@ public: typedef MAME_ABI_CXX_MEMBER_CALL generic_static_func generic_member_func; // generic constructor - delegate_base() = default; + delegate_base() noexcept = default; // copy constructor delegate_base(const delegate_base &src) @@ -751,7 +751,7 @@ public: } // comparison helper - bool operator==(const delegate_base &rhs) const + bool operator==(const delegate_base &rhs) const noexcept { return (m_raw_function == rhs.m_raw_function) && (object() == rhs.object()) && (m_raw_mfp == rhs.m_raw_mfp); } @@ -766,9 +766,9 @@ public: } // getters - bool has_object() const { return object() != nullptr; } - bool isnull() const { return !m_raw_function && m_raw_mfp.isnull(); } - bool is_mfp() const { return !m_raw_mfp.isnull(); } + bool has_object() const noexcept { return object() != nullptr; } + bool isnull() const noexcept { return !m_raw_function && m_raw_mfp.isnull(); } + bool is_mfp() const noexcept { return !m_raw_mfp.isnull(); } // late binding void late_bind(LateBindBase &object) @@ -779,7 +779,7 @@ public: protected: // return the actual object (not the one we use for calling) - delegate_generic_class *object() const { return is_mfp() ? m_raw_mfp.real_object(m_object) : m_object; } + delegate_generic_class *object() const noexcept { return is_mfp() ? m_raw_mfp.real_object(m_object) : m_object; } // bind the actual object template @@ -886,7 +886,7 @@ protected: template using suitable_functoid = std::is_invocable_r; public: - delegate() : basetype() { } + delegate() noexcept : basetype() { } delegate(delegate const &src) : basetype(src.m_functoid.has_value() ? static_cast(basetype()) : src) diff --git a/src/mame/apple/macrtc.cpp b/src/mame/apple/macrtc.cpp index b66decf9785..1f662e3a1f8 100644 --- a/src/mame/apple/macrtc.cpp +++ b/src/mame/apple/macrtc.cpp @@ -58,23 +58,23 @@ DEFINE_DEVICE_TYPE(RTC3430042, rtc3430042_device, "rtc3430042", "Apple 343-0042- // rtc4543_device - constructor //------------------------------------------------- -rtc3430042_device::rtc3430042_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, bool hasBigPRAM) - : device_t(mconfig, type, tag, owner, clock), - device_rtc_interface(mconfig, *this), - device_nvram_interface(mconfig, *this), - m_is_big_PRAM(hasBigPRAM), - m_time_was_set(false), - m_cko_cb(*this) +rtc3430042_device::rtc3430042_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, bool hasBigPRAM) : + device_t(mconfig, type, tag, owner, clock), + device_rtc_interface(mconfig, *this), + device_nvram_interface(mconfig, *this), + m_is_big_PRAM(hasBigPRAM), + m_time_was_set(false), + m_cko_cb(*this) { } -rtc3430042_device::rtc3430042_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : rtc3430042_device(mconfig, RTC3430042, tag, owner, clock, true) +rtc3430042_device::rtc3430042_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + rtc3430042_device(mconfig, RTC3430042, tag, owner, clock, true) { } -rtc3430040_device::rtc3430040_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : rtc3430042_device(mconfig, RTC3430040, tag, owner, clock, false) +rtc3430040_device::rtc3430040_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + rtc3430042_device(mconfig, RTC3430040, tag, owner, clock, false) { } diff --git a/src/mame/atari/gtia.cpp b/src/mame/atari/gtia.cpp index 94ea2e591dd..f2a557783bb 100644 --- a/src/mame/atari/gtia.cpp +++ b/src/mame/atari/gtia.cpp @@ -893,7 +893,7 @@ void gtia_device::write(offs_t offset, uint8_t data) recalc_m3(); break; - case 30: /* clear collisions */ + case 30: /* clear collisions */ m_r.m0pf = m_r.m1pf = m_r.m2pf = m_r.m3pf = m_r.p0pf = m_r.p1pf = m_r.p2pf = m_r.p3pf = m_r.m0pl = m_r.m1pl = m_r.m2pl = m_r.m3pl = diff --git a/src/mame/konami/k573fpga.h b/src/mame/konami/k573fpga.h index 26b7d1b78be..323b912f1ea 100644 --- a/src/mame/konami/k573fpga.h +++ b/src/mame/konami/k573fpga.h @@ -16,7 +16,7 @@ class k573fpga_device : public device_t public: k573fpga_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); - template void add_route(T &&... args) { subdevice("mpeg")->add_route(std::forward(args)...); } + template void add_route(T &&... args) { mas3507d.lookup()->add_route(std::forward(args)...); } template void set_ram(T &&tag) { ram.set_tag(std::forward(tag)); } void set_ddrsbm_fpga(bool flag) { is_ddrsbm_fpga = flag; } diff --git a/src/mame/pinball/wpc.cpp b/src/mame/pinball/wpc.cpp index 71aa8d2961c..d8f3a80a6c2 100644 --- a/src/mame/pinball/wpc.cpp +++ b/src/mame/pinball/wpc.cpp @@ -17,19 +17,19 @@ DEFINE_DEVICE_TYPE(WPCASIC, wpc_device, "wpc", "Williams WPC ASIC") -wpc_device::wpc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, WPCASIC, tag, owner, clock), - m_dmd_visiblepage(0), - m_irq_cb(*this), - m_firq_cb(*this), - m_sounddata_r(*this), - m_sounddata_w(*this), - m_soundctrl_r(*this), - m_soundctrl_w(*this), - m_sounds11_w(*this), - m_bank_w(*this), - m_dmdbank_w(*this), - m_io_keyboard(*this, ":X%d", 0U) +wpc_device::wpc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, WPCASIC, tag, owner, clock), + m_dmd_visiblepage(0), + m_irq_cb(*this), + m_firq_cb(*this), + m_sounddata_r(*this), + m_sounddata_w(*this), + m_soundctrl_r(*this), + m_soundctrl_w(*this), + m_sounds11_w(*this), + m_bank_w(*this), + m_dmdbank_w(*this), + m_io_keyboard(*this, ":X%d", 0U) { } diff --git a/src/mame/sgi/sgi_gr1.h b/src/mame/sgi/sgi_gr1.h index 3a4a7a706e5..529d8b2cd13 100644 --- a/src/mame/sgi/sgi_gr1.h +++ b/src/mame/sgi/sgi_gr1.h @@ -6,14 +6,17 @@ #pragma once -#include "machine/bankdev.h" -#include "screen.h" #include "sgi_ge5.h" #include "sgi_re2.h" #include "sgi_xmap2.h" + +#include "machine/bankdev.h" #include "video/bt45x.h" #include "video/bt431.h" +#include "screen.h" + + class sgi_gr1_device : public device_t { public: @@ -22,11 +25,11 @@ public: static constexpr feature_type imperfect_features() { return feature::GRAPHICS; } // configuration - auto out_vblank() { return subdevice("screen")->screen_vblank(); } - auto out_int() { return subdevice("ge5")->out_int(); } + auto out_vblank() { return m_screen.lookup()->screen_vblank(); } + auto out_int() { return m_ge.lookup()->out_int(); } auto out_int_fifo() { return m_int_fifo_cb.bind(); } - u32 dma_r() { return subdevice("ge5")->buffer_r(0); } + u32 dma_r() { return m_ge.lookup()->buffer_r(0); } void dma_w(u32 data) { fifo_w(0, data, 0xffffffffU); } void reset_w(int state); diff --git a/src/mame/shared/megacdcd.h b/src/mame/shared/megacdcd.h index 1fcc9cac199..6ee3a4c7969 100644 --- a/src/mame/shared/megacdcd.h +++ b/src/mame/shared/megacdcd.h @@ -22,7 +22,7 @@ public: template void set_cdc_do_dma_callback(T &&... args) { m_segacd_dma_callback.set(std::forward(args)...); } - template void set_cdrom_tag(T &&tag) { m_cdrom.set_tag(std::forward(tag)); subdevice("cdda")->set_cdrom_tag(std::forward(tag)); } + template void set_cdrom_tag(T &&tag) { m_cdrom.set_tag(std::forward(tag)); m_cdda.lookup()->set_cdrom_tag(std::forward(tag)); } template void set_68k_tag(T &&tag) { m_68k.set_tag(std::forward(tag)); } diff --git a/src/mame/shared/xbox_pci.h b/src/mame/shared/xbox_pci.h index 089a6642e70..e423f2e7bd4 100644 --- a/src/mame/shared/xbox_pci.h +++ b/src/mame/shared/xbox_pci.h @@ -459,13 +459,13 @@ public: mcpx_ide_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); template void set_bus_master_space(T &&bmtag, int bmspace) { - subdevice(m_pri.finder_tag())->set_bus_master_space(bmtag, bmspace); - subdevice(m_sec.finder_tag())->set_bus_master_space(bmtag, bmspace); + m_pri.lookup()->set_bus_master_space(bmtag, bmspace); + m_sec.lookup()->set_bus_master_space(bmtag, bmspace); } template void set_bus_master_space(const address_space_finder &finder) { - subdevice(m_pri.finder_tag())->set_bus_master_space(finder); - subdevice(m_sec.finder_tag())->set_bus_master_space(finder); + m_pri.lookup()->set_bus_master_space(finder); + m_sec.lookup()->set_bus_master_space(finder); } auto pri_interrupt_handler() { return m_pri_interrupt_handler.bind(); } diff --git a/src/mame/sunelectronics/ikki.cpp b/src/mame/sunelectronics/ikki.cpp index acf0cf39f35..ab150f10a53 100644 --- a/src/mame/sunelectronics/ikki.cpp +++ b/src/mame/sunelectronics/ikki.cpp @@ -496,17 +496,17 @@ TIMER_DEVICE_CALLBACK_MEMBER(ikki_state::irq) void ikki_state::ikki(machine_config &config) { - static constexpr XTAL MASTER_CLOCK = 20_MHz_XTAL; - static constexpr XTAL PIXEL_CLOCK = MASTER_CLOCK / 4; // guess - static constexpr XTAL CPU_CLOCK = 8_MHz_XTAL; + constexpr XTAL MASTER_CLOCK = 20_MHz_XTAL; + constexpr XTAL PIXEL_CLOCK = MASTER_CLOCK / 4; // guess + constexpr XTAL CPU_CLOCK = 8_MHz_XTAL; // also a guess - static constexpr int HTOTAL = (320); - static constexpr int HBEND = (8); - static constexpr int HBSTART = (248); - static constexpr int VTOTAL = (262); - static constexpr int VBEND = (16); - static constexpr int VBSTART = (240); + constexpr int HTOTAL = 320; + constexpr int HBEND = 8; + constexpr int HBSTART = 248; + constexpr int VTOTAL = 262; + constexpr int VBEND = 16; + constexpr int VBSTART = 240; // basic machine hardware Z80(config, m_maincpu, CPU_CLOCK / 2); // 4.000MHz diff --git a/src/mame/vsystem/vsystem_gga.cpp b/src/mame/vsystem/vsystem_gga.cpp index 945c813af42..0111664db95 100644 --- a/src/mame/vsystem/vsystem_gga.cpp +++ b/src/mame/vsystem/vsystem_gga.cpp @@ -23,10 +23,10 @@ DEFINE_DEVICE_TYPE(VSYSTEM_GGA, vsystem_gga_device, "vsystem_gga", "Video System // vsystem_gga_device - constructor //------------------------------------------------- -vsystem_gga_device::vsystem_gga_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, VSYSTEM_GGA, tag, owner, clock), - device_video_interface(mconfig, *this, false), - m_write_cb(*this) +vsystem_gga_device::vsystem_gga_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, VSYSTEM_GGA, tag, owner, clock), + device_video_interface(mconfig, *this, false), + m_write_cb(*this) { } -- cgit v1.2.3