~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/mame/machine/mcr.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
 
    Midway MCR system
4
 
 
5
 
***************************************************************************/
6
 
 
7
 
#include "emu.h"
8
 
#include "deprecat.h"
9
 
#include "audio/mcr.h"
10
 
#include "includes/mcr.h"
11
 
 
12
 
#define VERBOSE 0
13
 
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
14
 
 
15
 
 
16
 
/*************************************
17
 
 *
18
 
 *  Global variables
19
 
 *
20
 
 *************************************/
21
 
 
22
 
UINT8 mcr_cocktail_flip;
23
 
 
24
 
UINT32 mcr_cpu_board;
25
 
UINT32 mcr_sprite_board;
26
 
 
27
 
 
28
 
 
29
 
/*************************************
30
 
 *
31
 
 *  Statics
32
 
 *
33
 
 *************************************/
34
 
 
35
 
static emu_timer *ipu_watchdog_timer;
36
 
 
37
 
 
38
 
/*************************************
39
 
 *
40
 
 *  Function prototypes
41
 
 *
42
 
 *************************************/
43
 
 
44
 
static TIMER_CALLBACK( ipu_watchdog_reset );
45
 
static WRITE8_DEVICE_HANDLER( ipu_break_changed );
46
 
 
47
 
 
48
 
 
49
 
/*************************************
50
 
 *
51
 
 *  Graphics declarations
52
 
 *
53
 
 *************************************/
54
 
 
55
 
const gfx_layout mcr_bg_layout =
56
 
{
57
 
        8,8,
58
 
        RGN_FRAC(1,2),
59
 
        4,
60
 
        { STEP2(RGN_FRAC(1,2),1), STEP2(RGN_FRAC(0,2),1) },
61
 
        { STEP8(0,2) },
62
 
        { STEP8(0,16) },
63
 
        16*8
64
 
};
65
 
 
66
 
 
67
 
const gfx_layout mcr_sprite_layout =
68
 
{
69
 
        32,32,
70
 
        RGN_FRAC(1,4),
71
 
        4,
72
 
        { STEP4(0,1) },
73
 
        { STEP2(RGN_FRAC(0,4)+0,4), STEP2(RGN_FRAC(1,4)+0,4), STEP2(RGN_FRAC(2,4)+0,4), STEP2(RGN_FRAC(3,4)+0,4),
74
 
          STEP2(RGN_FRAC(0,4)+8,4), STEP2(RGN_FRAC(1,4)+8,4), STEP2(RGN_FRAC(2,4)+8,4), STEP2(RGN_FRAC(3,4)+8,4),
75
 
          STEP2(RGN_FRAC(0,4)+16,4), STEP2(RGN_FRAC(1,4)+16,4), STEP2(RGN_FRAC(2,4)+16,4), STEP2(RGN_FRAC(3,4)+16,4),
76
 
          STEP2(RGN_FRAC(0,4)+24,4), STEP2(RGN_FRAC(1,4)+24,4), STEP2(RGN_FRAC(2,4)+24,4), STEP2(RGN_FRAC(3,4)+24,4) },
77
 
        { STEP32(0,32) },
78
 
        32*32
79
 
};
80
 
 
81
 
 
82
 
 
83
 
/*************************************
84
 
 *
85
 
 *  Generic MCR CTC interface
86
 
 *
87
 
 *************************************/
88
 
 
89
 
const z80_daisy_config mcr_daisy_chain[] =
90
 
{
91
 
        { "ctc" },
92
 
        { NULL }
93
 
};
94
 
 
95
 
 
96
 
const z80_daisy_config mcr_ipu_daisy_chain[] =
97
 
{
98
 
        { "ipu_ctc" },
99
 
        { "ipu_pio1" },
100
 
        { "ipu_sio" },
101
 
        { "ipu_pio0" },
102
 
        { NULL }
103
 
};
104
 
 
105
 
 
106
 
Z80CTC_INTERFACE( mcr_ctc_intf )
107
 
