176
180
static READ8_HANDLER( maxrpm_ip1_r )
178
return latched_input;
182
mcr3_state *state = space->machine().driver_data<mcr3_state>();
183
return state->m_latched_input;
182
187
static READ8_HANDLER( maxrpm_ip2_r )
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");
188
194
/* reset on a start */
189
195
if (!(start & 0x08))
196
state->m_maxrpm_p1_shift = 0;
191
197
if (!(start & 0x04))
198
state->m_maxrpm_p2_shift = 0;
194
200
/* increment, decrement on falling edge */
195
if (!(shift & 0x01) && (maxrpm_last_shift & 0x01))
198
if (maxrpm_p1_shift > 4)
201
if (!(shift & 0x02) && (maxrpm_last_shift & 0x02))
204
if (maxrpm_p1_shift < 0)
207
if (!(shift & 0x04) && (maxrpm_last_shift & 0x04))
210
if (maxrpm_p2_shift > 4)
213
if (!(shift & 0x08) && (maxrpm_last_shift & 0x08))
216
if (maxrpm_p2_shift < 0)
220
maxrpm_last_shift = shift;
222
return ~((shift_bits[maxrpm_p1_shift] << 4) + shift_bits[maxrpm_p2_shift]);
201
if (!(shift & 0x01) && (state->m_maxrpm_last_shift & 0x01))
203
state->m_maxrpm_p1_shift++;
204
if (state->m_maxrpm_p1_shift > 4)
205
state->m_maxrpm_p1_shift = 4;
207
if (!(shift & 0x02) && (state->m_maxrpm_last_shift & 0x02))
209
state->m_maxrpm_p1_shift--;
210
if (state->m_maxrpm_p1_shift < 0)
211
state->m_maxrpm_p1_shift = 0;
213
if (!(shift & 0x04) && (state->m_maxrpm_last_shift & 0x04))
215
state->m_maxrpm_p2_shift++;
216
if (state->m_maxrpm_p2_shift > 4)
217
state->m_maxrpm_p2_shift = 4;
219
if (!(shift & 0x08) && (state->m_maxrpm_last_shift & 0x08))
221
state->m_maxrpm_p2_shift--;
222
if (state->m_maxrpm_p2_shift < 0)
223
state->m_maxrpm_p2_shift = 0;
226
state->m_maxrpm_last_shift = shift;
228
return ~((shift_bits[state->m_maxrpm_p1_shift] << 4) + shift_bits[state->m_maxrpm_p2_shift]);
226
232
static WRITE8_HANDLER( maxrpm_op5_w )
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;
231
238
/* remaining bits go to standard connections */
232
239
mcrmono_control_port_w(space, offset, data);
509
522
*************************************/
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)
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)
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)
1528
1528
*************************************/
1530
static void mcr_common_init(running_machine *machine, int sound_board)
1530
static void mcr_common_init(running_machine &machine, int sound_board)
1532
mcr3_state *state = machine.driver_data<mcr3_state>();
1532
1533
mcr_sound_init(machine, sound_board);
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);
1540
1541
static DRIVER_INIT( demoderm )
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));
1549
1550
static DRIVER_INIT( sarge )
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));
1556
1557
static DRIVER_INIT( maxrpm )
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));
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);
1572
1574
static DRIVER_INIT( rampage )
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));
1580
1582
static DRIVER_INIT( powerdrv )
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));
1589
1591
static DRIVER_INIT( stargrds )
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));
1598
1600
static DRIVER_INIT( spyhunt )
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);
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;
1610
1613
static DRIVER_INIT( crater )
1615
mcr3_state *state = machine.driver_data<mcr3_state>();
1612
1616
mcr_common_init(machine, MCR_SSIO);
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;
1619
1623
static DRIVER_INIT( turbotag )
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);
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;
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);
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));
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 )