~ubuntu-branches/debian/wheezy/mame/wheezy

« back to all changes in this revision

Viewing changes to src/mame/drivers/mcr3.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
#include "audio/mcr.h"
109
109
#include "machine/nvram.h"
110
110
#include "includes/mcr.h"
 
111
#include "includes/mcr3.h"
111
112
 
112
113
#include "turbotag.lh"
113
114
 
116
117
 
117
118
 
118
119
 
119
 
/*************************************
120
 
 *
121
 
 *  Local variables and tables
122
 
 *
123
 
 *************************************/
124
 
 
125
 
static UINT8 input_mux;
126
 
static UINT8 latched_input;
127
 
 
128
 
static UINT8 last_op4;
129
 
 
130
 
static UINT8 maxrpm_adc_control;
131
 
static UINT8 maxrpm_adc_select;
132
 
static UINT8 maxrpm_last_shift;
133
 
static INT8 maxrpm_p1_shift;
134
 
static INT8 maxrpm_p2_shift;
135
 
 
 
120
static WRITE8_HANDLER( mcrmono_control_port_w )
 
121
{
 
122
        /*
 
123
        Bit layout is as follows:
 
124
            D7 = n/c
 
125
            D6 = cocktail flip
 
126
            D5 = n/c
 
127
            D4 = n/c
 
128
            D3 = n/c
 
129
            D2 = n/c
 
130
            D1 = n/c
 
131
            D0 = coin meter 1
 
132
    */
 
133
 
 
134
        coin_counter_w(space->machine(), 0, (data >> 0) & 1);
 
135
        mcr_cocktail_flip = (data >> 6) & 1;
 
136
}
136
137
 
137
138
 
138
139
/*************************************
143
144
 
144
145
static READ8_HANDLER( demoderm_ip1_r )
145
146
{
146
 
        return input_port_read(space->machine, "MONO.IP1") |
147
 
                (input_port_read(space->machine, input_mux ? "MONO.IP1.ALT2" : "MONO.IP1.ALT1") << 2);
 
147
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
 
148
        return input_port_read(space->machine(), "MONO.IP1") |
 
149
                (input_port_read(space->machine(), state->m_input_mux ? "MONO.IP1.ALT2" : "MONO.IP1.ALT1") << 2);
148
150
}
149
151
 
150
152
 
151
153
static READ8_HANDLER( demoderm_ip2_r )
152
154
{
153
 
        return input_port_read(space->machine, "MONO.IP2") |
154
 
                (input_port_read(space->machine, input_mux ? "MONO.IP2.ALT2" : "MONO.IP2.ALT1") << 2);
 
155
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
 
156
        return input_port_read(space->machine(), "MONO.IP2") |
 
157
                (input_port_read(space->machine(), state->m_input_mux ? "MONO.IP2.ALT2" : "MONO.IP2.ALT1") << 2);
155
158
}
156
159
 
157
160
 
158
161
static WRITE8_HANDLER( demoderm_op6_w )
159
162
{
 
163
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
160
164
        /* top 2 bits select the input */
161
 
        if (data & 0x80) input_mux = 0;
162
 
        if (data & 0x40) input_mux = 1;
 
165
        if (data & 0x80) state->m_input_mux = 0;
 
166
        if (data & 0x40) state->m_input_mux = 1;
163
167
 
164
168
        /* low 5 bits control the turbo CS */
165
169
        turbocs_data_w(space, offset, data);
175
179
 
176
180
static READ8_HANDLER( maxrpm_ip1_r )
177
181
{
178
 
        return latched_input;
 
182
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
 
183
        return state->m_latched_input;
179
184
}
180
185
 
181
186
 
