~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to mess/src/emu/machine/6526cia.h

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**********************************************************************
2
 
 
3
 
    MOS 6526/8520 Complex Interface Adapter emulation
4
 
 
5
 
    Copyright MESS Team.
6
 
    Visit http://mamedev.org for licensing and usage restrictions.
7
 
 
8
 
**********************************************************************
9
 
                            _____   _____
10
 
                   Vss   1 |*    \_/     | 40  CNT
11
 
                   PA0   2 |             | 39  SP
12
 
                   PA1   3 |             | 38  RS0
13
 
                   PA2   4 |             | 37  RS1
14
 
                   PA3   5 |             | 36  RS2
15
 
                   PA4   6 |             | 35  RS3
16
 
                   PA5   7 |             | 34  _RES
17
 
                   PA6   8 |             | 33  DB0
18
 
                   PA7   9 |             | 32  DB1
19
 
                   PB0  10 |   MOS6526   | 31  DB2
20
 
                   PB1  11 |   MOS8520   | 30  DB3
21
 
                   PB2  12 |             | 29  DB4
22
 
                   PB3  13 |             | 28  DB5
23
 
                   PB4  14 |             | 27  DB6
24
 
                   PB5  15 |             | 26  DB7
25
 
                   PB6  16 |             | 25  phi2
26
 
                   PB7  17 |             | 24  _FLAG
27
 
                   _PC  18 |             | 23  _CS
28
 
                   TOD  19 |             | 22  R/W
29
 
                   Vcc  20 |_____________| 21  _IRQ
30
 
 
31
 
**********************************************************************/
32
 
 
33
 
#pragma once
34
 
 
35
 
#ifndef __6526CIA_H__
36
 
#define __6526CIA_H__
37
 
 
38
 
#include "emu.h"
39
 
 
40
 
 
41
 
 
42
 
//**************************************************************************
43
 
//  INTERFACE CONFIGURATION MACROS
44
 
//**************************************************************************
45
 
 
46
 
#define MCFG_MOS6526R1_ADD(_tag, _clock, _config) \
47
 
        MCFG_DEVICE_ADD(_tag, MOS6526R1, _clock) \
48
 
        MCFG_DEVICE_CONFIG(_config)
49
 
 
50
 
#define MCFG_MOS6526R2_ADD(_tag, _clock, _config) \
51
 
        MCFG_DEVICE_ADD(_tag, MOS6526R2, _clock) \
52
 
        MCFG_DEVICE_CONFIG(_config)
53
 
 
54
 
#define MCFG_MOS8520_ADD(_tag, _clock, _config) \
55
 
        MCFG_DEVICE_ADD(_tag, MOS8520, _clock) \
56
 
        MCFG_DEVICE_CONFIG(_config)
57
 
 
58
 
#define MOS6526_INTERFACE(name) \
59
 
        const mos6526_interface (name)=
60
 
 
61
 
#define MOS8520_INTERFACE(name) \
62
 
        const mos6526_interface (name)=
63
 
 
64
 
/***************************************************************************
65
 
    TYPE DEFINITIONS
66
 
***************************************************************************/
67
 
 
68
 
 
69
 
// ======================> mos6526_interface
70
 
 
71
 
struct mos6526_interface
72
 
{
73
 
        int m_tod_clock;
74
 
 
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;
79
 
 
80
 
        devcb_read8                     m_in_pa_cb;
81
 
        devcb_write8            m_out_pa_cb;
82
 
 
83
 
        devcb_read8                     m_in_pb_cb;
84
 
        devcb_write8            m_out_pb_cb;
85
 
};
86
 
 
87
 
 
88
 
 
89
 
// ======================> mos6526_device
90
 
 
91
 
class mos6526_device :  public device_t,
92
 
                        public mos6526_interface
93
 
{
94
 
    friend class dart_channel;
95
 
 
96
 
protected:
97
 
    // construction/destruction
98
 
    mos6526_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
99
 
 
100
 
public:
101
 
        UINT8 reg_r(UINT8 offset);
102
 
        void reg_w(UINT8 offset, UINT8 data);
103
 
 
104
 
        /* port access */
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); }
107
 
 
108
 
        /* interrupt request */
109
 
        UINT8 irq_r() { return m_irq; }
110
 
 
111
 
        /* time of day clock */
112
 
        void tod_w(UINT8 state) { if(state) clock_tod(); }
113
 
 
114
 
        /* serial counter */
115
 
        UINT8 cnt_r() { return m_cnt; }
116
 
        void cnt_w(UINT8 state);
117
 
 
118
 
        /* serial port */
119
 
        UINT8 sp_r() { return m_sp; }
120
 
        void sp_w(UINT8 state) { m_sp = state; }
