370
370
/*************************************
374
*************************************/
377
UINT16 *system32_workram;
378
UINT16 *system32_protram;
382
/*************************************
386
*************************************/
388
static UINT8 *z80_shared_ram;
390
/* V60 interrupt controller */
391
static UINT8 v60_irq_control[0x10];
392
static timer_device *v60_irq_timer[2];
394
/* sound interrupt controller */
395
static UINT8 sound_irq_control[4];
396
static UINT8 sound_irq_input;
397
static UINT8 sound_dummy_value;
398
static UINT16 sound_bank;
401
/* I/O chips and custom I/O */
402
static UINT8 misc_io_data[2][0x10];
403
static read16_space_func custom_io_r[2];
404
static write16_space_func custom_io_w[2];
405
static UINT8 analog_bank;
406
static UINT8 analog_value[4];
407
static UINT8 sonic_last[6];
409
/* callbacks to handle output */
410
typedef void (*sys32_output_callback)(int which, UINT16 data);
411
static sys32_output_callback segas32_sw1_output, segas32_sw2_output, segas32_sw3_output;
413
static void (*system32_prot_vblank)(device_t *device);
416
/*************************************
420
374
*************************************/
422
static void signal_v60_irq(running_machine *machine, int data);
423
static void signal_sound_irq(running_machine *machine, int which);
376
static void signal_v60_irq(running_machine &machine, int data);
377
static void signal_sound_irq(running_machine &machine, int which);
503
461
case 4: /* vectors */
504
v60_irq_control[offset] = data;
462
state->m_v60_irq_control[offset] = data;
507
465
case 5: /* unknown */
508
v60_irq_control[offset] = data;
466
state->m_v60_irq_control[offset] = data;
511
469
case 6: /* mask */
512
v60_irq_control[offset] = data;
513
update_irq_state(space->machine);
470
state->m_v60_irq_control[offset] = data;
471
update_irq_state(space->machine());
516
474
case 7: /* acknowledge */
517
v60_irq_control[offset] &= data;
518
update_irq_state(space->machine);
475
state->m_v60_irq_control[offset] &= data;
476
update_irq_state(space->machine());
522
480
case 9: /* timer 0 count */
523
v60_irq_control[offset] = data;
524
duration = v60_irq_control[8] + ((v60_irq_control[9] << 8) & 0xf00);
481
state->m_v60_irq_control[offset] = data;
482
duration = state->m_v60_irq_control[8] + ((state->m_v60_irq_control[9] << 8) & 0xf00);
527
attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_0_CLOCK)) * duration);
528
v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0);
485
attotime period = attotime::from_hz(TIMER_0_CLOCK) * duration;
486
state->m_v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0);
533
491
case 11: /* timer 1 count */
534
v60_irq_control[offset] = data;
535
duration = v60_irq_control[10] + ((v60_irq_control[11] << 8) & 0xf00);
492
state->m_v60_irq_control[offset] = data;
493
duration = state->m_v60_irq_control[10] + ((state->m_v60_irq_control[11] << 8) & 0xf00);
538
attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_1_CLOCK)) * duration);
539
v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1);
496
attotime period = attotime::from_hz(TIMER_1_CLOCK) * duration;
497
state->m_v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1);
704
if (segas32_sw2_output)
705
segas32_sw2_output(which, data);
665
if (state->m_sw2_output)
666
state->m_sw2_output(which, data);
708
669
/* miscellaneous output */
710
if (segas32_sw1_output)
711
segas32_sw1_output(which, data);
671
if (state->m_sw1_output)
672
state->m_sw1_output(which, data);
715
eeprom_device *device = space->machine->device<eeprom_device>("eeprom");
676
eeprom_device *device = space->machine().device<eeprom_device>("eeprom");
716
677
eeprom_write_bit(device, data & 0x80);
717
678
eeprom_set_cs_line(device, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE);
718
679
eeprom_set_clock_line(device, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
720
/* coin_lockout_w(space->machine, 1 + 2*which, data & 0x08);
721
coin_lockout_w(space->machine, 0 + 2*which, data & 0x04);*/
722
coin_counter_w(space->machine, 1 + 2*which, data & 0x02);
723
coin_counter_w(space->machine, 0 + 2*which, data & 0x01);
681
/* coin_lockout_w(space->machine(), 1 + 2*which, data & 0x08);
682
coin_lockout_w(space->machine(), 0 + 2*which, data & 0x04);*/
683
coin_counter_w(space->machine(), 1 + 2*which, data & 0x02);
684
coin_counter_w(space->machine(), 0 + 2*which, data & 0x01);
726
687
/* tile banking */
729
system32_tilebank_external = data;
690
state->m_system32_tilebank_external = data;
732
693
/* multi-32 EEPROM access */
733
eeprom_device *device = space->machine->device<eeprom_device>("eeprom");
694
eeprom_device *device = space->machine().device<eeprom_device>("eeprom");
734
695
eeprom_write_bit(device, data & 0x80);
735
696
eeprom_set_cs_line(device, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE);
736
697
eeprom_set_clock_line(device, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
801
762
static READ16_HANDLER( io_expansion_r )
804
return (*custom_io_r[0])(space, offset, mem_mask);
764
segas32_state *state = space->machine().driver_data<segas32_state>();
765
if (state->m_custom_io_r[0])
766
return (*state->m_custom_io_r[0])(space, offset, mem_mask);
806
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
768
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(&space->device()), offset);
811
773
static WRITE16_HANDLER( io_expansion_w )
775
segas32_state *state = space->machine().driver_data<segas32_state>();
813
776
/* only LSB matters */
814
777
if (!ACCESSING_BITS_0_7)
818
(*custom_io_w[0])(space, offset, data, mem_mask);
780
if (state->m_custom_io_w[0])
781
(*state->m_custom_io_w[0])(space, offset, data, mem_mask);
820
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
783
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
824
787
static READ32_HANDLER( io_expansion_0_r )
827
return (*custom_io_r[0])(space, offset*2+0, mem_mask) |
828
((*custom_io_r[0])(space, offset*2+1, mem_mask >> 16) << 16);
789
segas32_state *state = space->machine().driver_data<segas32_state>();
790
if (state->m_custom_io_r[0])
791
return (*state->m_custom_io_r[0])(space, offset*2+0, mem_mask) |
792
((*state->m_custom_io_r[0])(space, offset*2+1, mem_mask >> 16) << 16);
830
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
794
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(&space->device()), offset);
831
795
return 0xffffffff;
835
799
static WRITE32_HANDLER( io_expansion_0_w )
801
segas32_state *state = space->machine().driver_data<segas32_state>();
837
802
/* only LSB matters */
840
805
if (ACCESSING_BITS_0_7)
842
807
/* harddunk uses bits 4,5 for output lamps */
843
if (segas32_sw3_output)
844
segas32_sw3_output(0, data & 0xff);
808
if (state->m_sw3_output)
809
state->m_sw3_output(0, data & 0xff);
847
(*custom_io_w[0])(space, offset*2+0, data, mem_mask);
811
if (state->m_custom_io_w[0])
812
(*state->m_custom_io_w[0])(space, offset*2+0, data, mem_mask);
849
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
814
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
852
817
if (ACCESSING_BITS_16_23)
855
(*custom_io_w[0])(space, offset*2+1, data >> 16, mem_mask >> 16);
819
if (state->m_custom_io_w[0])
820
(*state->m_custom_io_w[0])(space, offset*2+1, data >> 16, mem_mask >> 16);
857
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
822
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
862
827
static READ32_HANDLER( io_expansion_1_r )
865
return (*custom_io_r[1])(space, offset*2+0, mem_mask) |
866
((*custom_io_r[1])(space, offset*2+1, mem_mask >> 16) << 16);
829
segas32_state *state = space->machine().driver_data<segas32_state>();
830
if (state->m_custom_io_r[1])
831
return (*state->m_custom_io_r[1])(space, offset*2+0, mem_mask) |
832
((*state->m_custom_io_r[1])(space, offset*2+1, mem_mask >> 16) << 16);
868
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
834
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(&space->device()), offset);
869
835
return 0xffffffff;
873
839
static WRITE32_HANDLER( io_expansion_1_w )
841
segas32_state *state = space->machine().driver_data<segas32_state>();
875
842
/* only LSB matters */
876
843
if (ACCESSING_BITS_0_7)
879
(*custom_io_w[1])(space, offset*2+0, data, mem_mask);
845
if (state->m_custom_io_w[1])
846
(*state->m_custom_io_w[1])(space, offset*2+0, data, mem_mask);
881
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
848
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
883
850
if (ACCESSING_BITS_16_23)
886
(*custom_io_w[1])(space, offset*2+1, data >> 16, mem_mask >> 16);
852
if (state->m_custom_io_w[1])
853
(*state->m_custom_io_w[1])(space, offset*2+1, data >> 16, mem_mask >> 16);
888
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
855
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
1106
static void signal_sound_irq(running_machine *machine, int which)
1083
static void signal_sound_irq(running_machine &machine, int which)
1085
segas32_state *state = machine.driver_data<segas32_state>();
1110
1088
/* see if this interrupt input is mapped to any vectors; if so, mark them */
1111
1089
for (i = 0; i < 3; i++)
1112
if (sound_irq_control[i] == which)
1113
sound_irq_input |= 1 << i;
1090
if (state->m_sound_irq_control[i] == which)
1091
state->m_sound_irq_input |= 1 << i;
1114
1092
update_sound_irq_state(machine);
1118
static void clear_sound_irq(running_machine *machine, int which)
1096
static void clear_sound_irq(running_machine &machine, int which)
1098
segas32_state *state = machine.driver_data<segas32_state>();
1121
1100
for (i = 0; i < 3; i++)
1122
if (sound_irq_control[i] == which)
1123
sound_irq_input &= ~(1 << i);
1101
if (state->m_sound_irq_control[i] == which)
1102
state->m_sound_irq_input &= ~(1 << i);
1124
1103
update_sound_irq_state(machine);
1128
1107
static WRITE8_HANDLER( sound_int_control_lo_w )
1109
segas32_state *state = space->machine().driver_data<segas32_state>();
1130
1110
/* odd offsets are interrupt acks */
1131
1111
if (offset & 1)
1133
sound_irq_input &= data;
1134
update_sound_irq_state(space->machine);
1113
state->m_sound_irq_input &= data;
1114
update_sound_irq_state(space->machine());
1137
1117
/* high offsets signal an IRQ to the v60 */
1138
1118
if (offset & 4)
1139
signal_v60_irq(space->machine, MAIN_IRQ_SOUND);
1119
signal_v60_irq(space->machine(), MAIN_IRQ_SOUND);
1143
1123
static WRITE8_HANDLER( sound_int_control_hi_w )
1145
sound_irq_control[offset] = data;
1146
update_sound_irq_state(space->machine);
1125
segas32_state *state = space->machine().driver_data<segas32_state>();
1126
state->m_sound_irq_control[offset] = data;
1127
update_sound_irq_state(space->machine());
1150
1131
static void ym3438_irq_handler(device_t *device, int state)
1153
signal_sound_irq(device->machine, SOUND_IRQ_YM3438);
1134
signal_sound_irq(device->machine(), SOUND_IRQ_YM3438);
1155
clear_sound_irq(device->machine, SOUND_IRQ_YM3438);
1136
clear_sound_irq(device->machine(), SOUND_IRQ_YM3438);
1216
1201
*************************************/
1218
static ADDRESS_MAP_START( system32_map, ADDRESS_SPACE_PROGRAM, 16 )
1203
static ADDRESS_MAP_START( system32_map, AS_PROGRAM, 16 )
1219
1204
ADDRESS_MAP_UNMAP_HIGH
1220
1205
AM_RANGE(0x000000, 0x1fffff) AM_ROM
1221
AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x0f0000) AM_RAM AM_BASE(&system32_workram)
1222
AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_videoram_r, system32_videoram_w) AM_BASE(&system32_videoram)
1223
AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_spriteram_r, system32_spriteram_w) AM_BASE(&system32_spriteram)
1206
AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x0f0000) AM_RAM AM_BASE_MEMBER(segas32_state, m_system32_workram)
1207
AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_videoram_r, system32_videoram_w) AM_BASE_MEMBER(segas32_state, m_system32_videoram)
1208
AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_spriteram_r, system32_spriteram_w) AM_BASE_MEMBER(segas32_state, m_system32_spriteram)
1224
1209
AM_RANGE(0x500000, 0x50000f) AM_MIRROR(0x0ffff0) AM_READWRITE(system32_sprite_control_r, system32_sprite_control_w)
1225
AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_paletteram_r, system32_paletteram_w) AM_BASE(&system32_paletteram[0])
1210
AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_paletteram_r, system32_paletteram_w) AM_BASE_MEMBER(segas32_state, m_system32_paletteram[0])
1226
1211
AM_RANGE(0x610000, 0x61007f) AM_MIRROR(0x0eff80) AM_READWRITE(system32_mixer_r, system32_mixer_w)
1227
1212
AM_RANGE(0x700000, 0x701fff) AM_MIRROR(0x0fe000) AM_READWRITE(shared_ram_16_r, shared_ram_16_w)
1228
1213
AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x0fff80) AM_READWRITE(io_chip_r, io_chip_w)
1233
1218
ADDRESS_MAP_END
1236
static ADDRESS_MAP_START( multi32_map, ADDRESS_SPACE_PROGRAM, 32 )
1221
static ADDRESS_MAP_START( multi32_map, AS_PROGRAM, 32 )
1237
1222
ADDRESS_MAP_UNMAP_HIGH
1238
1223
ADDRESS_MAP_GLOBAL_MASK(0xffffff)
1239
1224
AM_RANGE(0x000000, 0x1fffff) AM_ROM
1240
1225
AM_RANGE(0x200000, 0x21ffff) AM_MIRROR(0x0e0000) AM_RAM
1241
AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_videoram_r, multi32_videoram_w) AM_BASE((UINT32 **)&system32_videoram)
1242
AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_spriteram_r, multi32_spriteram_w) AM_BASE((UINT32 **)&system32_spriteram)
1226
AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_videoram_r, multi32_videoram_w) AM_BASE_MEMBER(segas32_state, m_system32_videoram)
1227
AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_spriteram_r, multi32_spriteram_w) AM_BASE_MEMBER(segas32_state, m_system32_spriteram)
1243
1228
AM_RANGE(0x500000, 0x50000f) AM_MIRROR(0x0ffff0) AM_READWRITE(multi32_sprite_control_r, multi32_sprite_control_w)
1244
AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_0_r, multi32_paletteram_0_w) AM_BASE((UINT32 **)&system32_paletteram[0])
1229
AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_0_r, multi32_paletteram_0_w) AM_BASE_MEMBER(segas32_state, m_system32_paletteram[0])
1245
1230
AM_RANGE(0x610000, 0x61007f) AM_MIRROR(0x06ff80) AM_WRITE(multi32_mixer_0_w)
1246
AM_RANGE(0x680000, 0x68ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_1_r, multi32_paletteram_1_w) AM_BASE((UINT32 **)&system32_paletteram[1])
1231
AM_RANGE(0x680000, 0x68ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_1_r, multi32_paletteram_1_w) AM_BASE_MEMBER(segas32_state, m_system32_paletteram[1])
1247
1232
AM_RANGE(0x690000, 0x69007f) AM_MIRROR(0x06ff80) AM_WRITE(multi32_mixer_1_w)
1248
1233
AM_RANGE(0x700000, 0x701fff) AM_MIRROR(0x0fe000) AM_READWRITE(shared_ram_32_r, shared_ram_32_w)
1249
1234
AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x07ff80) AM_READWRITE(io_chip_0_r, io_chip_0_w)
4020
4009
static DRIVER_INIT( arescue )
4022
segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4023
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00007, 0, 0, arescue_dsp_r, arescue_dsp_w);
4025
dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
4026
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810fff, 0, 0, dual_pcb_comms_r, dual_pcb_comms_w);
4027
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x818000, 0x818003, 0, 0, dual_pcb_masterslave);
4029
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810001, 0, 0, arescue_handshake_r);
4030
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x81000e, 0x81000f, 0, 0, arescue_slavebusy_r);
4032
segas32_sw1_output = arescue_sw1_output;
4011
segas32_state *state = machine.driver_data<segas32_state>();
4012
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4013
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa00007, FUNC(arescue_dsp_r), FUNC(arescue_dsp_w));
4015
state->m_dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
4016
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x810000, 0x810fff, FUNC(dual_pcb_comms_r), FUNC(dual_pcb_comms_w));
4017
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x818000, 0x818003, FUNC(dual_pcb_masterslave));
4019
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x810000, 0x810001, FUNC(arescue_handshake_r));
4020
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x81000e, 0x81000f, FUNC(arescue_slavebusy_r));
4022
state->m_sw1_output = arescue_sw1_output;
4036
4026
static DRIVER_INIT( arabfgt )
4038
segas32_common_init(extra_custom_io_r, NULL);
4028
segas32_common_init(machine, extra_custom_io_r, NULL);
4040
4030
/* install protection handlers */
4041
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00100, 0xa0011f, 0, 0, arf_wakeup_protection_r);
4042
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, arabfgt_protection_r, arabfgt_protection_w);
4031
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0xa00100, 0xa0011f, FUNC(arf_wakeup_protection_r));
4032
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa00fff, FUNC(arabfgt_protection_r), FUNC(arabfgt_protection_w));
4046
4036
static DRIVER_INIT( brival )
4048
segas32_common_init(extra_custom_io_r, NULL);
4038
segas32_state *state = machine.driver_data<segas32_state>();
4039
segas32_common_init(machine, extra_custom_io_r, NULL);
4050
4041
/* install protection handlers */
4051
system32_protram = auto_alloc_array(machine, UINT16, 0x1000/2);
4052
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20ba00, 0x20ba07, 0, 0, brival_protection_r);
4053
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, brival_protection_w);
4042
state->m_system32_protram = auto_alloc_array(machine, UINT16, 0x1000/2);
4043
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x20ba00, 0x20ba07, FUNC(brival_protection_r));
4044
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xa00000, 0xa00fff, FUNC(brival_protection_w));
4057
4048
static DRIVER_INIT( darkedge )
4059
segas32_common_init(extra_custom_io_r, NULL);
4050
segas32_state *state = machine.driver_data<segas32_state>();
4051
segas32_common_init(machine, extra_custom_io_r, NULL);
4061
4053
/* install protection handlers */
4062
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa7ffff, 0, 0, darkedge_protection_r, darkedge_protection_w);
4063
system32_prot_vblank = darkedge_fd1149_vblank;
4054
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa7ffff, FUNC(darkedge_protection_r), FUNC(darkedge_protection_w));
4055
state->m_system32_prot_vblank = darkedge_fd1149_vblank;
4066
4058
static DRIVER_INIT( dbzvrvs )
4068
segas32_common_init(NULL, NULL);
4060
segas32_common_init(machine, NULL, NULL);
4070
4062
/* install protection handlers */
4071
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa7ffff, 0, 0, dbzvrvs_protection_r, dbzvrvs_protection_w);
4063
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa7ffff, FUNC(dbzvrvs_protection_r), FUNC(dbzvrvs_protection_w));
4074
4066
static WRITE16_HANDLER( f1en_comms_echo_w )
4081
4073
static DRIVER_INIT( f1en )
4083
segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4085
dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
4086
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810fff, 0, 0, dual_pcb_comms_r, dual_pcb_comms_w);
4087
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x818000, 0x818003, 0, 0, dual_pcb_masterslave);
4089
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810048, 0x810049, 0, 0, f1en_comms_echo_w);
4091
segas32_sw1_output = radm_sw1_output;
4075
segas32_state *state = machine.driver_data<segas32_state>();
4076
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4078
state->m_dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
4079
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x810000, 0x810fff, FUNC(dual_pcb_comms_r), FUNC(dual_pcb_comms_w));
4080
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x818000, 0x818003, FUNC(dual_pcb_masterslave));
4082
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x810048, 0x810049, FUNC(f1en_comms_echo_w));
4084
state->m_sw1_output = radm_sw1_output;
4095
4088
static DRIVER_INIT( f1lap )
4097
segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4098
segas32_sw1_output = f1lap_sw1_output;
4090
segas32_state *state = machine.driver_data<segas32_state>();
4091
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4092
state->m_sw1_output = f1lap_sw1_output;
4102
4096
static DRIVER_INIT( ga2 )
4104
segas32_common_init(extra_custom_io_r, NULL);
4098
segas32_common_init(machine, extra_custom_io_r, NULL);
4106
4100
decrypt_ga2_protrom(machine);
4107
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, ga2_dpram_r, ga2_dpram_w);
4101
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa00fff, FUNC(ga2_dpram_r), FUNC(ga2_dpram_w));
4111
4105
static DRIVER_INIT( harddunk )
4113
segas32_common_init(extra_custom_io_r, NULL);
4114
segas32_sw1_output = harddunk_sw1_output;
4115
segas32_sw2_output = harddunk_sw2_output;
4116
segas32_sw3_output = harddunk_sw3_output;
4107
segas32_state *state = machine.driver_data<segas32_state>();
4108
segas32_common_init(machine, extra_custom_io_r, NULL);
4109
state->m_sw1_output = harddunk_sw1_output;
4110
state->m_sw2_output = harddunk_sw2_output;
4111
state->m_sw3_output = harddunk_sw3_output;
4120
4115
static DRIVER_INIT( holo )
4122
segas32_common_init(NULL, NULL);
4117
segas32_common_init(machine, NULL, NULL);
4126
4121
static DRIVER_INIT( jpark )
4123
segas32_state *state = machine.driver_data<segas32_state>();
4128
4124
/* Temp. Patch until we emulate the 'Drive Board', thanks to Malice */
4129
UINT16 *pROM = (UINT16 *)machine->region("maincpu")->base();
4125
UINT16 *pROM = (UINT16 *)machine.region("maincpu")->base();
4131
segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4127
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4133
4129
pROM[0xC15A8/2] = 0xCD70;
4134
4130
pROM[0xC15AA/2] = 0xD8CD;
4136
segas32_sw1_output = jpark_sw1_output;
4132
state->m_sw1_output = jpark_sw1_output;
4140
4136
static DRIVER_INIT( orunners )
4142
segas32_common_init(analog_custom_io_r, orunners_custom_io_w);
4143
segas32_sw1_output = orunners_sw1_output;
4144
segas32_sw2_output = orunners_sw2_output;
4138
segas32_state *state = machine.driver_data<segas32_state>();
4139
segas32_common_init(machine, analog_custom_io_r, orunners_custom_io_w);
4140
state->m_sw1_output = orunners_sw1_output;
4141
state->m_sw2_output = orunners_sw2_output;
4148
4145
static DRIVER_INIT( radm )
4150
segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4151
segas32_sw1_output = radm_sw1_output;
4152
segas32_sw2_output = radm_sw2_output;
4147
segas32_state *state = machine.driver_data<segas32_state>();
4148
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4149
state->m_sw1_output = radm_sw1_output;
4150
state->m_sw2_output = radm_sw2_output;
4156
4154
static DRIVER_INIT( radr )
4158
segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4159
segas32_sw1_output = radm_sw1_output;
4160
segas32_sw2_output = radr_sw2_output;
4156
segas32_state *state = machine.driver_data<segas32_state>();
4157
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4158
state->m_sw1_output = radm_sw1_output;
4159
state->m_sw2_output = radr_sw2_output;
4164
4163
static DRIVER_INIT( scross )
4166
multipcm_device *multipcm = machine->device<multipcm_device>("sega");
4167
segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4168
memory_install_write8_device_handler(cputag_get_address_space(machine, "soundcpu", ADDRESS_SPACE_PROGRAM), multipcm, 0xb0, 0xbf, 0, 0, scross_bank_w);
4165
segas32_state *state = machine.driver_data<segas32_state>();
4166
multipcm_device *multipcm = machine.device<multipcm_device>("sega");
4167
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4168
machine.device("soundcpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(*multipcm, 0xb0, 0xbf, FUNC(scross_bank_w));
4170
segas32_sw1_output = scross_sw1_output;
4171
segas32_sw2_output = scross_sw2_output;
4170
state->m_sw1_output = scross_sw1_output;
4171
state->m_sw2_output = scross_sw2_output;
4175
4175
static DRIVER_INIT( slipstrm )
4177
segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4177
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4181
4181
static DRIVER_INIT( sonic )
4183
segas32_common_init(sonic_custom_io_r, sonic_custom_io_w);
4183
segas32_common_init(machine, sonic_custom_io_r, sonic_custom_io_w);
4185
4185
/* install protection handlers */
4186
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20E5C4, 0x20E5C5, 0, 0, sonic_level_load_protection);
4186
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x20E5C4, 0x20E5C5, FUNC(sonic_level_load_protection));
4190
4190
static DRIVER_INIT( sonicp )
4192
segas32_common_init(sonic_custom_io_r, sonic_custom_io_w);
4192
segas32_common_init(machine, sonic_custom_io_r, sonic_custom_io_w);
4196
4196
static DRIVER_INIT( spidman )
4198
segas32_common_init(extra_custom_io_r, NULL);
4198
segas32_common_init(machine, extra_custom_io_r, NULL);
4202
4202
static DRIVER_INIT( svf )
4204
segas32_common_init(NULL, NULL);
4204
segas32_common_init(machine, NULL, NULL);
4208
4208
static DRIVER_INIT( jleague )
4210
segas32_common_init(NULL, NULL);
4211
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20F700, 0x20F705, 0, 0, jleague_protection_w);
4210
segas32_common_init(machine, NULL, NULL);
4211
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x20F700, 0x20F705, FUNC(jleague_protection_w));
4215
4215
static DRIVER_INIT( titlef )
4217
segas32_common_init(NULL, NULL);
4218
segas32_sw1_output = titlef_sw1_output;
4219
segas32_sw2_output = titlef_sw2_output;
4217
segas32_state *state = machine.driver_data<segas32_state>();
4218
segas32_common_init(machine, NULL, NULL);
4219
state->m_sw1_output = titlef_sw1_output;
4220
state->m_sw2_output = titlef_sw2_output;