182
187
static READ8_HANDLER( maxrpm_ip2_r )
183
188
{
 
189
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
184
190
        static const UINT8 shift_bits[5] = { 0x00, 0x05, 0x06, 0x01, 0x02 };
185
 
        UINT8 start = input_port_read(space->machine, "MONO.IP0");
186
 
        UINT8 shift = input_port_read(space->machine, "SHIFT");
 
191
        UINT8 start = input_port_read(space->machine(), "MONO.IP0");
 
192
        UINT8 shift = input_port_read(space->machine(), "SHIFT");
187
193
 
188
194
        /* reset on a start */
189
195
        if (!(start & 0x08))
190
 
                maxrpm_p1_shift = 0;
 
196
                state->m_maxrpm_p1_shift = 0;
191
197
        if (!(start & 0x04))
192
 
                maxrpm_p2_shift = 0;
 
198
                state->m_maxrpm_p2_shift = 0;
193
199
 
194
200
        /* increment, decrement on falling edge */
195
 
        if (!(shift & 0x01) && (maxrpm_last_shift & 0x01))
196
 
        {
197
 
                maxrpm_p1_shift++;
198
 
                if (maxrpm_p1_shift > 4)
199
 
                        maxrpm_p1_shift = 4;
200
 
        }
201
 
        if (!(shift & 0x02) && (maxrpm_last_shift & 0x02))
202
 
        {
203
 
                maxrpm_p1_shift--;
204
 
                if (maxrpm_p1_shift < 0)
205
 
                        maxrpm_p1_shift = 0;
206
 
        }
207
 
        if (!(shift & 0x04) && (maxrpm_last_shift & 0x04))
208
 
        {
209
 
                maxrpm_p2_shift++;
210
 
                if (maxrpm_p2_shift > 4)
211
 
                        maxrpm_p2_shift = 4;
212
 
        }
213
 
        if (!(shift & 0x08) && (maxrpm_last_shift & 0x08))
214
 
        {
215
 
                maxrpm_p2_shift--;
216
 
                if (maxrpm_p2_shift < 0)
217
 
                        maxrpm_p2_shift = 0;
218
 
        }
219
 
 
220
 
        maxrpm_last_shift = shift;
221
 
 
222
 
        return ~((shift_bits[maxrpm_p1_shift] << 4) + shift_bits[maxrpm_p2_shift]);
 
201
        if (!(shift & 0x01) && (state->m_maxrpm_last_shift & 0x01))
 
202
        {
 
203
                state->m_maxrpm_p1_shift++;
 
204
                if (state->m_maxrpm_p1_shift > 4)
 
205
                        state->m_maxrpm_p1_shift = 4;
 
206
        }
 
207
        if (!(shift & 0x02) && (state->m_maxrpm_last_shift & 0x02))
 
208
        {
 
209
                state->m_maxrpm_p1_shift--;
 
210
                if (state->m_maxrpm_p1_shift < 0)
 
211
                        state->m_maxrpm_p1_shift = 0;
 
212
        }
 
213
        if (!(shift & 0x04) && (state->m_maxrpm_last_shift & 0x04))
 
214
        {
 
215
                state->m_maxrpm_p2_shift++;
 
216
                if (state->m_maxrpm_p2_shift > 4)
 
217
                        state->m_maxrpm_p2_shift = 4;
 
218
        }
 
219
        if (!(shift & 0x08) && (state->m_maxrpm_last_shift & 0x08))
 
220
        {
 
221
                state->m_maxrpm_p2_shift--;
 
222
                if (state->m_maxrpm_p2_shift < 0)
 
223
                        state->m_maxrpm_p2_shift = 0;
 
224
        }
 
225
 
 
226
        state->m_maxrpm_last_shift = shift;
 
227
 
 
228
        return ~((shift_bits[state->m_maxrpm_p1_shift] << 4) + shift_bits[state->m_maxrpm_p2_shift]);
223
229
}
224
230
 
225
231
 
