From cc401fc77421367a15f1d23ef7ff94c59cf5f431 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 1 Mar 2022 00:50:51 +1100 Subject: cpu/hphybrid: Use device_delegate rather than devcb for hot callbacks unlikely to be chained. --- src/devices/cpu/hphybrid/hphybrid.cpp | 26 +++++++++++--------------- src/devices/cpu/hphybrid/hphybrid.h | 20 ++++++++++++-------- src/mame/drivers/hp64k.cpp | 2 +- src/mame/drivers/hp9825.cpp | 6 +++--- src/mame/drivers/hp9845.cpp | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/devices/cpu/hphybrid/hphybrid.cpp b/src/devices/cpu/hphybrid/hphybrid.cpp index 5897672ca53..e6c8f1f0906 100644 --- a/src/devices/cpu/hphybrid/hphybrid.cpp +++ b/src/devices/cpu/hphybrid/hphybrid.cpp @@ -167,11 +167,6 @@ WRITE_LINE_MEMBER(hp_hybrid_cpu_device::flag_w) BIT_CLR(m_flags, HPHYBRID_FLG_BIT); } -uint8_t hp_hybrid_cpu_device::pa_r() const -{ - return CURRENT_PA; -} - hp_hybrid_cpu_device::hp_hybrid_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t addrwidth) : cpu_device(mconfig, type, tag, owner, clock) , m_pa_changed_func(*this) @@ -243,9 +238,9 @@ void hp_hybrid_cpu_device::device_start() set_icountptr(m_icount); m_pa_changed_func.resolve_safe(); - m_opcode_func.resolve_safe(); + m_opcode_func.resolve(); m_stm_func.resolve(); - m_int_func.resolve_safe(0xff); + m_int_func.resolve(); } void hp_hybrid_cpu_device::device_reset() @@ -955,7 +950,7 @@ uint16_t hp_hybrid_cpu_device::RM(uint32_t addr) // Any access to internal registers removes forcing of BSC 2x m_forced_bsc_25 = false; - if (m_stm_func) { + if (!m_stm_func.isnull()) { m_stm_func(m_curr_cycle | CYCLE_RAL_MASK | CYCLE_RD_MASK); m_curr_cycle = 0; } @@ -1024,7 +1019,7 @@ uint16_t hp_hybrid_cpu_device::RM(uint32_t addr) return tmp; } else { m_icount -= m_r_cycles; - if (m_stm_func) { + if (!m_stm_func.isnull()) { m_stm_func(m_curr_cycle | CYCLE_RD_MASK); m_curr_cycle = 0; } @@ -1077,7 +1072,7 @@ void hp_hybrid_cpu_device::WM(uint32_t addr , uint16_t v) // Any access to internal registers removes forcing of BSC 2x m_forced_bsc_25 = false; - if (m_stm_func) { + if (!m_stm_func.isnull()) { m_stm_func(m_curr_cycle | CYCLE_RAL_MASK | CYCLE_WR_MASK); m_curr_cycle = 0; } @@ -1147,7 +1142,7 @@ void hp_hybrid_cpu_device::WM(uint32_t addr , uint16_t v) m_icount -= REGISTER_RW_CYCLES; } else { m_icount -= m_w_cycles; - if (m_stm_func) { + if (!m_stm_func.isnull()) { m_stm_func(m_curr_cycle | CYCLE_WR_MASK); m_curr_cycle = 0; } @@ -1196,7 +1191,8 @@ uint16_t hp_hybrid_cpu_device::fetch_at(uint32_t addr) { m_curr_cycle |= CYCLE_IFETCH_MASK; uint16_t opcode = RM(addr); - m_opcode_func(opcode); + if (!m_opcode_func.isnull()) + m_opcode_func(opcode); return opcode; } @@ -1326,7 +1322,7 @@ void hp_hybrid_cpu_device::check_for_interrupts() standard_irq_callback(irqline); // Get interrupt vector in low byte (level is available on PA3) - uint8_t vector = m_int_func(BIT(m_flags , HPHYBRID_IRH_BIT) ? 1 : 0); + uint8_t vector = !m_int_func.isnull() ? m_int_func(BIT(m_flags , HPHYBRID_IRH_BIT) ? 1 : 0) : 0xff; uint8_t new_PA; // Get highest numbered 1 @@ -1617,7 +1613,7 @@ bool hp_5061_3011_cpu_device::execute_no_bpc(uint16_t opcode , uint16_t& next_pc // 16 bits units. WM(tmp_addr >> 1 , tmp); } else { - if (m_stm_func) { + if (!m_stm_func.isnull()) { m_stm_func(m_curr_cycle | CYCLE_WR_MASK); m_curr_cycle = 0; } @@ -1986,7 +1982,7 @@ bool hp_09825_67907_cpu_device::execute_no_bpc(uint16_t opcode , uint16_t& next_ // 16 bits units. WM(tmp_addr , tmp); } else { - if (m_stm_func) { + if (!m_stm_func.isnull()) { m_stm_func(m_curr_cycle | CYCLE_WR_MASK); m_curr_cycle = 0; } diff --git a/src/devices/cpu/hphybrid/hphybrid.h b/src/devices/cpu/hphybrid/hphybrid.h index 3d4a7cc7536..3864282245d 100644 --- a/src/devices/cpu/hphybrid/hphybrid.h +++ b/src/devices/cpu/hphybrid/hphybrid.h @@ -47,17 +47,21 @@ #define HP_IOADDR_IC_SHIFT 0 // Compose an I/O address from PA & IC -inline constexpr unsigned HP_MAKE_IOADDR(unsigned pa , unsigned ic) { return ((pa << HP_IOADDR_PA_SHIFT) | (ic << HP_IOADDR_IC_SHIFT)); } +constexpr unsigned HP_MAKE_IOADDR(unsigned pa , unsigned ic) { return ((pa << HP_IOADDR_PA_SHIFT) | (ic << HP_IOADDR_IC_SHIFT)); } class hp_hybrid_cpu_device : public cpu_device { public: + using stm_delegate = device_delegate; + using opcode_delegate = device_delegate; + using int_delegate = device_delegate; + DECLARE_WRITE_LINE_MEMBER(dmar_w); DECLARE_WRITE_LINE_MEMBER(halt_w); DECLARE_WRITE_LINE_MEMBER(status_w); DECLARE_WRITE_LINE_MEMBER(flag_w); - uint8_t pa_r() const; + uint8_t pa_r() const { return m_reg_PA[0]; } auto pa_changed_cb() { return m_pa_changed_func.bind(); } @@ -82,13 +86,13 @@ public: }; // Called at start of each memory access - auto stm_cb() { return m_stm_func.bind(); } + template void set_stm_cb(T &&... args) { m_stm_func.set(std::forward(args)...); } // Tap into fetched opcodes - auto opcode_cb() { return m_opcode_func.bind(); } + template void set_opcode_cb(T &&... args) { m_opcode_func.set(std::forward(args)...); } // Acknowledge interrupts - auto int_cb() { return m_int_func.bind(); } + template void set_int_cb(T &&... args) { m_int_func.set(std::forward(args)...); } protected: hp_hybrid_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t addrwidth); @@ -160,9 +164,9 @@ protected: devcb_write8 m_pa_changed_func; uint8_t m_last_pa; - devcb_write16 m_opcode_func; - devcb_write8 m_stm_func; - devcb_read8 m_int_func; + opcode_delegate m_opcode_func; + stm_delegate m_stm_func; + int_delegate m_int_func; int m_icount; uint32_t m_addr_mask; diff --git a/src/mame/drivers/hp64k.cpp b/src/mame/drivers/hp64k.cpp index 3ed1cad3991..5657dae50b8 100644 --- a/src/mame/drivers/hp64k.cpp +++ b/src/mame/drivers/hp64k.cpp @@ -1380,7 +1380,7 @@ void hp64k_state::hp64k(machine_config &config) m_cpu->set_relative_mode(true); m_cpu->set_addrmap(AS_PROGRAM, &hp64k_state::cpu_mem_map); m_cpu->set_addrmap(AS_IO, &hp64k_state::cpu_io_map); - m_cpu->int_cb().set(FUNC(hp64k_state::int_cb)); + m_cpu->set_int_cb(FUNC(hp64k_state::int_cb)); // Actual keyboard refresh rate should be between 1 and 2 kHz TIMER(config, "kb_timer").configure_periodic(FUNC(hp64k_state::hp64k_kb_scan), attotime::from_hz(100)); diff --git a/src/mame/drivers/hp9825.cpp b/src/mame/drivers/hp9825.cpp index d4f373b3051..b4a0b5120a7 100644 --- a/src/mame/drivers/hp9825.cpp +++ b/src/mame/drivers/hp9825.cpp @@ -757,7 +757,7 @@ void hp9825_state::hp9825_base(machine_config &config) m_cpu->set_rw_cycles(6 , 6); m_cpu->set_relative_mode(false); m_cpu->set_addrmap(AS_IO , &hp9825_state::cpu_io_map); - m_cpu->int_cb().set(m_io_sys , FUNC(hp98x5_io_sys_device::int_r)); + m_cpu->set_int_cb(m_io_sys , FUNC(hp98x5_io_sys_device::int_r)); m_cpu->pa_changed_cb().set(m_io_sys , FUNC(hp98x5_io_sys_device::pa_w)); // Needed when 98035 RTC module is connected or time advances at about 1/4 the correct speed (NP misses a lot of 1kHz interrupts) @@ -1084,8 +1084,8 @@ void hp9825t_state::hp9825t(machine_config &config) { hp9825_base(config); m_cpu->set_addrmap(AS_PROGRAM , &hp9825t_state::cpu_mem_map); - m_cpu->stm_cb().set(FUNC(hp9825t_state::stm)); - m_cpu->opcode_cb().set(FUNC(hp9825t_state::opcode_fetch)); + m_cpu->set_stm_cb(FUNC(hp9825t_state::stm)); + m_cpu->set_opcode_cb(FUNC(hp9825t_state::opcode_fetch)); set_addrmap(0 , &hp9825t_state::ram_mem_map); set_addrmap(1 , &hp9825t_state::rom_mem_map); diff --git a/src/mame/drivers/hp9845.cpp b/src/mame/drivers/hp9845.cpp index 28f1e17f1f3..f9b45da62bb 100644 --- a/src/mame/drivers/hp9845.cpp +++ b/src/mame/drivers/hp9845.cpp @@ -3654,7 +3654,7 @@ void hp9845_base_state::hp9845_base(machine_config &config) m_ppu->set_9845_boot_mode(true); m_ppu->set_rw_cycles(6 , 6); m_ppu->set_relative_mode(true); - m_ppu->int_cb().set(m_io_sys , FUNC(hp98x5_io_sys_device::int_r)); + m_ppu->set_int_cb(m_io_sys , FUNC(hp98x5_io_sys_device::int_r)); m_ppu->pa_changed_cb().set(m_io_sys , FUNC(hp98x5_io_sys_device::pa_w)); HP98X5_IO_SYS(config , m_io_sys , 0); -- cgit v1.2.3