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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
 
174
174
/******************************************************************************/
175
175
 
176
 
static WRITE16_HANDLER( dec0_control_w )
 
176
WRITE16_MEMBER(dec0_state::dec0_control_w)
177
177
{
178
178
        switch (offset << 1)
179
179
        {
188
188
                case 4: /* 6502 sound cpu */
189
189
                        if (ACCESSING_BITS_0_7)
190
190
                        {
191
 
                                soundlatch_w(space, 0, data & 0xff);
192
 
                                cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
 
191
                                soundlatch_byte_w(space, 0, data & 0xff);
 
192
                                cputag_set_input_line(machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
193
193
                        }
194
194
                        break;
195
195
 
196
196
                case 6: /* Intel 8751 microcontroller - Bad Dudes, Heavy Barrel, Birdy Try only */
197
 
                        dec0_i8751_write(space->machine(), data);
 
197
                        dec0_i8751_write(machine(), data);
198
198
                        break;
199
199
 
200
200
                case 8: /* Interrupt ack (VBL - IRQ 6) */
201
 
                        cputag_set_input_line(space->machine(), "maincpu", 6, CLEAR_LINE);
 
201
                        cputag_set_input_line(machine(), "maincpu", 6, CLEAR_LINE);
202
202
                        break;
203
203
 
204
204
                case 0xa: /* Mix Psel(?). */
205
 
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space->device()),data,0x30c010+(offset<<1));
 
205
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space.device()),data,0x30c010+(offset<<1));
206
206
                        break;
207
207
 
208
208
                case 0xc: /* Cblk - coin blockout.  Seems to be unused by the games */
209
209
                        break;
210
210
 
211
211
                case 0xe: /* Reset Intel 8751? - not sure, all the games write here at startup */
212
 
                        dec0_i8751_reset(space->machine());
213
 
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space->device()),data,0x30c010+(offset<<1));
 
212
                        dec0_i8751_reset(machine());
 
213
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space.device()),data,0x30c010+(offset<<1));
214
214
                        break;
215
215
 
216
216
                default:
217
 
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space->device()),data,0x30c010+(offset<<1));
 
217
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space.device()),data,0x30c010+(offset<<1));
218
218
                        break;
219
219
        }
220
220
}
221
221
 
222
222
 
223
 
static WRITE16_HANDLER( automat_control_w )
 
223
WRITE16_MEMBER(dec0_state::automat_control_w)
224
224
{
225
225
        switch (offset << 1)
226
226
        {
227
227
                case 0xe: /* 6502 sound cpu */
228
228
                        if (ACCESSING_BITS_0_7)
229
229
                        {
230
 
                                soundlatch_w(space, 0, data & 0xff);
231
 
                                cputag_set_input_line(space->machine(), "audiocpu", 0, HOLD_LINE);
 
230
                                soundlatch_byte_w(space, 0, data & 0xff);
 
231
                                cputag_set_input_line(machine(), "audiocpu", 0, HOLD_LINE);
232
232
                        }
233
233
                        break;
234
234
 
240
240
                        break;
241
241
 
242
242
                case 0xa: /* Mix Psel(?). */
243
 
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space->device()),data,0x30c010+(offset<<1));
 
243
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space.device()),data,0x30c010+(offset<<1));
244
244
                        break;
245
245
 
246
246
                case 0xc: /* Cblk - coin blockout.  Seems to be unused by the games */
248
248
#endif
249
249
 
250
250
                default:
251
 
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space->device()),data,0x30c010+(offset<<1));
 
251
                        logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(&space.device()),data,0x30c010+(offset<<1));
252
252
                        break;
253
253
        }
254
254
}
255
255
 
256
 
static WRITE16_HANDLER( slyspy_control_w )
 