226
232
static WRITE8_HANDLER( maxrpm_op5_w )
227
233
{
 
234
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
228
235
        /* latch the low 4 bits as input to the ADC0844 */
229
 
        maxrpm_adc_control = data & 0x0f;
 
236
        state->m_maxrpm_adc_control = data & 0x0f;
230
237
 
231
238
        /* remaining bits go to standard connections */
232
239
        mcrmono_control_port_w(space, offset, data);
235
242
 
236
243
static WRITE8_HANDLER( maxrpm_op6_w )
237
244
{
 
245
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
238
246
        static const char *const inputs[] = { "MONO.IP1", "MONO.IP1.ALT1", "MONO.IP1.ALT2", "MONO.IP1.ALT3" };
239
247
        /*
240
248
        Reflective Sensor Control:
256
264
 
257
265
        /* when the read is toggled is when the ADC value is latched */
258
266
        if (!(data & 0x80))
259
 
                latched_input = input_port_read(space->machine, inputs[maxrpm_adc_select]);
 
267
                state->m_latched_input = input_port_read(space->machine(), inputs[state->m_maxrpm_adc_select]);
260
268
 
261
269
        /* when both the write and the enable are low, it's a write to the ADC0844 */
262
270
        /* unfortunately the behavior below doesn't match up with the inputs on the */
263
271
        /* schematics and wiring diagrams, so they must be wrong */
264
272
        if (!(data & 0x40) && !(data & 0x20))
265
 
                maxrpm_adc_select = (maxrpm_adc_control >> 1) & 3;
 
273
                state->m_maxrpm_adc_select = (state->m_maxrpm_adc_control >> 1) & 3;
266
274
 
267
275
        /* low 5 bits control the turbo CS */
268
276
        turbocs_data_w(space, offset, data);
278
286
 
279
287
static READ8_HANDLER( rampage_ip4_r )
280
288
{
281
 
        return input_port_read(space->machine, "MONO.IP4") | (soundsgood_status_r(space,0) << 7);
 
289
        return input_port_read(space->machine(), "MONO.IP4") | (soundsgood_status_r(space,0) << 7);
282
290
}
283
291
 
284
292
 
285
293
static WRITE8_HANDLER( rampage_op6_w )
286
294
{
287
295
        /* bit 5 controls reset of the Sounds Good board */
288
 
        soundsgood_reset_w(space->machine, (~data >> 5) & 1);
 
296
        soundsgood_reset_w(space->machine(), (~data >> 5) & 1);
289
297
 
290
298
        /* low 5 bits go directly to the Sounds Good board */
291
299
        soundsgood_data_w(space, offset, data);
301
309
 
302
310
static READ8_HANDLER( powerdrv_ip2_r )
303
311
{
304
 
        return input_port_read(space->machine, "MONO.IP2") | (soundsgood_status_r(space, 0) << 7);
 
312
        return input_port_read(space->machine(), "MONO.IP2") | (soundsgood_status_r(space, 0) << 7);
305
313
}
306
314
 
307
315
 
317
325
        /* bit 3 -> J1-10 = lamp 1 */
318
326
        /* bit 2 -> J1-8 = lamp 2 */
319
327
        /* bit 1 -> J1-6 = lamp 3 */
320
 
        set_led_status(space->machine, 0, (data >> 3) & 1);
321
 
        set_led_status(space->machine, 1, (data >> 2) & 1);
322
 
        set_led_status(space->machine, 2, (data >> 1) & 1);
 
328
        set_led_status(space->machine(), 0, (data >> 3) & 1);
 
329
        set_led_status(space->machine(), 1, (data >> 2) & 1);
 
330
        set_led_status(space->machine(), 2, (data >> 1) & 1);
323
331
 
324
332
        /* remaining bits go to standard connections */
325
333
        mcrmono_control_port_w(space, offset, data);
329
337
static WRITE8_HANDLER( powerdrv_op6_w )
330
338
{
331
339
        /* bit 5 controls reset of the Sounds Good board */
332
 
        soundsgood_reset_w(space->machine, (~data >> 5) & 1);
 
340
        soundsgood_reset_w(space->machine(), (~data >> 5) & 1);
333
341
 
334
342
        /* low 5 bits go directly to the Sounds Good board */
335
343
        soundsgood_data_w(space, offset, data);
345
353
 
346
354
static READ8_HANDLER( stargrds_ip0_r )
347
355
{
348
 
        UINT8 result = input_port_read(space->machine, "MONO.IP0");
349
 
        if (input_mux)
350
 
                result = (result & ~0x0a) | (input_port_read(space->machine, "MONO.IP0.ALT") & 0x0a);
 
356
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
 
357
        UINT8 result = input_port_read(space->machine(), "MONO.IP0");
 
358
        if (state->m_input_mux)
 
359
                result = (result & ~0x0a) | (input_port_read(space->machine(), "MONO.IP0.ALT") & 0x0a);
351
360
        return (result & ~0x10) | ((soundsgood_status_r(space, 0) << 4) & 0x10);
352
361
}
353
362
 
354
363
 
355
364
static WRITE8_HANDLER( stargrds_op5_w )
356
365
{
 
366
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
357
367
        /* bit 1 controls input muxing on port 0 */
358
 
        input_mux = (data >> 1) & 1;
 
368
        state->m_input_mux = (data >> 1) & 1;
359
369
 
360
370
        /* bit 2 controls light #0 */
361
371
        /* bit 3 controls light #1 */
362
372
        /* bit 4 controls light #2 */
363
 
        set_led_status(space->machine, 0, (data >> 2) & 1);
364
 
        set_led_status(space->machine, 1, (data >> 3) & 1);
365
 
        set_led_status(space->machine, 2, (data >> 4) & 1);
 
373
        set_led_status(space->machine(), 0, (data >> 2) & 1);
 
374
        set_led_status(space->machine(), 1, (data >> 3) & 1);
 
375
        set_led_status(space->machine(), 2, (data >> 4) & 1);
366
376
 
367
377
        /* remaining bits go to standard connections */
368
378
        mcrmono_control_port_w(space, offset, data);
372
382
static WRITE8_HANDLER( stargrds_op6_w )
373
383
{
374
384
        /* bit 6 controls reset of the Sounds Good board */
375
 
        soundsgood_reset_w(space->machine, (~data >> 6) & 1);
 
385
        soundsgood_reset_w(space->machine(), (~data >> 6) & 1);
376
386
 
377
387
        /* unline the other games, the STROBE is in the high bit instead of the low bit */
378
388
        soundsgood_data_w(space, offset, (data << 1) | (data >> 7));
388
398
 
389
399
static READ8_HANDLER( spyhunt_ip1_r )
390
400
{
391
 
        return input_port_read(space->machine, "SSIO.IP1") | (csdeluxe_status_r(space, 0) << 5);
 
401
        return input_port_read(space->machine(), "SSIO.IP1") | (csdeluxe_status_r(space, 0) << 5);
392
402
}
393
403
 
394
404
 
395
405
static READ8_HANDLER( spyhunt_ip2_r )
396
406
{
 
407
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
397
408
        /* multiplexed steering wheel/gas pedal */
398
 
        return input_port_read(space->machine, input_mux ? "SSIO.IP2.ALT" : "SSIO.IP2");
 
409
        return input_port_read(space->machine(), state->m_input_mux ? "SSIO.IP2.ALT" : "SSIO.IP2");
399
410
}
400
411
 
401
412
 
402
413
static WRITE8_HANDLER( spyhunt_op4_w )
403
414
{
 
415
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
404
416
        /* Spy Hunter uses port 4 for talking to the Chip Squeak Deluxe */
405
417
        /* (and for toggling the lamps and muxing the analog inputs) */
406
418
 
407
419
        /* mux select is in bit 7 */
408
 
        input_mux = (data >> 7) & 1;
 
420
        state->m_input_mux = (data >> 7) & 1;
409
421
 
410
422
        /*
411
423
        Lamp Driver:
416
428
            demuxer. The eight outputs directly control 8 lamps.
417
429
    */
418
430
        /* bit 5 = STR1 (J1-13) */
419
 
        if (((last_op4 ^ data) & 0x20) && !(data & 0x20))
 
431
        if (((state->m_last_op4 ^ data) & 0x20) && !(data & 0x20))
420
432
        {
421
433
                static const char *const lampname[8] =
422
434
                {
429
441
                /* bit 0 -> J1-12 (A0) */
430
442
                output_set_value(lampname[data & 7], (data >> 3) & 1);
431
443
        }
432
 
        last_op4 = data;
 
444
        state->m_last_op4 = data;
433
445
 
434
446
        /* low 5 bits go to control the Chip Squeak Deluxe */
435
447
        csdeluxe_data_w(space, offset, data);
445
457
 
446
458
static READ8_HANDLER( turbotag_ip2_r )
447
459
{
 
460
        mcr3_state *state = space->machine().driver_data<mcr3_state>();
448
461
        /* multiplexed steering wheel/gas pedal */
449
 
        if (input_mux)
450
 
                return input_port_read(space->machine, "SSIO.IP2.ALT");
 
462
        if (state->m_input_mux)
 
463
                return input_port_read(space->machine(), "SSIO.IP2.ALT");
451
464
 
452
 
        return input_port_read(space->machine, "SSIO.IP2") + 5 * (space->machine->primary_screen->frame_number() & 1);
 
465
        return input_port_read(space->machine(), "SSIO.IP2") + 5 * (space->machine().primary_screen->frame_number() & 1);
453
466
}
454
467
 
455
468
 
460
473
        /* Unfortunately, the game refuses to start if any bad ROM is   */
461
474
        /* found; to work around this, we catch the checksum byte read  */
462
475
        /* and modify it to what we know we will be getting.            */
463
 
        if (cpu_get_previouspc(space->cpu) == 0xb29)
 
476
        if (cpu_get_previouspc(&space->device()) == 0xb29)
464
477
                return 0x82;
465
478
        else
466
479
                return 0x92;
475
488
 *************************************/
476
489
 
477
490
/* address map verified from schematics */
478
 
static ADDRESS_MAP_START( mcrmono_map, ADDRESS_SPACE_PROGRAM, 8 )
 
491
static ADDRESS_MAP_START( mcrmono_map, AS_PROGRAM, 8 )
479
492
        ADDRESS_MAP_UNMAP_HIGH
480
493
        AM_RANGE(0x0000, 0xdfff) AM_ROM
481
494
        AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_SHARE("nvram")
482
 
        AM_RANGE(0xe800, 0xe9ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
 
495
        AM_RANGE(0xe800, 0xe9ff) AM_RAM AM_BASE_SIZE_MEMBER(mcr3_state, m_spriteram, m_spriteram_size)
483
496
        AM_RANGE(0xea00, 0xebff) AM_RAM
484
497
        AM_RANGE(0xec00, 0xec7f) AM_MIRROR(0x0380) AM_WRITE(mcr3_paletteram_w) AM_BASE_GENERIC(paletteram)
485
 
        AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(mcr3_videoram_w) AM_BASE_MEMBER(mcr_state, videoram)
 
498
        AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(mcr3_videoram_w) AM_BASE_MEMBER(mcr3_state, m_videoram)
486
499
        AM_RANGE(0xf800, 0xffff) AM_ROM         /* schematics show a 2716 @ 2B here, but nobody used it */
487
500
ADDRESS_MAP_END
488
501
 
489
502
/* I/O map verified from schematics */
490
 
static ADDRESS_MAP_START( mcrmono_portmap, ADDRESS_SPACE_IO, 8 )
 
503
static ADDRESS_MAP_START( mcrmono_portmap, AS_IO, 8 )
491
504
        ADDRESS_MAP_UNMAP_HIGH
492
505
        ADDRESS_MAP_GLOBAL_MASK(0xff)
493
506
        AM_RANGE(0x00, 0x00) AM_MIRROR(0x78) AM_READ_PORT("MONO.IP0")
509
522
 *************************************/
510
523
 
511
524
/* address map verified from schematics */
512
 
static ADDRESS_MAP_START( spyhunt_map, ADDRESS_SPACE_PROGRAM, 8 )
 
525
static ADDRESS_MAP_START( spyhunt_map, AS_PROGRAM, 8 )
513
526
        ADDRESS_MAP_UNMAP_HIGH
514
527
        AM_RANGE(0x0000, 0xdfff) AM_ROM
515
 
        AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(spyhunt_videoram_w) AM_BASE_MEMBER(mcr_state, videoram)
516
 
        AM_RANGE(0xe800, 0xebff) AM_MIRROR(0x0400) AM_RAM_WRITE(spyhunt_alpharam_w) AM_BASE(&spyhunt_alpharam)
 
528
        AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(spyhunt_videoram_w) AM_BASE_MEMBER(mcr3_state, m_videoram)
 
529
        AM_RANGE(0xe800, 0xebff) AM_MIRROR(0x0400) AM_RAM_WRITE(spyhunt_alpharam_w) AM_BASE_MEMBER(mcr3_state, m_spyhunt_alpharam)
517
530
        AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_SHARE("nvram")
518
 
        AM_RANGE(0xf800, 0xf9ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
 
531
        AM_RANGE(0xf800, 0xf9ff) AM_RAM AM_BASE_SIZE_MEMBER(mcr3_state, m_spriteram, m_spriteram_size)
519
532
        AM_RANGE(0xfa00, 0xfa7f) AM_MIRROR(0x0180) AM_WRITE(mcr3_paletteram_w) AM_BASE_GENERIC(paletteram)
520
533
ADDRESS_MAP_END
521
534
 
522
535
/* upper I/O map determined by PAL; only SSIO ports and scroll registers are verified from schematics */
523
 
static ADDRESS_MAP_START( spyhunt_portmap, ADDRESS_SPACE_IO, 8 )
 
536
static ADDRESS_MAP_START( spyhunt_portmap, AS_IO, 8 )
524
537
        ADDRESS_MAP_UNMAP_HIGH
525
538
        ADDRESS_MAP_GLOBAL_MASK(0xff)
526
539
        SSIO_INPUT_PORTS
527
 
        AM_RANGE(0x84, 0x86) AM_WRITE(mcr_scroll_value_w)
 
540
        AM_RANGE(0x84, 0x86) AM_WRITE(spyhunt_scroll_value_w)
528
541
        AM_RANGE(0xe0, 0xe0) AM_WRITE(watchdog_reset_w)
529
542
        AM_RANGE(0xe8, 0xe8) AM_WRITENOP
530
543
        AM_RANGE(0xf0, 0xf3) AM_DEVREADWRITE("ctc", z80ctc_r, z80ctc_w)
1073
1086
 *
1074
1087
 *************************************/
1075
1088
 
1076
 
/* Core MCR3 system with no sound */
1077
 
static MACHINE_CONFIG_START( mcr3_base, mcr_state )
 
1089
/* Core MCR monoboard system with no sound */
 
1090
static MACHINE_CONFIG_START( mcrmono, mcr3_state )
1078
1091
 
1079
1092
        /* basic machine hardware */
1080
1093
        MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK/4)
 
1094
        MCFG_CPU_PROGRAM_MAP(mcrmono_map)
 
1095
        MCFG_CPU_IO_MAP(mcrmono_portmap)
1081
1096
        MCFG_CPU_CONFIG(mcr_daisy_chain)
1082
1097
        MCFG_CPU_VBLANK_INT_HACK(mcr_interrupt,2)
1083
1098
 
1097
1112
        MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1098
1113
        MCFG_SCREEN_SIZE(32*16, 30*16)
1099
1114
        MCFG_SCREEN_VISIBLE_AREA(0*16, 32*16-1, 0*16, 30*16-1)
 
1115
        MCFG_SCREEN_UPDATE(mcr3)
1100
1116
 
1101
1117
        MCFG_GFXDECODE(mcr3)
1102
1118
        MCFG_PALETTE_LENGTH(64)
1103
1119
 
1104
 
        MCFG_VIDEO_START(mcr)
1105
 
        MCFG_VIDEO_UPDATE(mcr)
1106
 
MACHINE_CONFIG_END
1107
 
 
1108
 
 
1109
 
/*************************************/
1110
 
 
1111
 
 
1112
 
/* Core MCR monoboard system with no sound */
1113
 
static MACHINE_CONFIG_DERIVED( mcrmono, mcr3_base )
1114
 
 
1115
 
        /* basic machine hardware */
1116
 
 
1117
 
        MCFG_CPU_MODIFY("maincpu")
1118
 
        MCFG_CPU_PROGRAM_MAP(mcrmono_map)
1119
 
        MCFG_CPU_IO_MAP(mcrmono_portmap)
1120
 
 
1121
 
        /* video hardware */
1122
1120
        MCFG_VIDEO_START(mcrmono)
1123
 
        MCFG_VIDEO_UPDATE(mcr3)
1124
1121
MACHINE_CONFIG_END
1125
1122
 
1126
1123
 
 
1124
/*************************************/
 
1125
 
 
1126
 
1127
1127
/* Sarge/Demolition Derby Mono/Max RPM = MCR monoboard with Turbo Chip Squeak */
1128
1128
static MACHINE_CONFIG_DERIVED( mono_tcs, mcrmono )
1129
1129
 
1144
1144
 
1145
1145
 
1146
1146
/* Core scrolling system with SSIO sound */
1147
 
static MACHINE_CONFIG_DERIVED( mcrscroll, mcr3_base )
 
1147
static MACHINE_CONFIG_DERIVED( mcrscroll, mcrmono )
1148
1148
 
1149
1149
        /* basic machine hardware */
1150
1150
        MCFG_FRAGMENT_ADD(mcr_ssio)
1157
1157
        MCFG_SCREEN_MODIFY("screen")
1158
1158
        MCFG_SCREEN_SIZE(30*16, 30*16)
1159
1159
        MCFG_SCREEN_VISIBLE_AREA(0, 30*16-1, 0, 30*16-1)
 
1160
        MCFG_SCREEN_UPDATE(spyhunt)
1160
1161
        MCFG_GFXDECODE(spyhunt)
1161
1162
        MCFG_PALETTE_LENGTH(64+4)
1162
1163
 
1163
1164
        MCFG_PALETTE_INIT(spyhunt)
1164
1165
        MCFG_VIDEO_START(spyhunt)
1165
 
        MCFG_VIDEO_UPDATE(spyhunt)
1166
1166
MACHINE_CONFIG_END
1167
1167
 
1168
1168
 
1527
1527
 *
1528
1528
 *************************************/
1529
1529
 
1530
 
static void mcr_common_init(running_machine *machine, int sound_board)
 
1530
static void mcr_common_init(running_machine &machine, int sound_board)
1531
1531
{
 
1532
        mcr3_state *state = machine.driver_data<mcr3_state>();
1532
1533
        mcr_sound_init(machine, sound_board);
1533
1534
 
1534
 
        state_save_register_global(machine, input_mux);
1535
 
        state_save_register_global(machine, latched_input);
1536
 
        state_save_register_global(machine, last_op4);
 
1535
        state_save_register_global(machine, state->m_input_mux);
 
1536
        state_save_register_global(machine, state->m_latched_input);
 
1537
        state_save_register_global(machine, state->m_last_op4);
1537
1538
}
1538
1539
 
1539
1540
 
1540
1541
static DRIVER_INIT( demoderm )
1541
1542
{
1542
1543
        mcr_common_init(machine, MCR_TURBO_CHIP_SQUEAK);
1543
 
        memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x01, 0x01, 0, 0, demoderm_ip1_r);
1544
 
        memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x02, 0x02, 0, 0, demoderm_ip2_r);
1545
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x06, 0x06, 0, 0, demoderm_op6_w);
 
1544
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x01, 0x01, FUNC(demoderm_ip1_r));
 
1545
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x02, 0x02, FUNC(demoderm_ip2_r));
 
1546
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x06, 0x06, FUNC(demoderm_op6_w));
1546
1547
}
1547
1548
 
1548
1549
 
1549
1550
static DRIVER_INIT( sarge )
1550
1551
{
1551
1552
        mcr_common_init(machine, MCR_TURBO_CHIP_SQUEAK);
1552
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x06, 0x06, 0, 0, turbocs_data_w);
 
1553
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x06, 0x06, FUNC(turbocs_data_w));
1553
1554
}
1554
1555
 
1555
1556
 
1556
1557
static DRIVER_INIT( maxrpm )
1557
1558
{
 
1559
        mcr3_state *state = machine.driver_data<mcr3_state>();
1558
1560
        mcr_common_init(machine, MCR_TURBO_CHIP_SQUEAK);
1559
 
        memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x01, 0x01, 0, 0, maxrpm_ip1_r);
1560
 
        memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x02, 0x02, 0, 0, maxrpm_ip2_r);