{
108
 
        0,                                      /* timer disables */
109
 
        DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0),       /* interrupt handler */
110
 
        DEVCB_LINE(z80ctc_trg1_w),      /* ZC/TO0 callback */
111
 
        DEVCB_NULL,                     /* ZC/TO1 callback */
112
 
        DEVCB_NULL                      /* ZC/TO2 callback */
113
 
};
114
 
 
115
 
 
116
 
Z80CTC_INTERFACE( nflfoot_ctc_intf )
117
 
{
118
 
        0,                  /* timer disables */
119
 
        DEVCB_CPU_INPUT_LINE("ipu", INPUT_LINE_IRQ0),  /* interrupt handler */
120
 
        DEVCB_NULL,                     /* ZC/TO0 callback */
121
 
        DEVCB_NULL,                     /* ZC/TO1 callback */
122
 
        DEVCB_NULL              /* ZC/TO2 callback */
123
 
};
124
 
 
125
 
 
126
 
Z80PIO_INTERFACE( nflfoot_pio_intf )
127
 
{
128
 
        DEVCB_CPU_INPUT_LINE("ipu", INPUT_LINE_IRQ0),  /* interrupt handler */
129
 
        DEVCB_NULL,
130
 
        DEVCB_NULL,
131
 
        DEVCB_NULL,
132
 
        DEVCB_NULL,
133
 
        DEVCB_NULL,
134
 
        DEVCB_NULL
135
 
};
136
 
 
137
 
 
138
 
static WRITE_LINE_DEVICE_HANDLER( ipu_ctc_interrupt )
139
 
{
140
 
        cputag_set_input_line(device->machine(), "ipu", 0, state);
141
 
}
142
 
 
143
 
 
144
 
const z80sio_interface nflfoot_sio_intf =
145
 
{
146
 
        ipu_ctc_interrupt,      /* interrupt handler */
147
 
        0,                                      /* DTR changed handler */
148
 
        0,                                      /* RTS changed handler */
149
 
        ipu_break_changed,      /* BREAK changed handler */
150
 
        mcr_ipu_sio_transmit/* transmit handler */
151
 
};
152
 
 
153
 
 
154
 
 
155
 
/*************************************
156
 
 *
157
 
 *  Generic MCR machine initialization
158
 
 *
159
 
 *************************************/
160
 
 
161
 
MACHINE_START( mcr )
162
 
{
163
 
        state_save_register_global(machine, mcr_cocktail_flip);
164
 
}
165
 
 
166
 
 
167
 
MACHINE_START( nflfoot )
168
 
{
169
 
        /* allocate a timer for the IPU watchdog */
170
 
        ipu_watchdog_timer = machine.scheduler().timer_alloc(FUNC(ipu_watchdog_reset));
171
 
}
172
 
 
173
 
 
174
 
MACHINE_RESET( mcr )
175
 
{
176
 
        /* reset cocktail flip */
177
 
        mcr_cocktail_flip = 0;
178
 
 
179
 
        /* initialize the sound */
180
 
        mcr_sound_reset(machine);
181
 
}
182
 
 
183
 
 
184
 
 
185
 
/*************************************
186
 
 *
187
 
 *  Generic MCR interrupt handler
188
 
 *
189
 
 *************************************/
190
 
 
191
 
INTERRUPT_GEN( mcr_interrupt )
192
 
{
193
 
        device_t *ctc = device->machine().device("ctc");
194
 
 
195
 
        /* CTC line 2 is connected to VBLANK, which is once every 1/2 frame */
196
 
        /* for the 30Hz interlaced display */
197
 
        z80ctc_trg2_w(ctc, 1);
198
 
        z80ctc_trg2_w(ctc, 0);
199
 
 
200
 
        /* CTC line 3 is connected to 493, which is signalled once every */
201
 
        /* frame at 30Hz */
202
 
        if (cpu_getiloops(device) == 0)
203
 
        {
204
 
                z80ctc_trg3_w(ctc, 1);
205
 
                z80ctc_trg3_w(ctc, 0);
206
 
        }
207
 
}
208
 
 
209
 
 
210
 
