diff options
Diffstat (limited to 'src/devices/machine/6821pia.cpp')
-rw-r--r-- | src/devices/machine/6821pia.cpp | 108 |
1 files changed, 42 insertions, 66 deletions
diff --git a/src/devices/machine/6821pia.cpp b/src/devices/machine/6821pia.cpp index feae3e965c7..c7233fc5845 100644 --- a/src/devices/machine/6821pia.cpp +++ b/src/devices/machine/6821pia.cpp @@ -45,59 +45,35 @@ DEFINE_DEVICE_TYPE(PIA6821, pia6821_device, "pia6821", "6821 PIA") // pia6821_device - constructor //------------------------------------------------- -pia6821_device::pia6821_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, PIA6821, tag, owner, clock), - m_in_a_handler(*this), - m_in_b_handler(*this), - m_in_ca1_handler(*this), - m_in_cb1_handler(*this), - m_in_ca2_handler(*this), - m_out_a_handler(*this), - m_out_b_handler(*this), - m_ts_b_handler(*this), - m_ca2_handler(*this), - m_cb2_handler(*this), - m_irqa_handler(*this), - m_irqb_handler(*this), m_in_a(0), - m_in_ca1(true), m_in_ca2(true), m_out_a(0), m_a_input_overrides_output_mask(0), m_out_ca2(0), m_ddr_a(0), - m_ctl_a(0), m_irq_a1(false), m_irq_a2(false), - m_irq_a_state(0), m_in_b(0), - m_in_cb1(0), m_in_cb2(0), m_out_b(0), m_out_cb2(0), m_last_out_cb2_z(0), m_ddr_b(0), - m_ctl_b(0), m_irq_b1(false), m_irq_b2(false), - m_irq_b_state(0), m_in_a_pushed(false), m_out_a_needs_pulled(false), m_in_ca1_pushed(false), - m_in_ca2_pushed(false), m_out_ca2_needs_pulled(false), m_in_b_pushed(false), m_out_b_needs_pulled(false), - m_in_cb1_pushed(false), m_in_cb2_pushed(false), m_out_cb2_needs_pulled(false), m_logged_port_a_not_connected(false), - m_logged_port_b_not_connected(false), m_logged_ca1_not_connected(false), m_logged_ca2_not_connected(false), - m_logged_cb1_not_connected(false), m_logged_cb2_not_connected(false) +pia6821_device::pia6821_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, PIA6821, tag, owner, clock), + m_in_a_handler(*this, 0), + m_in_b_handler(*this, 0), + m_in_ca1_handler(*this, 1), + m_in_cb1_handler(*this, 0), + m_in_ca2_handler(*this, 1), + m_out_a_handler(*this), + m_out_b_handler(*this), + m_ts_b_handler(*this, 0), + m_ca2_handler(*this), + m_cb2_handler(*this), + m_irqa_handler(*this), + m_irqb_handler(*this), m_in_a(0), + m_in_ca1(true), m_in_ca2(true), m_out_a(0), m_a_input_overrides_output_mask(0), m_out_ca2(0), m_ddr_a(0), + m_ctl_a(0), m_irq_a1(false), m_irq_a2(false), + m_irq_a_state(0), m_in_b(0), + m_in_cb1(0), m_in_cb2(0), m_out_b(0), m_out_cb2(0), m_last_out_cb2_z(0), m_ddr_b(0), + m_ctl_b(0), m_irq_b1(false), m_irq_b2(false), + m_irq_b_state(0), m_in_a_pushed(false), m_out_a_needs_pulled(false), m_in_ca1_pushed(false), + m_in_ca2_pushed(false), m_out_ca2_needs_pulled(false), m_in_b_pushed(false), m_out_b_needs_pulled(false), + m_in_cb1_pushed(false), m_in_cb2_pushed(false), m_out_cb2_needs_pulled(false), m_logged_port_a_not_connected(false), + m_logged_port_b_not_connected(false), m_logged_ca1_not_connected(false), m_logged_ca2_not_connected(false), + m_logged_cb1_not_connected(false), m_logged_cb2_not_connected(false) { } //------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void pia6821_device::device_resolve_objects() -{ - // resolve callbacks - m_in_a_handler.resolve(); - m_in_b_handler.resolve(); - m_in_ca1_handler.resolve(); - m_in_cb1_handler.resolve(); - m_in_ca2_handler.resolve(); - m_out_a_handler.resolve(); - m_out_b_handler.resolve(); - m_ts_b_handler.resolve(); - m_ca2_handler.resolve(); - m_cb2_handler.resolve(); - m_irqa_handler.resolve_safe(); - m_irqb_handler.resolve_safe(); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -185,13 +161,13 @@ void pia6821_device::device_reset() m_irqb_handler(CLEAR_LINE); // reset port A to internal pullups - if (!m_out_a_handler.isnull()) + if (!m_out_a_handler.isunset()) m_out_a_handler(0xff); - if (!m_ca2_handler.isnull()) + if (!m_ca2_handler.isunset()) m_ca2_handler(1); // reset port B to three-state outputs - if (!m_out_b_handler.isnull() && !m_ts_b_handler.isnull()) + if (!m_out_b_handler.isunset() && !m_ts_b_handler.isunset()) m_out_b_handler(offs_t(0), m_ts_b_handler(), 0); } @@ -232,7 +208,7 @@ uint8_t pia6821_device::get_in_a_value() uint8_t ret; // update the input - if (!m_in_a_handler.isnull()) + if (!m_in_a_handler.isunset()) { port_a_data = m_in_a_handler(0); } @@ -285,7 +261,7 @@ uint8_t pia6821_device::get_in_b_value() uint8_t port_b_data; // update the input - if (!m_in_b_handler.isnull()) + if (!m_in_b_handler.isunset()) { port_b_data = m_in_b_handler(0); } @@ -349,7 +325,7 @@ uint8_t pia6821_device::get_out_b_value() uint8_t ret = m_out_b & m_ddr_b; // input pins are high-impedance - send them as zeros for backwards compatibility - if (m_ddr_b != 0xff && !m_ts_b_handler.isnull()) + if (m_ddr_b != 0xff && !m_ts_b_handler.isunset()) ret |= m_ts_b_handler() & ~m_ddr_b; return ret; @@ -365,7 +341,7 @@ void pia6821_device::set_out_ca2(int data) m_out_ca2 = data; // send to output function - if (!m_ca2_handler.isnull()) + if (!m_ca2_handler.isunset()) { m_ca2_handler(m_out_ca2); } @@ -393,7 +369,7 @@ void pia6821_device::set_out_cb2(int data) m_last_out_cb2_z = z; // send to output function - if (!m_cb2_handler.isnull()) + if (!m_cb2_handler.isunset()) { m_cb2_handler(m_out_cb2); } @@ -511,21 +487,21 @@ uint8_t pia6821_device::control_a_r() if (!machine().side_effects_disabled()) { // update CA1 & CA2 if callback exists, these in turn may update IRQ's - if (!m_in_ca1_handler.isnull()) + if (!m_in_ca1_handler.isunset()) { ca1_w(m_in_ca1_handler()); } - else if(!m_logged_ca1_not_connected && (!m_in_ca1_pushed)) + else if (!m_logged_ca1_not_connected && (!m_in_ca1_pushed)) { logerror("Warning! No CA1 read handler. Assuming pin not connected\n"); m_logged_ca1_not_connected = true; } - if (!m_in_ca2_handler.isnull()) + if (!m_in_ca2_handler.isunset()) { ca2_w(m_in_ca2_handler()); } - else if ( !m_logged_ca2_not_connected && c2_input(m_ctl_a) && !m_in_ca2_pushed) + else if (!m_logged_ca2_not_connected && c2_input(m_ctl_a) && !m_in_ca2_pushed) { logerror("Warning! No CA2 read handler. Assuming pin not connected\n"); m_logged_ca2_not_connected = true; @@ -559,7 +535,7 @@ uint8_t pia6821_device::control_b_r() if (!machine().side_effects_disabled()) { // update CB1 & CB2 if callback exists, these in turn may update IRQ's - if(!m_in_cb1_handler.isnull()) + if(!m_in_cb1_handler.isunset()) { cb1_w(m_in_cb1_handler()); } @@ -636,7 +612,7 @@ void pia6821_device::send_to_out_a_func(const char* message) LOG("PIA %s = %02X DDRA=%02x\n", message, data, m_ddr_a); - if (!m_out_a_handler.isnull()) + if (!m_out_a_handler.isunset()) { m_out_a_handler(offs_t(0), data); } @@ -660,7 +636,7 @@ void pia6821_device::send_to_out_b_func(const char* message) LOG("PIA %s = %02X DDRB=%02x\n", message, data, m_ddr_b); - if (!m_out_b_handler.isnull()) + if (!m_out_b_handler.isunset()) { m_out_b_handler(offs_t(0), data, m_ddr_b); } @@ -786,7 +762,7 @@ void pia6821_device::control_a_w(uint8_t data) else if (ca2_was_output) { LOGSETUP(" - CA2 pulled up as input\n"); - if (!m_ca2_handler.isnull()) + if (!m_ca2_handler.isunset()) m_ca2_handler(1); } @@ -871,7 +847,7 @@ void pia6821_device::write(offs_t offset, uint8_t data) void pia6821_device::set_a_input(uint8_t data) { - if (!m_in_a_handler.isnull()) + if (!m_in_a_handler.isunset()) throw emu_fatalerror("pia6821_device::set_a_input() called when m_in_a_handler set"); LOG("Set PIA input port A = %02X\n", data); @@ -1005,7 +981,7 @@ bool pia6821_device::ca2_output_z() void pia6821_device::portb_w(uint8_t data) { - if (!m_in_b_handler.isnull()) + if (!m_in_b_handler.isunset()) throw emu_fatalerror("pia6821_device::portb_w() called when in_b_func implemented"); LOG("Set PIA input port B = %02X\n", data); |