1561
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x05, 0x05, 0, 0, maxrpm_op5_w);
1562
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x06, 0x06, 0, 0, maxrpm_op6_w);
 
1561
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x01, 0x01, FUNC(maxrpm_ip1_r));
 
1562
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x02, 0x02, FUNC(maxrpm_ip2_r));
 
1563
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x05, 0x05, FUNC(maxrpm_op5_w));
 
1564
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x06, 0x06, FUNC(maxrpm_op6_w));
1563
1565
 
1564
 
        state_save_register_global(machine, maxrpm_adc_control);
1565
 
        state_save_register_global(machine, maxrpm_adc_select);
1566
 
        state_save_register_global(machine, maxrpm_last_shift);
1567
 
        state_save_register_global(machine, maxrpm_p1_shift);
1568
 
        state_save_register_global(machine, maxrpm_p2_shift);
 
1566
        state_save_register_global(machine, state->m_maxrpm_adc_control);
 
1567
        state_save_register_global(machine, state->m_maxrpm_adc_select);
 
1568
        state_save_register_global(machine, state->m_maxrpm_last_shift);
 
1569
        state_save_register_global(machine, state->m_maxrpm_p1_shift);
 
1570
        state_save_register_global(machine, state->m_maxrpm_p2_shift);
1569
1571
}
1570
1572
 
