1
/**********************************************************************
3
RCA CDP1871 Keyboard Encoder emulation
6
Visit http://mamedev.org for licensing and usage restrictions.
8
**********************************************************************
19
D10 10 | CDP1871 | 31 BUS 6
29
Vss 20 |_____________| 21 _CS1
31
**********************************************************************/
42
//**************************************************************************
44
//**************************************************************************
49
//**************************************************************************
50
// INTERFACE CONFIGURATION MACROS
51
//**************************************************************************
53
#define MCFG_CDP1871_ADD(_tag, _intrf, _clock) \
54
MCFG_DEVICE_ADD(_tag, CDP1871, _clock) \
55
MCFG_DEVICE_CONFIG(_intrf)
57
#define CDP1871_INTERFACE(name) \
58
const cdp1871_interface (name)=
62
//**************************************************************************
64
//**************************************************************************
66
// ======================> cdp1871_interface
68
struct cdp1871_interface
70
devcb_read8 in_d1_func;
71
devcb_read8 in_d2_func;
72
devcb_read8 in_d3_func;
73
devcb_read8 in_d4_func;
74
devcb_read8 in_d5_func;
75
devcb_read8 in_d6_func;
76
devcb_read8 in_d7_func;
77
devcb_read8 in_d8_func;
78
devcb_read8 in_d9_func;
79
devcb_read8 in_d10_func;
80
devcb_read8 in_d11_func;
82
devcb_read_line in_shift_func;
83
devcb_read_line in_control_func;
84
devcb_read_line in_alpha_func;
86
// this gets called for every change of the DA pin (pin 33)
87
devcb_write_line out_da_func;
89
// this gets called for every change of the RPT pin (pin 35)
90
devcb_write_line out_rpt_func;
94
// ======================> cdp1871_device_config
96
class cdp1871_device_config : public device_config,
97
public cdp1871_interface
99
friend class cdp1871_device;
101
// construction/destruction
102
cdp1871_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
106
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
107
virtual device_t *alloc_device(running_machine &machine) const;
110
// device_config overrides
111
virtual void device_config_complete();
115
// ======================> cdp1871_device
117
class cdp1871_device : public device_t
119
friend class cdp1871_device_config;
121
// construction/destruction
122
cdp1871_device(running_machine &_machine, const cdp1871_device_config &_config);
125
DECLARE_READ8_MEMBER( data_r );
127
DECLARE_READ_LINE_MEMBER( da_r );
128
DECLARE_READ_LINE_MEMBER( rpt_r );
131
// device-level overrides
132
virtual void device_start();
133
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
135
void change_output_lines();
136
void clock_scan_counters();
137
void detect_keypress();
140
devcb_resolved_write_line m_out_da_func;
141
devcb_resolved_write_line m_out_rpt_func;
142
devcb_resolved_read8 m_in_d_func[11];
143
devcb_resolved_read_line m_in_shift_func;
144
devcb_resolved_read_line m_in_control_func;
145
devcb_resolved_read_line m_in_alpha_func;
147
bool m_inhibit; // scan counter clock inhibit
148
int m_sense; // sense input scan counter
149
int m_drive; // modifier inputs
151
int m_shift; // latched shift modifier
152
int m_control; // latched control modifier
154
int m_da; // data available flag
155
int m_next_da; // next value of data available flag
156
int m_rpt; // repeat flag
157
int m_next_rpt; // next value of repeat flag
160
emu_timer *m_scan_timer; // keyboard scan timer
162
const cdp1871_device_config &m_config;
166
// device type definition
167
extern const device_type CDP1871;