diff options
author | 2023-06-17 01:10:05 +1000 | |
---|---|---|
committer | 2023-06-17 01:10:05 +1000 | |
commit | e9c1f4a42a6758a6fb75403e28c7dc6cf869081c (patch) | |
tree | 8e0b6d960bed4baec2408c9ab950218592ef33ec /src/devices/cpu/z80 | |
parent | c1ceb6e016763537c5109cc76fe5d1b4ae72fdb3 (diff) |
emu/devcb.h: Eliminated the need to call resolve() on callbacks. (#11333)
Read callbacks now need a default return value supplied at construction.
Replaced isnull() with isunset() which tells you if the callback wasn't
configured rather than whether it isn't safe to call.
Enabled validation of device callbacks (it seems it was disabled at some
point, probably accidentally).
Device callbacks and object finders now implement the same interface for
resolution.
Diffstat (limited to 'src/devices/cpu/z80')
-rw-r--r-- | src/devices/cpu/z80/kl5c80a12.cpp | 35 | ||||
-rw-r--r-- | src/devices/cpu/z80/kl5c80a12.h | 5 | ||||
-rw-r--r-- | src/devices/cpu/z80/kl5c80a16.cpp | 25 | ||||
-rw-r--r-- | src/devices/cpu/z80/kl5c80a16.h | 5 | ||||
-rw-r--r-- | src/devices/cpu/z80/kp63.cpp | 14 | ||||
-rw-r--r-- | src/devices/cpu/z80/kp63.h | 3 | ||||
-rw-r--r-- | src/devices/cpu/z80/kp64.cpp | 13 | ||||
-rw-r--r-- | src/devices/cpu/z80/kp64.h | 3 | ||||
-rw-r--r-- | src/devices/cpu/z80/kp69.cpp | 13 | ||||
-rw-r--r-- | src/devices/cpu/z80/kp69.h | 5 | ||||
-rw-r--r-- | src/devices/cpu/z80/tmpz84c011.cpp | 27 | ||||
-rw-r--r-- | src/devices/cpu/z80/tmpz84c015.cpp | 43 | ||||
-rw-r--r-- | src/devices/cpu/z80/z80.cpp | 6 |
13 files changed, 43 insertions, 154 deletions
diff --git a/src/devices/cpu/z80/kl5c80a12.cpp b/src/devices/cpu/z80/kl5c80a12.cpp index 495a0ab4afd..702facf2ad2 100644 --- a/src/devices/cpu/z80/kl5c80a12.cpp +++ b/src/devices/cpu/z80/kl5c80a12.cpp @@ -40,9 +40,9 @@ kl5c80a12_device::kl5c80a12_device(const machine_config &mconfig, const char *ta address_map_constructor(FUNC(kl5c80a12_device::internal_ram), this), address_map_constructor(FUNC(kl5c80a12_device::internal_io), this)) , m_kp69(*this, "kp69") - , m_porta_in_callback(*this) + , m_porta_in_callback(*this, 0) , m_porta_out_callback(*this) - , m_portb_in_callback(*this) + , m_portb_in_callback(*this, 0) , m_portb_out_callback(*this) , m_porta_data{0, 0} , m_porta_direction{0, 0} @@ -87,24 +87,6 @@ void kl5c80a12_device::internal_io(address_map &map) //------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void kl5c80a12_device::device_resolve_objects() -{ - // Resolve parallel port callbacks - for (int i = 0; i < 2; i++) - m_porta_in_callback[i].resolve_safe(m_porta_3state[i]); - m_porta_out_callback.resolve_all_safe(); - for (int i = 0; i < 3; i++) - m_portb_in_callback[i].resolve_safe(m_portb_3state[i]); - m_portb_out_callback.resolve_all_safe(); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -175,7 +157,20 @@ void kl5c80a12_device::device_add_mconfig(machine_config &config) void kl5c80a12_device::device_config_complete() { + kc82_device::device_config_complete(); + set_daisy_config(pseudo_daisy_config); + + for (int i = 0; i < 2; i++) + { + if (m_porta_in_callback[i].isunset()) + m_porta_in_callback[i].bind().set_constant(m_porta_3state[i]); + } + for (int i = 0; i < 3; i++) + { + if (m_portb_in_callback[i].isunset()) + m_portb_in_callback[i].bind().set_constant(m_portb_3state[i]); + } } diff --git a/src/devices/cpu/z80/kl5c80a12.h b/src/devices/cpu/z80/kl5c80a12.h index 28434f8c8f6..2d3884ad409 100644 --- a/src/devices/cpu/z80/kl5c80a12.h +++ b/src/devices/cpu/z80/kl5c80a12.h @@ -50,14 +50,13 @@ public: void set_p4_3state(u8 value) { m_portb_3state[2] = value; } protected: - // device-level overrides + // device_t implementation virtual void device_add_mconfig(machine_config &config) override; virtual void device_config_complete() override; - virtual void device_resolve_objects() override; virtual void device_start() override; virtual void device_reset() override; - // device_execute_interface overrides + // device_execute_interface implementation virtual u64 execute_clocks_to_cycles(u64 clocks) const noexcept override { return (clocks + 2 - 1) / 2; } virtual u64 execute_cycles_to_clocks(u64 cycles) const noexcept override { return (cycles * 2); } diff --git a/src/devices/cpu/z80/kl5c80a16.cpp b/src/devices/cpu/z80/kl5c80a16.cpp index d92cc9142de..5efe26a0d9b 100644 --- a/src/devices/cpu/z80/kl5c80a16.cpp +++ b/src/devices/cpu/z80/kl5c80a16.cpp @@ -35,7 +35,7 @@ kl5c80a16_device::kl5c80a16_device(const machine_config &mconfig, const char *ta address_map_constructor(), address_map_constructor(FUNC(kl5c80a16_device::internal_io), this)) , m_kp69(*this, "kp69") - , m_port_in_callback(*this) + , m_port_in_callback(*this, 0) , m_port_out_callback(*this) , m_port_data{0, 0, 0, 0} , m_port_direction{0x0f, 0, 0, 0} @@ -61,21 +61,6 @@ void kl5c80a16_device::internal_io(address_map &map) //------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void kl5c80a16_device::device_resolve_objects() -{ - // Resolve parallel port callbacks - for (int i = 0; i < 4; i++) - m_port_in_callback[i].resolve_safe(m_port_3state[i]); - m_port_out_callback.resolve_all_safe(); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -135,7 +120,15 @@ void kl5c80a16_device::device_add_mconfig(machine_config &config) void kl5c80a16_device::device_config_complete() { + kc82_device::device_config_complete(); + set_daisy_config(pseudo_daisy_config); + + for (int i = 0; i < 4; i++) + { + if (m_port_in_callback[i].isunset()) + m_port_in_callback[i].bind().set_constant(m_port_3state[i]); + } } diff --git a/src/devices/cpu/z80/kl5c80a16.h b/src/devices/cpu/z80/kl5c80a16.h index d3ac8eda636..a7cd2178396 100644 --- a/src/devices/cpu/z80/kl5c80a16.h +++ b/src/devices/cpu/z80/kl5c80a16.h @@ -47,14 +47,13 @@ public: void set_p3_3state(u8 value) { m_port_3state[3] = value; } protected: - // device-level overrides + // device_t implementation virtual void device_add_mconfig(machine_config &config) override; virtual void device_config_complete() override; - virtual void device_resolve_objects() override; virtual void device_start() override; virtual void device_reset() override; - // device_execute_interface overrides + // device_execute_interface implementation virtual u64 execute_clocks_to_cycles(u64 clocks) const noexcept override { return (clocks + 2 - 1) / 2; } virtual u64 execute_cycles_to_clocks(u64 cycles) const noexcept override { return (cycles * 2); } diff --git a/src/devices/cpu/z80/kp63.cpp b/src/devices/cpu/z80/kp63.cpp index db42ef30ecb..2d8d693d11f 100644 --- a/src/devices/cpu/z80/kp63.cpp +++ b/src/devices/cpu/z80/kp63.cpp @@ -99,20 +99,6 @@ kp63a_device::kp63a_device(const machine_config &mconfig, const char *tag, devic //------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void kp63_device::device_resolve_objects() -{ - // Resolve output callbacks - m_out_pulse_callback.resolve_all_safe(); - m_out_strobe_callback.resolve_all_safe(); -} - - -//------------------------------------------------- // timer_expired - handle timed count underflow //------------------------------------------------- diff --git a/src/devices/cpu/z80/kp63.h b/src/devices/cpu/z80/kp63.h index 4d5a84c2349..93e2779d668 100644 --- a/src/devices/cpu/z80/kp63.h +++ b/src/devices/cpu/z80/kp63.h @@ -34,8 +34,7 @@ protected: // construction/destruction kp63_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 num_counters, u8 mode_mask); - // device-level overrides - virtual void device_resolve_objects() override; + // device_t implementation virtual void device_start() override; virtual void device_reset() override; diff --git a/src/devices/cpu/z80/kp64.cpp b/src/devices/cpu/z80/kp64.cpp index 0a40c4bad5b..ec0b8fdfa87 100644 --- a/src/devices/cpu/z80/kp64.cpp +++ b/src/devices/cpu/z80/kp64.cpp @@ -89,19 +89,6 @@ kp64_device::kp64_device(const machine_config &mconfig, const char *tag, device_ //------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void kp64_device::device_resolve_objects() -{ - // Resolve output callback - m_out_callback.resolve_safe(); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- diff --git a/src/devices/cpu/z80/kp64.h b/src/devices/cpu/z80/kp64.h index 0bb09f8316a..d8a76dc91b6 100644 --- a/src/devices/cpu/z80/kp64.h +++ b/src/devices/cpu/z80/kp64.h @@ -36,8 +36,7 @@ public: void gate_w(int state); protected: - // device-level overrides - virtual void device_resolve_objects() override; + // device_t implementation virtual void device_start() override; virtual void device_reset() override; diff --git a/src/devices/cpu/z80/kp69.cpp b/src/devices/cpu/z80/kp69.cpp index 0e194138b2c..3b1b59dcb20 100644 --- a/src/devices/cpu/z80/kp69.cpp +++ b/src/devices/cpu/z80/kp69.cpp @@ -64,19 +64,6 @@ kp69_device::kp69_device(const machine_config &mconfig, const char *tag, device_ //------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void kp69_base_device::device_resolve_objects() -{ - // Resolve output callback - m_int_callback.resolve_safe(); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- diff --git a/src/devices/cpu/z80/kp69.h b/src/devices/cpu/z80/kp69.h index 285fc610119..31bfbd71fea 100644 --- a/src/devices/cpu/z80/kp69.h +++ b/src/devices/cpu/z80/kp69.h @@ -43,12 +43,11 @@ protected: // construction/destruction kp69_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); - // device-level overrides - virtual void device_resolve_objects() override; + // device_t implementation virtual void device_start() override; virtual void device_reset() override; - // device_z80daisy_interface overrides + // device_z80daisy_interface implementation virtual int z80daisy_irq_state() override; virtual int z80daisy_irq_ack() override; virtual void z80daisy_irq_reti() override; diff --git a/src/devices/cpu/z80/tmpz84c011.cpp b/src/devices/cpu/z80/tmpz84c011.cpp index c28aa2b243a..e7925ac74d5 100644 --- a/src/devices/cpu/z80/tmpz84c011.cpp +++ b/src/devices/cpu/z80/tmpz84c011.cpp @@ -41,11 +41,11 @@ tmpz84c011_device::tmpz84c011_device(const machine_config &mconfig, const char * m_outportsc(*this), m_outportsd(*this), m_outportse(*this), - m_inportsa(*this), - m_inportsb(*this), - m_inportsc(*this), - m_inportsd(*this), - m_inportse(*this), + m_inportsa(*this, 0), + m_inportsb(*this, 0), + m_inportsc(*this, 0), + m_inportsd(*this, 0), + m_inportse(*this, 0), m_zc0_cb(*this), m_zc1_cb(*this), m_zc2_cb(*this) @@ -69,23 +69,6 @@ void tmpz84c011_device::device_start() { z80_device::device_start(); - // resolve callbacks - m_outportsa.resolve_safe(); - m_outportsb.resolve_safe(); - m_outportsc.resolve_safe(); - m_outportsd.resolve_safe(); - m_outportse.resolve_safe(); - - m_inportsa.resolve_safe(0); - m_inportsb.resolve_safe(0); - m_inportsc.resolve_safe(0); - m_inportsd.resolve_safe(0); - m_inportse.resolve_safe(0); - - m_zc0_cb.resolve_safe(); - m_zc1_cb.resolve_safe(); - m_zc2_cb.resolve_safe(); - // register for save states save_item(NAME(m_pio_dir[0])); save_item(NAME(m_pio_latch[0])); diff --git a/src/devices/cpu/z80/tmpz84c015.cpp b/src/devices/cpu/z80/tmpz84c015.cpp index 55d21908b77..765ec6af6c9 100644 --- a/src/devices/cpu/z80/tmpz84c015.cpp +++ b/src/devices/cpu/z80/tmpz84c015.cpp @@ -61,11 +61,11 @@ tmpz84c015_device::tmpz84c015_device(const machine_config &mconfig, device_type m_zc_cb(*this), - m_in_pa_cb(*this), + m_in_pa_cb(*this, 0), m_out_pa_cb(*this), m_out_ardy_cb(*this), - m_in_pb_cb(*this), + m_in_pb_cb(*this, 0), m_out_pb_cb(*this), m_out_brdy_cb(*this), @@ -89,36 +89,6 @@ void tmpz84c015_device::device_start() { z80_device::device_start(); - // resolve callbacks - m_out_txda_cb.resolve_safe(); - m_out_dtra_cb.resolve_safe(); - m_out_rtsa_cb.resolve_safe(); - m_out_wrdya_cb.resolve_safe(); - m_out_synca_cb.resolve_safe(); - - m_out_txdb_cb.resolve_safe(); - m_out_dtrb_cb.resolve_safe(); - m_out_rtsb_cb.resolve_safe(); - m_out_wrdyb_cb.resolve_safe(); - m_out_syncb_cb.resolve_safe(); - - m_out_rxdrqa_cb.resolve_safe(); - m_out_txdrqa_cb.resolve_safe(); - m_out_rxdrqb_cb.resolve_safe(); - m_out_txdrqb_cb.resolve_safe(); - - m_zc_cb.resolve_all_safe(); - - m_in_pa_cb.resolve_safe(0); - m_out_pa_cb.resolve_safe(); - m_out_ardy_cb.resolve_safe(); - - m_in_pb_cb.resolve_safe(0); - m_out_pb_cb.resolve_safe(); - m_out_brdy_cb.resolve_safe(); - - m_wdtout_cb.resolve(); - // setup watchdog timer m_watchdog_timer = timer_alloc(FUNC(tmpz84c015_device::watchdog_timeout), this); @@ -238,8 +208,7 @@ void tmpz84c015_device::wdtcr_w(uint8_t data) void tmpz84c015_device::watchdog_clear() { - if (!m_wdtout_cb.isnull()) - m_wdtout_cb(CLEAR_LINE); + m_wdtout_cb(CLEAR_LINE); if (BIT(m_wdtmr, 7)) m_watchdog_timer->adjust(cycles_to_attotime(0x10000 << (BIT(m_wdtmr, 5, 2) * 2))); @@ -247,10 +216,8 @@ void tmpz84c015_device::watchdog_clear() TIMER_CALLBACK_MEMBER(tmpz84c015_device::watchdog_timeout) { - if (!m_wdtout_cb.isnull()) - m_wdtout_cb(ASSERT_LINE); - else - logerror("Watchdog timeout\n"); + logerror("Watchdog timeout\n"); + m_wdtout_cb(ASSERT_LINE); } diff --git a/src/devices/cpu/z80/z80.cpp b/src/devices/cpu/z80/z80.cpp index ab8192e2115..24471736584 100644 --- a/src/devices/cpu/z80/z80.cpp +++ b/src/devices/cpu/z80/z80.cpp @@ -3591,16 +3591,12 @@ void z80_device::device_start() m_cc_xy = cc_xy; m_cc_xycb = cc_xycb; m_cc_ex = cc_ex; - - m_irqack_cb.resolve_safe(); - m_refresh_cb.resolve_safe(); - m_nomreq_cb.resolve_safe(); - m_halt_cb.resolve_safe(); } void nsc800_device::device_start() { z80_device::device_start(); + save_item(NAME(m_nsc800_irq_state)); } |