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

« back to all changes in this revision

Viewing changes to mess/src/mame/machine/namco06.c

  • 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
 
    Namco 06XX
4
 
 
5
 
    This chip is used as an interface to up to 4 other custom chips.
6
 
    It signals IRQs to the custom MCUs when writes happen, and generates
7
 
    NMIs to the controlling CPU to drive reads based on a clock.
8
 
 
9
 
    SD0-SD7 are data I/O lines connecting to the controlling CPU
10
 
    SEL selects either control (1) or data (0), usually connected to
11
 
        an address line of the controlling CPU
12
 
    /NMI is an NMI signal line for the controlling CPU
13
 
 
14
 
    ID0-ID7 are data I/O lines connecting to the other custom chips
15
 
    /IO1-/IO4 are IRQ signal lines for each custom chip
16
 
 
17
 
                   +------+
18
 
                [1]|1   28|Vcc
19
 
                ID7|2   27|SD7
20
 
                ID6|3   26|SD6
21
 
                ID5|4   25|SD5
22
 
                ID4|5   24|SD4
23
 
                ID3|6   23|SD3
24
 
                ID2|7   22|SD2
25
 
                ID1|8   21|SD1
26
 
                ID0|9   20|SD0
27
 
               /IO1|10  19|/NMI
28
 
               /IO2|11  18|/CS
29
 
               /IO3|12  17|CLOCK
30
 
               /IO4|13  16|R/W
31
 
                GND|14  15|SEL
32
 
                   +------+
33
 
 
34
 
    [1] on polepos, galaga, xevious, and bosco: connected to K3 of the 51xx
35
 
        on bosco and xevious, connected to R8 of the 50xx
36
 
 
37
 
 
38
 
    06XX interface:
39
 
    ---------------
40
 
    Galaga                  51XX  ----  ----  54XX
41
 
    Bosconian (CPU board)   51XX  ----  50XX  54XX
42
 
    Bosconian (Video board) 50XX  52XX  ----  ----
43
 
    Xevious                 51XX  ----  50XX  54XX
44
 
    Dig Dug                 51XX  53XX  ----  ----
45
 
    Pole Position / PP II   51XX  53XX  52XX  54XX
46
 
 
47
 
 
48
 
    Galaga writes:
49
 
        control = 10(000), data = FF at startup
50
 
        control = 71(011), read 3, control = 10
51
 
        control = A1(101), write 4, control = 10
52
 
        control = A8(101), write 12, control = 10
53
 
 
54
 
    Xevious writes:
55
 
        control = 10 at startup
56
 
        control = A1(101), write 6, control = 10
57
 
        control = 71(011), read 3, control = 10
58
 
        control = 64(011), write 1, control = 10
59
 
        control = 74(011), read 4, control = 10
60
 
        control = 68(011), write 7, control = 10
61
 
 
62
 
    Dig Dug writes:
63
 
        control = 10(000), data = 10 at startup
64
 
        control = A1(101), write 3, control = 10
65
 
        control = 71(011), read 3, control = 10
66
 
        control = D2(110), read 2, control = 10
67
 
 
68
 
    Bosco writes:
69
 
        control = 10(000), data = FF at startup
70
 
        control = C8(110), write 17, control = 10
71
 
        control = 61(011), write 1, control = 10
72
 
        control = 71(011), read 3, control = 10
73
 
        control = 94(100), read 4, control = 10
74
 
        control = 64(011), write 1, control = 10
75
 
        control = 84(100), write 5, control = 10
76
 
 
77
 
 
78
 
        control = 34(001), write 1, control = 10
79
 
 
80
 
***************************************************************************/
81
 
 
82
 
#include "emu.h"
83
 
#include "machine/namco06.h"
84
 
#include "machine/namco50.h"
85
 
#include "machine/namco51.h"
86
 
#include "machine/namco53.h"
87
 
#include "audio/namco52.h"
88
 
#include "audio/namco54.h"
89
 
 
90
 
 
91
 
#define VERBOSE 0
92
 
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
93
 
 
94
 
 
95
 
 
96
 
typedef struct _namco_06xx_state namco_06xx_state;
97
 
struct _namco_06xx_state
98
 
{
99
 
        UINT8 m_control;
100
 
        emu_timer *m_nmi_timer;
101
 
        cpu_device *m_nmicpu;
102
 
        device_t *m_device[4];
103
 
        read8_device_func m_read[4];
104
 
        void (*m_readreq[4])(device_t *device);
105
 
        write8_device_func m_write[4];
106
 
};
107
 
 
108
 
INLINE namco_06xx_state *get_safe_token(device_t *device)
109
 