INTERRUPT_GEN( mcr_ipu_interrupt )
211
 
{
212
 
        device_t *ctc = device->machine().device("ipu_ctc");
213
 
 
214
 
        /* CTC line 3 is connected to 493, which is signalled once every */
215
 
        /* frame at 30Hz */
216
 
        if (cpu_getiloops(device) == 0)
217
 
        {
218
 
                z80ctc_trg3_w(ctc, 1);
219
 
                z80ctc_trg3_w(ctc, 0);
220
 
        }
221
 
}
222
 
 
223
 
 
224
 
/*************************************
225
 
 *
226
 
 *  Generic MCR port write handlers
227
 
 *
228
 
 *************************************/
229
 
 
230
 
WRITE8_HANDLER( mcr_control_port_w )
231
 
{
232
 
        /*
233
 
        Bit layout is as follows:
234
 
            D7 = n/c
235
 
            D6 = cocktail flip
236
 
            D5 = red LED
237
 
            D4 = green LED
238
 
            D3 = n/c
239
 
            D2 = coin meter 3
240
 
            D1 = coin meter 2
241
 
            D0 = coin meter 1
242
 
    */
243
 
 
244
 
        coin_counter_w(space->machine(), 0, (data >> 0) & 1);
245
 
        coin_counter_w(space->machine(), 1, (data >> 1) & 1);
246
 
        coin_counter_w(space->machine(), 2, (data >> 2) & 1);
247
 
        mcr_cocktail_flip = (data >> 6) & 1;
248
 
}
249
 
 
250
 
 
251
 
/*************************************
252
 
 *
253
 
 *  NFL Football IPU board
254
 
 *
255
 
 *************************************/
256
 
 
257
 
static WRITE8_DEVICE_HANDLER( ipu_break_changed )
258
 
{
259
 
        /* channel B is connected to the CED player */
260
 
        if (offset == 1)
261
 
        {
262
 
                logerror("DTR changed -> %d\n", data);
263
 
                if (data == 1)
264
 
                        z80sio_receive_data(device, 1, 0);
265
 
        }
266
 
}
267
 
 
268
 
 
269
 
WRITE8_HANDLER( mcr_ipu_laserdisk_w )
270
 
{
271
 
        /* bit 3 enables (1) LD video regardless of PIX SW */
272
 
        /* bit 2 enables (1) LD right channel audio */
273
 
        /* bit 1 enables (1) LD left channel audio */
274
 
        /* bit 0 enables (1) LD video if PIX SW == 1 */
275
 
        if (data != 0)
276
 
                logerror("%04X:mcr_ipu_laserdisk_w(%d) = %02X\n", cpu_get_pc(&space->device()), offset, data);
277
 
}
278
 
 
279
 
 
280
 
static TIMER_CALLBACK( ipu_watchdog_reset )
281
 
{
282
 
        logerror("ipu_watchdog_reset\n");
283
 
        cputag_set_input_line(machine, "ipu", INPUT_LINE_RESET, PULSE_LINE);
284
 
        devtag_reset(machine, "ipu_ctc");
285
 
        devtag_reset(machine, "ipu_pio0");
286
 
        devtag_reset(machine, "ipu_pio1");
287
 
        devtag_reset(machine, "ipu_sio");
288
 
}
289
 
 
290
 
 
291
 
READ8_HANDLER( mcr_ipu_watchdog_r )
292
 
{
293
 
        /* watchdog counter is clocked by 7.3728MHz crystal / 16 */
294
 
        /* watchdog is tripped when 14-bit counter overflows => / 32768 = 14.0625Hz*/
295
 
        ipu_watchdog_timer->adjust(attotime::from_hz(7372800 / 16 / 32768));
296
 
        return 0xff;
297
 
}
298
 
 
299
 
 
300
 
WRITE8_HANDLER( mcr_ipu_watchdog_w )
301
 
{
302
 
        mcr_ipu_watchdog_r(space,0);
303
 
}