From 48b45768a0e452f055ed52249ec0f3161a7370bc Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 13 May 2018 12:09:16 -0400 Subject: [PATCH] bus/cbus: Interrupt lines are now callbacks (nw) --- src/devices/bus/cbus/mpu_pc98.cpp | 1 - src/devices/bus/cbus/pc9801_118.cpp | 3 +-- src/devices/bus/cbus/pc9801_118.h | 1 - src/devices/bus/cbus/pc9801_26.cpp | 3 +-- src/devices/bus/cbus/pc9801_26.h | 1 - src/devices/bus/cbus/pc9801_86.cpp | 6 +++--- src/devices/bus/cbus/pc9801_86.h | 1 - src/devices/bus/cbus/pc9801_cbus.cpp | 16 +++++++++++++++- src/devices/bus/cbus/pc9801_cbus.h | 26 ++++++++++++++++++++++++++ src/mame/drivers/pc9801.cpp | 28 ++++++++++++++++++++++++++++ 10 files changed, 74 insertions(+), 12 deletions(-) diff --git a/src/devices/bus/cbus/mpu_pc98.cpp b/src/devices/bus/cbus/mpu_pc98.cpp index 85c841d8052..7978cbd75e6 100644 --- a/src/devices/bus/cbus/mpu_pc98.cpp +++ b/src/devices/bus/cbus/mpu_pc98.cpp @@ -8,7 +8,6 @@ #include "emu.h" #include "mpu_pc98.h" -#include "machine/pic8259.h" #define MPU_CORE_TAG "mpu401" diff --git a/src/devices/bus/cbus/pc9801_118.cpp b/src/devices/bus/cbus/pc9801_118.cpp index ca55b15da34..719f226fe3b 100644 --- a/src/devices/bus/cbus/pc9801_118.cpp +++ b/src/devices/bus/cbus/pc9801_118.cpp @@ -15,7 +15,6 @@ #include "emu.h" #include "bus/cbus/pc9801_118.h" -#include "machine/pic8259.h" #include "sound/2608intf.h" #include "speaker.h" @@ -43,7 +42,7 @@ WRITE8_MEMBER(pc9801_118_device::opn_portb_w){ m_joy_sel = data; } WRITE_LINE_MEMBER(pc9801_118_device::pc9801_sound_irq) { /* TODO: seems to die very often */ - machine().device(":pic8259_slave")->ir4_w(state); + m_bus->int_w<5>(state); } //------------------------------------------------- diff --git a/src/devices/bus/cbus/pc9801_118.h b/src/devices/bus/cbus/pc9801_118.h index 892f893abc3..99a4287e429 100644 --- a/src/devices/bus/cbus/pc9801_118.h +++ b/src/devices/bus/cbus/pc9801_118.h @@ -12,7 +12,6 @@ #pragma once #include "bus/cbus/pc9801_cbus.h" -#include "machine/pic8259.h" #include "sound/2608intf.h" diff --git a/src/devices/bus/cbus/pc9801_26.cpp b/src/devices/bus/cbus/pc9801_26.cpp index ab5cba671f6..6a31ef19ecc 100644 --- a/src/devices/bus/cbus/pc9801_26.cpp +++ b/src/devices/bus/cbus/pc9801_26.cpp @@ -14,7 +14,6 @@ #include "emu.h" #include "bus/cbus/pc9801_26.h" -#include "machine/pic8259.h" #include "sound/2203intf.h" #include "speaker.h" @@ -43,7 +42,7 @@ WRITE8_MEMBER(pc9801_26_device::opn_portb_w){ m_joy_sel = data; } WRITE_LINE_MEMBER(pc9801_26_device::pc9801_sound_irq) { /* TODO: seems to die very often */ - machine().device(":pic8259_slave")->ir4_w(state); + m_bus->int_w<5>(state); } diff --git a/src/devices/bus/cbus/pc9801_26.h b/src/devices/bus/cbus/pc9801_26.h index 7d0f183cc3a..0a7857242d8 100644 --- a/src/devices/bus/cbus/pc9801_26.h +++ b/src/devices/bus/cbus/pc9801_26.h @@ -12,7 +12,6 @@ Template for skeleton device #pragma once #include "bus/cbus/pc9801_cbus.h" -#include "machine/pic8259.h" #include "sound/2203intf.h" diff --git a/src/devices/bus/cbus/pc9801_86.cpp b/src/devices/bus/cbus/pc9801_86.cpp index ea57d86f41e..82715c4e718 100644 --- a/src/devices/bus/cbus/pc9801_86.cpp +++ b/src/devices/bus/cbus/pc9801_86.cpp @@ -44,7 +44,7 @@ WRITE_LINE_MEMBER(pc9801_86_device::sound_irq) { m_fmirq = state ? true : false; /* TODO: seems to die very often */ - machine().device(":pic8259_slave")->ir4_w(state || (m_pcmirq ? ASSERT_LINE : CLEAR_LINE)); + m_bus->int_w<5>(state || (m_pcmirq ? ASSERT_LINE : CLEAR_LINE)); } @@ -274,7 +274,7 @@ WRITE8_MEMBER(pc9801_86_device::pcm_w) m_head = m_tail = m_count = 0; if(!(data & 0x10)) { - machine().device(":pic8259_slave")->ir4_w(m_fmirq ? ASSERT_LINE : CLEAR_LINE); + m_bus->int_w<5>(m_fmirq ? ASSERT_LINE : CLEAR_LINE); if(!(queue_count() < m_irq_rate) || !(data & 0x80)) m_pcmirq = false; //TODO: this needs research } @@ -356,6 +356,6 @@ void pc9801_86_device::device_timer(emu_timer& timer, device_timer_id id, int pa if((queue_count() < m_irq_rate) && (m_pcm_ctrl & 0x20)) { m_pcmirq = true; - machine().device(":pic8259_slave")->ir4_w(ASSERT_LINE); + m_bus->int_w<5>(ASSERT_LINE); } } diff --git a/src/devices/bus/cbus/pc9801_86.h b/src/devices/bus/cbus/pc9801_86.h index 6192f80b85a..a4711f08462 100644 --- a/src/devices/bus/cbus/pc9801_86.h +++ b/src/devices/bus/cbus/pc9801_86.h @@ -12,7 +12,6 @@ #pragma once #include "bus/cbus/pc9801_cbus.h" -#include "machine/pic8259.h" #include "sound/2608intf.h" #include "sound/dac.h" diff --git a/src/devices/bus/cbus/pc9801_cbus.cpp b/src/devices/bus/cbus/pc9801_cbus.cpp index b07235204af..70f22990159 100644 --- a/src/devices/bus/cbus/pc9801_cbus.cpp +++ b/src/devices/bus/cbus/pc9801_cbus.cpp @@ -55,7 +55,8 @@ device_pc9801cbus_card_interface::~device_pc9801cbus_card_interface() pc9801_slot_device::pc9801_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, PC9801CBUS_SLOT, tag, owner, clock), device_slot_interface(mconfig, *this), - m_cpu(*this, "^maincpu") + m_cpu(*this, "^maincpu"), + m_int_callback{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}} { } @@ -72,6 +73,19 @@ void pc9801_slot_device::device_config_complete() } +//------------------------------------------------- +// device_resolve_objects - resolve objects that +// may be needed for other devices to set +// initial conditions at start time +//------------------------------------------------- + +void pc9801_slot_device::device_resolve_objects() +{ + for (auto &cb : m_int_callback) + cb.resolve_safe(); +} + + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- diff --git a/src/devices/bus/cbus/pc9801_cbus.h b/src/devices/bus/cbus/pc9801_cbus.h index 890519dfbbf..51787dec1ae 100644 --- a/src/devices/bus/cbus/pc9801_cbus.h +++ b/src/devices/bus/cbus/pc9801_cbus.h @@ -27,6 +27,26 @@ MCFG_DEVICE_ADD(_tag, PC9801CBUS_SLOT, 0) \ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) +#define MCFG_PC9801CBUS_INT0_CALLBACK(_devcb) \ + devcb = &downcast(*device).set_int_callback<0>(DEVCB_##_devcb); + +#define MCFG_PC9801CBUS_INT1_CALLBACK(_devcb) \ + devcb = &downcast(*device).set_int_callback<1>(DEVCB_##_devcb); + +#define MCFG_PC9801CBUS_INT2_CALLBACK(_devcb) \ + devcb = &downcast(*device).set_int_callback<2>(DEVCB_##_devcb); + +#define MCFG_PC9801CBUS_INT3_CALLBACK(_devcb) \ + devcb = &downcast(*device).set_int_callback<3>(DEVCB_##_devcb); + +#define MCFG_PC9801CBUS_INT4_CALLBACK(_devcb) \ + devcb = &downcast(*device).set_int_callback<4>(DEVCB_##_devcb); + +#define MCFG_PC9801CBUS_INT5_CALLBACK(_devcb) \ + devcb = &downcast(*device).set_int_callback<5>(DEVCB_##_devcb); + +#define MCFG_PC9801CBUS_INT6_CALLBACK(_devcb) \ + devcb = &downcast(*device).set_int_callback<6>(DEVCB_##_devcb); //************************************************************************** @@ -58,16 +78,22 @@ public: // construction/destruction pc9801_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + // configuration access + template devcb_base &set_int_callback(Object &&cb) { return m_int_callback[I].set_callback(std::forward(cb)); } + address_space &io_space() const { return m_cpu->space(AS_IO); } + template void int_w(bool state) { m_int_callback[I](state); } protected: // device-level overrides virtual void device_start() override; virtual void device_config_complete() override; + virtual void device_resolve_objects() override; private: // device_pc9801_slot_card_interface *m_card; required_device m_cpu; + devcb_write_line m_int_callback[7]; }; diff --git a/src/mame/drivers/pc9801.cpp b/src/mame/drivers/pc9801.cpp index fcee81b6962..3650bd595e6 100644 --- a/src/mame/drivers/pc9801.cpp +++ b/src/mame/drivers/pc9801.cpp @@ -2225,8 +2225,36 @@ MACHINE_CONFIG_END MACHINE_CONFIG_START(pc9801_state::pc9801_cbus) MCFG_PC9801CBUS_SLOT_ADD("cbus0", pc9801_cbus_devices, "pc9801_26") + MCFG_PC9801CBUS_INT0_CALLBACK(WRITELINE("ir3", input_merger_device, in_w<0>)) + MCFG_PC9801CBUS_INT1_CALLBACK(WRITELINE("ir5", input_merger_device, in_w<0>)) + MCFG_PC9801CBUS_INT2_CALLBACK(WRITELINE("ir6", input_merger_device, in_w<0>)) + MCFG_PC9801CBUS_INT3_CALLBACK(WRITELINE("ir9", input_merger_device, in_w<0>)) + MCFG_PC9801CBUS_INT4_CALLBACK(WRITELINE("pic8259_slave", pic8259_device, ir2_w)) + MCFG_PC9801CBUS_INT5_CALLBACK(WRITELINE("ir12", input_merger_device, in_w<0>)) + MCFG_PC9801CBUS_INT6_CALLBACK(WRITELINE("ir13", input_merger_device, in_w<0>)) + MCFG_PC9801CBUS_SLOT_ADD("cbus1", pc9801_cbus_devices, nullptr) + MCFG_PC9801CBUS_INT0_CALLBACK(WRITELINE("ir3", input_merger_device, in_w<1>)) + MCFG_PC9801CBUS_INT1_CALLBACK(WRITELINE("ir5", input_merger_device, in_w<1>)) + MCFG_PC9801CBUS_INT2_CALLBACK(WRITELINE("ir6", input_merger_device, in_w<1>)) + MCFG_PC9801CBUS_INT3_CALLBACK(WRITELINE("ir9", input_merger_device, in_w<1>)) + MCFG_PC9801CBUS_INT4_CALLBACK(WRITELINE("pic8259_slave", pic8259_device, ir3_w)) + MCFG_PC9801CBUS_INT5_CALLBACK(WRITELINE("ir12", input_merger_device, in_w<1>)) + MCFG_PC9801CBUS_INT6_CALLBACK(WRITELINE("ir13", input_merger_device, in_w<1>)) // TODO: six max slots + + MCFG_INPUT_MERGER_ANY_HIGH("ir3") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(WRITELINE("pic8259_master", pic8259_device, ir3_w)) + MCFG_INPUT_MERGER_ANY_HIGH("ir5") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(WRITELINE("pic8259_master", pic8259_device, ir5_w)) + MCFG_INPUT_MERGER_ANY_HIGH("ir6") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(WRITELINE("pic8259_master", pic8259_device, ir6_w)) + MCFG_INPUT_MERGER_ANY_HIGH("ir9") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(WRITELINE("pic8259_slave", pic8259_device, ir1_w)) + MCFG_INPUT_MERGER_ANY_HIGH("ir12") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(WRITELINE("pic8259_slave", pic8259_device, ir4_w)) + MCFG_INPUT_MERGER_ANY_HIGH("ir13") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(WRITELINE("pic8259_slave", pic8259_device, ir5_w)) MACHINE_CONFIG_END MACHINE_CONFIG_START(pc9801_state::pc9801_sasi)