cpu/hphybrid: Use device_delegate rather than devcb for hot callbacks unlikely to be chained.

This commit is contained in:
Vas Crabb 2022-03-01 00:50:51 +11:00
parent 7aebdc99d8
commit cc401fc774
5 changed files with 28 additions and 28 deletions

View File

@ -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;
}

View File

@ -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<void (uint8_t)>;
using opcode_delegate = device_delegate<void (uint16_t)>;
using int_delegate = device_delegate<uint8_t (offs_t)>;
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 <typename... T> void set_stm_cb(T &&... args) { m_stm_func.set(std::forward<T>(args)...); }
// Tap into fetched opcodes
auto opcode_cb() { return m_opcode_func.bind(); }
template <typename... T> void set_opcode_cb(T &&... args) { m_opcode_func.set(std::forward<T>(args)...); }
// Acknowledge interrupts
auto int_cb() { return m_int_func.bind(); }
template <typename... T> void set_int_cb(T &&... args) { m_int_func.set(std::forward<T>(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;

View File

@ -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));

View File

@ -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);

View File

@ -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);