1
/**********************************************************************
3
MOS 6526/8520 Complex Interface Adapter emulation
6
Visit http://mamedev.org for licensing and usage restrictions.
8
**********************************************************************
19
PB0 10 | MOS6526 | 31 DB2
20
PB1 11 | MOS8520 | 30 DB3
29
Vcc 20 |_____________| 21 _IRQ
31
**********************************************************************/
42
//**************************************************************************
43
// INTERFACE CONFIGURATION MACROS
44
//**************************************************************************
46
#define MCFG_MOS6526R1_ADD(_tag, _clock, _config) \
47
MCFG_DEVICE_ADD(_tag, MOS6526R1, _clock) \
48
MCFG_DEVICE_CONFIG(_config)
50
#define MCFG_MOS6526R2_ADD(_tag, _clock, _config) \
51
MCFG_DEVICE_ADD(_tag, MOS6526R2, _clock) \
52
MCFG_DEVICE_CONFIG(_config)
54
#define MCFG_MOS8520_ADD(_tag, _clock, _config) \
55
MCFG_DEVICE_ADD(_tag, MOS8520, _clock) \
56
MCFG_DEVICE_CONFIG(_config)
58
#define MOS6526_INTERFACE(name) \
59
const mos6526_interface (name)=
61
#define MOS8520_INTERFACE(name) \
62
const mos6526_interface (name)=
64
/***************************************************************************
66
***************************************************************************/
69
// ======================> mos6526_interface
71
struct mos6526_interface
75
devcb_write_line m_out_irq_cb;
76
devcb_write_line m_out_pc_cb;
77
devcb_write_line m_out_cnt_cb;
78
devcb_write_line m_out_sp_cb;
80
devcb_read8 m_in_pa_cb;
81
devcb_write8 m_out_pa_cb;
83
devcb_read8 m_in_pb_cb;
84
devcb_write8 m_out_pb_cb;
89
// ======================> mos6526_device
91
class mos6526_device : public device_t,
92
public mos6526_interface
94
friend class dart_channel;
97
// construction/destruction
98
mos6526_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
101
UINT8 reg_r(UINT8 offset);
102
void reg_w(UINT8 offset, UINT8 data);
105
UINT8 pa_r(UINT8 offset) { return (m_port[0].m_latch | ~m_port[0].m_ddr); }
106
UINT8 pb_r(UINT8 offset) { return (m_port[1].m_latch | ~m_port[1].m_ddr); }
108
/* interrupt request */
109
UINT8 irq_r() { return m_irq; }
111
/* time of day clock */
112
void tod_w(UINT8 state) { if(state) clock_tod(); }
115
UINT8 cnt_r() { return m_cnt; }
116
void cnt_w(UINT8 state);
119
UINT8 sp_r() { return m_sp; }
120
void sp_w(UINT8 state) { m_sp = state; }
123
void flag_w(UINT8 state);
126
void set_port_mask_value(int port, int data);
129
// device-level overrides
130
virtual void device_config_complete();
131
virtual void device_start();
132
virtual void device_reset();
133
virtual void device_post_load() { }
134
virtual void device_clock_changed() { }
136
static TIMER_CALLBACK( timer_proc );
137
static TIMER_CALLBACK( clock_tod_callback );
142
void update_interrupts();
143
void timer_bump(int timer);
144
void timer_underflow(int timer);
154
void update(int which, INT32 new_count);
162
mos6526_device* m_cia;
171
devcb_resolved_read8 m_read;
172
devcb_resolved_write8 m_write;
173
UINT8 m_mask_value; /* in READ operation the value can be forced by a extern electric circuit */
176
devcb_resolved_write_line m_out_irq_func;
177
devcb_resolved_write_line m_out_pc_func;
178
devcb_resolved_write_line m_out_cnt_func;
179
devcb_resolved_write_line m_out_sp_func;
182
cia_timer m_timer[2];
184
/* Time Of the Day clock (TOD) */
206
class mos6526r1_device : public mos6526_device
209
mos6526r1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
212
class mos6526r2_device : public mos6526_device
215
mos6526r2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
218
class mos8520_device : public mos6526_device
221
mos8520_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
225
// device type definition
226
extern const device_type MOS6526R1;
227
extern const device_type MOS6526R2;
228
extern const device_type MOS8520;
232
/***************************************************************************
234
***************************************************************************/
236
/* register access */
237
READ8_DEVICE_HANDLER( mos6526_r );
238
WRITE8_DEVICE_HANDLER( mos6526_w );
241
READ8_DEVICE_HANDLER( mos6526_pa_r );
242
READ8_DEVICE_HANDLER( mos6526_pb_r );
244
/* interrupt request */
245
READ_LINE_DEVICE_HANDLER( mos6526_irq_r );
247
/* time of day clock */
248
WRITE_LINE_DEVICE_HANDLER( mos6526_tod_w );
251
READ_LINE_DEVICE_HANDLER( mos6526_cnt_r );
252
WRITE_LINE_DEVICE_HANDLER( mos6526_cnt_w );
255
READ_LINE_DEVICE_HANDLER( mos6526_sp_r );
256
WRITE_LINE_DEVICE_HANDLER( mos6526_sp_w );
259
WRITE_LINE_DEVICE_HANDLER( mos6526_flag_w );
262
void cia_set_port_mask_value(device_t *device, int port, int data);
264
#endif /* __6526CIA_H__ */