1571
1573
 
1572
1574
static DRIVER_INIT( rampage )
1573
1575
{
1574
1576
        mcr_common_init(machine, MCR_SOUNDS_GOOD);
1575
 
        memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x04, 0x04, 0, 0, rampage_ip4_r);
1576
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x06, 0x06, 0, 0, rampage_op6_w);
 
1577
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x04, 0x04, FUNC(rampage_ip4_r));
 
1578
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x06, 0x06, FUNC(rampage_op6_w));
1577
1579
}
1578
1580
 
1579
1581
 
1580
1582
static DRIVER_INIT( powerdrv )
1581
1583
{
1582
1584
        mcr_common_init(machine, MCR_SOUNDS_GOOD);
1583
 
        memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x02, 0x02, 0, 0, powerdrv_ip2_r);
1584
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x05, 0x05, 0, 0, powerdrv_op5_w);
1585
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x06, 0x06, 0, 0, powerdrv_op6_w);
 
1585
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x02, 0x02, FUNC(powerdrv_ip2_r));
 
1586
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x05, 0x05, FUNC(powerdrv_op5_w));
 
1587
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x06, 0x06, FUNC(powerdrv_op6_w));
1586
1588
}
1587
1589
 
1588
1590
 
1589
1591
static DRIVER_INIT( stargrds )
1590
1592
{
1591
1593
        mcr_common_init(machine, MCR_SOUNDS_GOOD);
1592
 
        memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x00, 0x00, 0, 0, stargrds_ip0_r);