{
110
 
        assert(device != NULL);
111
 
        assert(device->type() == NAMCO_06XX);
112
 
 
113
 
        return (namco_06xx_state *)downcast<legacy_device_base *>(device)->token();
114
 
}
115
 
 
116
 
 
117
 
 
118
 
static TIMER_CALLBACK( nmi_generate )
119
 
{
120
 
        namco_06xx_state *state = get_safe_token((device_t *)ptr);
121
 
 
122
 
        if (!state->m_nmicpu->suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))
123
 
        {
124
 
                LOG(("NMI cpu '%s'\n",state->m_nmicpu->tag()));
125
 
 
126
 
                device_set_input_line(state->m_nmicpu, INPUT_LINE_NMI, PULSE_LINE);
127
 
        }
128
 
        else
129
 
                LOG(("NMI not generated because cpu '%s' is suspended\n",state->m_nmicpu->tag()));
130
 
}
131
 
 
132
 
 
133
 
READ8_DEVICE_HANDLER( namco_06xx_data_r )
134
 
{
135
 
        namco_06xx_state *state = get_safe_token(device);
136
 
        UINT8 result = 0xff;
137
 
        int devnum;
138
 
 
139
 
        LOG(("%s: 06XX '%s' read offset %d\n",device->machine().describe_context(),device->tag(),offset));
140
 
 
141
 
        if (!(state->m_control & 0x10))
142
 
        {
143
 
                logerror("%s: 06XX '%s' read in write mode %02x\n",device->machine().describe_context(),device->tag(),state->m_control);
144
 
                return 0;
145
 
        }
146
 
 
147
 
        for (devnum = 0; devnum < 4; devnum++)
148
 
                if ((state->m_control & (1 << devnum)) && state->m_read[devnum] != NULL)
149
 
                        result &= (*state->m_read[devnum])(state->m_device[devnum], 0);
150
 
 
151
 
        return result;
152
 
}
153
 
 
154
 
 
155
 
WRITE8_DEVICE_HANDLER( namco_06xx_data_w )
156
 
{
157
 
        namco_06xx_state *state = get_safe_token(device);
158
 
        int devnum;
159
 
 
160
 
        LOG(("%s: 06XX '%s' write offset %d = %02x\n",device->machine().describe_context(),device->tag(),offset,data));
161
 
 
162
 
        if (state->m_control & 0x10)
163
 
        {
164
 
                logerror("%s: 06XX '%s' write in read mode %02x\n",device->machine().describe_context(),device->tag(),state->m_control);
165
 
                return;
166
 
        }
167
 
 
168
 
        for (devnum = 0; devnum < 4; devnum++)
169
 
                if ((state->m_control & (1 << devnum)) && state->m_write[devnum] != NULL)
170
 
                        (*state->m_write[devnum])(state->m_device[devnum], 0, data);
171
 
}
172
 
 
173
 
 
174
 
READ8_DEVICE_HANDLER( namco_06xx_ctrl_r )
175
 
{
176
 
        namco_06xx_state *state = get_safe_token(device);
177
 
        LOG(("%s: 06XX '%s' ctrl_r\n",device->machine().describe_context(),device->tag()));
178
 
        return state->m_control;
179
 
}
180
 
 
181
 
WRITE8_DEVICE_HANDLER( namco_06xx_ctrl_w )
182
 
{
183
 
        namco_06xx_state *state = get_safe_token(device);
184
 
        int devnum;
185
 
 
186
 
        LOG(("%s: 06XX '%s' control %02x\n",device->machine().describe_context(),device->tag(),data));
187
 
 
188
 
        state->m_control = data;
189
 
 
190
 
        if ((state->m_control & 0x0f) == 0)
191
 
        {
192
 
                LOG(("disabling nmi generate timer\n"));
193
 
                state->m_nmi_timer->adjust(attotime::never);
194
 
        }
195
 
        else
196
 
        {
197
 
                LOG(("setting nmi generate timer to 200us\n"));
198
 
 
199
 
                // this timing is critical. Due to a bug, Bosconian will stop responding to
200
 
                // inputs if a transfer terminates at the wrong time.
201
 
                // On the other hand, the time cannot be too short otherwise the 54XX will
202
 
                // not have enough time to process the incoming controls.
203
 
                state->m_nmi_timer->adjust(attotime::from_usec(200), 0, attotime::from_usec(200));
204
 
 
205
 
                if (state->m_control & 0x10)
206
 
                        for (devnum = 0; devnum < 4; devnum++)
207
 
                                if ((state->m_control & (1 << devnum)) && state->m_readreq[devnum] != NULL)
208
 
                                        (*state->m_readreq[devnum])(state->m_device[devnum]);
209
 
        }
210
 
}
211
 
 
212
 
 
213
 