256
WRITE16_MEMBER(dec0_state::slyspy_control_w)
257
257
{
258
258
    switch (offset << 1)
259
259
        {
260
260
        case 0:
261
261
                        if (ACCESSING_BITS_0_7)
262
262
                        {
263
 
                                soundlatch_w(space, 0, data & 0xff);
264
 
                                cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
 
263
                                soundlatch_byte_w(space, 0, data & 0xff);
 
264
                                cputag_set_input_line(machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
265
265
                        }
266
266
                        break;
267
267
                case 2:
270
270
    }
271
271
}
272
272
 
273
 
static WRITE16_HANDLER( midres_sound_w )
 
273
WRITE16_MEMBER(dec0_state::midres_sound_w)
274
274
{
275
275
        if (ACCESSING_BITS_0_7)
276
276
        {
277
 
                soundlatch_w(space, 0, data & 0xff);
278
 
                cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
 
277
                soundlatch_byte_w(space, 0, data & 0xff);
 
278
                cputag_set_input_line(machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
279
279
        }
280
280
}
281
281
 
282
282
/******************************************************************************/
283
283
 
284
 
static ADDRESS_MAP_START( dec0_map, AS_PROGRAM, 16 )
 
284
static ADDRESS_MAP_START( dec0_map, AS_PROGRAM, 16, dec0_state )
285
285
        AM_RANGE(0x000000, 0x05ffff) AM_ROM
286
 
        AM_RANGE(0x240000, 0x240007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w)                                                 /* text layer */
287
 
        AM_RANGE(0x240010, 0x240017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w)
288
 
        AM_RANGE(0x242000, 0x24207f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
289
 
        AM_RANGE(0x242400, 0x2427ff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
286
        AM_RANGE(0x240000, 0x240007) AM_DEVWRITE_LEGACY("tilegen1", deco_bac06_pf_control_0_w)                                                  /* text layer */
 
287
        AM_RANGE(0x240010, 0x240017) AM_DEVWRITE_LEGACY("tilegen1", deco_bac06_pf_control_1_w)
 
288
        AM_RANGE(0x242000, 0x24207f) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
289
        AM_RANGE(0x242400, 0x2427ff) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
290
290
        AM_RANGE(0x242800, 0x243fff) AM_RAM                                                                                                             /* Robocop only */
291
 
        AM_RANGE(0x244000, 0x245fff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
292
 
 
293
 
        AM_RANGE(0x246000, 0x246007) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_0_w)                                                                 /* first tile layer */
294
 
        AM_RANGE(0x246010, 0x246017) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_1_w)
295
 
        AM_RANGE(0x248000, 0x24807f) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
296
 
        AM_RANGE(0x248400, 0x2487ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
297
 
        AM_RANGE(0x24a000, 0x24a7ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
298
 
 
299
 
        AM_RANGE(0x24c000, 0x24c007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w)                                                         /* second tile layer */
300
 
        AM_RANGE(0x24c010, 0x24c017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w)
301
 
        AM_RANGE(0x24c800, 0x24c87f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
302
 
        AM_RANGE(0x24cc00, 0x24cfff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
303
 
        AM_RANGE(0x24d000, 0x24d7ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
291
        AM_RANGE(0x244000, 0x245fff) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
292
 
 
293
        AM_RANGE(0x246000, 0x246007) AM_DEVWRITE_LEGACY("tilegen2", deco_bac06_pf_control_0_w)                                                                  /* first tile layer */
 
294
        AM_RANGE(0x246010, 0x246017) AM_DEVWRITE_LEGACY("tilegen2", deco_bac06_pf_control_1_w)
 
295
        AM_RANGE(0x248000, 0x24807f) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
296
        AM_RANGE(0x248400, 0x2487ff) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
297
        AM_RANGE(0x24a000, 0x24a7ff) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
298
 
 
299
        AM_RANGE(0x24c000, 0x24c007) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_0_w)                                                          /* second tile layer */
 
300
        AM_RANGE(0x24c010, 0x24c017) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_1_w)
 
301
        AM_RANGE(0x24c800, 0x24c87f) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
302
        AM_RANGE(0x24cc00, 0x24cfff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
303
        AM_RANGE(0x24d000, 0x24d7ff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
304
304
 
305
305
        AM_RANGE(0x300000, 0x30001f) AM_READ(dec0_rotary_r)
306
306
        AM_RANGE(0x30c000, 0x30c00b) AM_READ(dec0_controls_r)
307
307
        AM_RANGE(0x30c010, 0x30c01f) AM_WRITE(dec0_control_w)                                                                   /* Priority, sound, etc. */
308
 
        AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(dec0_paletteram_rg_w) AM_BASE_GENERIC(paletteram)
309
 
        AM_RANGE(0x314000, 0x3147ff) AM_RAM_WRITE(dec0_paletteram_b_w) AM_BASE_GENERIC(paletteram2)
310
 
        AM_RANGE(0xff8000, 0xffbfff) AM_RAM AM_BASE_MEMBER(dec0_state, m_ram)                                                                   /* Main ram */
311
 
        AM_RANGE(0xffc000, 0xffc7ff) AM_RAM AM_BASE_MEMBER(dec0_state, m_spriteram)                                                             /* Sprites */
 
308
        AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(dec0_paletteram_rg_w) AM_SHARE("paletteram")
 
309
        AM_RANGE(0x314000, 0x3147ff) AM_RAM_WRITE(dec0_paletteram_b_w) AM_SHARE("paletteram2")
 
310
        AM_RANGE(0xff8000, 0xffbfff) AM_RAM AM_SHARE("ram")                                                                     /* Main ram */
 
311
        AM_RANGE(0xffc000, 0xffc7ff) AM_RAM AM_SHARE("spriteram")                                                               /* Sprites */
312
312
ADDRESS_MAP_END
313
313
 
314
 
static ADDRESS_MAP_START( robocop_sub_map, AS_PROGRAM, 8 )
 
314
static ADDRESS_MAP_START( robocop_sub_map, AS_PROGRAM, 8, dec0_state )
315
315
        AM_RANGE(0x000000, 0x00ffff) AM_ROM
316
316
        AM_RANGE(0x1f0000, 0x1f1fff) AM_RAM                                                                     /* Main ram */
317
 
        AM_RANGE(0x1f2000, 0x1f3fff) AM_RAM AM_BASE_MEMBER(dec0_state, m_robocop_shared_ram)    /* Shared ram */
318
 
        AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE(h6280_irq_status_w)
 
317
        AM_RANGE(0x1f2000, 0x1f3fff) AM_RAM AM_SHARE("robocop_shared")  /* Shared ram */
 
318
        AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE_LEGACY(h6280_irq_status_w)
319
319
ADDRESS_MAP_END
320
320
 
321
 
static ADDRESS_MAP_START( hippodrm_sub_map, AS_PROGRAM, 8 )
 
321
static ADDRESS_MAP_START( hippodrm_sub_map, AS_PROGRAM, 8, dec0_state )
322
322
        AM_RANGE(0x000000, 0x00ffff) AM_ROM
323
323
        AM_RANGE(0x180000, 0x1800ff) AM_READWRITE(hippodrm_shared_r, hippodrm_shared_w)
324
 
        AM_RANGE(0x1a0000, 0x1a0007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control0_8bit_packed_w)
325
 
        AM_RANGE(0x1a0010, 0x1a001f) AM_DEVWRITE("tilegen3", deco_bac06_pf_control1_8bit_swap_w)
326
 
        AM_RANGE(0x1a1000, 0x1a17ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_8bit_swap_r, deco_bac06_pf_data_8bit_swap_w)
 
324
        AM_RANGE(0x1a0000, 0x1a0007) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control0_8bit_packed_w)
 
325
        AM_RANGE(0x1a0010, 0x1a001f) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control1_8bit_swap_w)
 
326
        AM_RANGE(0x1a1000, 0x1a17ff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_data_8bit_swap_r, deco_bac06_pf_data_8bit_swap_w)
327
327
        AM_RANGE(0x1d0000, 0x1d00ff) AM_READWRITE(hippodrm_prot_r, hippodrm_prot_w)
328
328
        AM_RANGE(0x1f0000, 0x1f1fff) AM_RAMBANK("bank8") /* Main ram */
329
 
        AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE(h6280_irq_status_w)
 
329
        AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE_LEGACY(h6280_irq_status_w)
330
330
        AM_RANGE(0x1ff402, 0x1ff403) AM_READ_PORT("VBLANK")
331
331
ADDRESS_MAP_END
332
332
 
333
333
 
334
334
 
335
 
READ16_HANDLER( slyspy_controls_r )
 
335
READ16_MEMBER(dec0_state::slyspy_controls_r)
336
336
{
337
337
        switch (offset<<1)
338
338
        {
339
339
                case 0: /* Dip Switches */
340
 
                        return input_port_read(space->machine(), "DSW");
 
340
                        return ioport("DSW")->read();
341
341
 
342
342
                case 2: /* Player 1 & Player 2 joysticks & fire buttons */
343
 
                        return input_port_read(space->machine(), "INPUTS");
 
343
                        return ioport("INPUTS")->read();
344
344
 
345
345
                case 4: /* Credits */
346
 
                        return input_port_read(space->machine(), "SYSTEM");
 
346
                        return ioport("SYSTEM")->read();
347
347
        }
348
348
 
349
349
        logerror("Unknown control read at 30c000 %d\n", offset);
350
350
        return ~0;
351
351
}
352
352
 
353
 
READ16_HANDLER( slyspy_protection_r )
 
353
READ16_MEMBER(dec0_state::slyspy_protection_r)
354
354
{
355
355
        /* These values are for Boulderdash, I have no idea what they do in Slyspy */
356
356
        switch (offset<<1) {
360
360
                case 6:         return 0x2;
361
361
        }
362
362
 
363
 
        logerror("%04x, Unknown protection read at 30c000 %d\n", cpu_get_pc(&space->device()), offset);
 
363
        logerror("%04x, Unknown protection read at 30c000 %d\n", cpu_get_pc(&space.device()), offset);
364
364
        return 0;
365
365
}
366
366
 
398
398
 
399
399
*/
400
400
 
401
 
static WRITE16_HANDLER( unmapped_w )
 
401
WRITE16_MEMBER(dec0_state::unmapped_w)
402
402
{
403
403
        // fall through for unmapped protection areas
404
 
        dec0_state *state = space->machine().driver_data<dec0_state>();
405
 
        logerror("unmapped memory write to %04x = %04x in mode %d\n", 0x240000+offset*2, data, state->m_slyspy_state);
 
404
        logerror("unmapped memory write to %04x = %04x in mode %d\n", 0x240000+offset*2, data, m_slyspy_state);
406
405
}
407
406
 
408
407
void slyspy_set_protection_map(running_machine& machine, int type);
409
408
 
410
 
WRITE16_HANDLER( slyspy_state_w )
 
409
WRITE16_MEMBER(dec0_state::slyspy_state_w)
411
410
{
412
 
        dec0_state *state = space->machine().driver_data<dec0_state>();
413
 
        state->m_slyspy_state=0;
414
 
        slyspy_set_protection_map(space->machine(), state->m_slyspy_state);
 
411
        m_slyspy_state=0;
 
412
        slyspy_set_protection_map(machine(), m_slyspy_state);
415
413
}
416
414
 
417
 
READ16_HANDLER( slyspy_state_r )
 
415
READ16_MEMBER(dec0_state::slyspy_state_r)
418
416
{
419
 
        dec0_state *state = space->machine().driver_data<dec0_state>();
420
 
        state->m_slyspy_state++;
421
 
        state->m_slyspy_state=state->m_slyspy_state%4;
422
 
        slyspy_set_protection_map(space->machine(), state->m_slyspy_state);
 
417
        m_slyspy_state++;
 
418
        m_slyspy_state=m_slyspy_state%4;
 
419
        slyspy_set_protection_map(machine(), m_slyspy_state);
423
420
 
424
421
        return 0; /* Value doesn't mater */
425
422
}
426
423
 
427
424
void slyspy_set_protection_map(running_machine& machine, int type)
428
425
{
 
426
        dec0_state *state = machine.driver_data<dec0_state>();
429
427
        address_space* space = machine.device("maincpu")->memory().space(AS_PROGRAM);
430
428
 
431
429
        deco_bac06_device *tilegen1 = (deco_bac06_device*)space->machine().device<deco_bac06_device>("tilegen1");
432
430
        deco_bac06_device *tilegen2 = (deco_bac06_device*)space->machine().device<deco_bac06_device>("tilegen2");
433
431
 
434
 
        space->install_legacy_write_handler( 0x240000, 0x24ffff, FUNC(unmapped_w));
 
432
        space->install_write_handler( 0x240000, 0x24ffff, write16_delegate(FUNC(dec0_state::unmapped_w),state));
435
433
 
436
 
        space->install_legacy_write_handler( 0x24a000, 0x24a001, FUNC(slyspy_state_w));
437
 
        space->install_legacy_read_handler( 0x244000, 0x244001, FUNC(slyspy_state_r));
 
434
        space->install_write_handler( 0x24a000, 0x24a001, write16_delegate(FUNC(dec0_state::slyspy_state_w),state));
 
435
        space->install_read_handler( 0x244000, 0x244001, read16_delegate(FUNC(dec0_state::slyspy_state_r),state));
438
436
 
439
437
        switch (type)
440
438
        {
495
493
 
496
494
 
497
495
 
498
 
static ADDRESS_MAP_START( slyspy_map, AS_PROGRAM, 16 )
 
496
static ADDRESS_MAP_START( slyspy_map, AS_PROGRAM, 16, dec0_state )
499
497
        AM_RANGE(0x000000, 0x05ffff) AM_ROM
500
498
 
501
499
        /* The location of p1 & pf2 can change in the 240000 - 24ffff region according to protection */
502
500
 
503
501
        /* Pf3 is unaffected by protection */
504
 
        AM_RANGE(0x300000, 0x300007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w)
505
 
        AM_RANGE(0x300010, 0x300017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w)
506
 
        AM_RANGE(0x300800, 0x30087f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
507
 
        AM_RANGE(0x300c00, 0x300fff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
508
 
        AM_RANGE(0x301000, 0x3017ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
502
        AM_RANGE(0x300000, 0x300007) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_0_w)
 
503
        AM_RANGE(0x300010, 0x300017) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_1_w)
 
504
        AM_RANGE(0x300800, 0x30087f) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
505
        AM_RANGE(0x300c00, 0x300fff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
506
        AM_RANGE(0x301000, 0x3017ff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
509
507
 
510
 
        AM_RANGE(0x304000, 0x307fff) AM_RAM AM_BASE_MEMBER(dec0_state, m_ram)   /* Sly spy main ram */
511
 
        AM_RANGE(0x308000, 0x3087ff) AM_RAM AM_BASE_MEMBER(dec0_state, m_spriteram)     /* Sprites */
512
 
        AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
 
508
        AM_RANGE(0x304000, 0x307fff) AM_RAM AM_SHARE("ram")     /* Sly spy main ram */
 
509
        AM_RANGE(0x308000, 0x3087ff) AM_RAM AM_SHARE("spriteram")       /* Sprites */
 
510
        AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram")
513
511
        AM_RANGE(0x314000, 0x314003) AM_WRITE(slyspy_control_w)
514
512
        AM_RANGE(0x314008, 0x31400f) AM_READ(slyspy_controls_r)
515
513
        AM_RANGE(0x31c000, 0x31c00f) AM_READ(slyspy_protection_r) AM_WRITENOP
516
514
ADDRESS_MAP_END
517
515
 
518
516
 
519
 
static ADDRESS_MAP_START( midres_map, AS_PROGRAM, 16 )
 
517
static ADDRESS_MAP_START( midres_map, AS_PROGRAM, 16, dec0_state )
520
518
        AM_RANGE(0x000000, 0x07ffff) AM_ROM
521
 
        AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE_MEMBER(dec0_state, m_ram)
522
 
        AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_MEMBER(dec0_state, m_spriteram)
523
 
        AM_RANGE(0x140000, 0x1407ff) AM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
 
519
        AM_RANGE(0x100000, 0x103fff) AM_RAM AM_SHARE("ram")
 
520
        AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_SHARE("spriteram")
 
521
        AM_RANGE(0x140000, 0x1407ff) AM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram")
524
522
        AM_RANGE(0x160000, 0x160001) AM_WRITE(dec0_priority_w)
525
523
        AM_RANGE(0x180000, 0x18000f) AM_READ(midres_controls_r)
526
524
        AM_RANGE(0x180008, 0x18000f) AM_WRITENOP /* ?? watchdog ?? */
527
525
        AM_RANGE(0x1a0000, 0x1a0001) AM_WRITE(midres_sound_w)
528
526
 
529
 
        AM_RANGE(0x200000, 0x200007) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_0_w)
530
 
        AM_RANGE(0x200010, 0x200017) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_1_w)
531
 
        AM_RANGE(0x220000, 0x2207ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
532
 
        AM_RANGE(0x220800, 0x220fff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)    /* mirror address used in end sequence */
533
 
        AM_RANGE(0x240000, 0x24007f) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
534
 
        AM_RANGE(0x240400, 0x2407ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
535
 
 
536
 
        AM_RANGE(0x280000, 0x280007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w)
537
 
        AM_RANGE(0x280010, 0x280017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w)
538
 
        AM_RANGE(0x2a0000, 0x2a07ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
539
 
        AM_RANGE(0x2c0000, 0x2c007f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
540
 
        AM_RANGE(0x2c0400, 0x2c07ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
541
 
 
542
 
        AM_RANGE(0x300000, 0x300007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w)
543
 
        AM_RANGE(0x300010, 0x300017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w)
544
 
        AM_RANGE(0x320000, 0x321fff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
545
 
        AM_RANGE(0x340000, 0x34007f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
546
 
        AM_RANGE(0x340400, 0x3407ff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
527
        AM_RANGE(0x200000, 0x200007) AM_DEVWRITE_LEGACY("tilegen2", deco_bac06_pf_control_0_w)
 
528
        AM_RANGE(0x200010, 0x200017) AM_DEVWRITE_LEGACY("tilegen2", deco_bac06_pf_control_1_w)
 
529
        AM_RANGE(0x220000, 0x2207ff) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
530
        AM_RANGE(0x220800, 0x220fff) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)     /* mirror address used in end sequence */
 
531
        AM_RANGE(0x240000, 0x24007f) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
532
        AM_RANGE(0x240400, 0x2407ff) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
533
 
 
534
        AM_RANGE(0x280000, 0x280007) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_0_w)
 
535
        AM_RANGE(0x280010, 0x280017) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_1_w)
 
536
        AM_RANGE(0x2a0000, 0x2a07ff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
537
        AM_RANGE(0x2c0000, 0x2c007f) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
538
        AM_RANGE(0x2c0400, 0x2c07ff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
539
 
 
540
        AM_RANGE(0x300000, 0x300007) AM_DEVWRITE_LEGACY("tilegen1", deco_bac06_pf_control_0_w)
 
541
        AM_RANGE(0x300010, 0x300017) AM_DEVWRITE_LEGACY("tilegen1", deco_bac06_pf_control_1_w)
 
542
        AM_RANGE(0x320000, 0x321fff) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
543
        AM_RANGE(0x340000, 0x34007f) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
544
        AM_RANGE(0x340400, 0x3407ff) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
547
545
 
548
546
        AM_RANGE(0x320000, 0x321fff) AM_RAM
549
547
ADDRESS_MAP_END
550
548
 
551
549
/******************************************************************************/
552
550
 
553
 
static ADDRESS_MAP_START( dec0_s_map, AS_PROGRAM, 8 )
 
551
static ADDRESS_MAP_START( dec0_s_map, AS_PROGRAM, 8, dec0_state )
554
552
        AM_RANGE(0x0000, 0x05ff) AM_RAM
555
 
        AM_RANGE(0x0800, 0x0801) AM_DEVWRITE("ym1", ym2203_w)
556
 
        AM_RANGE(0x1000, 0x1001) AM_DEVWRITE("ym2", ym3812_w)
557
 
        AM_RANGE(0x3000, 0x3000) AM_READ(soundlatch_r)
558
 
        AM_RANGE(0x3800, 0x3800) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
 
553
        AM_RANGE(0x0800, 0x0801) AM_DEVWRITE_LEGACY("ym1", ym2203_w)
 
554
        AM_RANGE(0x1000, 0x1001) AM_DEVWRITE_LEGACY("ym2", ym3812_w)
 
555
        AM_RANGE(0x3000, 0x3000) AM_READ(soundlatch_byte_r)
 
556
        AM_RANGE(0x3800, 0x3800) AM_DEVREADWRITE("oki", okim6295_device, read, write)
559
557
        AM_RANGE(0x8000, 0xffff) AM_ROM
560
558
ADDRESS_MAP_END
561
559
 
562
560
/* Physical memory map (21 bits) */
563
 
static ADDRESS_MAP_START( slyspy_s_map, AS_PROGRAM, 8 )
 
561
static ADDRESS_MAP_START( slyspy_s_map, AS_PROGRAM, 8, dec0_state )
564
562
        AM_RANGE(0x000000, 0x00ffff) AM_ROM
565
 
        AM_RANGE(0x090000, 0x090001) AM_DEVWRITE("ym2", ym3812_w)
 
563
        AM_RANGE(0x090000, 0x090001) AM_DEVWRITE_LEGACY("ym2", ym3812_w)
566
564
        AM_RANGE(0x0a0000, 0x0a0001) AM_READNOP /* Protection counter */
567
 
        AM_RANGE(0x0b0000, 0x0b0001) AM_DEVWRITE("ym1", ym2203_w)
568
 
        AM_RANGE(0x0e0000, 0x0e0001) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
569
 
        AM_RANGE(0x0f0000, 0x0f0001) AM_READ(soundlatch_r)
 
565
        AM_RANGE(0x0b0000, 0x0b0001) AM_DEVWRITE_LEGACY("ym1", ym2203_w)
 
566
        AM_RANGE(0x0e0000, 0x0e0001) AM_DEVREADWRITE("oki", okim6295_device, read, write)
 
567
        AM_RANGE(0x0f0000, 0x0f0001) AM_READ(soundlatch_byte_r)
570
568
        AM_RANGE(0x1f0000, 0x1f1fff) AM_RAMBANK("bank8")
571
 
        AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE(h6280_irq_status_w)
 
569
        AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE_LEGACY(h6280_irq_status_w)
572
570
ADDRESS_MAP_END
573
571
 
574
 
static ADDRESS_MAP_START( midres_s_map, AS_PROGRAM, 8 )
 
572
static ADDRESS_MAP_START( midres_s_map, AS_PROGRAM, 8, dec0_state )
575
573
        AM_RANGE(0x000000, 0x00ffff) AM_ROM
576
 
        AM_RANGE(0x108000, 0x108001) AM_DEVWRITE("ym2", ym3812_w)
577
 
        AM_RANGE(0x118000, 0x118001) AM_DEVWRITE("ym1", ym2203_w)
578
 
        AM_RANGE(0x130000, 0x130001) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
579
 
        AM_RANGE(0x138000, 0x138001) AM_READ(soundlatch_r)
 
574
        AM_RANGE(0x108000, 0x108001) AM_DEVWRITE_LEGACY("ym2", ym3812_w)
 
575
        AM_RANGE(0x118000, 0x118001) AM_DEVWRITE_LEGACY("ym1", ym2203_w)
 
576
        AM_RANGE(0x130000, 0x130001) AM_DEVREADWRITE("oki", okim6295_device, read, write)
 
577
        AM_RANGE(0x138000, 0x138001) AM_READ(soundlatch_byte_r)
580
578
        AM_RANGE(0x1f0000, 0x1f1fff) AM_RAMBANK("bank8")
581
 
        AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE(h6280_irq_status_w)
 
579
        AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE_LEGACY(h6280_irq_status_w)
582
580
ADDRESS_MAP_END
583
581
 
584
582
 
585
583
 
586
584
 
587
585
 
588
 
static ADDRESS_MAP_START( secretab_map, AS_PROGRAM, 16 )
 
586
static ADDRESS_MAP_START( secretab_map, AS_PROGRAM, 16, dec0_state )
589
587
        AM_RANGE(0x000000, 0x05ffff) AM_ROM
590
 
        AM_RANGE(0x240000, 0x240007) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_0_w)
591
 
        AM_RANGE(0x240010, 0x240017) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_1_w)
592
 
        AM_RANGE(0x246000, 0x247fff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
593
 
//  AM_RANGE(0x240000, 0x24007f) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
594
 
//  AM_RANGE(0x240400, 0x2407ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
588
        AM_RANGE(0x240000, 0x240007) AM_DEVWRITE_LEGACY("tilegen2", deco_bac06_pf_control_0_w)
 
589
        AM_RANGE(0x240010, 0x240017) AM_DEVWRITE_LEGACY("tilegen2", deco_bac06_pf_control_1_w)
 
590
        AM_RANGE(0x246000, 0x247fff) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
591
//  AM_RANGE(0x240000, 0x24007f) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
592
//  AM_RANGE(0x240400, 0x2407ff) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
595
593
 
596
 
//  AM_RANGE(0x200000, 0x300007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w)
597
 
//  AM_RANGE(0x300010, 0x300017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w)
598
 
        AM_RANGE(0x24e000, 0x24ffff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
599
 
//  AM_RANGE(0x340000, 0x34007f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
600
 
//  AM_RANGE(0x340400, 0x3407ff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
594
//  AM_RANGE(0x200000, 0x300007) AM_DEVWRITE_LEGACY("tilegen1", deco_bac06_pf_control_0_w)
 
595
//  AM_RANGE(0x300010, 0x300017) AM_DEVWRITE_LEGACY("tilegen1", deco_bac06_pf_control_1_w)
 
596
        AM_RANGE(0x24e000, 0x24ffff) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
597
//  AM_RANGE(0x340000, 0x34007f) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
598
//  AM_RANGE(0x340400, 0x3407ff) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
601
599
 
602
600
        AM_RANGE(0x314008, 0x31400f) AM_READ(slyspy_controls_r)
603
601
//  AM_RANGE(0x314000, 0x314003) AM_WRITE(slyspy_control_w)
604
602
 
605
 
        AM_RANGE(0x300000, 0x300007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w)
606
 
        AM_RANGE(0x300010, 0x300017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w)
607
 
        AM_RANGE(0x300800, 0x30087f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
608
 
        AM_RANGE(0x300c00, 0x300fff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
609
 
        AM_RANGE(0x301000, 0x3017ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
610
 
        AM_RANGE(0x301800, 0x307fff) AM_RAM AM_BASE_MEMBER(dec0_state, m_ram) /* Sly spy main ram */
611
 
        AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
612
 
        AM_RANGE(0xb08000, 0xb087ff) AM_RAM AM_BASE_MEMBER(dec0_state, m_spriteram) /* Sprites */
 
603
        AM_RANGE(0x300000, 0x300007) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_0_w)
 
604
        AM_RANGE(0x300010, 0x300017) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_1_w)
 
605
        AM_RANGE(0x300800, 0x30087f) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
606
        AM_RANGE(0x300c00, 0x300fff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
607
        AM_RANGE(0x301000, 0x3017ff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
608
        AM_RANGE(0x301800, 0x307fff) AM_RAM AM_SHARE("ram") /* Sly spy main ram */
 
609
        AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram")
 
610
        AM_RANGE(0xb08000, 0xb087ff) AM_RAM AM_SHARE("spriteram") /* Sprites */
613
611
ADDRESS_MAP_END
614
612
 
615
613
 
616
 
static ADDRESS_MAP_START( automat_map, AS_PROGRAM, 16 )
 
614
static ADDRESS_MAP_START( automat_map, AS_PROGRAM, 16, dec0_state )
617
615
        AM_RANGE(0x000000, 0x05ffff) AM_ROM
618
616
 
619
 
        AM_RANGE(0x240000, 0x240007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w)                 /* text layer */
620
 
        AM_RANGE(0x240010, 0x240017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w)
621
 
        AM_RANGE(0x242000, 0x24207f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
622
 
        AM_RANGE(0x242400, 0x2427ff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
617
        AM_RANGE(0x240000, 0x240007) AM_DEVWRITE_LEGACY("tilegen1", deco_bac06_pf_control_0_w)                  /* text layer */
 
618
        AM_RANGE(0x240010, 0x240017) AM_DEVWRITE_LEGACY("tilegen1", deco_bac06_pf_control_1_w)
 
619
        AM_RANGE(0x242000, 0x24207f) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
620
        AM_RANGE(0x242400, 0x2427ff) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
623
621
        AM_RANGE(0x242800, 0x243fff) AM_RAM                                                             /* Robocop only */
624
 
        AM_RANGE(0x244000, 0x245fff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
625
 
 
626
 
        AM_RANGE(0x246000, 0x246007) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_0_w)                 /* first tile layer */
627
 
        AM_RANGE(0x246010, 0x246017) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_1_w)
628
 
        AM_RANGE(0x248000, 0x24807f) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
629
 
        AM_RANGE(0x248400, 0x2487ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
630
 
        AM_RANGE(0x24a000, 0x24a7ff)  AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
631
 
 
632
 
        AM_RANGE(0x24c000, 0x24c007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w)                 /* second tile layer */
633
 
        AM_RANGE(0x24c010, 0x24c017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w)
634
 
        AM_RANGE(0x24c800, 0x24c87f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
635
 
        AM_RANGE(0x24cc00, 0x24cfff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
636
 
        AM_RANGE(0x24d000, 0x24d7ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
622
        AM_RANGE(0x244000, 0x245fff) AM_DEVREADWRITE_LEGACY("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
623
 
 
624
        AM_RANGE(0x246000, 0x246007) AM_DEVWRITE_LEGACY("tilegen2", deco_bac06_pf_control_0_w)                  /* first tile layer */
 
625
        AM_RANGE(0x246010, 0x246017) AM_DEVWRITE_LEGACY("tilegen2", deco_bac06_pf_control_1_w)
 
626
        AM_RANGE(0x248000, 0x24807f) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
627
        AM_RANGE(0x248400, 0x2487ff) AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
628
        AM_RANGE(0x24a000, 0x24a7ff)  AM_DEVREADWRITE_LEGACY("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
 
629
 
 
630
        AM_RANGE(0x24c000, 0x24c007) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_0_w)                  /* second tile layer */
 
631
        AM_RANGE(0x24c010, 0x24c017) AM_DEVWRITE_LEGACY("tilegen3", deco_bac06_pf_control_1_w)
 
632
        AM_RANGE(0x24c800, 0x24c87f) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w)
 
633
        AM_RANGE(0x24cc00, 0x24cfff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w)
 
634
        AM_RANGE(0x24d000, 0x24d7ff) AM_DEVREADWRITE_LEGACY("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
637
635
 
638
636
        AM_RANGE(0x300000, 0x30001f) AM_READ(dec0_rotary_r)
639
637
        AM_RANGE(0x30c000, 0x30c00b) AM_READ(dec0_controls_r)
640
638
        AM_RANGE(0x30c000, 0x30c01f) AM_WRITE(automat_control_w)                        /* Priority, sound, etc. */
641
 
        AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
 
639
        AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram")
642
640
        AM_RANGE(0x314000, 0x3147ff) AM_RAM
643
641
        AM_RANGE(0x400008, 0x400009) AM_WRITE(dec0_priority_w)                          // NEW
644
 
        AM_RANGE(0xff8000, 0xffbfff) AM_RAM AM_BASE_MEMBER(dec0_state, m_ram)                           /* Main ram */
645
 
        AM_RANGE(0xffc000, 0xffc7ff) AM_RAM AM_BASE_MEMBER(dec0_state, m_spriteram)                     /* Sprites */
 
642
        AM_RANGE(0xff8000, 0xffbfff) AM_RAM AM_SHARE("ram")                             /* Main ram */
 
643
        AM_RANGE(0xffc000, 0xffc7ff) AM_RAM AM_SHARE("spriteram")                       /* Sprites */
646
644
ADDRESS_MAP_END
647
645
 
648
 
static WRITE8_HANDLER( automat_adpcm_w )
 
646
WRITE8_MEMBER(dec0_state::automat_adpcm_w)
649
647
{
650
 
        dec0_state *state = space->machine().driver_data<dec0_state>();
651
 
        state->m_automat_adpcm_byte = data;
 
648
        m_automat_adpcm_byte = data;
652
649
}
653
650
 
654
 
static ADDRESS_MAP_START( automat_s_map, AS_PROGRAM, 8 )
 
651
static ADDRESS_MAP_START( automat_s_map, AS_PROGRAM, 8, dec0_state )
655
652
        AM_RANGE(0xc000, 0xc7ff) AM_RAM
656
 
//  AM_RANGE(0xc800, 0xc800) AM_WRITE(ym2203_control_port_0_w)
657
 
//  AM_RANGE(0xc801, 0xc801) AM_WRITE(ym2203_write_port_0_w)
658
 
        AM_RANGE(0xd800, 0xd800) AM_READ(soundlatch_r)
659
 
//  AM_RANGE(0xd000, 0xd000) AM_WRITE(ym2203_control_port_1_w)
660
 
//  AM_RANGE(0xd001, 0xd001) AM_WRITE(ym2203_write_port_1_w)
 
653
//  AM_RANGE(0xc800, 0xc800) AM_WRITE_LEGACY(ym2203_control_port_0_w)
 
654
//  AM_RANGE(0xc801, 0xc801) AM_WRITE_LEGACY(ym2203_write_port_0_w)
 
655
        AM_RANGE(0xd800, 0xd800) AM_READ(soundlatch_byte_r)
 
656
//  AM_RANGE(0xd000, 0xd000) AM_WRITE_LEGACY(ym2203_control_port_1_w)
 
657
//  AM_RANGE(0xd001, 0xd001) AM_WRITE_LEGACY(ym2203_write_port_1_w)
661
658
        AM_RANGE(0xf000, 0xf000) AM_WRITE(automat_adpcm_w)
662
659
        AM_RANGE(0x0000, 0xffff) AM_ROM
663
660
ADDRESS_MAP_END
664
661
 
665
 
static ADDRESS_MAP_START( mcu_io_map, AS_IO, 8 )
 
662
static ADDRESS_MAP_START( mcu_io_map, AS_IO, 8, dec0_state )
666
663
        ADDRESS_MAP_UNMAP_HIGH
667
664
        AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_READWRITE(dec0_mcu_port_r, dec0_mcu_port_w)
668
665
ADDRESS_MAP_END
696
693
        PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_COIN1 )
697
694
        PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_COIN2 )
698
695
        PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 )
699
 
        PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_VBLANK )
 
696
        PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")
700
697
INPUT_PORTS_END
701
698
 
702
699
static INPUT_PORTS_START( dec1 )
722
719
        PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
723
720
        PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
724
721
        PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
725
 
        PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_VBLANK )
 
722
        PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")
726
723
        PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
727
724
        PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
728
725
        PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
980
977
        PORT_DIPUNUSED_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW2:8" ) // Always OFF
981
978
 
982
979
        PORT_START("VBLANK")
983
 
        PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK )
 
980
        PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")
984
981
INPUT_PORTS_END
985
982
 
986
983
static INPUT_PORTS_START( ffantasy )
1124
1121
        PORT_INCLUDE( dec1 )
1125
1122
 
1126
1123
        PORT_MODIFY("SYSTEM")
1127
 
        PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_VBLANK )          /* extremely slow palette fades with ACTIVE_HIGH */
 
1124
        PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")            /* extremely slow palette fades with ACTIVE_HIGH */
1128
1125
 
1129
1126
        PORT_START("DSW")
1130
1127
        /* Different Coinage. Just a few combinations from manual, the rest was figured out */
1877
1874
        ROM_LOAD( "eg08.2c",   0x0000, 0x10000, CRC(92f2c916) SHA1(38b4ed81edcc2069b096591bdc5baab8b9edfa9a) ) // different to baddudes
1878
1875
ROM_END
1879
1876
 
 
1877
ROM_START( drgninjab )
 
1878
        ROM_REGION( 0x60000, "maincpu", 0 )     /* 6*64k for 68000 code, middle 0x20000 unused */
 
1879
    ROM_LOAD16_BYTE( "n-12.d2",  0x00000, 0x10000, CRC(5a70eb52) SHA1(26fd48ea71cd5196e3907eebcf1234f44a3d7dba) )
 
1880
    ROM_LOAD16_BYTE( "n-11.a2",  0x00001, 0x10000, CRC(3887eb92) SHA1(a8650ce128927955497540d7c6fbd23516afdb24) )
 
1881
        ROM_LOAD16_BYTE( "eg06.6c",  0x40000, 0x10000, CRC(2b81faf7) SHA1(6d10c29f5ee06856843d83e77ba24c2b6e00a9cb) )
 
1882
        ROM_LOAD16_BYTE( "eg03.6a",  0x40001, 0x10000, CRC(c52c2e9d) SHA1(399f2b7df9d558c8f33bf1a7c8048c62e0f54cec) )
 
1883
 
 
1884
        ROM_REGION( 0x10000, "audiocpu", 0 )    /* Sound CPU */
 
1885
        ROM_LOAD( "eg07.8a",   0x8000, 0x8000, CRC(001d2f51) SHA1(f186671f0450ccf9201577a5caf0efc490c6645e) )
 
1886
 
 
1887
        ROM_REGION( 0x1000, "mcu", 0 )  /* i8751 microcontroller */
 
1888
        ROM_LOAD( "i8751",     0x0000, 0x1000, NO_DUMP )
 
1889
 
 
1890
        /* various graphic and sound roms also differ when compared to baddudes */
 
1891
 
 
1892
        ROM_REGION( 0x10000, "gfx1", 0 ) /* chars */
 
1893
        //ROM_LOAD( "drgninja.25",  0x00000, 0x08000, CRC(6791bc20) SHA1(7240b2688cda04ee9ea331472a84fbffc85b8e90) )
 
1894
        // the rom below was found on a genuine 'dragonninja' pcb, compared to the other ROM it has the 'bad dudes' (unused) logo
 
1895
        // partially erased, and a bad pixel on the left arrow character.  Is the other rom a cleaned up hack, or from a bootleg,
 
1896
        // or did Data East actually clean it up on a later PCB?
 
1897
        ROM_LOAD( "eg25.15j",  0x00000, 0x08000, CRC(dd557b19) SHA1(ce1e76aeb7e147f373bb48dbc1becc1601953499) ) // different to baddudes
 
1898
        ROM_LOAD( "eg26.16j",  0x08000, 0x08000, CRC(5d75fc8f) SHA1(92947dd78bfe8067fb5f645fa1ef212e48b69c70) ) // different to baddudes
 
1899
 
 
1900
        ROM_REGION( 0x40000, "gfx2", 0 ) /* tiles */
 
1901
        ROM_LOAD( "eg18.14d",  0x00000, 0x10000, CRC(05cfc3e5) SHA1(a0163921c77dc9706463a402c3dd45ec4341cd21) )
 
1902
        ROM_LOAD( "eg20.17d",  0x10000, 0x10000, CRC(e11e988f) SHA1(0c59f0d8d1abe414c7e1ebd49d454179fed2cd00) )
 
1903
        ROM_LOAD( "eg22.14f",  0x20000, 0x10000, CRC(b893d880) SHA1(99e228174677f2e3e96154f77bfa9bf0f1c0a6a5) )
 
1904
        ROM_LOAD( "eg24.17f",  0x30000, 0x10000, CRC(6f226dda) SHA1(65ebb16a292c57d49c135fce7ed7537146226eb5) )
 
1905
 
 
1906
        ROM_REGION( 0x20000, "gfx3", 0 ) /* tiles */
 
1907
        ROM_LOAD( "eg30.9j",   0x08000, 0x08000, CRC(2438e67e) SHA1(5f143aeb83606a2c64d0b31bfee38156d231dcc9) )
 
1908
        ROM_CONTINUE(          0x00000, 0x08000 )       /* the two halves are swapped */
 
1909
        ROM_LOAD( "eg28.9f",   0x18000, 0x08000, CRC(5c692ab3) SHA1(4c58ff50833f869575f1a15c776fbf1429944fab) )
 
1910
        ROM_CONTINUE(          0x10000, 0x08000 )
 
1911
 
 
1912
        ROM_REGION( 0x80000, "gfx4", 0 ) /* sprites */
 
1913
        ROM_LOAD( "eg15.16c",  0x00000, 0x10000, CRC(5617d67f) SHA1(8f684de27ae79c4d35720706cdd2733af0e0a9cc) ) // different to baddudes
 
1914
        ROM_LOAD( "eg16.17c",  0x10000, 0x08000, CRC(17e42633) SHA1(405f5296a741901677cca978a1b287d894eb1e54) )
 
1915
        ROM_LOAD( "eg11.16a",  0x20000, 0x10000, CRC(ba83e8d8) SHA1(63092a5d0da0c9228a72a83b43a67a47b1388724) ) // different to baddudes
 
1916
        ROM_LOAD( "eg12.17a",  0x30000, 0x08000, CRC(fea2a134) SHA1(525dd5f48993db1fe1e3c095442884178f75e8e0) )
 
1917
        ROM_LOAD( "eg13.13c",  0x40000, 0x10000, CRC(fd91e08e) SHA1(8998f020791c8830e963096dc7b8fcb430d041d4) ) // different to baddudes
 
1918
        ROM_LOAD( "eg14.14c",  0x50000, 0x08000, CRC(e83c760a) SHA1(d08db381658b8b3288c5eaa9048a906126e0f712) )
 
1919
        ROM_LOAD( "eg09.13a",  0x60000, 0x10000, CRC(601b7b23) SHA1(c1c665614f1377bc47720382b25c965266a2593f)) // different to baddudes
 
1920
        ROM_LOAD( "eg10.14a",  0x70000, 0x08000, CRC(eeee8a1a) SHA1(2bf8378ff38f6a7c7cbd4cbd489de25cb1f0fe71) )
 
1921
 
 
1922
        ROM_REGION( 0x40000, "oki", 0 ) /* ADPCM samples */
 
1923
        ROM_LOAD( "eg08.2c",   0x0000, 0x10000, CRC(92f2c916) SHA1(38b4ed81edcc2069b096591bdc5baab8b9edfa9a) ) // different to baddudes
 
1924
ROM_END
 
1925
 
1880
1926
ROM_START( birdtry )
1881
1927
        ROM_REGION( 0x60000, "maincpu", 0 )     /* 6*64k for 68000 code */
1882
1928
        ROM_LOAD16_BYTE( "ek-04.bin",     0x00000, 0x10000, CRC(5f0f4686) SHA1(5eea74f5626339ebd50e623029f21f1cd0f93135) )
2992
3038
 
2993
3039
static DRIVER_INIT( convert_robocop_gfx4_to_automat )
2994
3040
{
2995
 
        UINT8* R = machine.region("gfx4")->base();
 
3041
        UINT8* R = machine.root_device().memregion("gfx4")->base();
2996
3042
        int i;
2997
3043
 
2998
3044
        for (i=0;i<0x80000;i++)
3013
3059
 
3014
3060
static DRIVER_INIT( midresb )
3015
3061
{
3016
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x00180000, 0x0018000f, FUNC(dec0_controls_r) );
3017
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x001a0000, 0x001a000f, FUNC(dec0_rotary_r) );
 
3062
        dec0_state *state = machine.driver_data<dec0_state>();
 
3063
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x00180000, 0x0018000f, read16_delegate(FUNC(dec0_state::dec0_controls_r),state));
 
3064
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x001a0000, 0x001a000f, read16_delegate(FUNC(dec0_state::dec0_rotary_r),state));
3018
3065
 
3019
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x00180014, 0x00180015, FUNC(midres_sound_w) );
 
3066
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_write_handler(0x00180014, 0x00180015, write16_delegate(FUNC(dec0_state::midres_sound_w),state));
3020
3067
}
3021
3068
 
3022
3069
/******************************************************************************/
3026
3073
GAME( 1987, hbarrelw,   hbarrel,  hbarrel,  hbarrel,  hbarrel,  ROT270, "Data East Corporation", "Heavy Barrel (World)", 0 )
3027
3074
GAME( 1988, baddudes,   0,        baddudes, baddudes, baddudes, ROT0,   "Data East USA",         "Bad Dudes vs. Dragonninja (US)", 0 )
3028
3075
GAME( 1988, drgninja,   baddudes, baddudes, drgninja, baddudes, ROT0,   "Data East Corporation", "Dragonninja (Japan)", 0 )
 
3076
GAME( 1988, drgninjab,  baddudes, baddudes, drgninja, baddudes, ROT0,   "bootleg", "Dragonninja (bootleg)", 0 )
3029
3077
/* A Bad Dudes bootleg with 68705 like the midres and ffantasy ones exists, but is not dumped */
3030
3078
GAME( 1988, birdtry,    0,        birdtry,  birdtry,  birdtry,  ROT270, "Data East Corporation", "Birdie Try (Japan)", GAME_UNEMULATED_PROTECTION )
3031
3079
GAME( 1988, robocop,    0,        robocop,  robocop,  robocop,  ROT0,   "Data East Corporation", "Robocop (World revision 4)", 0 )