1593
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x05, 0x05, 0, 0, stargrds_op5_w);
1594
 
        memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x06, 0x06, 0, 0, stargrds_op6_w);
 
1594
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x00, 0x00, FUNC(stargrds_ip0_r));
 
1595
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x05, 0x05, FUNC(stargrds_op5_w));
 
1596
        machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x06, 0x06, FUNC(stargrds_op6_w));
1595
1597
}
1596
1598
 
1597
1599
 
1598
1600
static DRIVER_INIT( spyhunt )
1599
1601
{
 
1602
        mcr3_state *state = machine.driver_data<mcr3_state>();
1600
1603
        mcr_common_init(machine, MCR_SSIO | MCR_CHIP_SQUEAK_DELUXE);
1601
1604
        ssio_set_custom_input(1, 0x60, spyhunt_ip1_r);
1602
1605
        ssio_set_custom_input(2, 0xff, spyhunt_ip2_r);
1603
1606
        ssio_set_custom_output(4, 0xff, spyhunt_op4_w);
1604
1607
 
1605
 
        spyhunt_sprite_color_mask = 0x00;
1606
 
        spyhunt_scroll_offset = 16;
 
1608
        state->m_spyhunt_sprite_color_mask = 0x00;
 
1609
        state->m_spyhunt_scroll_offset = 16;
1607
1610
}
1608
1611
 
