summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/6821pia.h
blob: 58080e02864b4394d195fb3ad9bc4b4f8f4e28b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**********************************************************************

    Motorola 6821 PIA interface and emulation

    Notes:
        * pia6821_get_port_b_z_mask() gives the caller the bitmask
          that show which bits are high-impendance when
          reading port B, thus neither 0 or 1.
          pia6821_get_output_cb2_z() returns the same
          information for the CB2 pin
        * pia6821_set_port_a_z_mask allows the input callback to
          indicate which port A bits are disconnected.
          For these bit, the read operation will return the
          output buffer's contents
        * the 'alt' interface functions are used when the A0 and A1
          address bits are swapped
        * all 'int' data or return values are Boolean

**********************************************************************/

#ifndef __6821NEW_H__
#define __6821NEW_H__


/***************************************************************************
    CONSTANTS
***************************************************************************/

#define PIA6821		DEVICE_GET_INFO_NAME(pia6821)
#define PIA6822		DEVICE_GET_INFO_NAME(pia6822)


/***************************************************************************
    TYPE DEFINITIONS
***************************************************************************/

/*------------- PIA interface structure -----------------*/

typedef struct _pia6821_interface pia6821_interface;
struct _pia6821_interface
{
	devcb_read8 in_a_func;
	devcb_read8 in_b_func;
	devcb_read_line in_ca1_func;
	devcb_read_line in_cb1_func;
	devcb_read_line in_ca2_func;
	devcb_read_line in_cb2_func;
	devcb_write8 out_a_func;
	devcb_write8 out_b_func;
	devcb_write_line out_ca2_func;
	devcb_write_line out_cb2_func;
	devcb_write_line irq_a_func;
	devcb_write_line irq_b_func;
};


/***************************************************************************
    PROTOTYPES
***************************************************************************/

DEVICE_GET_INFO( pia6821 );
DEVICE_GET_INFO( pia6822 );

READ8_DEVICE_HANDLER( pia6821_r );
WRITE8_DEVICE_HANDLER( pia6821_w );

READ8_DEVICE_HANDLER( pia6821_alt_r );
WRITE8_DEVICE_HANDLER( pia6821_alt_w );

UINT8 pia6821_get_port_b_z_mask(running_device *device);  /* see first note */
void pia6821_set_port_a_z_mask(running_device *device, UINT8 data);  /* see second note */

READ8_DEVICE_HANDLER( pia6821_porta_r );
WRITE8_DEVICE_HANDLER( pia6821_porta_w );
void pia6821_set_input_a(running_device *device, UINT8 data, UINT8 z_mask);
UINT8 pia6821_get_output_a(running_device *device);

READ8_DEVICE_HANDLER( pia6821_ca1_r );
WRITE8_DEVICE_HANDLER( pia6821_ca1_w );

READ8_DEVICE_HANDLER( pia6821_ca2_r );
WRITE8_DEVICE_HANDLER( pia6821_ca2_w );
int pia6821_get_output_ca2(running_device *device);
int pia6821_get_output_ca2_z(running_device *device);

READ8_DEVICE_HANDLER( pia6821_portb_r );
WRITE8_DEVICE_HANDLER( pia6821_portb_w );
UINT8 pia6821_get_output_b(running_device *device);

READ8_DEVICE_HANDLER( pia6821_cb1_r );
WRITE8_DEVICE_HANDLER( pia6821_cb1_w );

READ8_DEVICE_HANDLER( pia6821_cb2_r );
WRITE8_DEVICE_HANDLER( pia6821_cb2_w );
int pia6821_get_output_cb2(running_device *device);
int pia6821_get_output_cb2_z(running_device *device);

int pia6821_get_irq_a(running_device *device);
int pia6821_get_irq_b(running_device *device);


/***************************************************************************
    DEVICE CONFIGURATION MACROS
***************************************************************************/

#define MDRV_PIA6821_ADD(_tag, _intrf) \
	MDRV_DEVICE_ADD(_tag, PIA6821, 0) \
	MDRV_DEVICE_CONFIG(_intrf)

#define MDRV_PIA6821_MODIFY(_tag, _intrf) \
	MDRV_DEVICE_MODIFY(_tag) \
	MDRV_DEVICE_CONFIG(_intrf)

#define MDRV_PIA6822_ADD(_tag, _intrf) \
	MDRV_DEVICE_ADD(_tag, PIA6822, 0) \
	MDRV_DEVICE_CONFIG(_intrf)

#define MDRV_PIA6822_MODIFY(_tag, _intrf) \
	MDRV_DEVICE_MODIFY(_tag) \
	MDRV_DEVICE_CONFIG(_intrf)

#endif /* __6821NEW_H__ */