diff options
-rw-r--r-- | src/emu/bus/vic20/user.c | 109 | ||||
-rw-r--r-- | src/emu/bus/vic20/user.h | 168 | ||||
-rw-r--r-- | src/emu/bus/vic20/vic1011.c | 92 | ||||
-rw-r--r-- | src/emu/bus/vic20/vic1011.h | 14 | ||||
-rw-r--r-- | src/mess/drivers/vic20.c | 106 | ||||
-rw-r--r-- | src/mess/includes/vic20.h | 19 |
6 files changed, 305 insertions, 203 deletions
diff --git a/src/emu/bus/vic20/user.c b/src/emu/bus/vic20/user.c index 4bff531c08c..e0716a53b84 100644 --- a/src/emu/bus/vic20/user.c +++ b/src/emu/bus/vic20/user.c @@ -55,38 +55,29 @@ device_vic20_user_port_interface::~device_vic20_user_port_interface() //------------------------------------------------- vic20_user_port_device::vic20_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, VIC20_USER_PORT, "VIC-20 user port", tag, owner, clock, "vic20_user_port", __FILE__), - device_slot_interface(mconfig, *this) + device_t(mconfig, VIC20_USER_PORT, "VIC-20 user port", tag, owner, clock, "vic20_user_port", __FILE__), + device_slot_interface(mconfig, *this), + m_3_handler(*this), + m_4_handler(*this), + m_5_handler(*this), + m_6_handler(*this), + m_7_handler(*this), + m_8_handler(*this), + m_b_handler(*this), + m_c_handler(*this), + m_d_handler(*this), + m_e_handler(*this), + m_f_handler(*this), + m_h_handler(*this), + m_j_handler(*this), + m_k_handler(*this), + m_l_handler(*this), + m_m_handler(*this) { } //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void vic20_user_port_device::device_config_complete() -{ - // inherit a copy of the static data - const vic20_user_port_interface *intf = reinterpret_cast<const vic20_user_port_interface *>(static_config()); - if (intf != NULL) - { - *static_cast<vic20_user_port_interface *>(this) = *intf; - } - - // or initialize to defaults if none provided - else - { - memset(&m_out_cb1_cb, 0, sizeof(m_out_cb1_cb)); - memset(&m_out_cb2_cb, 0, sizeof(m_out_cb2_cb)); - memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb)); - } -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -95,10 +86,40 @@ void vic20_user_port_device::device_start() m_card = dynamic_cast<device_vic20_user_port_interface *>(get_card_device()); // resolve callbacks - m_out_light_pen_func.resolve(m_out_light_pen_cb, *this); - m_out_cb1_func.resolve(m_out_cb1_cb, *this); - m_out_cb2_func.resolve(m_out_cb2_cb, *this); - m_out_reset_func.resolve(m_out_reset_cb, *this); + m_3_handler.resolve_safe(); + m_4_handler.resolve_safe(); + m_5_handler.resolve_safe(); + m_6_handler.resolve_safe(); + m_7_handler.resolve_safe(); + m_8_handler.resolve_safe(); + m_b_handler.resolve_safe(); + m_c_handler.resolve_safe(); + m_d_handler.resolve_safe(); + m_e_handler.resolve_safe(); + m_f_handler.resolve_safe(); + m_h_handler.resolve_safe(); + m_j_handler.resolve_safe(); + m_k_handler.resolve_safe(); + m_l_handler.resolve_safe(); + m_m_handler.resolve_safe(); + + // pull up + m_3_handler(1); + m_4_handler(1); + m_5_handler(1); + m_6_handler(1); + m_7_handler(1); + m_8_handler(1); + m_b_handler(1); + m_c_handler(1); + m_d_handler(1); + m_e_handler(1); + m_f_handler(1); + m_h_handler(1); + m_j_handler(1); + m_k_handler(1); + m_l_handler(1); + m_m_handler(1); } @@ -115,22 +136,28 @@ void vic20_user_port_device::device_reset() } -READ8_MEMBER( vic20_user_port_device::pb_r ) { UINT8 data = 0xff; if (m_card != NULL) data = m_card->vic20_pb_r(space, offset); return data; } -WRITE8_MEMBER( vic20_user_port_device::pb_w ) { if (m_card != NULL) m_card->vic20_pb_w(space, offset, data); } -READ_LINE_MEMBER( vic20_user_port_device::joy0_r ) { int state = 1; if (m_card != NULL) state = m_card->vic20_joy0_r(); return state; } -READ_LINE_MEMBER( vic20_user_port_device::joy1_r ) { int state = 1; if (m_card != NULL) state = m_card->vic20_joy1_r(); return state; } -READ_LINE_MEMBER( vic20_user_port_device::joy2_r ) { int state = 1; if (m_card != NULL) state = m_card->vic20_joy2_r(); return state; } -READ_LINE_MEMBER( vic20_user_port_device::light_pen_r ) { int state = 1; if (m_card != NULL) state = m_card->vic20_light_pen_r(); return state; } -READ_LINE_MEMBER( vic20_user_port_device::cassette_switch_r ) { int state = 1; if (m_card != NULL) state = m_card->vic20_cassette_switch_r(); return state; } -WRITE_LINE_MEMBER( vic20_user_port_device::cb1_w ) { if (m_card != NULL) m_card->vic20_cb1_w(state); } -WRITE_LINE_MEMBER( vic20_user_port_device::cb2_w ) { if (m_card != NULL) m_card->vic20_cb2_w(state); } -WRITE_LINE_MEMBER( vic20_user_port_device::atn_w ) { if (m_card != NULL) m_card->vic20_atn_w(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_7 ) { if (m_card != NULL) m_card->write_7(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_9 ) { if (m_card != NULL) m_card->write_9(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_b ) { if (m_card != NULL) m_card->write_b(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_c ) { if (m_card != NULL) m_card->write_c(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_d ) { if (m_card != NULL) m_card->write_d(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_e ) { if (m_card != NULL) m_card->write_e(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_f ) { if (m_card != NULL) m_card->write_f(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_h ) { if (m_card != NULL) m_card->write_h(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_j ) { if (m_card != NULL) m_card->write_j(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_k ) { if (m_card != NULL) m_card->write_k(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_l ) { if (m_card != NULL) m_card->write_l(state); } +WRITE_LINE_MEMBER( vic20_user_port_device::write_m ) { if (m_card != NULL) m_card->write_m(state); } + //------------------------------------------------- // SLOT_INTERFACE( vic20_user_port_cards ) //------------------------------------------------- +// slot devices +#include "vic1011.h" + SLOT_INTERFACE_START( vic20_user_port_cards ) SLOT_INTERFACE("rs232", VIC1011) SLOT_INTERFACE_END diff --git a/src/emu/bus/vic20/user.h b/src/emu/bus/vic20/user.h index 501b1511282..f36b73c5dc6 100644 --- a/src/emu/bus/vic20/user.h +++ b/src/emu/bus/vic20/user.h @@ -45,74 +45,128 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define VIC20_USER_PORT_INTERFACE(_name) \ - const vic20_user_port_interface (_name) = - - -#define MCFG_VIC20_USER_PORT_ADD(_tag, _config, _slot_intf, _def_slot) \ +#define MCFG_VIC20_USER_PORT_ADD(_tag, _slot_intf, _def_slot) \ MCFG_DEVICE_ADD(_tag, VIC20_USER_PORT, 0) \ - MCFG_DEVICE_CONFIG(_config) \ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) +#define MCFG_VIC20_USER_PORT_3_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_3_handler(*device, DEVCB2_##_devcb); +#define MCFG_VIC20_USER_PORT_4_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_4_handler(*device, DEVCB2_##_devcb); -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** +#define MCFG_VIC20_USER_PORT_5_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_5_handler(*device, DEVCB2_##_devcb); -// ======================> vic20_user_port_interface +#define MCFG_VIC20_USER_PORT_6_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_6_handler(*device, DEVCB2_##_devcb); -struct vic20_user_port_interface -{ - devcb_write_line m_out_light_pen_cb; - devcb_write_line m_out_cb1_cb; - devcb_write_line m_out_cb2_cb; - devcb_write_line m_out_reset_cb; -}; +#define MCFG_VIC20_USER_PORT_7_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_7_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_8_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_8_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_B_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_b_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_C_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_c_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_D_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_d_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_E_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_e_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_F_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_f_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_H_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_h_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_J_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_j_handler(*device, DEVCB2_##_devcb); +#define MCFG_VIC20_USER_PORT_K_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_k_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_L_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_l_handler(*device, DEVCB2_##_devcb); + +#define MCFG_VIC20_USER_PORT_M_HANDLER(_devcb) \ + devcb = &vic20_user_port_device::set_m_handler(*device, DEVCB2_##_devcb); + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** // ======================> vic20_user_port_device class device_vic20_user_port_interface; class vic20_user_port_device : public device_t, - public vic20_user_port_interface, - public device_slot_interface + public device_slot_interface { public: // construction/destruction vic20_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + template<class _Object> static devcb2_base &set_3_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_3_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_4_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_4_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_5_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_5_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_6_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_6_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_7_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_7_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_8_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_8_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_b_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_b_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_c_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_c_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_d_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_d_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_e_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_e_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_f_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_f_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_h_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_h_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_j_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_j_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_k_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_k_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_l_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_l_handler.set_callback(object); } + template<class _Object> static devcb2_base &set_m_handler(device_t &device, _Object object) { return downcast<vic20_user_port_device &>(device).m_m_handler.set_callback(object); } + // computer interface - DECLARE_READ8_MEMBER( pb_r ); - DECLARE_WRITE8_MEMBER( pb_w ); - DECLARE_READ_LINE_MEMBER( joy0_r ); - DECLARE_READ_LINE_MEMBER( joy1_r ); - DECLARE_READ_LINE_MEMBER( joy2_r ); - DECLARE_READ_LINE_MEMBER( light_pen_r ); - DECLARE_READ_LINE_MEMBER( cassette_switch_r ); - DECLARE_WRITE_LINE_MEMBER( cb1_w ); - DECLARE_WRITE_LINE_MEMBER( cb2_w ); - DECLARE_WRITE_LINE_MEMBER( atn_w ); - DECLARE_WRITE_LINE_MEMBER( port_reset_w ); - - // cartridge interface - DECLARE_WRITE_LINE_MEMBER( light_pen_w ) { m_out_light_pen_func(state); } - DECLARE_WRITE_LINE_MEMBER( via_cb1_w ) { m_out_cb1_func(state); } - DECLARE_WRITE_LINE_MEMBER( via_cb2_w ) { m_out_cb2_func(state); } - DECLARE_WRITE_LINE_MEMBER( reset_w ) { m_out_reset_func(state); } + DECLARE_WRITE_LINE_MEMBER( write_7 ); + DECLARE_WRITE_LINE_MEMBER( write_9 ); + DECLARE_WRITE_LINE_MEMBER( write_b ); + DECLARE_WRITE_LINE_MEMBER( write_c ); + DECLARE_WRITE_LINE_MEMBER( write_d ); + DECLARE_WRITE_LINE_MEMBER( write_e ); + DECLARE_WRITE_LINE_MEMBER( write_f ); + DECLARE_WRITE_LINE_MEMBER( write_h ); + DECLARE_WRITE_LINE_MEMBER( write_j ); + DECLARE_WRITE_LINE_MEMBER( write_k ); + DECLARE_WRITE_LINE_MEMBER( write_l ); + DECLARE_WRITE_LINE_MEMBER( write_m ); + + // device interface + devcb2_write_line m_3_handler; + devcb2_write_line m_4_handler; + devcb2_write_line m_5_handler; + devcb2_write_line m_6_handler; + devcb2_write_line m_7_handler; + devcb2_write_line m_8_handler; + devcb2_write_line m_b_handler; + devcb2_write_line m_c_handler; + devcb2_write_line m_d_handler; + devcb2_write_line m_e_handler; + devcb2_write_line m_f_handler; + devcb2_write_line m_h_handler; + devcb2_write_line m_j_handler; + devcb2_write_line m_k_handler; + devcb2_write_line m_l_handler; + devcb2_write_line m_m_handler; protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); - devcb_resolved_write_line m_out_light_pen_func; - devcb_resolved_write_line m_out_cb1_func; - devcb_resolved_write_line m_out_cb2_func; - devcb_resolved_write_line m_out_reset_func; - device_vic20_user_port_interface *m_card; }; @@ -123,21 +177,21 @@ protected: class device_vic20_user_port_interface : public device_slot_card_interface { public: - // construction/destruction device_vic20_user_port_interface(const machine_config &mconfig, device_t &device); virtual ~device_vic20_user_port_interface(); - virtual UINT8 vic20_pb_r(address_space &space, offs_t offset) { return 0xff; }; - virtual void vic20_pb_w(address_space &space, offs_t offset, UINT8 data) { }; - - virtual int vic20_joy0_r() { return 1; }; - virtual int vic20_joy1_r() { return 1; }; - virtual int vic20_joy2_r() { return 1; }; - virtual int vic20_light_pen_r() { return 1; }; - virtual int vic20_cassette_switch_r() { return 1; }; - virtual void vic20_cb1_w(int state) { }; - virtual void vic20_cb2_w(int state) { }; - virtual void vic20_atn_w(int state) { }; + DECLARE_WRITE_LINE_MEMBER( write_7 ) {}; + DECLARE_WRITE_LINE_MEMBER( write_9 ) {}; + DECLARE_WRITE_LINE_MEMBER( write_b ) {}; + DECLARE_WRITE_LINE_MEMBER( write_c ) {}; + DECLARE_WRITE_LINE_MEMBER( write_d ) {}; + DECLARE_WRITE_LINE_MEMBER( write_e ) {}; + DECLARE_WRITE_LINE_MEMBER( write_f ) {}; + DECLARE_WRITE_LINE_MEMBER( write_h ) {}; + DECLARE_WRITE_LINE_MEMBER( write_j ) {}; + DECLARE_WRITE_LINE_MEMBER( write_k ) {}; + DECLARE_WRITE_LINE_MEMBER( write_l ) {}; + DECLARE_WRITE_LINE_MEMBER( write_m ) {}; protected: vic20_user_port_device *m_slot; @@ -147,12 +201,6 @@ protected: // device type definition extern const device_type VIC20_USER_PORT; - -// slot devices -#include "vic1011.h" - SLOT_INTERFACE_EXTERN( vic20_user_port_cards ); - - #endif diff --git a/src/emu/bus/vic20/vic1011.c b/src/emu/bus/vic20/vic1011.c index 81ea93cb8e2..e575443821a 100644 --- a/src/emu/bus/vic20/vic1011.c +++ b/src/emu/bus/vic20/vic1011.c @@ -34,7 +34,10 @@ const device_type VIC1011 = &device_creator<vic1011_device>; static MACHINE_CONFIG_FRAGMENT( vic1011 ) MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL) - MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, rxd_w)) + MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, write_rxd)) + MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, write_dcdin)) + MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, write_cts)) + MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, write_dsr)) MACHINE_CONFIG_END @@ -74,80 +77,43 @@ void vic1011_device::device_start() { } - -//------------------------------------------------- -// vic20_pb_r - port B read -//------------------------------------------------- - -UINT8 vic1011_device::vic20_pb_r(address_space &space, offs_t offset) +WRITE_LINE_MEMBER( vic1011_device::write_rxd ) { - /* - - bit description - - 0 Sin - 1 - 2 - 3 - 4 DCDin - 5 - 6 CTS - 7 DSR - - */ - - UINT8 data = 0; - - data |= !m_rs232->rx(); - data |= m_rs232->dcd_r() << 4; - data |= m_rs232->cts_r() << 6; - data |= m_rs232->dsr_r() << 7; - - return data; + m_slot->m_b_handler(!state); + m_slot->m_c_handler(!state); } - -//------------------------------------------------- -// vic20_pb_w - port B write -//------------------------------------------------- - -void vic1011_device::vic20_pb_w(address_space &space, offs_t offset, UINT8 data) +void vic1011_device::write_d(int state) { - /* - - bit description - - 0 - 1 RTS - 2 DTR - 3 - 4 - 5 DCDout - 6 - 7 - - */ - - m_rs232->rts_w(BIT(data, 1)); - m_rs232->dtr_w(BIT(data, 2)); + m_rs232->rts_w(state); } +void vic1011_device::write_e(int state) +{ + m_rs232->dtr_w(state); +} -//------------------------------------------------- -// vic20_cb2_w - CB2 write -//------------------------------------------------- +WRITE_LINE_MEMBER( vic1011_device::write_dcdin ) +{ + m_slot->m_h_handler(state); +} -void vic1011_device::vic20_cb2_w(int state) +void vic1011_device::write_j(int state) { - m_rs232->tx(!state); + /// dcdout } +WRITE_LINE_MEMBER( vic1011_device::write_cts ) +{ + m_slot->m_k_handler(state); +} -//------------------------------------------------- -// rxd_w - -//------------------------------------------------- +WRITE_LINE_MEMBER( vic1011_device::write_dsr ) +{ + m_slot->m_l_handler(state); +} -WRITE_LINE_MEMBER( vic1011_device::rxd_w ) +void vic1011_device::write_m(int state) { - m_slot->via_cb1_w(!state); + m_rs232->tx(!state); } diff --git a/src/emu/bus/vic20/vic1011.h b/src/emu/bus/vic20/vic1011.h index ed034a33900..3591381106f 100644 --- a/src/emu/bus/vic20/vic1011.h +++ b/src/emu/bus/vic20/vic1011.h @@ -36,17 +36,19 @@ public: // optional information overrides virtual machine_config_constructor device_mconfig_additions() const; - DECLARE_WRITE_LINE_MEMBER( rxd_w ); + DECLARE_WRITE_LINE_MEMBER( write_rxd ); + DECLARE_WRITE_LINE_MEMBER( write_d ); + DECLARE_WRITE_LINE_MEMBER( write_e ); + DECLARE_WRITE_LINE_MEMBER( write_dcdin ); + DECLARE_WRITE_LINE_MEMBER( write_j ); + DECLARE_WRITE_LINE_MEMBER( write_cts ); + DECLARE_WRITE_LINE_MEMBER( write_dsr ); + DECLARE_WRITE_LINE_MEMBER( write_m ); protected: // device-level overrides virtual void device_start(); - // device_vic20_user_port_interface overrides - virtual UINT8 vic20_pb_r(address_space &space, offs_t offset); - virtual void vic20_pb_w(address_space &space, offs_t offset, UINT8 data); - virtual void vic20_cb2_w(int state); - private: required_device<rs232_port_device> m_rs232; }; diff --git a/src/mess/drivers/vic20.c b/src/mess/drivers/vic20.c index 888a83a067e..96024fecd8e 100644 --- a/src/mess/drivers/vic20.c +++ b/src/mess/drivers/vic20.c @@ -411,15 +411,15 @@ READ8_MEMBER( vic20_state::via1_pa_r ) data |= m_iec->data_r() << 1; // joystick / user port - UINT8 joy = m_joy1->joy_r(); + UINT8 joy = m_joy->joy_r(); - data |= (m_user->joy0_r() && BIT(joy, 0)) << 2; - data |= (m_user->joy1_r() && BIT(joy, 1)) << 3; - data |= (m_user->joy2_r() && BIT(joy, 2)) << 4; - data |= (m_user->light_pen_r() && BIT(joy, 5)) << 5; + data |= (m_user_joy0 && BIT(joy, 0)) << 2; + data |= (m_user_joy1 && BIT(joy, 1)) << 3; + data |= (m_user_joy2 && BIT(joy, 2)) << 4; + data |= (m_user_light_pen && BIT(joy, 5)) << 5; // cassette switch - data |= (m_user->cassette_switch_r() && m_cassette->sense_r()) << 6; + data |= (m_user_cassette_switch && m_cassette->sense_r()) << 6; return data; } @@ -442,12 +442,25 @@ WRITE8_MEMBER( vic20_state::via1_pa_w ) */ // light pen strobe + m_user->write_7(BIT(data, 5)); m_vic->lp_w(BIT(data, 5)); // serial attention out + m_user->write_9(!BIT(data, 7)); m_iec->atn_w(!BIT(data, 7)); } +WRITE8_MEMBER( vic20_state::via1_pb_w ) +{ + m_user->write_c((data>>0)&1); + m_user->write_d((data>>1)&1); + m_user->write_e((data>>2)&1); + m_user->write_f((data>>3)&1); + m_user->write_h((data>>4)&1); + m_user->write_j((data>>5)&1); + m_user->write_k((data>>6)&1); + m_user->write_l((data>>7)&1); +} READ8_MEMBER( vic20_state::via2_pa_r ) { @@ -500,7 +513,7 @@ READ8_MEMBER( vic20_state::via2_pb_r ) UINT8 data = 0xff; // joystick - UINT8 joy = m_joy1->joy_r(); + UINT8 joy = m_joy->joy_r(); data &= BIT(joy, 3) << 7; @@ -557,20 +570,6 @@ WRITE_LINE_MEMBER( vic20_state::exp_reset_w ) } -//------------------------------------------------- -// VIC20_USER_PORT_INTERFACE( user_intf ) -//------------------------------------------------- - -static VIC20_USER_PORT_INTERFACE( user_intf ) -{ - DEVCB_DEVICE_LINE_MEMBER(M6560_TAG, mos6560_device, lp_w), - DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_cb1), - DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_cb2), - DEVCB_DRIVER_LINE_MEMBER(vic20_state, exp_reset_w) -}; - - - //************************************************************************** // MACHINE INITIALIZATION //************************************************************************** @@ -608,7 +607,37 @@ void vic20_state::machine_reset() m_user->reset(); } +WRITE_LINE_MEMBER(vic20_state::write_user_joy0) +{ + m_user_joy0 = state; +} + +WRITE_LINE_MEMBER(vic20_state::write_user_joy1) +{ + m_user_joy1 = state; +} + +WRITE_LINE_MEMBER(vic20_state::write_user_joy2) +{ + m_user_joy2 = state; +} + +WRITE_LINE_MEMBER(vic20_state::write_light_pen) +{ + m_light_pen = state; + m_vic->lp_w(m_light_pen && m_user_light_pen); +} +WRITE_LINE_MEMBER(vic20_state::write_user_light_pen) +{ + m_user_light_pen = state; + m_vic->lp_w(m_light_pen && m_user_light_pen); +} + +WRITE_LINE_MEMBER(vic20_state::write_user_cassette_switch) +{ + m_user_cassette_switch = state; +} //************************************************************************** // MACHINE DRIVERS @@ -621,13 +650,11 @@ void vic20_state::machine_reset() static MACHINE_CONFIG_START( vic20, vic20_state ) // devices MCFG_DEVICE_ADD(M6522_1_TAG, VIA6522, 0) - MCFG_VIA6522_READPA_HANDLER(READ8(vic20_state, via1_pa_r)) - MCFG_VIA6522_READPB_HANDLER(DEVREAD8(VIC20_USER_PORT_TAG, vic20_user_port_device, pb_r)) MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(vic20_state, via1_pa_w)) - MCFG_VIA6522_WRITEPB_HANDLER(DEVWRITE8(VIC20_USER_PORT_TAG, vic20_user_port_device, pb_w)) - MCFG_VIA6522_CB1_HANDLER(DEVWRITELINE(VIC20_USER_PORT_TAG, vic20_user_port_device, cb1_w)) + MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(vic20_state, via1_pb_w)) + MCFG_VIA6522_CB1_HANDLER(DEVWRITELINE(VIC20_USER_PORT_TAG, vic20_user_port_device, write_b)) MCFG_VIA6522_CA2_HANDLER(DEVWRITELINE(PET_DATASSETTE_PORT_TAG, pet_datassette_port_device, motor_w)) - MCFG_VIA6522_CB2_HANDLER(DEVWRITELINE(VIC20_USER_PORT_TAG, vic20_user_port_device, cb2_w)) + MCFG_VIA6522_CB2_HANDLER(DEVWRITELINE(VIC20_USER_PORT_TAG, vic20_user_port_device, write_m)) MCFG_VIA6522_IRQ_HANDLER(DEVWRITELINE(M6502_TAG, m6502_device, nmi_line)) MCFG_DEVICE_ADD(M6522_2_TAG, VIA6522, 0) @@ -641,7 +668,28 @@ static MACHINE_CONFIG_START( vic20, vic20_state ) MCFG_PET_DATASSETTE_PORT_ADD(PET_DATASSETTE_PORT_TAG, cbm_datassette_devices, "c1530", DEVWRITELINE(M6522_2_TAG, via6522_device, write_ca1)) MCFG_CBM_IEC_ADD("c1541") MCFG_CBM_IEC_BUS_SRQ_CALLBACK(DEVWRITELINE(M6522_2_TAG, via6522_device, write_cb1)) - MCFG_VIC20_USER_PORT_ADD(VIC20_USER_PORT_TAG, user_intf, vic20_user_port_cards, NULL) + + MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy") + MCFG_VCS_CONTROL_PORT_TRIGGER_HANDLER(WRITELINE(vic20_state, write_light_pen)) + + MCFG_VIC20_USER_PORT_ADD(VIC20_USER_PORT_TAG, vic20_user_port_cards, NULL) + MCFG_VIC20_USER_PORT_3_HANDLER(WRITELINE(vic20_state, exp_reset_w)) + MCFG_VIC20_USER_PORT_4_HANDLER(WRITELINE(vic20_state, write_user_joy0)) + MCFG_VIC20_USER_PORT_5_HANDLER(WRITELINE(vic20_state, write_user_joy1)) + MCFG_VIC20_USER_PORT_6_HANDLER(WRITELINE(vic20_state, write_user_joy2)) + MCFG_VIC20_USER_PORT_7_HANDLER(WRITELINE(vic20_state, write_user_light_pen)) + MCFG_VIC20_USER_PORT_8_HANDLER(WRITELINE(vic20_state, write_user_cassette_switch)) + MCFG_VIC20_USER_PORT_B_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_cb1)) + MCFG_VIC20_USER_PORT_C_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb0)) + MCFG_VIC20_USER_PORT_D_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb1)) + MCFG_VIC20_USER_PORT_E_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb2)) + MCFG_VIC20_USER_PORT_F_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb3)) + MCFG_VIC20_USER_PORT_H_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb4)) + MCFG_VIC20_USER_PORT_J_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb5)) + MCFG_VIC20_USER_PORT_K_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb6)) + MCFG_VIC20_USER_PORT_L_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb7)) + MCFG_VIC20_USER_PORT_M_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_cb2)) + MCFG_QUICKLOAD_ADD("quickload", vic20_state, cbm_vc20, "p00,prg", CBM_QUICKLOAD_DELAY_SECONDS) // software lists @@ -672,8 +720,6 @@ static MACHINE_CONFIG_DERIVED( ntsc, vic20 ) // devices MCFG_VIC20_EXPANSION_SLOT_ADD(VIC20_EXPANSION_SLOT_TAG, MOS6560_CLOCK, vic20_expansion_cards, NULL) MCFG_VIC20_EXPANSION_SLOT_IRQ_CALLBACKS(INPUTLINE(M6502_TAG, M6502_IRQ_LINE), INPUTLINE(M6502_TAG, M6502_NMI_LINE), WRITELINE(vic20_state, exp_reset_w)) - MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy") - MCFG_VCS_CONTROL_PORT_TRIGGER_HANDLER(DEVWRITELINE(M6560_TAG, mos6560_device, lp_w)) // software lists MCFG_SOFTWARE_LIST_FILTER("cart_list", "NTSC") @@ -699,8 +745,6 @@ static MACHINE_CONFIG_DERIVED( pal, vic20 ) // devices MCFG_VIC20_EXPANSION_SLOT_ADD(VIC20_EXPANSION_SLOT_TAG, MOS6561_CLOCK, vic20_expansion_cards, NULL) MCFG_VIC20_EXPANSION_SLOT_IRQ_CALLBACKS(INPUTLINE(M6502_TAG, M6502_IRQ_LINE), INPUTLINE(M6502_TAG, M6502_NMI_LINE), WRITELINE(vic20_state, exp_reset_w)) - MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy") - MCFG_VCS_CONTROL_PORT_TRIGGER_HANDLER(DEVWRITELINE(M6561_TAG, mos6561_device, lp_w)) // software lists MCFG_SOFTWARE_LIST_FILTER("cart_list", "PAL") diff --git a/src/mess/includes/vic20.h b/src/mess/includes/vic20.h index 11adf40fd1d..21f730c7fd4 100644 --- a/src/mess/includes/vic20.h +++ b/src/mess/includes/vic20.h @@ -38,7 +38,7 @@ public: m_via2(*this, M6522_2_TAG), m_vic(*this, M6560_TAG), m_iec(*this, CBM_IEC_TAG), - m_joy1(*this, CONTROL1_TAG), + m_joy(*this, CONTROL1_TAG), m_exp(*this, VIC20_EXPANSION_SLOT_TAG), m_user(*this, VIC20_USER_PORT_TAG), m_cassette(*this, PET_DATASSETTE_PORT_TAG), @@ -64,7 +64,7 @@ public: required_device<via6522_device> m_via2; required_device<mos6560_device> m_vic; required_device<cbm_iec_device> m_iec; - required_device<vcs_control_port_device> m_joy1; + required_device<vcs_control_port_device> m_joy; required_device<vic20_expansion_slot_device> m_exp; required_device<vic20_user_port_device> m_user; required_device<pet_datassette_port_device> m_cassette; @@ -95,8 +95,16 @@ public: DECLARE_READ8_MEMBER( vic_lighty_cb ); DECLARE_READ8_MEMBER( vic_lightbut_cb ); + DECLARE_WRITE_LINE_MEMBER( write_light_pen ); + DECLARE_WRITE_LINE_MEMBER( write_user_joy0 ); + DECLARE_WRITE_LINE_MEMBER( write_user_joy1 ); + DECLARE_WRITE_LINE_MEMBER( write_user_joy2 ); + DECLARE_WRITE_LINE_MEMBER( write_user_light_pen ); + DECLARE_WRITE_LINE_MEMBER( write_user_cassette_switch ); + DECLARE_READ8_MEMBER( via1_pa_r ); DECLARE_WRITE8_MEMBER( via1_pa_w ); + DECLARE_WRITE8_MEMBER( via1_pb_w ); DECLARE_READ8_MEMBER( via2_pa_r ); DECLARE_READ8_MEMBER( via2_pb_r ); @@ -143,6 +151,13 @@ public: IO2 = 6, IO3 = 7 }; + + int m_light_pen; + int m_user_joy0; + int m_user_joy1; + int m_user_joy2; + int m_user_light_pen; + int m_user_cassette_switch; }; #endif |