1609
1612
 
1610
1613
static DRIVER_INIT( crater )
1611
1614
{
 
1615
        mcr3_state *state = machine.driver_data<mcr3_state>();
1612
1616
        mcr_common_init(machine, MCR_SSIO);
1613
1617
 
1614
 
        spyhunt_sprite_color_mask = 0x03;
1615
 
        spyhunt_scroll_offset = 96;
 
1618
        state->m_spyhunt_sprite_color_mask = 0x03;
 
1619
        state->m_spyhunt_scroll_offset = 96;
1616
1620
}
1617
1621
 
1618
1622
 
1619
1623
static DRIVER_INIT( turbotag )
1620
1624
{
 
1625
        mcr3_state *state = machine.driver_data<mcr3_state>();
1621
1626
        mcr_common_init(machine, MCR_SSIO | MCR_CHIP_SQUEAK_DELUXE);
1622
1627
        ssio_set_custom_input(1, 0x60, spyhunt_ip1_r);
1623
1628
        ssio_set_custom_input(2, 0xff, turbotag_ip2_r);
1624
1629
        ssio_set_custom_output(4, 0xff, spyhunt_op4_w);
1625
1630
 
1626
 
        spyhunt_sprite_color_mask = 0x00;
1627
 
        spyhunt_scroll_offset = 88;
 
1631
        state->m_spyhunt_sprite_color_mask = 0x00;
 
1632
        state->m_spyhunt_scroll_offset = 88;
1628
1633
 
1629
1634
        /* the SSIO Z80 doesn't have any program to execute */
1630
 
        machine->device<cpu_device>("csdcpu")->suspend(SUSPEND_REASON_DISABLE, 1);
 
1635
        machine.device<cpu_device>("csdcpu")->suspend(SUSPEND_REASON_DISABLE, 1);
1631
1636
 
1632
1637
        /* kludge for bad ROM read */
1633
 
        memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0b53, 0x0b53, 0, 0, turbotag_kludge_r);
 