121
 
 
122
 
        /* flag */
123
 
        void flag_w(UINT8 state);
124
 
 
125
 
        /* port mask */
126
 
        void set_port_mask_value(int port, int data);
127
 
 
128
 
protected:
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() { }
135
 
 
136
 
        static TIMER_CALLBACK( timer_proc );
137
 
        static TIMER_CALLBACK( clock_tod_callback );
138
 
 
139
 
private:
140
 
 
141
 
        void update_pc();
142
 
        void update_interrupts();
143
 
        void timer_bump(int timer);
144
 
        void timer_underflow(int timer);
145
 
        void increment();
146
 
        void clock_tod();
147
 
 
148
 
        struct cia_timer
149
 
        {
150
 
        public:
151
 
                cia_timer() { }
152
 
 
153
 
                UINT16 get_count();
154
 
                void update(int which, INT32 new_count);
155
 
 
156
 
                UINT32                  m_clock;
157
 
                UINT16                  m_latch;
158
 
                UINT16                  m_count;
159
 
                UINT8                   m_mode;
160
 
                UINT8                   m_irq;
161
 
                emu_timer*              m_timer;
162
 
                mos6526_device* m_cia;
163
 
        };
164
 
 
165
 
        struct cia_port
166
 
        {
167
 
                UINT8           m_ddr;
168
 
                UINT8           m_latch;
169
 
                UINT8           m_in;
170
 
                UINT8           m_out;
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 */
174
 
        };
175
 
 
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;
180
 
 
181
 
        cia_port                m_port[2];
182
 
        cia_timer               m_timer[2];
183
 
 
184
 
        /* Time Of the Day clock (TOD) */
185
 
        UINT32                  m_tod;
186
 
        UINT32                  m_tod_latch;
187
 
        UINT8                   m_tod_latched;
188
 
        UINT8                   m_tod_running;
189
 
        UINT32                  m_alarm;
190
 
 
191
 
        /* Interrupts */
192
 
        UINT8                   m_icr;
193
 
        UINT8                   m_ics;
194
 
        UINT8                   m_irq;
195
 
        int                             m_flag;
196
 
 
197
 
        /* Serial */
198
 
        UINT8                   m_loaded;
199
 
        UINT8                   m_sdr;
200
 
        UINT8                   m_sp;
201
 
        UINT8                   m_cnt;
202
 
        UINT8                   m_shift;
203
 
        UINT8                   m_serial;
204
 
};
205
 
 
206
 
class mos6526r1_device : public mos6526_device
207
 
{
208
 
public:
209
 
        mos6526r1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
210
 
};
211
 
 
212
 
class mos6526r2_device : public mos6526_device
213
 
{
214
 
public:
215
 
        mos6526r2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
216
 
};
217
 
 
218
 
class mos8520_device : public mos6526_device
219
 
{
220
 
public:
221
 
        mos8520_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
222
 
};
223
 
 
224
 
 
225
 
// device type definition
226
 
extern const device_type MOS6526R1;
227
 
extern const device_type MOS6526R2;
228
 
extern const device_type MOS8520;
229
 
 
230
 
 
231
 
 
232
 
/***************************************************************************
233
 
    FUNCTION PROTOTYPES
234
 
***************************************************************************/
235
 
 
236
 
/* register access */
237
 
READ8_DEVICE_HANDLER( mos6526_r );
238
 
WRITE8_DEVICE_HANDLER( mos6526_w );
239
 
 
240
 
/* port access */
241
 
READ8_DEVICE_HANDLER( mos6526_pa_r );
242
 
READ8_DEVICE_HANDLER( mos6526_pb_r );
243
 
 
244
 
/* interrupt request */
245
 
READ_LINE_DEVICE_HANDLER( mos6526_irq_r );
246
 
 
247
 
/* time of day clock */
248
 
WRITE_LINE_DEVICE_HANDLER( mos6526_tod_w );
249
 
 
250
 
/* serial counter */
251
 
READ_LINE_DEVICE_HANDLER( mos6526_cnt_r );
252
 
WRITE_LINE_DEVICE_HANDLER( mos6526_cnt_w );
253
 
 
254
 
/* serial port */
255
 
READ_LINE_DEVICE_HANDLER( mos6526_sp_r );
256
 
WRITE_LINE_DEVICE_HANDLER( mos6526_sp_w );
257
 
 
258
 
/* flag */
259
 
WRITE_LINE_DEVICE_HANDLER( mos6526_flag_w );
260
 
 
261
 
/* port mask */
262
 
void cia_set_port_mask_value(device_t *device, int port, int data);
263
 
 
264
 
#endif /* __6526CIA_H__ */