/***************************************************************************
214
 
    DEVICE INTERFACE
215
 
***************************************************************************/
216
 
 
217
 
/*-------------------------------------------------
218
 
    device start callback
219
 
-------------------------------------------------*/
220
 
 
221
 
static DEVICE_START( namco_06xx )
222
 
{
223
 
        const namco_06xx_config *config = (const namco_06xx_config *)downcast<const legacy_device_base *>(device)->inline_config();
224
 
        namco_06xx_state *state = get_safe_token(device);
225
 
        int devnum;
226
 
 
227
 
        assert(config != NULL);
228
 
 
229
 
        /* resolve our CPU */
230
 
        state->m_nmicpu = device->machine().device<cpu_device>(config->nmicpu);
231
 
        assert(state->m_nmicpu != NULL);
232
 
 
233
 
        /* resolve our devices */
234
 
        state->m_device[0] = (config->chip0 != NULL) ? device->machine().device(config->chip0) : NULL;
235
 
        assert(state->m_device[0] != NULL || config->chip0 == NULL);
236
 
        state->m_device[1] = (config->chip1 != NULL) ? device->machine().device(config->chip1) : NULL;
237
 
        assert(state->m_device[1] != NULL || config->chip1 == NULL);
238
 
        state->m_device[2] = (config->chip2 != NULL) ? device->machine().device(config->chip2) : NULL;
239
 
        assert(state->m_device[2] != NULL || config->chip2 == NULL);
240
 
        state->m_device[3] = (config->chip3 != NULL) ? device->machine().device(config->chip3) : NULL;
241
 
        assert(state->m_device[3] != NULL || config->chip3 == NULL);
242
 
 
243
 
        /* loop over devices and set their read/write handlers */
244
 
        for (devnum = 0; devnum < 4; devnum++)
245
 
                if (state->m_device[devnum] != NULL)
246
 
                {
247
 
                        device_type type = state->m_device[devnum]->type();
248
 
 
249
 
                        if (type == NAMCO_50XX)
250
 
                        {
251
 
                                state->m_read[devnum] = namco_50xx_read;
252
 
                                state->m_readreq[devnum] = namco_50xx_read_request;
253
 
                                state->m_write[devnum] = namco_50xx_write;
254
 
                        }
255
 
                        else if (type == NAMCO_51XX)
256
 
                        {
257
 
                                state->m_read[devnum] = namco_51xx_read;
258
 
                                state->m_write[devnum] = namco_51xx_write;
259
 
                        }
260
 
                        else if (type == NAMCO_52XX)
261
 
                                state->m_write[devnum] = namco_52xx_write;
262
 
                        else if (type == NAMCO_53XX)
263
 
                        {
264
 
                                state->m_read[devnum] = namco_53xx_read;
265
 
                                state->m_readreq[devnum] = namco_53xx_read_request;
266
 
                        }
267
 
                        else if (type == NAMCO_54XX)
268
 
                                state->m_write[devnum] = namco_54xx_write;
269
 
                        else
270
 
                                fatalerror("Unknown device type %s connected to Namco 06xx", state->m_device[devnum]->name());
271
 
                }
272
 
 
273
 
        /* allocate a timer */
274
 
        state->m_nmi_timer = device->machine().scheduler().timer_alloc(FUNC(nmi_generate), (void *)device);
275
 
 
276
 
        device->save_item(NAME(state->m_control));
277
 
}
278
 
 
279
 
 
280
 
/*-------------------------------------------------
281
 
    device reset callback
282
 
-------------------------------------------------*/
283
 
 
284
 
static DEVICE_RESET( namco_06xx )
285
 
{
286
 
        namco_06xx_state *state = get_safe_token(device);
287
 
        state->m_control = 0;
288
 
}
289
 
 
290
 
 
291
 
/*-------------------------------------------------
292
 
    device definition
293
 
-------------------------------------------------*/
294
 
 
295
 
static const char DEVTEMPLATE_SOURCE[] = __FILE__;
296
 
 
297
 
#define DEVTEMPLATE_ID(p,s)             p##namco_06xx##s
298
 
#define DEVTEMPLATE_FEATURES    DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG
299
 
#define DEVTEMPLATE_NAME                "Namco 06xx"
300
 
#define DEVTEMPLATE_FAMILY              "Namco I/O"
301
 
#define DEVTEMPLATE_SHORTNAME   "namco06xx"
302
 
#include "devtempl.h"
303
 
 
304
 
 
305
 
DEFINE_LEGACY_DEVICE(NAMCO_06XX, namco_06xx);