1638
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x0b53, 0x0b53, FUNC(turbotag_kludge_r));
1634
1639
}
1635
1640
 
1636
1641
 
1644
1649
/* MCR monoboard games */
1645
1650
GAME( 1984, demoderm, demoderb, mono_tcs,  demoderm, demoderm, ROT0,  "Bally Midway", "Demolition Derby (2-Player Mono Board Version)", GAME_SUPPORTS_SAVE )
1646
1651
GAME( 1985, sarge,    0,        mono_tcs,  sarge,    sarge,    ROT0,  "Bally Midway", "Sarge", GAME_SUPPORTS_SAVE )
1647
 
GAME( 1986, maxrpm,   0,        mono_tcs,  maxrpm,   maxrpm,   ROT0,  "Bally Midway", "Max RPM", GAME_SUPPORTS_SAVE )
1648
 
GAME( 1986, rampage,  0,        mono_sg,   rampage,  rampage,  ROT0,  "Bally Midway", "Rampage (revision 3)", GAME_SUPPORTS_SAVE )
1649
 
GAME( 1986, rampage2, rampage,  mono_sg,   rampage,  rampage,  ROT0,  "Bally Midway", "Rampage (revision 2)", GAME_SUPPORTS_SAVE )
 
1652
GAME( 1986, maxrpm,   0,        mono_tcs,  maxrpm,   maxrpm,   ROT0,  "Bally Midway", "Max RPM (ver 2)", GAME_SUPPORTS_SAVE )
 
1653
GAME( 1986, rampage,  0,        mono_sg,   rampage,  rampage,  ROT0,  "Bally Midway", "Rampage (ver 3 8-27-86)", GAME_SUPPORTS_SAVE )
 
1654
GAME( 1986, rampage2, rampage,  mono_sg,   rampage,  rampage,  ROT0,  "Bally Midway", "Rampage (ver 2 8-4-86)", GAME_SUPPORTS_SAVE )
1650
1655
GAME( 1986, powerdrv, 0,        mono_sg,   powerdrv, powerdrv, ROT0,  "Bally Midway", "Power Drive", GAME_SUPPORTS_SAVE )
1651
1656
GAME( 1987, stargrds, 0,        mono_sg,   stargrds, stargrds, ROT0,  "Bally Midway", "Star Guards", GAME_SUPPORTS_SAVE )
1652
1657