Previous 199869 Revisions Next

r26899 Thursday 2nd January, 2014 at 22:03:04 UTC by smf
Modernised VIC20 user port [smf]
[src/emu/bus/vic20]user.c user.h vic1011.c vic1011.h
[src/mess/drivers]vic20.c
[src/mess/includes]vic20.h

trunk/src/mess/drivers/vic20.c
r26898r26899
411411   data |= m_iec->data_r() << 1;
412412
413413   // joystick / user port
414   UINT8 joy = m_joy1->joy_r();
414   UINT8 joy = m_joy->joy_r();
415415
416   data |= (m_user->joy0_r() && BIT(joy, 0)) << 2;
417   data |= (m_user->joy1_r() && BIT(joy, 1)) << 3;
418   data |= (m_user->joy2_r() && BIT(joy, 2)) << 4;
419   data |= (m_user->light_pen_r() && BIT(joy, 5)) << 5;
416   data |= (m_user_joy0 && BIT(joy, 0)) << 2;
417   data |= (m_user_joy1 && BIT(joy, 1)) << 3;
418   data |= (m_user_joy2 && BIT(joy, 2)) << 4;
419   data |= (m_user_light_pen && BIT(joy, 5)) << 5;
420420
421421   // cassette switch
422   data |= (m_user->cassette_switch_r() && m_cassette->sense_r()) << 6;
422   data |= (m_user_cassette_switch && m_cassette->sense_r()) << 6;
423423
424424   return data;
425425}
r26898r26899
442442   */
443443
444444   // light pen strobe
445   m_user->write_7(BIT(data, 5));
445446   m_vic->lp_w(BIT(data, 5));
446447
447448   // serial attention out
449   m_user->write_9(!BIT(data, 7));
448450   m_iec->atn_w(!BIT(data, 7));
449451}
450452
453WRITE8_MEMBER( vic20_state::via1_pb_w )
454{
455   m_user->write_c((data>>0)&1);
456   m_user->write_d((data>>1)&1);
457   m_user->write_e((data>>2)&1);
458   m_user->write_f((data>>3)&1);
459   m_user->write_h((data>>4)&1);
460   m_user->write_j((data>>5)&1);
461   m_user->write_k((data>>6)&1);
462   m_user->write_l((data>>7)&1);
463}
451464
452465READ8_MEMBER( vic20_state::via2_pa_r )
453466{
r26898r26899
500513   UINT8 data = 0xff;
501514
502515   // joystick
503   UINT8 joy = m_joy1->joy_r();
516   UINT8 joy = m_joy->joy_r();
504517
505518   data &= BIT(joy, 3) << 7;
506519
r26898r26899
557570}
558571
559572
560//-------------------------------------------------
561//  VIC20_USER_PORT_INTERFACE( user_intf )
562//-------------------------------------------------
563
564static VIC20_USER_PORT_INTERFACE( user_intf )
565{
566   DEVCB_DEVICE_LINE_MEMBER(M6560_TAG, mos6560_device, lp_w),
567   DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_cb1),
568   DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_cb2),
569   DEVCB_DRIVER_LINE_MEMBER(vic20_state, exp_reset_w)
570};
571
572
573
574573//**************************************************************************
575574//  MACHINE INITIALIZATION
576575//**************************************************************************
r26898r26899
608607   m_user->reset();
609608}
610609
610WRITE_LINE_MEMBER(vic20_state::write_user_joy0)
611{
612   m_user_joy0 = state;
613}
611614
615WRITE_LINE_MEMBER(vic20_state::write_user_joy1)
616{
617   m_user_joy1 = state;
618}
612619
620WRITE_LINE_MEMBER(vic20_state::write_user_joy2)
621{
622   m_user_joy2 = state;
623}
624
625WRITE_LINE_MEMBER(vic20_state::write_light_pen)
626{
627   m_light_pen = state;
628   m_vic->lp_w(m_light_pen && m_user_light_pen);
629}
630
631WRITE_LINE_MEMBER(vic20_state::write_user_light_pen)
632{
633   m_user_light_pen = state;
634   m_vic->lp_w(m_light_pen && m_user_light_pen);
635}
636
637WRITE_LINE_MEMBER(vic20_state::write_user_cassette_switch)
638{
639   m_user_cassette_switch = state;
640}
641
613642//**************************************************************************
614643//  MACHINE DRIVERS
615644//**************************************************************************
r26898r26899
621650static MACHINE_CONFIG_START( vic20, vic20_state )
622651   // devices
623652   MCFG_DEVICE_ADD(M6522_1_TAG, VIA6522, 0)
624   MCFG_VIA6522_READPA_HANDLER(READ8(vic20_state, via1_pa_r))
625   MCFG_VIA6522_READPB_HANDLER(DEVREAD8(VIC20_USER_PORT_TAG, vic20_user_port_device, pb_r))
626653   MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(vic20_state, via1_pa_w))
627   MCFG_VIA6522_WRITEPB_HANDLER(DEVWRITE8(VIC20_USER_PORT_TAG, vic20_user_port_device, pb_w))
628   MCFG_VIA6522_CB1_HANDLER(DEVWRITELINE(VIC20_USER_PORT_TAG, vic20_user_port_device, cb1_w))
654   MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(vic20_state, via1_pb_w))
655   MCFG_VIA6522_CB1_HANDLER(DEVWRITELINE(VIC20_USER_PORT_TAG, vic20_user_port_device, write_b))
629656   MCFG_VIA6522_CA2_HANDLER(DEVWRITELINE(PET_DATASSETTE_PORT_TAG, pet_datassette_port_device, motor_w))
630   MCFG_VIA6522_CB2_HANDLER(DEVWRITELINE(VIC20_USER_PORT_TAG, vic20_user_port_device, cb2_w))
657   MCFG_VIA6522_CB2_HANDLER(DEVWRITELINE(VIC20_USER_PORT_TAG, vic20_user_port_device, write_m))
631658   MCFG_VIA6522_IRQ_HANDLER(DEVWRITELINE(M6502_TAG, m6502_device, nmi_line))
632659
633660   MCFG_DEVICE_ADD(M6522_2_TAG, VIA6522, 0)
r26898r26899
641668   MCFG_PET_DATASSETTE_PORT_ADD(PET_DATASSETTE_PORT_TAG, cbm_datassette_devices, "c1530", DEVWRITELINE(M6522_2_TAG, via6522_device, write_ca1))
642669   MCFG_CBM_IEC_ADD("c1541")
643670   MCFG_CBM_IEC_BUS_SRQ_CALLBACK(DEVWRITELINE(M6522_2_TAG, via6522_device, write_cb1))
644   MCFG_VIC20_USER_PORT_ADD(VIC20_USER_PORT_TAG, user_intf, vic20_user_port_cards, NULL)
671
672   MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy")
673   MCFG_VCS_CONTROL_PORT_TRIGGER_HANDLER(WRITELINE(vic20_state, write_light_pen))
674
675   MCFG_VIC20_USER_PORT_ADD(VIC20_USER_PORT_TAG, vic20_user_port_cards, NULL)
676   MCFG_VIC20_USER_PORT_3_HANDLER(WRITELINE(vic20_state, exp_reset_w))
677   MCFG_VIC20_USER_PORT_4_HANDLER(WRITELINE(vic20_state, write_user_joy0))
678   MCFG_VIC20_USER_PORT_5_HANDLER(WRITELINE(vic20_state, write_user_joy1))
679   MCFG_VIC20_USER_PORT_6_HANDLER(WRITELINE(vic20_state, write_user_joy2))
680   MCFG_VIC20_USER_PORT_7_HANDLER(WRITELINE(vic20_state, write_user_light_pen))
681   MCFG_VIC20_USER_PORT_8_HANDLER(WRITELINE(vic20_state, write_user_cassette_switch))
682   MCFG_VIC20_USER_PORT_B_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_cb1))
683   MCFG_VIC20_USER_PORT_C_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb0))
684   MCFG_VIC20_USER_PORT_D_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb1))
685   MCFG_VIC20_USER_PORT_E_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb2))
686   MCFG_VIC20_USER_PORT_F_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb3))
687   MCFG_VIC20_USER_PORT_H_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb4))
688   MCFG_VIC20_USER_PORT_J_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb5))
689   MCFG_VIC20_USER_PORT_K_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb6))
690   MCFG_VIC20_USER_PORT_L_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_pb7))
691   MCFG_VIC20_USER_PORT_M_HANDLER(DEVWRITELINE(M6522_1_TAG, via6522_device, write_cb2))
692
645693   MCFG_QUICKLOAD_ADD("quickload", vic20_state, cbm_vc20, "p00,prg", CBM_QUICKLOAD_DELAY_SECONDS)
646694
647695   // software lists
r26898r26899
672720   // devices
673721   MCFG_VIC20_EXPANSION_SLOT_ADD(VIC20_EXPANSION_SLOT_TAG, MOS6560_CLOCK, vic20_expansion_cards, NULL)
674722   MCFG_VIC20_EXPANSION_SLOT_IRQ_CALLBACKS(INPUTLINE(M6502_TAG, M6502_IRQ_LINE), INPUTLINE(M6502_TAG, M6502_NMI_LINE), WRITELINE(vic20_state, exp_reset_w))
675   MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy")
676   MCFG_VCS_CONTROL_PORT_TRIGGER_HANDLER(DEVWRITELINE(M6560_TAG, mos6560_device, lp_w))
677723
678724   // software lists
679725   MCFG_SOFTWARE_LIST_FILTER("cart_list", "NTSC")
r26898r26899
699745   // devices
700746   MCFG_VIC20_EXPANSION_SLOT_ADD(VIC20_EXPANSION_SLOT_TAG, MOS6561_CLOCK, vic20_expansion_cards, NULL)
701747   MCFG_VIC20_EXPANSION_SLOT_IRQ_CALLBACKS(INPUTLINE(M6502_TAG, M6502_IRQ_LINE), INPUTLINE(M6502_TAG, M6502_NMI_LINE), WRITELINE(vic20_state, exp_reset_w))
702   MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy")
703   MCFG_VCS_CONTROL_PORT_TRIGGER_HANDLER(DEVWRITELINE(M6561_TAG, mos6561_device, lp_w))
704748
705749   // software lists
706750   MCFG_SOFTWARE_LIST_FILTER("cart_list", "PAL")
trunk/src/mess/includes/vic20.h
r26898r26899
3838         m_via2(*this, M6522_2_TAG),
3939         m_vic(*this, M6560_TAG),
4040         m_iec(*this, CBM_IEC_TAG),
41         m_joy1(*this, CONTROL1_TAG),
41         m_joy(*this, CONTROL1_TAG),
4242         m_exp(*this, VIC20_EXPANSION_SLOT_TAG),
4343         m_user(*this, VIC20_USER_PORT_TAG),
4444         m_cassette(*this, PET_DATASSETTE_PORT_TAG),
r26898r26899
6464   required_device<via6522_device> m_via2;
6565   required_device<mos6560_device> m_vic;
6666   required_device<cbm_iec_device> m_iec;
67   required_device<vcs_control_port_device> m_joy1;
67   required_device<vcs_control_port_device> m_joy;
6868   required_device<vic20_expansion_slot_device> m_exp;
6969   required_device<vic20_user_port_device> m_user;
7070   required_device<pet_datassette_port_device> m_cassette;
r26898r26899
9595   DECLARE_READ8_MEMBER( vic_lighty_cb );
9696   DECLARE_READ8_MEMBER( vic_lightbut_cb );
9797
98   DECLARE_WRITE_LINE_MEMBER( write_light_pen );
99   DECLARE_WRITE_LINE_MEMBER( write_user_joy0 );
100   DECLARE_WRITE_LINE_MEMBER( write_user_joy1 );
101   DECLARE_WRITE_LINE_MEMBER( write_user_joy2 );
102   DECLARE_WRITE_LINE_MEMBER( write_user_light_pen );
103   DECLARE_WRITE_LINE_MEMBER( write_user_cassette_switch );
104
98105   DECLARE_READ8_MEMBER( via1_pa_r );
99106   DECLARE_WRITE8_MEMBER( via1_pa_w );
107   DECLARE_WRITE8_MEMBER( via1_pb_w );
100108
101109   DECLARE_READ8_MEMBER( via2_pa_r );
102110   DECLARE_READ8_MEMBER( via2_pb_r );
r26898r26899
143151      IO2 = 6,
144152      IO3 = 7
145153   };
154
155   int m_light_pen;
156   int m_user_joy0;
157   int m_user_joy1;
158   int m_user_joy2;
159   int m_user_light_pen;
160   int m_user_cassette_switch;
146161};
147162
148163#endif
trunk/src/emu/bus/vic20/user.c
r26898r26899
5555//-------------------------------------------------
5656
5757vic20_user_port_device::vic20_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
58      device_t(mconfig, VIC20_USER_PORT, "VIC-20 user port", tag, owner, clock, "vic20_user_port", __FILE__),
59      device_slot_interface(mconfig, *this)
58   device_t(mconfig, VIC20_USER_PORT, "VIC-20 user port", tag, owner, clock, "vic20_user_port", __FILE__),
59   device_slot_interface(mconfig, *this),
60   m_3_handler(*this),
61   m_4_handler(*this),
62   m_5_handler(*this),
63   m_6_handler(*this),
64   m_7_handler(*this),
65   m_8_handler(*this),
66   m_b_handler(*this),
67   m_c_handler(*this),
68   m_d_handler(*this),
69   m_e_handler(*this),
70   m_f_handler(*this),
71   m_h_handler(*this),
72   m_j_handler(*this),
73   m_k_handler(*this),
74   m_l_handler(*this),
75   m_m_handler(*this)
6076{
6177}
6278
6379
6480//-------------------------------------------------
65//  device_config_complete - perform any
66//  operations now that the configuration is
67//  complete
68//-------------------------------------------------
69
70void vic20_user_port_device::device_config_complete()
71{
72   // inherit a copy of the static data
73   const vic20_user_port_interface *intf = reinterpret_cast<const vic20_user_port_interface *>(static_config());
74   if (intf != NULL)
75   {
76      *static_cast<vic20_user_port_interface *>(this) = *intf;
77   }
78
79   // or initialize to defaults if none provided
80   else
81   {
82      memset(&m_out_cb1_cb, 0, sizeof(m_out_cb1_cb));
83      memset(&m_out_cb2_cb, 0, sizeof(m_out_cb2_cb));
84      memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb));
85   }
86}
87
88
89//-------------------------------------------------
9081//  device_start - device-specific startup
9182//-------------------------------------------------
9283
r26898r26899
9586   m_card = dynamic_cast<device_vic20_user_port_interface *>(get_card_device());
9687
9788   // resolve callbacks
98   m_out_light_pen_func.resolve(m_out_light_pen_cb, *this);
99   m_out_cb1_func.resolve(m_out_cb1_cb, *this);
100   m_out_cb2_func.resolve(m_out_cb2_cb, *this);
101   m_out_reset_func.resolve(m_out_reset_cb, *this);
89   m_3_handler.resolve_safe();
90   m_4_handler.resolve_safe();
91   m_5_handler.resolve_safe();
92   m_6_handler.resolve_safe();
93   m_7_handler.resolve_safe();
94   m_8_handler.resolve_safe();
95   m_b_handler.resolve_safe();
96   m_c_handler.resolve_safe();
97   m_d_handler.resolve_safe();
98   m_e_handler.resolve_safe();
99   m_f_handler.resolve_safe();
100   m_h_handler.resolve_safe();
101   m_j_handler.resolve_safe();
102   m_k_handler.resolve_safe();
103   m_l_handler.resolve_safe();
104   m_m_handler.resolve_safe();
105
106   // pull up
107   m_3_handler(1);
108   m_4_handler(1);
109   m_5_handler(1);
110   m_6_handler(1);
111   m_7_handler(1);
112   m_8_handler(1);
113   m_b_handler(1);
114   m_c_handler(1);
115   m_d_handler(1);
116   m_e_handler(1);
117   m_f_handler(1);
118   m_h_handler(1);
119   m_j_handler(1);
120   m_k_handler(1);
121   m_l_handler(1);
122   m_m_handler(1);
102123}
103124
104125
r26898r26899
115136}
116137
117138
118READ8_MEMBER( vic20_user_port_device::pb_r ) { UINT8 data = 0xff; if (m_card != NULL) data = m_card->vic20_pb_r(space, offset); return data; }
119WRITE8_MEMBER( vic20_user_port_device::pb_w ) { if (m_card != NULL) m_card->vic20_pb_w(space, offset, data); }
120READ_LINE_MEMBER( vic20_user_port_device::joy0_r ) { int state = 1; if (m_card != NULL) state = m_card->vic20_joy0_r(); return state; }
121READ_LINE_MEMBER( vic20_user_port_device::joy1_r ) { int state = 1; if (m_card != NULL) state = m_card->vic20_joy1_r(); return state; }
122READ_LINE_MEMBER( vic20_user_port_device::joy2_r ) { int state = 1; if (m_card != NULL) state = m_card->vic20_joy2_r(); return state; }
123READ_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; }
124READ_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; }
125WRITE_LINE_MEMBER( vic20_user_port_device::cb1_w ) { if (m_card != NULL) m_card->vic20_cb1_w(state); }
126WRITE_LINE_MEMBER( vic20_user_port_device::cb2_w ) { if (m_card != NULL) m_card->vic20_cb2_w(state); }
127WRITE_LINE_MEMBER( vic20_user_port_device::atn_w ) { if (m_card != NULL) m_card->vic20_atn_w(state); }
139WRITE_LINE_MEMBER( vic20_user_port_device::write_7 ) { if (m_card != NULL) m_card->write_7(state); }
140WRITE_LINE_MEMBER( vic20_user_port_device::write_9 ) { if (m_card != NULL) m_card->write_9(state); }
141WRITE_LINE_MEMBER( vic20_user_port_device::write_b ) { if (m_card != NULL) m_card->write_b(state); }
142WRITE_LINE_MEMBER( vic20_user_port_device::write_c ) { if (m_card != NULL) m_card->write_c(state); }
143WRITE_LINE_MEMBER( vic20_user_port_device::write_d ) { if (m_card != NULL) m_card->write_d(state); }
144WRITE_LINE_MEMBER( vic20_user_port_device::write_e ) { if (m_card != NULL) m_card->write_e(state); }
145WRITE_LINE_MEMBER( vic20_user_port_device::write_f ) { if (m_card != NULL) m_card->write_f(state); }
146WRITE_LINE_MEMBER( vic20_user_port_device::write_h ) { if (m_card != NULL) m_card->write_h(state); }
147WRITE_LINE_MEMBER( vic20_user_port_device::write_j ) { if (m_card != NULL) m_card->write_j(state); }
148WRITE_LINE_MEMBER( vic20_user_port_device::write_k ) { if (m_card != NULL) m_card->write_k(state); }
149WRITE_LINE_MEMBER( vic20_user_port_device::write_l ) { if (m_card != NULL) m_card->write_l(state); }
150WRITE_LINE_MEMBER( vic20_user_port_device::write_m ) { if (m_card != NULL) m_card->write_m(state); }
128151
129152
153
130154//-------------------------------------------------
131155//  SLOT_INTERFACE( vic20_user_port_cards )
132156//-------------------------------------------------
133157
158// slot devices
159#include "vic1011.h"
160
134161SLOT_INTERFACE_START( vic20_user_port_cards )
135162   SLOT_INTERFACE("rs232", VIC1011)
136163SLOT_INTERFACE_END
trunk/src/emu/bus/vic20/user.h
r26898r26899
4545//  INTERFACE CONFIGURATION MACROS
4646//**************************************************************************
4747
48#define VIC20_USER_PORT_INTERFACE(_name) \
49   const vic20_user_port_interface (_name) =
50
51
52#define MCFG_VIC20_USER_PORT_ADD(_tag, _config, _slot_intf, _def_slot) \
48#define MCFG_VIC20_USER_PORT_ADD(_tag, _slot_intf, _def_slot) \
5349   MCFG_DEVICE_ADD(_tag, VIC20_USER_PORT, 0) \
54   MCFG_DEVICE_CONFIG(_config) \
5550   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
5651
52#define MCFG_VIC20_USER_PORT_3_HANDLER(_devcb) \
53   devcb = &vic20_user_port_device::set_3_handler(*device, DEVCB2_##_devcb);
5754
55#define MCFG_VIC20_USER_PORT_4_HANDLER(_devcb) \
56   devcb = &vic20_user_port_device::set_4_handler(*device, DEVCB2_##_devcb);
5857
58#define MCFG_VIC20_USER_PORT_5_HANDLER(_devcb) \
59   devcb = &vic20_user_port_device::set_5_handler(*device, DEVCB2_##_devcb);
60
61#define MCFG_VIC20_USER_PORT_6_HANDLER(_devcb) \
62   devcb = &vic20_user_port_device::set_6_handler(*device, DEVCB2_##_devcb);
63
64#define MCFG_VIC20_USER_PORT_7_HANDLER(_devcb) \
65   devcb = &vic20_user_port_device::set_7_handler(*device, DEVCB2_##_devcb);
66
67#define MCFG_VIC20_USER_PORT_8_HANDLER(_devcb) \
68   devcb = &vic20_user_port_device::set_8_handler(*device, DEVCB2_##_devcb);
69
70#define MCFG_VIC20_USER_PORT_B_HANDLER(_devcb) \
71   devcb = &vic20_user_port_device::set_b_handler(*device, DEVCB2_##_devcb);
72
73#define MCFG_VIC20_USER_PORT_C_HANDLER(_devcb) \
74   devcb = &vic20_user_port_device::set_c_handler(*device, DEVCB2_##_devcb);
75
76#define MCFG_VIC20_USER_PORT_D_HANDLER(_devcb) \
77   devcb = &vic20_user_port_device::set_d_handler(*device, DEVCB2_##_devcb);
78
79#define MCFG_VIC20_USER_PORT_E_HANDLER(_devcb) \
80   devcb = &vic20_user_port_device::set_e_handler(*device, DEVCB2_##_devcb);
81
82#define MCFG_VIC20_USER_PORT_F_HANDLER(_devcb) \
83   devcb = &vic20_user_port_device::set_f_handler(*device, DEVCB2_##_devcb);
84
85#define MCFG_VIC20_USER_PORT_H_HANDLER(_devcb) \
86   devcb = &vic20_user_port_device::set_h_handler(*device, DEVCB2_##_devcb);
87
88#define MCFG_VIC20_USER_PORT_J_HANDLER(_devcb) \
89   devcb = &vic20_user_port_device::set_j_handler(*device, DEVCB2_##_devcb);
90
91#define MCFG_VIC20_USER_PORT_K_HANDLER(_devcb) \
92   devcb = &vic20_user_port_device::set_k_handler(*device, DEVCB2_##_devcb);
93
94#define MCFG_VIC20_USER_PORT_L_HANDLER(_devcb) \
95   devcb = &vic20_user_port_device::set_l_handler(*device, DEVCB2_##_devcb);
96
97#define MCFG_VIC20_USER_PORT_M_HANDLER(_devcb) \
98   devcb = &vic20_user_port_device::set_m_handler(*device, DEVCB2_##_devcb);
99
100
59101//**************************************************************************
60102//  TYPE DEFINITIONS
61103//**************************************************************************
62104
63// ======================> vic20_user_port_interface
64
65struct vic20_user_port_interface
66{
67   devcb_write_line    m_out_light_pen_cb;
68   devcb_write_line    m_out_cb1_cb;
69   devcb_write_line    m_out_cb2_cb;
70   devcb_write_line    m_out_reset_cb;
71};
72
73
74105// ======================> vic20_user_port_device
75106
76107class device_vic20_user_port_interface;
77108
78109class vic20_user_port_device : public device_t,
79                        public vic20_user_port_interface,
80                        public device_slot_interface
110   public device_slot_interface
81111{
82112public:
83113   // construction/destruction
84114   vic20_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
85115
116   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); }
117   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); }
118   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); }
119   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); }
120   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); }
121   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); }
122   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); }
123   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); }
124   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); }
125   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); }
126   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); }
127   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); }
128   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); }
129   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); }
130   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); }
131   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); }
132
86133   // computer interface
87   DECLARE_READ8_MEMBER( pb_r );
88   DECLARE_WRITE8_MEMBER( pb_w );
89   DECLARE_READ_LINE_MEMBER( joy0_r );
90   DECLARE_READ_LINE_MEMBER( joy1_r );
91   DECLARE_READ_LINE_MEMBER( joy2_r );
92   DECLARE_READ_LINE_MEMBER( light_pen_r );
93   DECLARE_READ_LINE_MEMBER( cassette_switch_r );
94   DECLARE_WRITE_LINE_MEMBER( cb1_w );
95   DECLARE_WRITE_LINE_MEMBER( cb2_w );
96   DECLARE_WRITE_LINE_MEMBER( atn_w );
97   DECLARE_WRITE_LINE_MEMBER( port_reset_w );
134   DECLARE_WRITE_LINE_MEMBER( write_7 );
135   DECLARE_WRITE_LINE_MEMBER( write_9 );
136   DECLARE_WRITE_LINE_MEMBER( write_b );
137   DECLARE_WRITE_LINE_MEMBER( write_c );
138   DECLARE_WRITE_LINE_MEMBER( write_d );
139   DECLARE_WRITE_LINE_MEMBER( write_e );
140   DECLARE_WRITE_LINE_MEMBER( write_f );
141   DECLARE_WRITE_LINE_MEMBER( write_h );
142   DECLARE_WRITE_LINE_MEMBER( write_j );
143   DECLARE_WRITE_LINE_MEMBER( write_k );
144   DECLARE_WRITE_LINE_MEMBER( write_l );
145   DECLARE_WRITE_LINE_MEMBER( write_m );
98146
99   // cartridge interface
100   DECLARE_WRITE_LINE_MEMBER( light_pen_w ) { m_out_light_pen_func(state); }
101   DECLARE_WRITE_LINE_MEMBER( via_cb1_w ) { m_out_cb1_func(state); }
102   DECLARE_WRITE_LINE_MEMBER( via_cb2_w ) { m_out_cb2_func(state); }
103   DECLARE_WRITE_LINE_MEMBER( reset_w ) { m_out_reset_func(state); }
147   // device interface
148   devcb2_write_line m_3_handler;
149   devcb2_write_line m_4_handler;
150   devcb2_write_line m_5_handler;
151   devcb2_write_line m_6_handler;
152   devcb2_write_line m_7_handler;
153   devcb2_write_line m_8_handler;
154   devcb2_write_line m_b_handler;
155   devcb2_write_line m_c_handler;
156   devcb2_write_line m_d_handler;
157   devcb2_write_line m_e_handler;
158   devcb2_write_line m_f_handler;
159   devcb2_write_line m_h_handler;
160   devcb2_write_line m_j_handler;
161   devcb2_write_line m_k_handler;
162   devcb2_write_line m_l_handler;
163   devcb2_write_line m_m_handler;
104164
105165protected:
106166   // device-level overrides
107   virtual void device_config_complete();
108167   virtual void device_start();
109168   virtual void device_reset();
110169
111   devcb_resolved_write_line   m_out_light_pen_func;
112   devcb_resolved_write_line   m_out_cb1_func;
113   devcb_resolved_write_line   m_out_cb2_func;
114   devcb_resolved_write_line   m_out_reset_func;
115
116170   device_vic20_user_port_interface *m_card;
117171};
118172
r26898r26899
123177class device_vic20_user_port_interface : public device_slot_card_interface
124178{
125179public:
126   // construction/destruction
127180   device_vic20_user_port_interface(const machine_config &mconfig, device_t &device);
128181   virtual ~device_vic20_user_port_interface();
129182
130   virtual UINT8 vic20_pb_r(address_space &space, offs_t offset) { return 0xff; };
131   virtual void vic20_pb_w(address_space &space, offs_t offset, UINT8 data) { };
183   DECLARE_WRITE_LINE_MEMBER( write_7 ) {};
184   DECLARE_WRITE_LINE_MEMBER( write_9 ) {};
185   DECLARE_WRITE_LINE_MEMBER( write_b ) {};
186   DECLARE_WRITE_LINE_MEMBER( write_c ) {};
187   DECLARE_WRITE_LINE_MEMBER( write_d ) {};
188   DECLARE_WRITE_LINE_MEMBER( write_e ) {};
189   DECLARE_WRITE_LINE_MEMBER( write_f ) {};
190   DECLARE_WRITE_LINE_MEMBER( write_h ) {};
191   DECLARE_WRITE_LINE_MEMBER( write_j ) {};
192   DECLARE_WRITE_LINE_MEMBER( write_k ) {};
193   DECLARE_WRITE_LINE_MEMBER( write_l ) {};
194   DECLARE_WRITE_LINE_MEMBER( write_m ) {};
132195
133   virtual int vic20_joy0_r() { return 1; };
134   virtual int vic20_joy1_r() { return 1; };
135   virtual int vic20_joy2_r() { return 1; };
136   virtual int vic20_light_pen_r() { return 1; };
137   virtual int vic20_cassette_switch_r() { return 1; };
138   virtual void vic20_cb1_w(int state) { };
139   virtual void vic20_cb2_w(int state) { };
140   virtual void vic20_atn_w(int state) { };
141
142196protected:
143197   vic20_user_port_device *m_slot;
144198};
r26898r26899
147201// device type definition
148202extern const device_type VIC20_USER_PORT;
149203
150
151// slot devices
152#include "vic1011.h"
153
154204SLOT_INTERFACE_EXTERN( vic20_user_port_cards );
155205
156
157
158206#endif
trunk/src/emu/bus/vic20/vic1011.c
r26898r26899
3434
3535static MACHINE_CONFIG_FRAGMENT( vic1011 )
3636   MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
37   MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, rxd_w))
37   MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, write_rxd))
38   MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, write_dcdin))
39   MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, write_cts))
40   MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, write_dsr))
3841MACHINE_CONFIG_END
3942
4043
r26898r26899
7477{
7578}
7679
80WRITE_LINE_MEMBER( vic1011_device::write_rxd )
81{
82   m_slot->m_b_handler(!state);
83   m_slot->m_c_handler(!state);
84}
7785
78//-------------------------------------------------
79//  vic20_pb_r - port B read
80//-------------------------------------------------
86void vic1011_device::write_d(int state)
87{
88   m_rs232->rts_w(state);
89}
8190
82UINT8 vic1011_device::vic20_pb_r(address_space &space, offs_t offset)
91void vic1011_device::write_e(int state)
8392{
84   /*
93   m_rs232->dtr_w(state);
94}
8595
86       bit     description
87
88       0       Sin
89       1
90       2
91       3
92       4       DCDin
93       5
94       6       CTS
95       7       DSR
96
97   */
98
99   UINT8 data = 0;
100
101   data |= !m_rs232->rx();
102   data |= m_rs232->dcd_r() << 4;
103   data |= m_rs232->cts_r() << 6;
104   data |= m_rs232->dsr_r() << 7;
105
106   return data;
96WRITE_LINE_MEMBER( vic1011_device::write_dcdin )
97{
98   m_slot->m_h_handler(state);
10799}
108100
109
110//-------------------------------------------------
111//  vic20_pb_w - port B write
112//-------------------------------------------------
113
114void vic1011_device::vic20_pb_w(address_space &space, offs_t offset, UINT8 data)
101void vic1011_device::write_j(int state)
115102{
116   /*
103   /// dcdout
104}
117105
118       bit     description
119
120       0
121       1       RTS
122       2       DTR
123       3
124       4
125       5       DCDout
126       6
127       7
128
129   */
130
131   m_rs232->rts_w(BIT(data, 1));
132   m_rs232->dtr_w(BIT(data, 2));
106WRITE_LINE_MEMBER( vic1011_device::write_cts )
107{
108   m_slot->m_k_handler(state);
133109}
134110
135
136//-------------------------------------------------
137//  vic20_cb2_w - CB2 write
138//-------------------------------------------------
139
140void vic1011_device::vic20_cb2_w(int state)
111WRITE_LINE_MEMBER( vic1011_device::write_dsr )
141112{
142   m_rs232->tx(!state);
113   m_slot->m_l_handler(state);
143114}
144115
145
146//-------------------------------------------------
147//  rxd_w -
148//-------------------------------------------------
149
150WRITE_LINE_MEMBER( vic1011_device::rxd_w )
116void vic1011_device::write_m(int state)
151117{
152   m_slot->via_cb1_w(!state);
118   m_rs232->tx(!state);
153119}
trunk/src/emu/bus/vic20/vic1011.h
r26898r26899
3636   // optional information overrides
3737   virtual machine_config_constructor device_mconfig_additions() const;
3838
39   DECLARE_WRITE_LINE_MEMBER( rxd_w );
39   DECLARE_WRITE_LINE_MEMBER( write_rxd );
40   DECLARE_WRITE_LINE_MEMBER( write_d );
41   DECLARE_WRITE_LINE_MEMBER( write_e );
42   DECLARE_WRITE_LINE_MEMBER( write_dcdin );
43   DECLARE_WRITE_LINE_MEMBER( write_j );
44   DECLARE_WRITE_LINE_MEMBER( write_cts );
45   DECLARE_WRITE_LINE_MEMBER( write_dsr );
46   DECLARE_WRITE_LINE_MEMBER( write_m );
4047
4148protected:
4249   // device-level overrides
4350   virtual void device_start();
4451
45   // device_vic20_user_port_interface overrides
46   virtual UINT8 vic20_pb_r(address_space &space, offs_t offset);
47   virtual void vic20_pb_w(address_space &space, offs_t offset, UINT8 data);
48   virtual void vic20_cb2_w(int state);
49
5052private:
5153   required_device<rs232_port_device> m_rs232;
5254};

Previous 199869 Revisions Next


© 1997-2024 The MAME Team