Previous 199869 Revisions Next

r26011 Tuesday 5th November, 2013 at 18:08:17 UTC by Osso
harddriv: moved handlers in the driver state. (nw)
[src/mame/drivers]harddriv.c
[src/mame/includes]harddriv.h
[src/mame/machine]harddriv.c
[src/mame/video]harddriv.c

trunk/src/mame/drivers/harddriv.c
r26010r26011
428428static ADDRESS_MAP_START( driver_68k_map, AS_PROGRAM, 16, harddriv_state )
429429   ADDRESS_MAP_UNMAP_HIGH
430430   AM_RANGE(0x000000, 0x0fffff) AM_ROM
431   AM_RANGE(0x600000, 0x603fff) AM_READ_LEGACY(hd68k_port0_r)
432   AM_RANGE(0x604000, 0x607fff) AM_WRITE_LEGACY(hd68k_nwr_w)
431   AM_RANGE(0x600000, 0x603fff) AM_READ(hd68k_port0_r)
432   AM_RANGE(0x604000, 0x607fff) AM_WRITE(hd68k_nwr_w)
433433   AM_RANGE(0x608000, 0x60bfff) AM_WRITE(watchdog_reset16_w)
434   AM_RANGE(0x60c000, 0x60ffff) AM_WRITE_LEGACY(hd68k_irq_ack_w)
435   AM_RANGE(0xa00000, 0xa7ffff) AM_WRITE_LEGACY(hd68k_wr0_write)
436   AM_RANGE(0xa80000, 0xafffff) AM_READ_PORT("a80000") AM_WRITE_LEGACY(hd68k_wr1_write)
437   AM_RANGE(0xb00000, 0xb7ffff) AM_READWRITE_LEGACY(hd68k_adc8_r, hd68k_wr2_write)
438   AM_RANGE(0xb80000, 0xbfffff) AM_READWRITE_LEGACY(hd68k_adc12_r, hd68k_adc_control_w)
439   AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE_LEGACY(hd68k_gsp_io_r, hd68k_gsp_io_w)
440   AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE_LEGACY(hd68k_msp_io_r, hd68k_msp_io_w)
434   AM_RANGE(0x60c000, 0x60ffff) AM_WRITE(hd68k_irq_ack_w)
435   AM_RANGE(0xa00000, 0xa7ffff) AM_WRITE(hd68k_wr0_write)
436   AM_RANGE(0xa80000, 0xafffff) AM_READ_PORT("a80000") AM_WRITE(hd68k_wr1_write)
437   AM_RANGE(0xb00000, 0xb7ffff) AM_READWRITE(hd68k_adc8_r, hd68k_wr2_write)
438   AM_RANGE(0xb80000, 0xbfffff) AM_READWRITE(hd68k_adc12_r, hd68k_adc_control_w)
439   AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE(hd68k_gsp_io_r, hd68k_gsp_io_w)
440   AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE(hd68k_msp_io_r, hd68k_msp_io_w)
441441   AM_RANGE(0xff0000, 0xff001f) AM_DEVREADWRITE8("duartn68681", duartn68681_device, read, write, 0xff00)
442   AM_RANGE(0xff4000, 0xff4fff) AM_READWRITE_LEGACY(hd68k_zram_r, hd68k_zram_w) AM_SHARE("zram")
442   AM_RANGE(0xff4000, 0xff4fff) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_SHARE("zram")
443443   AM_RANGE(0xff8000, 0xffffff) AM_RAM
444444ADDRESS_MAP_END
445445
r26010r26011
447447static ADDRESS_MAP_START( driver_gsp_map, AS_PROGRAM, 16, harddriv_state )
448448   ADDRESS_MAP_UNMAP_HIGH
449449   AM_RANGE(0x00000000, 0x0000200f) AM_NOP                 /* hit during self-test */
450   AM_RANGE(0x02000000, 0x0207ffff) AM_READWRITE_LEGACY(hdgsp_vram_2bpp_r, hdgsp_vram_1bpp_w)
451   AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE_LEGACY(tms34010_io_register_r, hdgsp_io_w)
452   AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE_LEGACY(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_SHARE("gsp_control_lo")
453   AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE_LEGACY(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_SHARE("gsp_control_hi")
454   AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE_LEGACY(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_SHARE("gsp_palram_lo")
455   AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE_LEGACY(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_SHARE("gsp_palram_hi")
450   AM_RANGE(0x02000000, 0x0207ffff) AM_READWRITE(hdgsp_vram_2bpp_r, hdgsp_vram_1bpp_w)
451   AM_RANGE(0xc0000000, 0xc00001ff) AM_READ_LEGACY(tms34010_io_register_r) AM_WRITE(hdgsp_io_w)
452   AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_SHARE("gsp_control_lo")
453   AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_SHARE("gsp_control_hi")
454   AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_SHARE("gsp_palram_lo")
455   AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_SHARE("gsp_palram_hi")
456456   AM_RANGE(0xff800000, 0xffffffff) AM_RAM AM_SHARE("gsp_vram")
457457ADDRESS_MAP_END
458458
r26010r26011
476476static ADDRESS_MAP_START( multisync_68k_map, AS_PROGRAM, 16, harddriv_state )
477477   ADDRESS_MAP_UNMAP_HIGH
478478   AM_RANGE(0x000000, 0x0fffff) AM_ROM
479   AM_RANGE(0x604000, 0x607fff) AM_READWRITE_LEGACY(hd68k_sound_reset_r, hd68k_nwr_w)
479   AM_RANGE(0x604000, 0x607fff) AM_READWRITE(hd68k_sound_reset_r, hd68k_nwr_w)
480480   AM_RANGE(0x608000, 0x60bfff) AM_WRITE(watchdog_reset16_w)
481   AM_RANGE(0x60c000, 0x60ffff) AM_READWRITE_LEGACY(hd68k_port0_r, hd68k_irq_ack_w)
482   AM_RANGE(0xa00000, 0xa7ffff) AM_WRITE_LEGACY(hd68k_wr0_write)
483   AM_RANGE(0xa80000, 0xafffff) AM_READ_PORT("a80000") AM_WRITE_LEGACY(hd68k_wr1_write)
484   AM_RANGE(0xb00000, 0xb7ffff) AM_READWRITE_LEGACY(hd68k_adc8_r, hd68k_wr2_write)
485   AM_RANGE(0xb80000, 0xbfffff) AM_READWRITE_LEGACY(hd68k_adc12_r, hd68k_adc_control_w)
486   AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE_LEGACY(hd68k_gsp_io_r, hd68k_gsp_io_w)
487   AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE_LEGACY(hd68k_msp_io_r, hd68k_msp_io_w)
481   AM_RANGE(0x60c000, 0x60ffff) AM_READWRITE(hd68k_port0_r, hd68k_irq_ack_w)
482   AM_RANGE(0xa00000, 0xa7ffff) AM_WRITE(hd68k_wr0_write)
483   AM_RANGE(0xa80000, 0xafffff) AM_READ_PORT("a80000") AM_WRITE(hd68k_wr1_write)
484   AM_RANGE(0xb00000, 0xb7ffff) AM_READWRITE(hd68k_adc8_r, hd68k_wr2_write)
485   AM_RANGE(0xb80000, 0xbfffff) AM_READWRITE(hd68k_adc12_r, hd68k_adc_control_w)
486   AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE(hd68k_gsp_io_r, hd68k_gsp_io_w)
487   AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE(hd68k_msp_io_r, hd68k_msp_io_w)
488488   AM_RANGE(0xff0000, 0xff001f) AM_DEVREADWRITE8("duartn68681", duartn68681_device, read, write, 0xff00)
489   AM_RANGE(0xff4000, 0xff4fff) AM_READWRITE_LEGACY(hd68k_zram_r, hd68k_zram_w) AM_SHARE("zram")
489   AM_RANGE(0xff4000, 0xff4fff) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_SHARE("zram")
490490   AM_RANGE(0xff8000, 0xffffff) AM_RAM
491491ADDRESS_MAP_END
492492
r26010r26011
494494static ADDRESS_MAP_START( multisync_gsp_map, AS_PROGRAM, 16, harddriv_state )
495495   ADDRESS_MAP_UNMAP_HIGH
496496   AM_RANGE(0x00000000, 0x0000200f) AM_NOP                 /* hit during self-test */
497   AM_RANGE(0x02000000, 0x020fffff) AM_READWRITE_LEGACY(hdgsp_vram_2bpp_r, hdgsp_vram_2bpp_w)
498   AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE_LEGACY(tms34010_io_register_r, hdgsp_io_w)
499   AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE_LEGACY(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_SHARE("gsp_control_lo")
500   AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE_LEGACY(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_SHARE("gsp_control_hi")
501   AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE_LEGACY(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_SHARE("gsp_palram_lo")
502   AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE_LEGACY(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_SHARE("gsp_palram_hi")
497   AM_RANGE(0x02000000, 0x020fffff) AM_READWRITE(hdgsp_vram_2bpp_r, hdgsp_vram_2bpp_w)
498   AM_RANGE(0xc0000000, 0xc00001ff) AM_READ_LEGACY(tms34010_io_register_r) AM_WRITE(hdgsp_io_w)
499   AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_SHARE("gsp_control_lo")
500   AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_SHARE("gsp_control_hi")
501   AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_SHARE("gsp_palram_lo")
502   AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_SHARE("gsp_palram_hi")
503503   AM_RANGE(0xff800000, 0xffbfffff) AM_MIRROR(0x0400000) AM_RAM AM_SHARE("gsp_vram")
504504ADDRESS_MAP_END
505505
r26010r26011
514514static ADDRESS_MAP_START( multisync2_68k_map, AS_PROGRAM, 16, harddriv_state )
515515   ADDRESS_MAP_UNMAP_HIGH
516516   AM_RANGE(0x000000, 0x1fffff) AM_ROM
517   AM_RANGE(0x604000, 0x607fff) AM_WRITE_LEGACY(hd68k_nwr_w)
517   AM_RANGE(0x604000, 0x607fff) AM_WRITE(hd68k_nwr_w)
518518   AM_RANGE(0x608000, 0x60bfff) AM_WRITE(watchdog_reset16_w)
519   AM_RANGE(0x60c000, 0x60ffff) AM_READWRITE_LEGACY(hd68k_port0_r, hd68k_irq_ack_w)
520   AM_RANGE(0xa00000, 0xa7ffff) AM_WRITE_LEGACY(hd68k_wr0_write)
521   AM_RANGE(0xa80000, 0xafffff) AM_READ_PORT("a80000") AM_WRITE_LEGACY(hd68k_wr1_write)
522   AM_RANGE(0xb00000, 0xb7ffff) AM_READWRITE_LEGACY(hd68k_adc8_r, hd68k_wr2_write)
523   AM_RANGE(0xb80000, 0xbfffff) AM_READWRITE_LEGACY(hd68k_adc12_r, hd68k_adc_control_w)
524   AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE_LEGACY(hd68k_gsp_io_r, hd68k_gsp_io_w)
525   AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE_LEGACY(hd68k_msp_io_r, hd68k_msp_io_w)
519   AM_RANGE(0x60c000, 0x60ffff) AM_READWRITE(hd68k_port0_r, hd68k_irq_ack_w)
520   AM_RANGE(0xa00000, 0xa7ffff) AM_WRITE(hd68k_wr0_write)
521   AM_RANGE(0xa80000, 0xafffff) AM_READ_PORT("a80000") AM_WRITE(hd68k_wr1_write)
522   AM_RANGE(0xb00000, 0xb7ffff) AM_READWRITE(hd68k_adc8_r, hd68k_wr2_write)
523   AM_RANGE(0xb80000, 0xbfffff) AM_READWRITE(hd68k_adc12_r, hd68k_adc_control_w)
524   AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE(hd68k_gsp_io_r, hd68k_gsp_io_w)
525   AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE(hd68k_msp_io_r, hd68k_msp_io_w)
526526   AM_RANGE(0xfc0000, 0xfc001f) AM_DEVREADWRITE8("duartn68681", duartn68681_device, read, write, 0xff00)
527   AM_RANGE(0xfd0000, 0xfd0fff) AM_MIRROR(0x004000) AM_READWRITE_LEGACY(hd68k_zram_r, hd68k_zram_w) AM_SHARE("zram")
527   AM_RANGE(0xfd0000, 0xfd0fff) AM_MIRROR(0x004000) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_SHARE("zram")
528528   AM_RANGE(0xff0000, 0xffffff) AM_RAM
529529ADDRESS_MAP_END
530530
r26010r26011
533533static ADDRESS_MAP_START( multisync2_gsp_map, AS_PROGRAM, 16, harddriv_state )
534534   ADDRESS_MAP_UNMAP_HIGH
535535   AM_RANGE(0x00000000, 0x0000200f) AM_NOP                 /* hit during self-test */
536   AM_RANGE(0x02000000, 0x020fffff) AM_READWRITE_LEGACY(hdgsp_vram_2bpp_r, hdgsp_vram_2bpp_w)
537   AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE_LEGACY(tms34010_io_register_r, hdgsp_io_w)
538   AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE_LEGACY(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_SHARE("gsp_control_lo")
539   AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE_LEGACY(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_SHARE("gsp_control_hi")
540   AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE_LEGACY(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_SHARE("gsp_palram_lo")
541   AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE_LEGACY(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_SHARE("gsp_palram_hi")
536   AM_RANGE(0x02000000, 0x020fffff) AM_READWRITE(hdgsp_vram_2bpp_r, hdgsp_vram_2bpp_w)
537   AM_RANGE(0xc0000000, 0xc00001ff) AM_READ_LEGACY(tms34010_io_register_r) AM_WRITE(hdgsp_io_w)
538   AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_SHARE("gsp_control_lo")
539   AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_SHARE("gsp_control_hi")
540   AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_SHARE("gsp_palram_lo")
541   AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_SHARE("gsp_palram_hi")
542542   AM_RANGE(0xff800000, 0xffffffff) AM_RAM AM_SHARE("gsp_vram")
543543ADDRESS_MAP_END
544544
r26010r26011
559559static ADDRESS_MAP_START( adsp_data_map, AS_DATA, 16, harddriv_state )
560560   ADDRESS_MAP_UNMAP_HIGH
561561   AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("adsp_data")
562   AM_RANGE(0x2000, 0x2fff) AM_READWRITE_LEGACY(hdadsp_special_r, hdadsp_special_w)
562   AM_RANGE(0x2000, 0x2fff) AM_READWRITE(hdadsp_special_r, hdadsp_special_w)
563563ADDRESS_MAP_END
564564
565565
r26010r26011
580580   ADDRESS_MAP_UNMAP_HIGH
581581   AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("adsp_data")
582582   AM_RANGE(0x3800, 0x3bff) AM_RAM                     /* internal RAM */
583   AM_RANGE(0x3fe0, 0x3fff) AM_READWRITE_LEGACY(hdds3_control_r, hdds3_control_w)  /* adsp control regs */
584   AM_RANGE(0x2000, 0x3fff) AM_READWRITE_LEGACY(hdds3_special_r, hdds3_special_w)
583   AM_RANGE(0x3fe0, 0x3fff) AM_READWRITE(hdds3_control_r, hdds3_control_w)  /* adsp control regs */
584   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(hdds3_special_r, hdds3_special_w)
585585ADDRESS_MAP_END
586586
587587
r26010r26011
593593static ADDRESS_MAP_START( ds3sdsp_data_map, AS_DATA, 16, harddriv_state )
594594   ADDRESS_MAP_UNMAP_HIGH
595595   AM_RANGE(0x3800, 0x39ff) AM_RAM                     /* internal RAM */
596   AM_RANGE(0x3fe0, 0x3fff) AM_READWRITE_LEGACY(hdds3_sdsp_control_r, hdds3_sdsp_control_w)
597   AM_RANGE(0x2000, 0x3fff) AM_READWRITE_LEGACY(hdds3_sdsp_special_r, hdds3_sdsp_special_w)
596   AM_RANGE(0x3fe0, 0x3fff) AM_READWRITE(hdds3_sdsp_control_r, hdds3_sdsp_control_w)
597   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(hdds3_sdsp_special_r, hdds3_sdsp_special_w)
598598ADDRESS_MAP_END
599599
600600
r26010r26011
607607   ADDRESS_MAP_UNMAP_HIGH
608608   AM_RANGE(0x0000, 0x1fff) AM_RAM // TODO
609609   AM_RANGE(0x3800, 0x39ff) AM_RAM                     /* internal RAM */
610   AM_RANGE(0x3fe0, 0x3fff) AM_READWRITE_LEGACY(hdds3_xdsp_control_r, hdds3_xdsp_control_w)
610   AM_RANGE(0x3fe0, 0x3fff) AM_READWRITE(hdds3_xdsp_control_r, hdds3_xdsp_control_w)
611611ADDRESS_MAP_END
612612
613613
r26010r26011
40544054   /* install handlers for the compact driving games' inputs */
40554055   if (compact_inputs)
40564056   {
4057      state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x400000, 0x400001, FUNC(hdc68k_wheel_r));
4058      state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x408000, 0x408001, FUNC(hdc68k_wheel_edge_reset_w));
4059      state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0xa80000, 0xafffff, FUNC(hdc68k_port1_r));
4057      state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x400000, 0x400001, read16_delegate(FUNC(harddriv_state::hdc68k_wheel_r), state));
4058      state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x408000, 0x408001, write16_delegate(FUNC(harddriv_state::hdc68k_wheel_edge_reset_w), state));
4059      state->m_maincpu->space(AS_PROGRAM).install_read_handler(0xa80000, 0xafffff, read16_delegate(FUNC(harddriv_state::hdc68k_port1_r), state));
40604060   }
40614061}
40624062
r26010r26011
40674067   harddriv_state *state = machine.driver_data<harddriv_state>();
40684068
40694069   /* install ADSP program RAM */
4070   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x800000, 0x807fff, FUNC(hd68k_adsp_program_r), FUNC(hd68k_adsp_program_w));
4070   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x800000, 0x807fff, read16_delegate(FUNC(harddriv_state::hd68k_adsp_program_r), state), write16_delegate(FUNC(harddriv_state::hd68k_adsp_program_w), state));
40714071
40724072   /* install ADSP data RAM */
4073   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x808000, 0x80bfff, FUNC(hd68k_adsp_data_r), FUNC(hd68k_adsp_data_w));
4073   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x808000, 0x80bfff, read16_delegate(FUNC(harddriv_state::hd68k_adsp_data_r), state), write16_delegate(FUNC(harddriv_state::hd68k_adsp_data_w), state));
40744074
40754075   /* install ADSP serial buffer RAM */
4076   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x810000, 0x813fff, FUNC(hd68k_adsp_buffer_r), FUNC(hd68k_adsp_buffer_w));
4076   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x810000, 0x813fff, read16_delegate(FUNC(harddriv_state::hd68k_adsp_buffer_r), state), write16_delegate(FUNC(harddriv_state::hd68k_adsp_buffer_w), state));
40774077
40784078   /* install ADSP control locations */
4079   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x818000, 0x81801f, FUNC(hd68k_adsp_control_w));
4080   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x818060, 0x81807f, FUNC(hd68k_adsp_irq_clear_w));
4081   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x838000, 0x83ffff, FUNC(hd68k_adsp_irq_state_r));
4079   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x818000, 0x81801f, write16_delegate(FUNC(harddriv_state::hd68k_adsp_control_w), state));
4080   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x818060, 0x81807f, write16_delegate(FUNC(harddriv_state::hd68k_adsp_irq_clear_w), state));
4081   state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x838000, 0x83ffff, read16_delegate(FUNC(harddriv_state::hd68k_adsp_irq_state_r), state));
40824082}
40834083
40844084
r26010r26011
40884088   harddriv_state *state = machine.driver_data<harddriv_state>();
40894089
40904090   /* install ADSP program RAM */
4091   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x800000, 0x807fff, FUNC(hd68k_ds3_program_r), FUNC(hd68k_ds3_program_w));
4091   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x800000, 0x807fff, read16_delegate(FUNC(harddriv_state::hd68k_ds3_program_r), state), write16_delegate(FUNC(harddriv_state::hd68k_ds3_program_w), state));
40924092
40934093   /* install ADSP data RAM */
4094   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x808000, 0x80bfff, FUNC(hd68k_adsp_data_r), FUNC(hd68k_adsp_data_w));
4095   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x80c000, 0x80dfff, FUNC(hdds3_special_r), FUNC(hdds3_special_w));
4094   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x808000, 0x80bfff, read16_delegate(FUNC(harddriv_state::hd68k_adsp_data_r), state), write16_delegate(FUNC(harddriv_state::hd68k_adsp_data_w), state));
4095   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x80c000, 0x80dfff, read16_delegate(FUNC(harddriv_state::hdds3_special_r), state), write16_delegate(FUNC(harddriv_state::hdds3_special_w), state));
40964096
40974097   /* install ADSP control locations */
4098   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x820000, 0x8207ff, FUNC(hd68k_ds3_gdata_r));
4099   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x820800, 0x820fff, FUNC(hd68k_ds3_girq_state_r));
4100   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x820000, 0x8207ff, FUNC(hd68k_ds3_gdata_w));
4101   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x821000, 0x8217ff, FUNC(hd68k_adsp_irq_clear_w));
4098   state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x820000, 0x8207ff, read16_delegate(FUNC(harddriv_state::hd68k_ds3_gdata_r), state));
4099   state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x820800, 0x820fff, read16_delegate(FUNC(harddriv_state::hd68k_ds3_girq_state_r), state));
4100   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x820000, 0x8207ff, write16_delegate(FUNC(harddriv_state::hd68k_ds3_gdata_w), state));
4101   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x821000, 0x8217ff, write16_delegate(FUNC(harddriv_state::hd68k_adsp_irq_clear_w), state));
41024102
4103   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x822000, 0x8227ff, FUNC(hd68k_ds3_sdata_r));
4104   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x822800, 0x822fff, FUNC(hd68k_ds3_sirq_state_r));
4105   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x822000, 0x8227ff, FUNC(hd68k_ds3_sdata_w));
4106   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x823000, 0x8237ff, FUNC(hd68k_ds3_sirq_clear_w));
4107   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x823800, 0x823fff, FUNC(hd68k_ds3_control_w));
4103   state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x822000, 0x8227ff, read16_delegate(FUNC(harddriv_state::hd68k_ds3_sdata_r), state));
4104   state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x822800, 0x822fff, read16_delegate(FUNC(harddriv_state::hd68k_ds3_sirq_state_r), state));
4105   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x822000, 0x8227ff, write16_delegate(FUNC(harddriv_state::hd68k_ds3_sdata_w), state));
4106   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x823000, 0x8237ff, write16_delegate(FUNC(harddriv_state::hd68k_ds3_sirq_clear_w), state));
4107   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x823800, 0x823fff, write16_delegate(FUNC(harddriv_state::hd68k_ds3_control_w), state));
41084108
41094109   /* predetermine memory regions */
41104110   state->m_ds3_sdata_memory = (UINT16 *)state->memregion("ds3sdsp_data")->base();
r26010r26011
41864186   UINT8 *usr3 = state->memregion("user3")->base();
41874187
41884188   /* install ASIC61 */
4189   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x85c000, 0x85c7ff, FUNC(hd68k_dsk_dsp32_r), FUNC(hd68k_dsk_dsp32_w));
4189   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x85c000, 0x85c7ff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_dsp32_r), state), write16_delegate(FUNC(harddriv_state::hd68k_dsk_dsp32_w), state));
41904190
41914191   /* install control registers */
4192   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x85c800, 0x85c81f, FUNC(hd68k_dsk_control_w));
4192   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x85c800, 0x85c81f, write16_delegate(FUNC(harddriv_state::hd68k_dsk_control_w), state));
41934193
41944194   /* install extra RAM */
4195   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x900000, 0x90ffff, FUNC(hd68k_dsk_ram_r), FUNC(hd68k_dsk_ram_w));
4195   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x900000, 0x90ffff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_ram_r), state), write16_delegate(FUNC(harddriv_state::hd68k_dsk_ram_w), state));
41964196   state->m_dsk_ram = (UINT16 *)(usr3 + 0x40000);
41974197
41984198   /* install extra ZRAM */
4199   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x910000, 0x910fff, FUNC(hd68k_dsk_zram_r), FUNC(hd68k_dsk_zram_w));
4199   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x910000, 0x910fff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_zram_r), state), write16_delegate(FUNC(harddriv_state::hd68k_dsk_zram_w), state));
42004200   state->m_dsk_zram = (UINT16 *)(usr3 + 0x50000);
42014201
42024202   /* install ASIC65 */
r26010r26011
42054205   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x918000, 0x91bfff, FUNC(asic65_io_r));
42064206
42074207   /* install extra ROM */
4208   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x940000, 0x9fffff, FUNC(hd68k_dsk_small_rom_r));
4208   state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x940000, 0x9fffff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_small_rom_r), state));
42094209   state->m_dsk_rom = (UINT16 *)(usr3 + 0x00000);
42104210
42114211   /* set up the ASIC65 */
r26010r26011
42254225   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x825000, 0x825001, FUNC(asic65_io_r));
42264226
42274227   /* install ASIC61 */
4228   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x827000, 0x8277ff, FUNC(hd68k_dsk_dsp32_r), FUNC(hd68k_dsk_dsp32_w));
4228   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x827000, 0x8277ff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_dsp32_r), state), write16_delegate(FUNC(harddriv_state::hd68k_dsk_dsp32_w), state));
42294229
42304230   /* install control registers */
4231   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x827800, 0x82781f, FUNC(hd68k_dsk_control_w));
4231   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x827800, 0x82781f, write16_delegate(FUNC(harddriv_state::hd68k_dsk_control_w), state));
42324232
42334233   /* install extra RAM */
4234   state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0x880000, 0x8bffff, FUNC(hd68k_dsk_ram_r), FUNC(hd68k_dsk_ram_w));
4234   state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x880000, 0x8bffff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_ram_r), state), write16_delegate(FUNC(harddriv_state::hd68k_dsk_ram_w), state));
42354235   state->m_dsk_ram = (UINT16 *)(usr3 + 0x100000);
42364236
42374237   /* install extra ROM */
4238   state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x900000, 0x9fffff, FUNC(hd68k_dsk_rom_r));
4238   state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x900000, 0x9fffff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_rom_r), state));
42394239   state->m_dsk_rom = (UINT16 *)(usr3 + 0x000000);
42404240
42414241   /* set up the ASIC65 */
r26010r26011
42574257   asic65_config(machine, ASIC65_STEELTAL);
42584258
42594259   /* install DSPCOM control */
4260   state->m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x904000, 0x90401f, FUNC(hddspcom_control_w));
4260   state->m_maincpu->space(AS_PROGRAM).install_write_handler(0x904000, 0x90401f, write16_delegate(FUNC(harddriv_state::hddspcom_control_w), state));
42614261}
42624262
42634263
r26010r26011
42914291   init_driver_sound(machine());
42924292
42934293   /* set up gsp speedup handler */
4294   m_gsp_speedup_addr[0] = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfff9fc00, 0xfff9fc0f, FUNC(hdgsp_speedup1_w));
4295   m_gsp_speedup_addr[1] = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfffcfc00, 0xfffcfc0f, FUNC(hdgsp_speedup2_w));
4296   m_gsp->space(AS_PROGRAM).install_legacy_read_handler(0xfff9fc00, 0xfff9fc0f, FUNC(hdgsp_speedup_r));
4294   m_gsp_speedup_addr[0] = m_gsp->space(AS_PROGRAM).install_write_handler(0xfff9fc00, 0xfff9fc0f, write16_delegate(FUNC(harddriv_state::hdgsp_speedup1_w), this));
4295   m_gsp_speedup_addr[1] = m_gsp->space(AS_PROGRAM).install_write_handler(0xfffcfc00, 0xfffcfc0f, write16_delegate(FUNC(harddriv_state::hdgsp_speedup2_w), this));
4296   m_gsp->space(AS_PROGRAM).install_read_handler(0xfff9fc00, 0xfff9fc0f, read16_delegate(FUNC(harddriv_state::hdgsp_speedup_r), this));
42974297   m_gsp_speedup_pc = 0xffc00f10;
42984298
42994299   /* set up msp speedup handler */
4300   m_msp_speedup_addr = m_msp->space(AS_PROGRAM).install_legacy_write_handler(0x00751b00, 0x00751b0f, FUNC(hdmsp_speedup_w));
4301   m_msp->space(AS_PROGRAM).install_legacy_read_handler(0x00751b00, 0x00751b0f, FUNC(hdmsp_speedup_r));
4300   m_msp_speedup_addr = m_msp->space(AS_PROGRAM).install_write_handler(0x00751b00, 0x00751b0f, write16_delegate(FUNC(harddriv_state::hdmsp_speedup_w), this));
4301   m_msp->space(AS_PROGRAM).install_read_handler(0x00751b00, 0x00751b0f, read16_delegate(FUNC(harddriv_state::hdmsp_speedup_r), this));
43024302   m_msp_speedup_pc = 0x00723b00;
43034303
43044304   /* set up adsp speedup handlers */
4305   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4305   m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), this));
43064306}
43074307
43084308
r26010r26011
43144314   init_driver_sound(machine());
43154315
43164316   /* set up gsp speedup handler */
4317   m_gsp_speedup_addr[0] = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfff9fc00, 0xfff9fc0f, FUNC(hdgsp_speedup1_w));
4318   m_gsp_speedup_addr[1] = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfffcfc00, 0xfffcfc0f, FUNC(hdgsp_speedup2_w));
4319   m_gsp->space(AS_PROGRAM).install_legacy_read_handler(0xfff9fc00, 0xfff9fc0f, FUNC(hdgsp_speedup_r));
4317   m_gsp_speedup_addr[0] = m_gsp->space(AS_PROGRAM).install_write_handler(0xfff9fc00, 0xfff9fc0f, write16_delegate(FUNC(harddriv_state::hdgsp_speedup1_w), this));
4318   m_gsp_speedup_addr[1] = m_gsp->space(AS_PROGRAM).install_write_handler(0xfffcfc00, 0xfffcfc0f, write16_delegate(FUNC(harddriv_state::hdgsp_speedup2_w), this));
4319   m_gsp->space(AS_PROGRAM).install_read_handler(0xfff9fc00, 0xfff9fc0f, read16_delegate(FUNC(harddriv_state::hdgsp_speedup_r), this));
43204320   m_gsp_speedup_pc = 0xfff40ff0;
43214321
43224322   /* set up msp speedup handler */
4323   m_msp_speedup_addr = m_msp->space(AS_PROGRAM).install_legacy_write_handler(0x00751b00, 0x00751b0f, FUNC(hdmsp_speedup_w));
4324   m_msp->space(AS_PROGRAM).install_legacy_read_handler(0x00751b00, 0x00751b0f, FUNC(hdmsp_speedup_r));
4323   m_msp_speedup_addr = m_msp->space(AS_PROGRAM).install_write_handler(0x00751b00, 0x00751b0f, write16_delegate(FUNC(harddriv_state::hdmsp_speedup_w), this));
4324   m_msp->space(AS_PROGRAM).install_read_handler(0x00751b00, 0x00751b0f, read16_delegate(FUNC(harddriv_state::hdmsp_speedup_r), this));
43254325   m_msp_speedup_pc = 0x00723b00;
43264326
43274327   /* set up adsp speedup handlers */
4328   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4328   m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), this));
43294329}
43304330
43314331
r26010r26011
43364336   init_adsp(machine());
43374337
43384338   /* set up gsp speedup handler */
4339   m_gsp_speedup_addr[0] = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfff9fc00, 0xfff9fc0f, FUNC(hdgsp_speedup1_w));
4340   m_gsp_speedup_addr[1] = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfffcfc00, 0xfffcfc0f, FUNC(hdgsp_speedup2_w));
4341   m_gsp->space(AS_PROGRAM).install_legacy_read_handler(0xfff9fc00, 0xfff9fc0f, FUNC(hdgsp_speedup_r));
4339   m_gsp_speedup_addr[0] = m_gsp->space(AS_PROGRAM).install_write_handler(0xfff9fc00, 0xfff9fc0f, write16_delegate(FUNC(harddriv_state::hdgsp_speedup1_w), this));
4340   m_gsp_speedup_addr[1] = m_gsp->space(AS_PROGRAM).install_write_handler(0xfffcfc00, 0xfffcfc0f, write16_delegate(FUNC(harddriv_state::hdgsp_speedup2_w), this));
4341   m_gsp->space(AS_PROGRAM).install_read_handler(0xfff9fc00, 0xfff9fc0f, read16_delegate(FUNC(harddriv_state::hdgsp_speedup_r), this));
43424342   m_gsp_speedup_pc = 0xfff41070;
43434343
43444344   /* set up adsp speedup handlers */
4345   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4345   m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), this));
43464346}
43474347
43484348
r26010r26011
43564356
43574357   /* set up the slapstic */
43584358   slapstic_init(machine(), 117);
4359   m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0xe0000, 0xfffff, FUNC(rd68k_slapstic_r), FUNC(rd68k_slapstic_w));
4359   m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), this), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), this));
43604360
43614361   /* synchronization */
4362   m_rddsp32_sync[0] = m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x613c00, 0x613c03, FUNC(rddsp32_sync0_w));
4363   m_rddsp32_sync[1] = m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x613e00, 0x613e03, FUNC(rddsp32_sync1_w));
4362   m_rddsp32_sync[0] = m_dsp32->space(AS_PROGRAM).install_write_handler(0x613c00, 0x613c03, write32_delegate(FUNC(harddriv_state::rddsp32_sync0_w), this));
4363   m_rddsp32_sync[1] = m_dsp32->space(AS_PROGRAM).install_write_handler(0x613e00, 0x613e03, write32_delegate(FUNC(harddriv_state::rddsp32_sync1_w), this));
43644364
43654365   /* set up adsp speedup handlers */
4366   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4366   m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), this));
43674367}
43684368
43694369
r26010r26011
43794379
43804380   /* set up the slapstic */
43814381   slapstic_init(machine, 117);
4382   state->m_m68k_slapstic_base = state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0xe0000, 0xfffff, FUNC(rd68k_slapstic_r), FUNC(rd68k_slapstic_w));
4382   state->m_m68k_slapstic_base = state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), state), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), state));
43834383
43844384   /* synchronization */
4385   state->m_rddsp32_sync[0] = state->m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x613c00, 0x613c03, FUNC(rddsp32_sync0_w));
4386   state->m_rddsp32_sync[1] = state->m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x613e00, 0x613e03, FUNC(rddsp32_sync1_w));
4385   state->m_rddsp32_sync[0] = state->m_dsp32->space(AS_PROGRAM).install_write_handler(0x613c00, 0x613c03, write32_delegate(FUNC(harddriv_state::rddsp32_sync0_w), state));
4386   state->m_rddsp32_sync[1] = state->m_dsp32->space(AS_PROGRAM).install_write_handler(0x613e00, 0x613e03, write32_delegate(FUNC(harddriv_state::rddsp32_sync1_w), state));
43874387
43884388   /* set up protection hacks */
4389   state->m_gsp_protection = state->m_gsp->space(AS_PROGRAM).install_legacy_write_handler(gsp_protection, gsp_protection + 0x0f, FUNC(hdgsp_protection_w));
4389   state->m_gsp_protection = state->m_gsp->space(AS_PROGRAM).install_write_handler(gsp_protection, gsp_protection + 0x0f, write16_delegate(FUNC(harddriv_state::hdgsp_protection_w), state));
43904390
43914391   /* set up gsp speedup handler */
4392   state->m_gsp_speedup_addr[0] = state->m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfff76f60, 0xfff76f6f, FUNC(rdgsp_speedup1_w));
4393   state->m_gsp->space(AS_PROGRAM).install_legacy_read_handler(0xfff76f60, 0xfff76f6f, FUNC(rdgsp_speedup1_r));
4392   state->m_gsp_speedup_addr[0] = state->m_gsp->space(AS_PROGRAM).install_write_handler(0xfff76f60, 0xfff76f6f, write16_delegate(FUNC(harddriv_state::rdgsp_speedup1_w), state));
4393   state->m_gsp->space(AS_PROGRAM).install_read_handler(0xfff76f60, 0xfff76f6f, read16_delegate(FUNC(harddriv_state::rdgsp_speedup1_r), state));
43944394   state->m_gsp_speedup_pc = 0xfff43a00;
43954395
43964396   /* set up adsp speedup handlers */
4397   state->m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4397   state->m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), state));
43984398}
43994399
44004400DRIVER_INIT_MEMBER(harddriv_state,racedrivc) { racedrivc_init_common(machine(), 0xfff95cd0); }
r26010r26011
44374437   /* set up the SLOOP */
44384438   if (!proto_sloop)
44394439   {
4440      state->m_m68k_slapstic_base = state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0xe0000, 0xfffff, FUNC(st68k_sloop_r), FUNC(st68k_sloop_w));
4441      state->m_m68k_sloop_alt_base = state->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x4e000, 0x4ffff, FUNC(st68k_sloop_alt_r));
4440      state->m_m68k_slapstic_base = state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::st68k_sloop_r), state),  write16_delegate(FUNC(harddriv_state::st68k_sloop_w), state));
4441      state->m_m68k_sloop_alt_base = state->m_maincpu->space(AS_PROGRAM).install_read_handler(0x4e000, 0x4ffff, read16_delegate(FUNC(harddriv_state::st68k_sloop_alt_r), state));
44424442   }
44434443   else
4444      state->m_m68k_slapstic_base = state->m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0xe0000, 0xfffff, FUNC(st68k_protosloop_r), FUNC(st68k_protosloop_w));
4444      state->m_m68k_slapstic_base = state->m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::st68k_protosloop_r), state), write16_delegate(FUNC(harddriv_state::st68k_protosloop_w), state));
44454445
44464446   /* set up protection hacks */
4447   state->m_gsp_protection = state->m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfff965d0, 0xfff965df, FUNC(hdgsp_protection_w));
4447   state->m_gsp_protection = state->m_gsp->space(AS_PROGRAM).install_write_handler(0xfff965d0, 0xfff965df, write16_delegate(FUNC(harddriv_state::hdgsp_protection_w), state));
44484448
44494449   /* set up adsp speedup handlers */
4450   state->m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4451   state->m_adsp->space(AS_DATA).install_legacy_read_handler(0x1f99, 0x1f99, FUNC(hdds3_speedup_r));
4450   state->m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), state));
4451   state->m_adsp->space(AS_DATA).install_read_handler(0x1f99, 0x1f99, read16_delegate(FUNC(harddriv_state::hdds3_speedup_r), state));
44524452   state->m_ds3_speedup_addr = &state->m_adsp_data_memory[0x1f99];
44534453   state->m_ds3_speedup_pc = 0xff;
44544454   state->m_ds3_transfer_pc = ds3_transfer_pc;
r26010r26011
44804480
44814481   /* set up the slapstic */
44824482   slapstic_init(machine(), 117);
4483   m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_legacy_readwrite_handler(0xe0000, 0xfffff, FUNC(rd68k_slapstic_r), FUNC(rd68k_slapstic_w));
4483   m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), this), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), this));
44844484
4485   m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0xa80000, 0xafffff, FUNC(hda68k_port1_r));
4485   m_maincpu->space(AS_PROGRAM).install_read_handler(0xa80000, 0xafffff, read16_delegate(FUNC(harddriv_state::hda68k_port1_r), this));
44864486
44874487   /* synchronization */
4488   m_rddsp32_sync[0] = m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x613c00, 0x613c03, FUNC(rddsp32_sync0_w));
4489   m_rddsp32_sync[1] = m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x613e00, 0x613e03, FUNC(rddsp32_sync1_w));
4488   m_rddsp32_sync[0] = m_dsp32->space(AS_PROGRAM).install_write_handler(0x613c00, 0x613c03, write32_delegate(FUNC(harddriv_state::rddsp32_sync0_w), this));
4489   m_rddsp32_sync[1] = m_dsp32->space(AS_PROGRAM).install_write_handler(0x613e00, 0x613e03, write32_delegate(FUNC(harddriv_state::rddsp32_sync1_w), this));
44904490
44914491   /* set up protection hacks */
4492   m_gsp_protection = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfff960a0, 0xfff960af, FUNC(hdgsp_protection_w));
4492   m_gsp_protection = m_gsp->space(AS_PROGRAM).install_write_handler(0xfff960a0, 0xfff960af, write16_delegate(FUNC(harddriv_state::hdgsp_protection_w), this));
44934493
44944494   /* set up adsp speedup handlers */
4495   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4496   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1f99, 0x1f99, FUNC(hdds3_speedup_r));
4495   m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), this));
4496   m_adsp->space(AS_DATA).install_read_handler(0x1f99, 0x1f99, read16_delegate(FUNC(harddriv_state::hdds3_speedup_r), this));
44974497   m_ds3_speedup_addr = &m_adsp_data_memory[0x1f99];
44984498   m_ds3_speedup_pc = 0xff;
44994499   m_ds3_transfer_pc = 0x43672;
r26010r26011
45074507   init_ds3(machine());
45084508   init_dsk2(machine());
45094509
4510   m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0xa80000, 0xafffff, FUNC(hda68k_port1_r));
4510   m_maincpu->space(AS_PROGRAM).install_read_handler(0xa80000, 0xafffff, read16_delegate(FUNC(harddriv_state::hda68k_port1_r), this));
45114511
45124512   /* synchronization */
4513   m_rddsp32_sync[0] = m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x21fe00, 0x21fe03, FUNC(rddsp32_sync0_w));
4514   m_rddsp32_sync[1] = m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x21ff00, 0x21ff03, FUNC(rddsp32_sync1_w));
4513   m_rddsp32_sync[0] = m_dsp32->space(AS_PROGRAM).install_write_handler(0x613c00, 0x613c03, write32_delegate(FUNC(harddriv_state::rddsp32_sync0_w), this));
4514   m_rddsp32_sync[1] = m_dsp32->space(AS_PROGRAM).install_write_handler(0x613e00, 0x613e03, write32_delegate(FUNC(harddriv_state::rddsp32_sync1_w), this));
45154515
45164516   /* set up protection hacks */
4517   m_gsp_protection = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfff943f0, 0xfff943ff, FUNC(hdgsp_protection_w));
4517   m_gsp_protection = m_gsp->space(AS_PROGRAM).install_write_handler(0xfff960a0, 0xfff960af, write16_delegate(FUNC(harddriv_state::hdgsp_protection_w), this));
45184518
45194519   /* set up adsp speedup handlers */
4520   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4521   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1f99, 0x1f99, FUNC(hdds3_speedup_r));
4520   m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), this));
4521   m_adsp->space(AS_DATA).install_read_handler(0x1f99, 0x1f99, read16_delegate(FUNC(harddriv_state::hdds3_speedup_r), this));
45224522   m_ds3_speedup_addr = &m_adsp_data_memory[0x1f99];
45234523   m_ds3_speedup_pc = 0x2da;
45244524   m_ds3_transfer_pc = 0x407b8;
r26010r26011
45324532   init_ds3(machine());
45334533   init_dsk2(machine());
45344534
4535   m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0xa80000, 0xafffff, FUNC(hda68k_port1_r));
4535   m_maincpu->space(AS_PROGRAM).install_read_handler(0xa80000, 0xafffff, read16_delegate(FUNC(harddriv_state::hda68k_port1_r), this));
45364536
45374537   /* synchronization */
4538   m_rddsp32_sync[0] = m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x21fe00, 0x21fe03, FUNC(rddsp32_sync0_w));
4539   m_rddsp32_sync[1] = m_dsp32->space(AS_PROGRAM).install_legacy_write_handler(0x21ff00, 0x21ff03, FUNC(rddsp32_sync1_w));
4538   m_rddsp32_sync[0] = m_dsp32->space(AS_PROGRAM).install_write_handler(0x613c00, 0x613c03, write32_delegate(FUNC(harddriv_state::rddsp32_sync0_w), this));
4539   m_rddsp32_sync[1] = m_dsp32->space(AS_PROGRAM).install_write_handler(0x613e00, 0x613e03, write32_delegate(FUNC(harddriv_state::rddsp32_sync1_w), this));
45404540
45414541   /* set up protection hacks */
4542   m_gsp_protection = m_gsp->space(AS_PROGRAM).install_legacy_write_handler(0xfff916c0, 0xfff916cf, FUNC(hdgsp_protection_w));
4542   m_gsp_protection = m_gsp->space(AS_PROGRAM).install_write_handler(0xfff916c0, 0xfff916cf, write16_delegate(FUNC(harddriv_state::hdgsp_protection_w), this));
45434543
45444544   /* set up adsp speedup handlers */
4545   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1fff, 0x1fff, FUNC(hdadsp_speedup_r));
4546   m_adsp->space(AS_DATA).install_legacy_read_handler(0x1f9a, 0x1f9a, FUNC(hdds3_speedup_r));
4545   m_adsp->space(AS_DATA).install_read_handler(0x1fff, 0x1fff, read16_delegate(FUNC(harddriv_state::hdadsp_speedup_r), this));
4546   m_adsp->space(AS_DATA).install_read_handler(0x1f9a, 0x1f9a, read16_delegate(FUNC(harddriv_state::hdds3_speedup_r), this));
45474547   m_ds3_speedup_addr = &m_adsp_data_memory[0x1f9a];
45484548   m_ds3_speedup_pc = 0x2d9;
45494549   m_ds3_transfer_pc = 0X407da;
trunk/src/mame/machine/harddriv.c
r26010r26011
127127}
128128
129129
130WRITE16_HANDLER( hd68k_irq_ack_w )
130WRITE16_MEMBER( harddriv_state::hd68k_irq_ack_w )
131131{
132   harddriv_state *state = space.machine().driver_data<harddriv_state>();
133   state->m_irq_state = 0;
134   state->update_interrupts();
132   m_irq_state = 0;
133   update_interrupts();
135134}
136135
137136
r26010r26011
158157 *
159158 *************************************/
160159
161READ16_HANDLER( hd68k_gsp_io_r )
160READ16_MEMBER( harddriv_state::hd68k_gsp_io_r )
162161{
163   harddriv_state *state = space.machine().driver_data<harddriv_state>();
164162   UINT16 result;
165163   offset = (offset / 2) ^ 1;
166   state->m_hd34010_host_access = TRUE;
167   result = tms34010_host_r(state->m_gsp, offset);
168   state->m_hd34010_host_access = FALSE;
164   m_hd34010_host_access = TRUE;
165   result = tms34010_host_r(m_gsp, offset);
166   m_hd34010_host_access = FALSE;
169167   return result;
170168}
171169
172170
173WRITE16_HANDLER( hd68k_gsp_io_w )
171WRITE16_MEMBER( harddriv_state::hd68k_gsp_io_w )
174172{
175   harddriv_state *state = space.machine().driver_data<harddriv_state>();
176173   offset = (offset / 2) ^ 1;
177   state->m_hd34010_host_access = TRUE;
178   tms34010_host_w(state->m_gsp, offset, data);
179   state->m_hd34010_host_access = FALSE;
174   m_hd34010_host_access = TRUE;
175   tms34010_host_w(m_gsp, offset, data);
176   m_hd34010_host_access = FALSE;
180177}
181178
182179
r26010r26011
187184 *
188185 *************************************/
189186
190READ16_HANDLER( hd68k_msp_io_r )
187READ16_MEMBER( harddriv_state::hd68k_msp_io_r )
191188{
192   harddriv_state *state = space.machine().driver_data<harddriv_state>();
193189   UINT16 result;
194190   offset = (offset / 2) ^ 1;
195   state->m_hd34010_host_access = TRUE;
196   result = (state->m_msp != NULL) ? tms34010_host_r(state->m_msp, offset) : 0xffff;
197   state->m_hd34010_host_access = FALSE;
191   m_hd34010_host_access = TRUE;
192   result = (m_msp != NULL) ? tms34010_host_r(m_msp, offset) : 0xffff;
193   m_hd34010_host_access = FALSE;
198194   return result;
199195}
200196
201197
202WRITE16_HANDLER( hd68k_msp_io_w )
198WRITE16_MEMBER( harddriv_state::hd68k_msp_io_w )
203199{
204   harddriv_state *state = space.machine().driver_data<harddriv_state>();
205200   offset = (offset / 2) ^ 1;
206   if (state->m_msp != NULL)
201   if (m_msp != NULL)
207202   {
208      state->m_hd34010_host_access = TRUE;
209      tms34010_host_w(state->m_msp, offset, data);
210      state->m_hd34010_host_access = FALSE;
203      m_hd34010_host_access = TRUE;
204      tms34010_host_w(m_msp, offset, data);
205      m_hd34010_host_access = FALSE;
211206   }
212207}
213208
r26010r26011
219214 *
220215 *************************************/
221216
222READ16_HANDLER( hd68k_port0_r )
217READ16_MEMBER( harddriv_state::hd68k_port0_r )
223218{
224219   /* port is as follows:
225220
r26010r26011
236231           .....
237232       0x8000 = SW1 #1
238233   */
239   harddriv_state *state = space.machine().driver_data<harddriv_state>();
240   int temp = (space.machine().root_device().ioport("SW1")->read() << 8) | space.machine().root_device().ioport("IN0")->read();
241   if (state->get_hblank(*state->m_screen)) temp ^= 0x0002;
234   int temp = (ioport("SW1")->read() << 8) | ioport("IN0")->read();
235   if (get_hblank(*m_screen)) temp ^= 0x0002;
242236   temp ^= 0x0018;     /* both EOCs always high for now */
243237   return temp;
244238}
245239
246240
247READ16_HANDLER( hdc68k_port1_r )
241READ16_MEMBER( harddriv_state::hdc68k_port1_r )
248242{
249   harddriv_state *state = space.machine().driver_data<harddriv_state>();
250   UINT16 result = state->ioport("a80000")->read();
251   UINT16 diff = result ^ state->m_hdc68k_last_port1;
243   UINT16 result = ioport("a80000")->read();
244   UINT16 diff = result ^ m_hdc68k_last_port1;
252245
253246   /* if a new shifter position is selected, use it */
254247   /* if it's the same shifter position as last time, go back to neutral */
255248   if ((diff & 0x0100) && !(result & 0x0100))
256      state->m_hdc68k_shifter_state = (state->m_hdc68k_shifter_state == 1) ? 0 : 1;
249      m_hdc68k_shifter_state = (m_hdc68k_shifter_state == 1) ? 0 : 1;
257250   if ((diff & 0x0200) && !(result & 0x0200))
258      state->m_hdc68k_shifter_state = (state->m_hdc68k_shifter_state == 2) ? 0 : 2;
251      m_hdc68k_shifter_state = (m_hdc68k_shifter_state == 2) ? 0 : 2;
259252   if ((diff & 0x0400) && !(result & 0x0400))
260      state->m_hdc68k_shifter_state = (state->m_hdc68k_shifter_state == 4) ? 0 : 4;
253      m_hdc68k_shifter_state = (m_hdc68k_shifter_state == 4) ? 0 : 4;
261254   if ((diff & 0x0800) && !(result & 0x0800))
262      state->m_hdc68k_shifter_state = (state->m_hdc68k_shifter_state == 8) ? 0 : 8;
255      m_hdc68k_shifter_state = (m_hdc68k_shifter_state == 8) ? 0 : 8;
263256
264257   /* merge in the new shifter value */
265   result = (result | 0x0f00) ^ (state->m_hdc68k_shifter_state << 8);
258   result = (result | 0x0f00) ^ (m_hdc68k_shifter_state << 8);
266259
267260   /* merge in the wheel edge latch bit */
268   if (state->m_hdc68k_wheel_edge)
261   if (m_hdc68k_wheel_edge)
269262      result ^= 0x4000;
270263
271   state->m_hdc68k_last_port1 = result;
264   m_hdc68k_last_port1 = result;
272265   return result;
273266}
274267
275268
276READ16_HANDLER( hda68k_port1_r )
269READ16_MEMBER( harddriv_state::hda68k_port1_r )
277270{
278   harddriv_state *state = space.machine().driver_data<harddriv_state>();
279   UINT16 result = state->ioport("a80000")->read();
271   UINT16 result = ioport("a80000")->read();
280272
281273   /* merge in the wheel edge latch bit */
282   if (state->m_hdc68k_wheel_edge)
274   if (m_hdc68k_wheel_edge)
283275      result ^= 0x4000;
284276
285277   return result;
286278}
287279
288280
289READ16_HANDLER( hdc68k_wheel_r )
281READ16_MEMBER( harddriv_state::hdc68k_wheel_r )
290282{
291   harddriv_state *state = space.machine().driver_data<harddriv_state>();
292
293283   /* grab the new wheel value and upconvert to 12 bits */
294   UINT16 new_wheel = state->ioport("12BADC0")->read() << 4;
284   UINT16 new_wheel = ioport("12BADC0")->read() << 4;
295285
296286   /* hack to display the wheel position */
297287   if (space.machine().input().code_pressed(KEYCODE_LSHIFT))
298288      popmessage("%04X", new_wheel);
299289
300290   /* if we crossed the center line, latch the edge bit */
301   if ((state->m_hdc68k_last_wheel / 0xf0) != (new_wheel / 0xf0))
302      state->m_hdc68k_wheel_edge = 1;
291   if ((m_hdc68k_last_wheel / 0xf0) != (new_wheel / 0xf0))
292      m_hdc68k_wheel_edge = 1;
303293
304294   /* remember the last value and return the low 8 bits */
305   state->m_hdc68k_last_wheel = new_wheel;
295   m_hdc68k_last_wheel = new_wheel;
306296   return (new_wheel << 8) | 0xff;
307297}
308298
309299
310READ16_HANDLER( hd68k_adc8_r )
300READ16_MEMBER( harddriv_state::hd68k_adc8_r )
311301{
312   harddriv_state *state = space.machine().driver_data<harddriv_state>();
313   return state->m_adc8_data;
302   return m_adc8_data;
314303}
315304
316305
317READ16_HANDLER( hd68k_adc12_r )
306READ16_MEMBER( harddriv_state::hd68k_adc12_r )
318307{
319   harddriv_state *state = space.machine().driver_data<harddriv_state>();
320   return state->m_adc12_byte ? ((state->m_adc12_data >> 8) & 0x0f) : (state->m_adc12_data & 0xff);
308   return m_adc12_byte ? ((m_adc12_data >> 8) & 0x0f) : (m_adc12_data & 0xff);
321309}
322310
323311
324READ16_HANDLER( hd68k_sound_reset_r )
312READ16_MEMBER( harddriv_state::hd68k_sound_reset_r )
325313{
326   harddriv_state *state = space.machine().driver_data<harddriv_state>();
327   if (state->m_jsa != NULL)
328      state->m_jsa->reset();
314   if (m_jsa != NULL)
315      m_jsa->reset();
329316   return ~0;
330317}
331318
r26010r26011
337324 *
338325 *************************************/
339326
340WRITE16_HANDLER( hd68k_adc_control_w )
327WRITE16_MEMBER( harddriv_state::hd68k_adc_control_w )
341328{
342329   static const char *const adc8names[] = { "8BADC0", "8BADC1", "8BADC2", "8BADC3", "8BADC4", "8BADC5", "8BADC6", "8BADC7" };
343330   static const char *const adc12names[] = { "12BADC0", "12BADC1", "12BADC2", "12BADC3" };
344   harddriv_state *state = space.machine().driver_data<harddriv_state>();
331   
332   COMBINE_DATA(&m_adc_control);
345333
346   COMBINE_DATA(&state->m_adc_control);
347
348334   /* handle a write to the 8-bit ADC address select */
349   if (state->m_adc_control & 0x08)
335   if (m_adc_control & 0x08)
350336   {
351      state->m_adc8_select = state->m_adc_control & 0x07;
352      state->m_adc8_data = state->ioport(adc8names[state->m_adc8_select])->read();
337      m_adc8_select = m_adc_control & 0x07;
338      m_adc8_data = ioport(adc8names[m_adc8_select])->read();
353339   }
354340
355341   /* handle a write to the 12-bit ADC address select */
356   if (state->m_adc_control & 0x40)
342   if (m_adc_control & 0x40)
357343   {
358      state->m_adc12_select = (state->m_adc_control >> 4) & 0x03;
359      state->m_adc12_data = space.machine().root_device().ioport(adc12names[state->m_adc12_select])->read() << 4;
344      m_adc12_select = (m_adc_control >> 4) & 0x03;
345      m_adc12_data = space.machine().root_device().ioport(adc12names[m_adc12_select])->read() << 4;
360346   }
361347
362348   /* bit 7 selects which byte of the 12 bit data to read */
363   state->m_adc12_byte = (state->m_adc_control >> 7) & 1;
349   m_adc12_byte = (m_adc_control >> 7) & 1;
364350}
365351
366352
367WRITE16_HANDLER( hd68k_wr0_write )
353WRITE16_MEMBER( harddriv_state::hd68k_wr0_write )
368354{
369355   /* bit 3 selects the value; data is ignored */
370356   data = (offset >> 3) & 1;
r26010r26011
389375}
390376
391377
392WRITE16_HANDLER( hd68k_wr1_write )
378WRITE16_MEMBER( harddriv_state::hd68k_wr1_write )
393379{
394380   if (offset == 0) { //   logerror("Shifter Interface Latch = %02X\n", data);
395381   } else {                logerror("/WR1(%04X)=%02X\n", offset, data);
r26010r26011
397383}
398384
399385
400WRITE16_HANDLER( hd68k_wr2_write )
386WRITE16_MEMBER( harddriv_state::hd68k_wr2_write )
401387{
402388   if (offset == 0) { //   logerror("Steering Wheel Latch = %02X\n", data);
403389   } else {                logerror("/WR2(%04X)=%02X\n", offset, data);
r26010r26011
405391}
406392
407393
408WRITE16_HANDLER( hd68k_nwr_w )
394WRITE16_MEMBER( harddriv_state::hd68k_nwr_w )
409395{
410   harddriv_state *state = space.machine().driver_data<harddriv_state>();
411
412396   /* bit 3 selects the value; data is ignored */
413397   data = (offset >> 3) & 1;
414398
r26010r26011
425409      case 3: /* LC2 */
426410         break;
427411      case 4: /* ZP1 */
428         state->m_m68k_zp1 = data;
412         m_m68k_zp1 = data;
429413         break;
430414      case 5: /* ZP2 */
431         state->m_m68k_zp2 = data;
415         m_m68k_zp2 = data;
432416         break;
433417      case 6: /* /GSPRES */
434418         logerror("Write to /GSPRES(%d)\n", data);
435         if (state->m_gsp != NULL)
436            state->m_gsp->set_input_line(INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE);
419         if (m_gsp != NULL)
420            m_gsp->set_input_line(INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE);
437421         break;
438422      case 7: /* /MSPRES */
439423         logerror("Write to /MSPRES(%d)\n", data);
440         if (state->m_msp != NULL)
441            state->m_msp->set_input_line(INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE);
424         if (m_msp != NULL)
425            m_msp->set_input_line(INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE);
442426         break;
443427   }
444428}
445429
446430
447WRITE16_HANDLER( hdc68k_wheel_edge_reset_w )
431WRITE16_MEMBER( harddriv_state::hdc68k_wheel_edge_reset_w )
448432{
449433   /* reset the edge latch */
450   harddriv_state *state = space.machine().driver_data<harddriv_state>();
451   state->m_hdc68k_wheel_edge = 0;
434   m_hdc68k_wheel_edge = 0;
452435}
453436
454437
r26010r26011
459442 *
460443 *************************************/
461444
462READ16_HANDLER( hd68k_zram_r )
445READ16_MEMBER( harddriv_state::hd68k_zram_r )
463446{
464   harddriv_state *state = space.machine().driver_data<harddriv_state>();
465   return state->m_zram[offset];
447   return m_zram[offset];
466448}
467449
468450
469WRITE16_HANDLER( hd68k_zram_w )
451WRITE16_MEMBER( harddriv_state::hd68k_zram_w )
470452{
471   harddriv_state *state = space.machine().driver_data<harddriv_state>();
472   if (state->m_m68k_zp1 == 0 && state->m_m68k_zp2 == 1)
473      COMBINE_DATA(&state->m_zram[offset]);
453   if (m_m68k_zp1 == 0 && m_m68k_zp2 == 1)
454      COMBINE_DATA(&m_zram[offset]);
474455}
475456
476457
r26010r26011
494475 *
495476 *************************************/
496477
497WRITE16_HANDLER( hdgsp_io_w )
478WRITE16_MEMBER( harddriv_state::hdgsp_io_w )
498479{
499   harddriv_state *state = space.machine().driver_data<harddriv_state>();
500
501480   /* detect an enabling of the shift register and force yielding */
502481   if (offset == REG_DPYCTL)
503482   {
504483      UINT8 new_shiftreg = (data >> 11) & 1;
505      if (new_shiftreg != state->m_last_gsp_shiftreg)
484      if (new_shiftreg != m_last_gsp_shiftreg)
506485      {
507         state->m_last_gsp_shiftreg = new_shiftreg;
486         m_last_gsp_shiftreg = new_shiftreg;
508487         if (new_shiftreg)
509488            space.device().execute().yield();
510489      }
r26010r26011
512491
513492   /* detect changes to HEBLNK and HSBLNK and force an update before they change */
514493   if ((offset == REG_HEBLNK || offset == REG_HSBLNK) && data != tms34010_io_register_r(space, offset, 0xffff))
515      state->m_screen->update_partial(state->m_screen->vpos() - 1);
494      m_screen->update_partial(m_screen->vpos() - 1);
516495
517496   tms34010_io_register_w(space, offset, data, mem_mask);
518497}
r26010r26011
525504 *
526505 *************************************/
527506
528WRITE16_HANDLER( hdgsp_protection_w )
507WRITE16_MEMBER( harddriv_state::hdgsp_protection_w )
529508{
530   harddriv_state *state = space.machine().driver_data<harddriv_state>();
531
532509   /* this memory address is incremented whenever a protection check fails */
533510   /* after it reaches a certain value, the GSP will randomly trash a */
534511   /* register; we just prevent it from ever going above 0 */
535   *state->m_gsp_protection = 0;
512   *m_gsp_protection = 0;
536513}
537514
538515
r26010r26011
547524 *
548525 *************************************/
549526
550READ16_HANDLER( hd68k_adsp_program_r )
527READ16_MEMBER( harddriv_state::hd68k_adsp_program_r )
551528{
552   harddriv_state *state = space.machine().driver_data<harddriv_state>();
553   UINT32 word = state->m_adsp_pgm_memory[offset/2];
529   UINT32 word = m_adsp_pgm_memory[offset/2];
554530   return (!(offset & 1)) ? (word >> 16) : (word & 0xffff);
555531}
556532
557533
558WRITE16_HANDLER( hd68k_adsp_program_w )
534WRITE16_MEMBER( harddriv_state::hd68k_adsp_program_w )
559535{
560   harddriv_state *state = space.machine().driver_data<harddriv_state>();
561   UINT32 *base = &state->m_adsp_pgm_memory[offset/2];
536   UINT32 *base = &m_adsp_pgm_memory[offset/2];
562537   UINT32 oldword = *base;
563538   UINT16 temp;
564539
r26010r26011
585560 *
586561 *************************************/
587562
588READ16_HANDLER( hd68k_adsp_data_r )
563READ16_MEMBER( harddriv_state::hd68k_adsp_data_r )
589564{
590   harddriv_state *state = space.machine().driver_data<harddriv_state>();
591   return state->m_adsp_data_memory[offset];
565   return m_adsp_data_memory[offset];
592566}
593567
594568
595WRITE16_HANDLER( hd68k_adsp_data_w )
569WRITE16_MEMBER( harddriv_state::hd68k_adsp_data_w )
596570{
597   harddriv_state *state = space.machine().driver_data<harddriv_state>();
571   COMBINE_DATA(&m_adsp_data_memory[offset]);
598572
599   COMBINE_DATA(&state->m_adsp_data_memory[offset]);
600
601573   /* any write to $1FFF is taken to be a trigger; synchronize the CPUs */
602574   if (offset == 0x1fff)
603575   {
604576      logerror("%06X:ADSP sync address written (%04X)\n", space.device().safe_pcbase(), data);
605577      space.machine().scheduler().synchronize();
606      state->m_adsp->signal_interrupt_trigger();
578      m_adsp->signal_interrupt_trigger();
607579   }
608580   else
609581      logerror("%06X:ADSP W@%04X (%04X)\n", space.device().safe_pcbase(), offset, data);
r26010r26011
617589 *
618590 *************************************/
619591
620READ16_HANDLER( hd68k_adsp_buffer_r )
592READ16_MEMBER( harddriv_state::hd68k_adsp_buffer_r )
621593{
622   harddriv_state *state = space.machine().driver_data<harddriv_state>();
623/*  logerror("hd68k_adsp_buffer_r(%04X)\n", offset);*/
624   return state->m_som_memory[state->m_m68k_adsp_buffer_bank * 0x2000 + offset];
594   /*  logerror("hd68k_adsp_buffer_r(%04X)\n", offset);*/
595   return m_som_memory[m_m68k_adsp_buffer_bank * 0x2000 + offset];
625596}
626597
627598
628WRITE16_HANDLER( hd68k_adsp_buffer_w )
599WRITE16_MEMBER( harddriv_state::hd68k_adsp_buffer_w )
629600{
630   harddriv_state *state = space.machine().driver_data<harddriv_state>();
631   COMBINE_DATA(&state->m_som_memory[state->m_m68k_adsp_buffer_bank * 0x2000 + offset]);
601   COMBINE_DATA(&m_som_memory[m_m68k_adsp_buffer_bank * 0x2000 + offset]);
632602}
633603
634604
r26010r26011
690660}
691661
692662
693WRITE16_HANDLER( hd68k_adsp_control_w )
663WRITE16_MEMBER( harddriv_state::hd68k_adsp_control_w )
694664{
695   harddriv_state *state = space.machine().driver_data<harddriv_state>();
696
697665   /* bit 3 selects the value; data is ignored */
698666   int val = (offset >> 3) & 1;
699667
r26010r26011
708676
709677      case 3:
710678         logerror("ADSP bank = %d (deferred)\n", val);
711         space.machine().scheduler().synchronize(timer_expired_delegate(FUNC(harddriv_state::deferred_adsp_bank_switch),state), val);
679         space.machine().scheduler().synchronize(timer_expired_delegate(FUNC(harddriv_state::deferred_adsp_bank_switch),this), val);
712680         break;
713681
714682      case 5:
715683         /* connected to the /BR (bus request) line; this effectively halts */
716684         /* the ADSP at the next instruction boundary */
717         state->m_adsp_br = !val;
718         logerror("ADSP /BR = %d\n", !state->m_adsp_br);
719         if (state->m_adsp_br || state->m_adsp_halt)
720            state->m_adsp->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
685         m_adsp_br = !val;
686         logerror("ADSP /BR = %d\n", !m_adsp_br);
687         if (m_adsp_br || m_adsp_halt)
688            m_adsp->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
721689         else
722690         {
723            state->m_adsp->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
691            m_adsp->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
724692            /* a yield in this case is not enough */
725693            /* we would need to increase the interleaving otherwise */
726694            /* note that this only affects the test mode */
r26010r26011
731699      case 6:
732700         /* connected to the /HALT line; this effectively halts */
733701         /* the ADSP at the next instruction boundary */
734         state->m_adsp_halt = !val;
735         logerror("ADSP /HALT = %d\n", !state->m_adsp_halt);
736         if (state->m_adsp_br || state->m_adsp_halt)
737            state->m_adsp->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
702         m_adsp_halt = !val;
703         logerror("ADSP /HALT = %d\n", !m_adsp_halt);
704         if (m_adsp_br || m_adsp_halt)
705            m_adsp->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
738706         else
739707         {
740            state->m_adsp->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
708            m_adsp->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
741709            /* a yield in this case is not enough */
742710            /* we would need to increase the interleaving otherwise */
743711            /* note that this only affects the test mode */
r26010r26011
747715
748716      case 7:
749717         logerror("ADSP reset = %d\n", val);
750         state->m_adsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
718         m_adsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
751719         space.device().execute().yield();
752720         break;
753721
r26010r26011
758726}
759727
760728
761WRITE16_HANDLER( hd68k_adsp_irq_clear_w )
729WRITE16_MEMBER( harddriv_state::hd68k_adsp_irq_clear_w )
762730{
763   harddriv_state *state = space.machine().driver_data<harddriv_state>();
764731   logerror("%06X:68k clears ADSP interrupt\n", space.device().safe_pcbase());
765   state->m_adsp_irq_state = 0;
766   state->update_interrupts();
732   m_adsp_irq_state = 0;
733   update_interrupts();
767734}
768735
769736
770READ16_HANDLER( hd68k_adsp_irq_state_r )
737READ16_MEMBER( harddriv_state::hd68k_adsp_irq_state_r )
771738{
772   harddriv_state *state = space.machine().driver_data<harddriv_state>();
773739   int result = 0xfffd;
774   if (state->m_adsp_xflag) result ^= 2;
775   if (state->m_adsp_irq_state) result ^= 1;
740   if (m_adsp_xflag) result ^= 2;
741   if (m_adsp_irq_state) result ^= 1;
776742   logerror("%06X:68k reads ADSP interrupt state = %04x\n", space.device().safe_pcbase(), result);
777743   return result;
778744}
r26010r26011
785751 *
786752 *************************************/
787753
788READ16_HANDLER( hdadsp_special_r )
754READ16_MEMBER( harddriv_state::hdadsp_special_r )
789755{
790   harddriv_state *state = space.machine().driver_data<harddriv_state>();
791756   switch (offset & 7)
792757   {
793758      case 0: /* /SIMBUF */
794         if (state->m_adsp_eprom_base + state->m_adsp_sim_address < state->m_sim_memory_size)
795            return state->m_sim_memory[state->m_adsp_eprom_base + state->m_adsp_sim_address++];
759         if (m_adsp_eprom_base + m_adsp_sim_address < m_sim_memory_size)
760            return m_sim_memory[m_adsp_eprom_base + m_adsp_sim_address++];
796761         else
797762            return 0xff;
798763
r26010r26011
813778}
814779
815780
816WRITE16_HANDLER( hdadsp_special_w )
781WRITE16_MEMBER( harddriv_state::hdadsp_special_w )
817782{
818   harddriv_state *state = space.machine().driver_data<harddriv_state>();
819783   switch (offset & 7)
820784   {
821785      case 1: /* /SIMCLK */
822         state->m_adsp_sim_address = data;
786         m_adsp_sim_address = data;
823787         break;
824788
825789      case 2: /* SOMLATCH */
826         state->m_som_memory[(state->m_m68k_adsp_buffer_bank ^ 1) * 0x2000 + (state->m_adsp_som_address++ & 0x1fff)] = data;
790         m_som_memory[(m_m68k_adsp_buffer_bank ^ 1) * 0x2000 + (m_adsp_som_address++ & 0x1fff)] = data;
827791         break;
828792
829793      case 3: /* /SOMCLK */
830         state->m_adsp_som_address = data;
794         m_adsp_som_address = data;
831795         break;
832796
833797      case 5: /* /XOUT */
834         state->m_adsp_xflag = data & 1;
798         m_adsp_xflag = data & 1;
835799         break;
836800
837801      case 6: /* /GINT */
838802         logerror("%04X:ADSP signals interrupt\n", space.device().safe_pcbase());
839         state->m_adsp_irq_state = 1;
840         state->update_interrupts();
803         m_adsp_irq_state = 1;
804         update_interrupts();
841805         break;
842806
843807      case 7: /* /MP */
844         state->m_adsp_eprom_base = 0x10000 * data;
808         m_adsp_eprom_base = 0x10000 * data;
845809         break;
846810
847811      default:
r26010r26011
863827 *
864828 *************************************/
865829
866static void update_ds3_irq(harddriv_state *state)
830void harddriv_state::update_ds3_irq()
867831{
868832   /* update the IRQ2 signal to the ADSP2101 */
869   if (!(!state->m_ds3_g68flag && state->m_ds3_g68irqs) && !(state->m_ds3_gflag && state->m_ds3_gfirqs))
870      state->m_adsp->set_input_line(ADSP2100_IRQ2, ASSERT_LINE);
833   if (!(!m_ds3_g68flag && m_ds3_g68irqs) && !(m_ds3_gflag && m_ds3_gfirqs))
834      m_adsp->set_input_line(ADSP2100_IRQ2, ASSERT_LINE);
871835   else
872      state->m_adsp->set_input_line(ADSP2100_IRQ2, CLEAR_LINE);
836      m_adsp->set_input_line(ADSP2100_IRQ2, CLEAR_LINE);
873837}
874838
875839
876static void update_ds3_sirq(harddriv_state *state)
840void harddriv_state::update_ds3_sirq()
877841{
878842   /* update the IRQ2 signal to the ADSP2105 */
879   if (!(!state->m_ds3_s68flag && state->m_ds3_s68irqs) && !(state->m_ds3_sflag && state->m_ds3_sfirqs))
880      state->m_ds3sdsp->set_input_line(ADSP2105_IRQ2, ASSERT_LINE);
843   if (!(!m_ds3_s68flag && m_ds3_s68irqs) && !(m_ds3_sflag && m_ds3_sfirqs))
844      m_ds3sdsp->set_input_line(ADSP2105_IRQ2, ASSERT_LINE);
881845   else
882      state->m_ds3sdsp->set_input_line(ADSP2105_IRQ2, CLEAR_LINE);
846      m_ds3sdsp->set_input_line(ADSP2105_IRQ2, CLEAR_LINE);
883847}
884848
885849
886WRITE16_HANDLER( hd68k_ds3_control_w )
850WRITE16_MEMBER( harddriv_state::hd68k_ds3_control_w )
887851{
888   harddriv_state *state = space.machine().driver_data<harddriv_state>();
889852   int val = (offset >> 3) & 1;
890853
891854   switch (offset & 7)
892855   {
893856      case 0:
894857         /* SRES - reset sound CPU */
895         if (state->m_ds3sdsp)
858         if (m_ds3sdsp)
896859         {
897            state->m_ds3sdsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
898            state->m_ds3sdsp->load_boot_data(state->m_ds3sdsp->region()->base(), state->m_ds3sdsp_pgm_memory);
860            m_ds3sdsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
861            m_ds3sdsp->load_boot_data(m_ds3sdsp->region()->base(), m_ds3sdsp_pgm_memory);
899862
900            if (val && !state->m_ds3_sreset)
863            if (val && !m_ds3_sreset)
901864            {
902               state->m_ds3_sflag = 0;
903               state->m_ds3_scmd = 0;
904               state->m_ds3_sfirqs = 0;
905               state->m_ds3_s68irqs = !state->m_ds3_sfirqs;
906               update_ds3_sirq(state);
865               m_ds3_sflag = 0;
866               m_ds3_scmd = 0;
867               m_ds3_sfirqs = 0;
868               m_ds3_s68irqs = !m_ds3_sfirqs;
869               update_ds3_sirq();
907870            }
908            state->m_ds3_sreset = val;
871            m_ds3_sreset = val;
909872            space.device().execute().yield();
910873         }
911874         break;
912875
913876      case 1:
914877         /* XRES - reset sound helper CPU */
915         if (state->m_ds3xdsp)
878         if (m_ds3xdsp)
916879         {
917            state->m_ds3xdsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
918            state->m_ds3xdsp->load_boot_data(state->m_ds3xdsp->region()->base(), state->m_ds3xdsp_pgm_memory);
880            m_ds3xdsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
881            m_ds3xdsp->load_boot_data(m_ds3xdsp->region()->base(), m_ds3xdsp_pgm_memory);
919882         }
920883         break;
921884
922885      case 2:
923886         /* connected to the /BR (bus request) line; this effectively halts */
924887         /* the ADSP at the next instruction boundary */
925         state->m_adsp_br = !val;
926         if (state->m_adsp_br)
927            state->m_adsp->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
888         m_adsp_br = !val;
889         if (m_adsp_br)
890            m_adsp->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
928891         else
929892         {
930            state->m_adsp->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
893            m_adsp->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
931894            /* a yield in this case is not enough */
932895            /* we would need to increase the interleaving otherwise */
933896            /* note that this only affects the test mode */
r26010r26011
936899         break;
937900
938901      case 3:
939         state->m_adsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
940         if (val && !state->m_ds3_reset)
902         m_adsp->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
903         if (val && !m_ds3_reset)
941904         {
942            state->m_ds3_gflag = 0;
943            state->m_ds3_gcmd = 0;
944            state->m_ds3_gfirqs = 0;
945            state->m_ds3_g68irqs = !state->m_ds3_gfirqs;
946            state->m_ds3_send = 0;
947            update_ds3_irq(state);
905            m_ds3_gflag = 0;
906            m_ds3_gcmd = 0;
907            m_ds3_gfirqs = 0;
908            m_ds3_g68irqs = !m_ds3_gfirqs;
909            m_ds3_send = 0;
910            update_ds3_irq();
948911         }
949         state->m_ds3_reset = val;
912         m_ds3_reset = val;
950913         space.device().execute().yield();
951914         logerror("DS III reset = %d\n", val);
952915         break;
r26010r26011
969932 *
970933 *************************************/
971934
972READ16_HANDLER( hd68k_ds3_girq_state_r )
935READ16_MEMBER( harddriv_state::hd68k_ds3_girq_state_r )
973936{
974   harddriv_state *state = space.machine().driver_data<harddriv_state>();
975937   int result = 0x0fff;
976   if (state->m_ds3_g68flag) result ^= 0x8000;
977   if (state->m_ds3_gflag) result ^= 0x4000;
978   if (state->m_ds3_g68irqs) result ^= 0x2000;
979   if (!state->m_adsp_irq_state) result ^= 0x1000;
938   if (m_ds3_g68flag) result ^= 0x8000;
939   if (m_ds3_gflag) result ^= 0x4000;
940   if (m_ds3_g68irqs) result ^= 0x2000;
941   if (!m_adsp_irq_state) result ^= 0x1000;
980942   return result;
981943}
982944
983945
984READ16_HANDLER( hd68k_ds3_gdata_r )
946READ16_MEMBER( harddriv_state::hd68k_ds3_gdata_r )
985947{
986   harddriv_state *state = space.machine().driver_data<harddriv_state>();
987948   offs_t pc = space.device().safe_pc();
988949
989   state->m_ds3_gflag = 0;
990   update_ds3_irq(state);
950   m_ds3_gflag = 0;
951   update_ds3_irq();
991952
992   logerror("%06X:hd68k_ds3_gdata_r(%04X)\n", space.device().safe_pcbase(), state->m_ds3_gdata);
953   logerror("%06X:hd68k_ds3_gdata_r(%04X)\n", space.device().safe_pcbase(), m_ds3_gdata);
993954
994955   /* attempt to optimize the transfer if conditions are right */
995   if (&space.device() == state->m_maincpu && pc == state->m_ds3_transfer_pc &&
996      !(!state->m_ds3_g68flag && state->m_ds3_g68irqs) && !(state->m_ds3_gflag && state->m_ds3_gfirqs))
956   if (&space.device() == m_maincpu && pc == m_ds3_transfer_pc &&
957      !(!m_ds3_g68flag && m_ds3_g68irqs) && !(m_ds3_gflag && m_ds3_gfirqs))
997958   {
998      UINT32 destaddr = state->m_maincpu->state_int(M68K_A1);
999      UINT16 count68k = state->m_maincpu->state_int(M68K_D1);
1000      UINT16 mstat = state->m_adsp->state_int(ADSP2100_MSTAT);
1001      UINT16 i6 = state->m_adsp->state_int((mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC);
1002      UINT16 l6 = state->m_adsp->state_int(ADSP2100_L6) - 1;
1003      UINT16 m7 = state->m_adsp->state_int(ADSP2100_M7);
959      UINT32 destaddr = m_maincpu->state_int(M68K_A1);
960      UINT16 count68k = m_maincpu->state_int(M68K_D1);
961      UINT16 mstat = m_adsp->state_int(ADSP2100_MSTAT);
962      UINT16 i6 = m_adsp->state_int((mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC);
963      UINT16 l6 = m_adsp->state_int(ADSP2100_L6) - 1;
964      UINT16 m7 = m_adsp->state_int(ADSP2100_M7);
1004965
1005      logerror("%06X:optimizing 68k transfer, %d words\n", state->m_maincpu->pcbase(), count68k);
966      logerror("%06X:optimizing 68k transfer, %d words\n", m_maincpu->pcbase(), count68k);
1006967
1007      while (count68k > 0 && state->m_adsp_data_memory[0x16e6] > 0)
968      while (count68k > 0 && m_adsp_data_memory[0x16e6] > 0)
1008969      {
1009         space.write_word(destaddr, state->m_ds3_gdata);
970         space.write_word(destaddr, m_ds3_gdata);
1010971         {
1011            state->m_adsp_data_memory[0x16e6]--;
1012            state->m_ds3_gdata = state->m_adsp_pgm_memory[i6] >> 8;
972            m_adsp_data_memory[0x16e6]--;
973            m_ds3_gdata = m_adsp_pgm_memory[i6] >> 8;
1013974            i6 = (i6 & ~l6) | ((i6 + m7) & l6);
1014975         }
1015976         count68k--;
1016977      }
1017      state->m_maincpu->set_state_int(M68K_D1, count68k);
1018      state->m_adsp->set_state_int((mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC, i6);
1019      state->m_adsp_speedup_count[1]++;
978      m_maincpu->set_state_int(M68K_D1, count68k);
979      m_adsp->set_state_int((mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC, i6);
980      m_adsp_speedup_count[1]++;
1020981   }
1021982
1022983   /* if we just cleared the IRQ, we are going to do some VERY timing critical reads */
r26010r26011
1025986   space.device().execute().spin_until_trigger(DS3_TRIGGER);
1026987   space.machine().scheduler().trigger(DS3_TRIGGER, attotime::from_usec(5));
1027988
1028   return state->m_ds3_gdata;
989   return m_ds3_gdata;
1029990}
1030991
1031992
1032WRITE16_HANDLER( hd68k_ds3_gdata_w )
993WRITE16_MEMBER( harddriv_state::hd68k_ds3_gdata_w )
1033994{
1034   harddriv_state *state = space.machine().driver_data<harddriv_state>();
995   logerror("%06X:hd68k_ds3_gdata_w(%04X)\n", space.device().safe_pcbase(), m_ds3_gdata);
1035996
1036   logerror("%06X:hd68k_ds3_gdata_w(%04X)\n", space.device().safe_pcbase(), state->m_ds3_gdata);
1037
1038   COMBINE_DATA(&state->m_ds3_g68data);
1039   state->m_ds3_g68flag = 1;
1040   state->m_ds3_gcmd = offset & 1;
1041   state->m_adsp->signal_interrupt_trigger();
1042   update_ds3_irq(state);
997   COMBINE_DATA(&m_ds3_g68data);
998   m_ds3_g68flag = 1;
999   m_ds3_gcmd = offset & 1;
1000   m_adsp->signal_interrupt_trigger();
1001   update_ds3_irq();
10431002}
10441003
10451004
r26010r26011
10501009 *
10511010 *************************************/
10521011
1053WRITE16_HANDLER( hd68k_ds3_sirq_clear_w )
1012WRITE16_MEMBER( harddriv_state::hd68k_ds3_sirq_clear_w )
10541013{
1055   harddriv_state *state = space.machine().driver_data<harddriv_state>();
10561014   logerror("%06X:68k clears ADSP interrupt\n", space.device().safe_pcbase());
1057   state->m_sound_int_state = 0;
1058   state->update_interrupts();
1015   m_sound_int_state = 0;
1016   update_interrupts();
10591017}
10601018
10611019
1062READ16_HANDLER( hd68k_ds3_sirq_state_r )
1020READ16_MEMBER( harddriv_state::hd68k_ds3_sirq_state_r )
10631021{
1064   harddriv_state *state = space.machine().driver_data<harddriv_state>();
10651022   int result = 0x0fff;
1066   if (state->m_ds3_s68flag) result ^= 0x8000;
1067   if (state->m_ds3_sflag) result ^= 0x4000;
1068   if (state->m_ds3_s68irqs) result ^= 0x2000;
1069   if (!state->m_sound_int_state) result ^= 0x1000;
1023   if (m_ds3_s68flag) result ^= 0x8000;
1024   if (m_ds3_sflag) result ^= 0x4000;
1025   if (m_ds3_s68irqs) result ^= 0x2000;
1026   if (!m_sound_int_state) result ^= 0x1000;
10701027   return result;
10711028}
10721029
10731030
1074READ16_HANDLER( hd68k_ds3_sdata_r )
1031READ16_MEMBER( harddriv_state::hd68k_ds3_sdata_r )
10751032{
1076   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1033   m_ds3_sflag = 0;
1034   update_ds3_sirq();
10771035
1078   state->m_ds3_sflag = 0;
1079   update_ds3_sirq(state);
1080
10811036   /* if we just cleared the IRQ, we are going to do some VERY timing critical reads */
10821037   /* it is important that all the CPUs be in sync before we continue, so spin a little */
10831038   /* while to let everyone else catch up */
10841039   space.device().execute().spin_until_trigger(DS3_STRIGGER);
10851040   space.machine().scheduler().trigger(DS3_STRIGGER, attotime::from_usec(5));
10861041
1087   return state->m_ds3_sdata;
1042   return m_ds3_sdata;
10881043}
10891044
10901045
1091WRITE16_HANDLER( hd68k_ds3_sdata_w )
1046WRITE16_MEMBER( harddriv_state::hd68k_ds3_sdata_w )
10921047{
1093   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1048   COMBINE_DATA(&m_ds3_s68data);
1049   m_ds3_s68flag = 1;
1050   m_ds3_scmd = offset & 1;
1051   m_ds3sdsp->signal_interrupt_trigger();
10941052
1095   COMBINE_DATA(&state->m_ds3_s68data);
1096   state->m_ds3_s68flag = 1;
1097   state->m_ds3_scmd = offset & 1;
1098   state->m_ds3sdsp->signal_interrupt_trigger();
1099
1100   update_ds3_sirq(state);
1053   update_ds3_sirq();
11011054}
11021055
11031056
1104READ16_HANDLER( hdds3_sdsp_special_r )
1057READ16_MEMBER( harddriv_state::hdds3_sdsp_special_r )
11051058{
1106   harddriv_state *state = space.machine().driver_data<harddriv_state>();
11071059   int result;
11081060
11091061   switch (offset & 7)
11101062   {
11111063      case 0:
1112         state->m_ds3_s68flag = 0;
1113         update_ds3_sirq(state);
1114         return state->m_ds3_s68data;
1064         m_ds3_s68flag = 0;
1065         update_ds3_sirq();
1066         return m_ds3_s68data;
11151067
11161068      case 1:
11171069         result = 0x0fff;
1118         if (state->m_ds3_scmd) result ^= 0x8000;
1119         if (state->m_ds3_s68flag) result ^= 0x4000;
1120         if (state->m_ds3_sflag) result ^= 0x2000;
1070         if (m_ds3_scmd) result ^= 0x8000;
1071         if (m_ds3_s68flag) result ^= 0x4000;
1072         if (m_ds3_sflag) result ^= 0x2000;
11211073         return result;
11221074
11231075      case 4:
1124         if (state->m_ds3_sdata_address < state->m_ds3_sdata_memory_size)
1125            return state->m_ds3_sdata_memory[state->m_ds3_sdata_address];
1076         if (m_ds3_sdata_address < m_ds3_sdata_memory_size)
1077            return m_ds3_sdata_memory[m_ds3_sdata_address];
11261078         else
11271079            return 0xff;
11281080
r26010r26011
11401092}
11411093
11421094
1143WRITE16_HANDLER( hdds3_sdsp_special_w )
1095WRITE16_MEMBER( harddriv_state::hdds3_sdsp_special_w )
11441096{
1145   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1146
11471097   /* Note: DS IV is slightly different */
11481098   switch (offset & 7)
11491099   {
11501100      case 0:
1151         state->m_ds3_sdata = data;
1152         state->m_ds3_sflag = 1;
1153         update_ds3_sirq(state);
1101         m_ds3_sdata = data;
1102         m_ds3_sflag = 1;
1103         update_ds3_sirq();
11541104
11551105         /* once we've written data, trigger the main CPU to wake up again */
11561106         space.machine().scheduler().trigger(DS3_STRIGGER);
11571107         break;
11581108
11591109      case 1:
1160         state->m_sound_int_state = (data >> 1) & 1;
1161         state->update_interrupts();
1110         m_sound_int_state = (data >> 1) & 1;
1111         update_interrupts();
11621112         break;
11631113
11641114      case 2: /* bit 0 = T1 (unused) */
11651115         break;
11661116
11671117      case 3:
1168         state->m_ds3_sfirqs = (data >> 1) & 1;
1169         state->m_ds3_s68irqs = !state->m_ds3_sfirqs;
1170         update_ds3_sirq(state);
1118         m_ds3_sfirqs = (data >> 1) & 1;
1119         m_ds3_s68irqs = !m_ds3_sfirqs;
1120         update_ds3_sirq();
11711121         break;
11721122
11731123      case 4:
1174         state->m_ds3dac1->write_signed16(data);
1124         m_ds3dac1->write_signed16(data);
11751125         break;
11761126
11771127      case 5:
1178         state->m_ds3dac2->write_signed16(data);
1128         m_ds3dac2->write_signed16(data);
11791129         break;
11801130
11811131      case 6:
1182         state->m_ds3_sdata_address = (state->m_ds3_sdata_address & 0xffff0000) | (data & 0xffff);
1132         m_ds3_sdata_address = (m_ds3_sdata_address & 0xffff0000) | (data & 0xffff);
11831133         break;
11841134
11851135      case 7:
1186         state->m_ds3_sdata_address = (state->m_ds3_sdata_address & 0x0000ffff) | (data << 16);
1136         m_ds3_sdata_address = (m_ds3_sdata_address & 0x0000ffff) | (data << 16);
11871137         break;
11881138   }
11891139}
11901140
1191READ16_HANDLER( hdds3_sdsp_control_r )
1141READ16_MEMBER( harddriv_state::hdds3_sdsp_control_r )
11921142{
1193   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1194
11951143   switch (offset)
11961144   {
11971145      default:
1198         return state->m_ds3sdsp_regs[offset];
1146         return m_ds3sdsp_regs[offset];
11991147   }
12001148
12011149   return 0xff;
12021150}
12031151
12041152
1205WRITE16_HANDLER( hdds3_sdsp_control_w )
1153WRITE16_MEMBER( harddriv_state::hdds3_sdsp_control_w )
12061154{
1207   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1208
12091155   switch (offset)
12101156   {
12111157      case 0x1b:
12121158         // Scale
12131159         data &= 0xff;
12141160
1215         if (state->m_ds3sdsp_regs[0x1b] != data)
1161         if (m_ds3sdsp_regs[0x1b] != data)
12161162         {
1217            state->m_ds3sdsp_regs[0x1b] = data;
1163            m_ds3sdsp_regs[0x1b] = data;
12181164            hdds3sdsp_reset_timer(space.machine());
12191165         }
12201166         break;
12211167
12221168      case 0x1c:
12231169         // Count
1224         if (state->m_ds3sdsp_regs[0x1c] != data)
1170         if (m_ds3sdsp_regs[0x1c] != data)
12251171         {
1226            state->m_ds3sdsp_regs[0x1c] = data;
1172            m_ds3sdsp_regs[0x1c] = data;
12271173            hdds3sdsp_reset_timer(space.machine());
12281174         }
12291175         break;
12301176
12311177      case 0x1d:
12321178         // Period
1233         state->m_ds3sdsp_regs[0x1d] = data;
1179         m_ds3sdsp_regs[0x1d] = data;
12341180         break;
12351181
12361182      case 0x1e:
1237         state->m_ds3sdsp_regs[0x1e] = data;
1183         m_ds3sdsp_regs[0x1e] = data;
12381184         break;
12391185
12401186      case 0x1f:
r26010r26011
12421188         if (data & 0x200)
12431189         {
12441190            UINT32 page = (data >> 6) & 7;
1245            state->m_ds3sdsp->load_boot_data(state->m_ds3sdsp->region()->base() + (0x2000 * page), state->m_ds3sdsp_pgm_memory);
1246            state->m_ds3sdsp->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
1191            m_ds3sdsp->load_boot_data(m_ds3sdsp->region()->base() + (0x2000 * page), m_ds3sdsp_pgm_memory);
1192            m_ds3sdsp->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
12471193            data &= ~0x200;
12481194         }
12491195
1250         state->m_ds3sdsp_regs[0x1f] = data;
1196         m_ds3sdsp_regs[0x1f] = data;
12511197         break;
12521198
12531199      default:
1254         state->m_ds3sdsp_regs[offset] = data;
1200         m_ds3sdsp_regs[offset] = data;
12551201         break;
12561202   }
12571203}
12581204
12591205
1260READ16_HANDLER( hdds3_xdsp_control_r )
1206READ16_MEMBER( harddriv_state::hdds3_xdsp_control_r )
12611207{
1262   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1263
12641208   switch (offset)
12651209   {
12661210      default:
1267         return state->m_ds3xdsp_regs[offset];
1211         return m_ds3xdsp_regs[offset];
12681212   }
12691213
12701214   return 0xff;
12711215}
12721216
12731217
1274WRITE16_HANDLER( hdds3_xdsp_control_w )
1218WRITE16_MEMBER( harddriv_state::hdds3_xdsp_control_w )
12751219{
1276   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1277
12781220   switch (offset)
12791221   {
12801222      default:
1281         state->m_ds3xdsp_regs[offset] = data;
1223         m_ds3xdsp_regs[offset] = data;
12821224         break;
12831225   }
12841226}
r26010r26011
14301372 *
14311373 *************************************/
14321374
1433READ16_HANDLER( hdds3_special_r )
1375READ16_MEMBER( harddriv_state::hdds3_special_r )
14341376{
1435   harddriv_state *state = space.machine().driver_data<harddriv_state>();
14361377   int result;
14371378
14381379   switch (offset & 7)
14391380   {
14401381      case 0:
1441         state->m_ds3_g68flag = 0;
1442         update_ds3_irq(state);
1443         return state->m_ds3_g68data;
1382         m_ds3_g68flag = 0;
1383         update_ds3_irq();
1384         return m_ds3_g68data;
14441385
14451386      case 1:
14461387         result = 0x0fff;
1447         if (state->m_ds3_gcmd) result ^= 0x8000;
1448         if (state->m_ds3_g68flag) result ^= 0x4000;
1449         if (state->m_ds3_gflag) result ^= 0x2000;
1388         if (m_ds3_gcmd) result ^= 0x8000;
1389         if (m_ds3_g68flag) result ^= 0x4000;
1390         if (m_ds3_gflag) result ^= 0x2000;
14501391         return result;
14511392
14521393      case 6:
1453         logerror("ADSP r @ %04x\n", state->m_ds3_sim_address);
1454         if (state->m_ds3_sim_address < state->m_sim_memory_size)
1455            return state->m_sim_memory[state->m_ds3_sim_address];
1394         logerror("ADSP r @ %04x\n", m_ds3_sim_address);
1395         if (m_ds3_sim_address < m_sim_memory_size)
1396            return m_sim_memory[m_ds3_sim_address];
14561397         else
14571398            return 0xff;
14581399   }
r26010r26011
14601401}
14611402
14621403
1463WRITE16_HANDLER( hdds3_special_w )
1404WRITE16_MEMBER( harddriv_state::hdds3_special_w )
14641405{
1465   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1466
14671406   /* IMPORTANT! these data values also write through to the underlying RAM */
1468   state->m_adsp_data_memory[offset] = data;
1407   m_adsp_data_memory[offset] = data;
14691408
14701409   switch (offset & 7)
14711410   {
14721411      case 0:
14731412         logerror("%04X:ADSP sets gdata to %04X\n", space.device().safe_pcbase(), data);
1474         state->m_ds3_gdata = data;
1475         state->m_ds3_gflag = 1;
1476         update_ds3_irq(state);
1413         m_ds3_gdata = data;
1414         m_ds3_gflag = 1;
1415         update_ds3_irq();
14771416
14781417         /* once we've written data, trigger the main CPU to wake up again */
14791418         space.machine().scheduler().trigger(DS3_TRIGGER);
r26010r26011
14811420
14821421      case 1:
14831422         logerror("%04X:ADSP sets interrupt = %d\n", space.device().safe_pcbase(), (data >> 1) & 1);
1484         state->m_adsp_irq_state = (data >> 1) & 1;
1485         state->update_interrupts();
1423         m_adsp_irq_state = (data >> 1) & 1;
1424         update_interrupts();
14861425         break;
14871426
14881427      case 2:
1489         state->m_ds3_send = (data >> 0) & 1;
1428         m_ds3_send = (data >> 0) & 1;
14901429         break;
14911430
14921431      case 3:
1493         state->m_ds3_gfirqs = (data >> 1) & 1;
1494         state->m_ds3_g68irqs = !state->m_ds3_gfirqs;
1495         update_ds3_irq(state);
1432         m_ds3_gfirqs = (data >> 1) & 1;
1433         m_ds3_g68irqs = !m_ds3_gfirqs;
1434         update_ds3_irq();
14961435         break;
14971436
14981437      case 4:
1499         state->m_ds3_sim_address = (state->m_ds3_sim_address & 0xffff0000) | (data & 0xffff);
1438         m_ds3_sim_address = (m_ds3_sim_address & 0xffff0000) | (data & 0xffff);
15001439         break;
15011440
15021441      case 5:
1503         state->m_ds3_sim_address = (state->m_ds3_sim_address & 0xffff) | ((data << 16) & 0x00070000);
1442         m_ds3_sim_address = (m_ds3_sim_address & 0xffff) | ((data << 16) & 0x00070000);
15041443         break;
15051444   }
15061445}
15071446
15081447
1509READ16_HANDLER( hdds3_control_r )
1448READ16_MEMBER( harddriv_state::hdds3_control_r )
15101449{
15111450   logerror("adsp2101 control r @ %04X\n", 0x3fe0 + offset);
15121451   return 0;
15131452}
15141453
15151454
1516WRITE16_HANDLER( hdds3_control_w )
1455WRITE16_MEMBER( harddriv_state::hdds3_control_w )
15171456{
15181457   if (offset != 0x1e && offset != 0x1f)
15191458      logerror("adsp2101 control w @ %04X = %04X\n", 0x3fe0 + offset, data);
r26010r26011
15271466 *
15281467 *************************************/
15291468
1530READ16_HANDLER( hd68k_ds3_program_r )
1469READ16_MEMBER( harddriv_state::hd68k_ds3_program_r )
15311470{
1532   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1533   UINT32 *base = &state->m_adsp_pgm_memory[offset & 0x1fff];
1471   UINT32 *base = &m_adsp_pgm_memory[offset & 0x1fff];
15341472   UINT32 word = *base;
15351473   return (!(offset & 0x2000)) ? (word >> 8) : (word & 0xff);
15361474}
15371475
15381476
1539WRITE16_HANDLER( hd68k_ds3_program_w )
1477WRITE16_MEMBER( harddriv_state::hd68k_ds3_program_w )
15401478{
1541   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1542   UINT32 *base = &state->m_adsp_pgm_memory[offset & 0x1fff];
1479   UINT32 *base = &m_adsp_pgm_memory[offset & 0x1fff];
15431480   UINT32 oldword = *base;
15441481   UINT16 temp;
15451482
r26010r26011
15861523 *
15871524 *************************************/
15881525
1589WRITE16_HANDLER( hd68k_dsk_control_w )
1526WRITE16_MEMBER( harddriv_state::hd68k_dsk_control_w )
15901527{
1591   harddriv_state *state = space.machine().driver_data<harddriv_state>();
15921528   int val = (offset >> 3) & 1;
15931529   switch (offset & 7)
15941530   {
15951531      case 0: /* DSPRESTN */
1596         state->m_dsp32->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
1532         m_dsp32->set_input_line(INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE);
15971533         break;
15981534
15991535      case 1: /* DSPZN */
1600         state->m_dsp32->set_input_line(INPUT_LINE_HALT, val ? CLEAR_LINE : ASSERT_LINE);
1536         m_dsp32->set_input_line(INPUT_LINE_HALT, val ? CLEAR_LINE : ASSERT_LINE);
16011537         break;
16021538
16031539      case 2: /* ZW1 */
r26010r26011
16271563 *
16281564 *************************************/
16291565
1630READ16_HANDLER( hd68k_dsk_ram_r )
1566READ16_MEMBER( harddriv_state::hd68k_dsk_ram_r )
16311567{
1632   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1633   return state->m_dsk_ram[offset];
1568   return m_dsk_ram[offset];
16341569}
16351570
16361571
1637WRITE16_HANDLER( hd68k_dsk_ram_w )
1572WRITE16_MEMBER( harddriv_state::hd68k_dsk_ram_w )
16381573{
1639   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1640   COMBINE_DATA(&state->m_dsk_ram[offset]);
1574   COMBINE_DATA(&m_dsk_ram[offset]);
16411575}
16421576
16431577
1644READ16_HANDLER( hd68k_dsk_zram_r )
1578READ16_MEMBER( harddriv_state::hd68k_dsk_zram_r )
16451579{
1646   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1647   return state->m_dsk_zram[offset];
1580   return m_dsk_zram[offset];
16481581}
16491582
16501583
1651WRITE16_HANDLER( hd68k_dsk_zram_w )
1584WRITE16_MEMBER( harddriv_state::hd68k_dsk_zram_w )
16521585{
1653   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1654   COMBINE_DATA(&state->m_dsk_zram[offset]);
1586   COMBINE_DATA(&m_dsk_zram[offset]);
16551587}
16561588
16571589
1658READ16_HANDLER( hd68k_dsk_small_rom_r )
1590READ16_MEMBER( harddriv_state::hd68k_dsk_small_rom_r )
16591591{
1660   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1661   return state->m_dsk_rom[offset & 0x1ffff];
1592   return m_dsk_rom[offset & 0x1ffff];
16621593}
16631594
16641595
1665READ16_HANDLER( hd68k_dsk_rom_r )
1596READ16_MEMBER( harddriv_state::hd68k_dsk_rom_r )
16661597{
1667   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1668   return state->m_dsk_rom[offset];
1598   return m_dsk_rom[offset];
16691599}
16701600
16711601
r26010r26011
16761606 *
16771607 *************************************/
16781608
1679WRITE16_HANDLER( hd68k_dsk_dsp32_w )
1609WRITE16_MEMBER( harddriv_state::hd68k_dsk_dsp32_w )
16801610{
1681   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1682   state->m_dsk_pio_access = TRUE;
1683   state->m_dsp32->pio_w(offset, data);
1684   state->m_dsk_pio_access = FALSE;
1611   m_dsk_pio_access = TRUE;
1612   m_dsp32->pio_w(offset, data);
1613   m_dsk_pio_access = FALSE;
16851614}
16861615
16871616
1688READ16_HANDLER( hd68k_dsk_dsp32_r )
1617READ16_MEMBER( harddriv_state::hd68k_dsk_dsp32_r )
16891618{
1690   harddriv_state *state = space.machine().driver_data<harddriv_state>();
16911619   UINT16 result;
1692   state->m_dsk_pio_access = TRUE;
1693   result = state->m_dsp32->pio_r(offset);
1694   state->m_dsk_pio_access = FALSE;
1620   m_dsk_pio_access = TRUE;
1621   result = m_dsp32->pio_r(offset);
1622   m_dsk_pio_access = FALSE;
16951623   return result;
16961624}
16971625
r26010r26011
17081636}
17091637
17101638
1711WRITE32_HANDLER( rddsp32_sync0_w )
1639WRITE32_MEMBER( harddriv_state::rddsp32_sync0_w )
17121640{
1713   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1714   if (state->m_dsk_pio_access)
1641   if (m_dsk_pio_access)
17151642   {
1716      UINT32 *dptr = &state->m_rddsp32_sync[0][offset];
1643      UINT32 *dptr = &m_rddsp32_sync[0][offset];
17171644      UINT32 newdata = *dptr;
17181645      COMBINE_DATA(&newdata);
1719      state->m_dataptr[state->m_next_msp_sync % MAX_MSP_SYNC] = dptr;
1720      state->m_dataval[state->m_next_msp_sync % MAX_MSP_SYNC] = newdata;
1721      space.machine().scheduler().synchronize(timer_expired_delegate(FUNC(harddriv_state::rddsp32_sync_cb),state), state->m_next_msp_sync++ % MAX_MSP_SYNC);
1646      m_dataptr[m_next_msp_sync % MAX_MSP_SYNC] = dptr;
1647      m_dataval[m_next_msp_sync % MAX_MSP_SYNC] = newdata;
1648      space.machine().scheduler().synchronize(timer_expired_delegate(FUNC(harddriv_state::rddsp32_sync_cb),this), m_next_msp_sync++ % MAX_MSP_SYNC);
17221649   }
17231650   else
1724      COMBINE_DATA(&state->m_rddsp32_sync[0][offset]);
1651      COMBINE_DATA(&m_rddsp32_sync[0][offset]);
17251652}
17261653
17271654
1728WRITE32_HANDLER( rddsp32_sync1_w )
1655WRITE32_MEMBER( harddriv_state::rddsp32_sync1_w )
17291656{
1730   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1731   if (state->m_dsk_pio_access)
1657   if (m_dsk_pio_access)
17321658   {
1733      UINT32 *dptr = &state->m_rddsp32_sync[1][offset];
1659      UINT32 *dptr = &m_rddsp32_sync[1][offset];
17341660      UINT32 newdata = *dptr;
17351661      COMBINE_DATA(&newdata);
1736      state->m_dataptr[state->m_next_msp_sync % MAX_MSP_SYNC] = dptr;
1737      state->m_dataval[state->m_next_msp_sync % MAX_MSP_SYNC] = newdata;
1738      space.machine().scheduler().synchronize(timer_expired_delegate(FUNC(harddriv_state::rddsp32_sync_cb),state), state->m_next_msp_sync++ % MAX_MSP_SYNC);
1662      m_dataptr[m_next_msp_sync % MAX_MSP_SYNC] = dptr;
1663      m_dataval[m_next_msp_sync % MAX_MSP_SYNC] = newdata;
1664      space.machine().scheduler().synchronize(timer_expired_delegate(FUNC(harddriv_state::rddsp32_sync_cb),this), m_next_msp_sync++ % MAX_MSP_SYNC);
17391665   }
17401666   else
1741      COMBINE_DATA(&state->m_rddsp32_sync[1][offset]);
1667      COMBINE_DATA(&m_rddsp32_sync[1][offset]);
17421668}
17431669
17441670
r26010r26011
17541680 *
17551681 *************************************/
17561682
1757WRITE16_HANDLER( hddspcom_control_w )
1683WRITE16_MEMBER( harddriv_state::hddspcom_control_w )
17581684{
17591685   int val = (offset >> 3) & 1;
17601686   switch (offset & 7)
r26010r26011
17821708 *
17831709 *************************************/
17841710
1785WRITE16_HANDLER( rd68k_slapstic_w )
1711WRITE16_MEMBER( harddriv_state::rd68k_slapstic_w )
17861712{
17871713   slapstic_tweak(space, offset & 0x3fff);
17881714}
17891715
17901716
1791READ16_HANDLER( rd68k_slapstic_r )
1717READ16_MEMBER( harddriv_state::rd68k_slapstic_r )
17921718{
1793   harddriv_state *state = space.machine().driver_data<harddriv_state>();
17941719   int bank = slapstic_tweak(space, offset & 0x3fff) * 0x4000;
1795   return state->m_m68k_slapstic_base[bank + (offset & 0x3fff)];
1720   return m_m68k_slapstic_base[bank + (offset & 0x3fff)];
17961721}
17971722
17981723
r26010r26011
18031728 *
18041729 *************************************/
18051730
1806static int st68k_sloop_tweak(harddriv_state *state, offs_t offset)
1731int harddriv_state::st68k_sloop_tweak(offs_t offset)
18071732{
18081733   static int last_offset;
18091734
r26010r26011
18121737      switch (offset)
18131738      {
18141739         case 0x78e8:
1815            state->m_st68k_sloop_bank = 0;
1740            m_st68k_sloop_bank = 0;
18161741            break;
18171742         case 0x6ca4:
1818            state->m_st68k_sloop_bank = 1;
1743            m_st68k_sloop_bank = 1;
18191744            break;
18201745         case 0x15ea:
1821            state->m_st68k_sloop_bank = 2;
1746            m_st68k_sloop_bank = 2;
18221747            break;
18231748         case 0x6b28:
1824            state->m_st68k_sloop_bank = 3;
1749            m_st68k_sloop_bank = 3;
18251750            break;
18261751      }
18271752   }
18281753   last_offset = offset;
1829   return state->m_st68k_sloop_bank;
1754   return m_st68k_sloop_bank;
18301755}
18311756
18321757
1833WRITE16_HANDLER( st68k_sloop_w )
1758WRITE16_MEMBER( harddriv_state::st68k_sloop_w )
18341759{
1835   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1836   st68k_sloop_tweak(state, offset & 0x3fff);
1760   st68k_sloop_tweak(offset & 0x3fff);
18371761}
18381762
18391763
1840READ16_HANDLER( st68k_sloop_r )
1764READ16_MEMBER( harddriv_state::st68k_sloop_r )
18411765{
1842   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1843   int bank = st68k_sloop_tweak(state, offset) * 0x4000;
1844   return state->m_m68k_slapstic_base[bank + (offset & 0x3fff)];
1766   int bank = st68k_sloop_tweak(offset) * 0x4000;
1767   return m_m68k_slapstic_base[bank + (offset & 0x3fff)];
18451768}
18461769
18471770
1848READ16_HANDLER( st68k_sloop_alt_r )
1771READ16_MEMBER( harddriv_state::st68k_sloop_alt_r )
18491772{
1850   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1851   if (state->m_st68k_last_alt_sloop_offset == 0x00fe)
1773   if (m_st68k_last_alt_sloop_offset == 0x00fe)
18521774   {
18531775      switch (offset*2)
18541776      {
18551777         case 0x22c:
1856            state->m_st68k_sloop_bank = 0;
1778            m_st68k_sloop_bank = 0;
18571779            break;
18581780         case 0x1e2:
1859            state->m_st68k_sloop_bank = 1;
1781            m_st68k_sloop_bank = 1;
18601782            break;
18611783         case 0x1fa:
1862            state->m_st68k_sloop_bank = 2;
1784            m_st68k_sloop_bank = 2;
18631785            break;
18641786         case 0x206:
1865            state->m_st68k_sloop_bank = 3;
1787            m_st68k_sloop_bank = 3;
18661788            break;
18671789      }
18681790   }
1869   state->m_st68k_last_alt_sloop_offset = offset*2;
1870   return state->m_m68k_sloop_alt_base[offset];
1791   m_st68k_last_alt_sloop_offset = offset*2;
1792   return m_m68k_sloop_alt_base[offset];
18711793}
18721794
18731795
1874static int st68k_protosloop_tweak(harddriv_state *state, offs_t offset)
1796int harddriv_state::st68k_protosloop_tweak(offs_t offset)
18751797{
18761798   static int last_offset;
18771799
r26010r26011
18801802      switch (offset)
18811803      {
18821804         case 0x0001:
1883            state->m_st68k_sloop_bank = 0;
1805            m_st68k_sloop_bank = 0;
18841806            break;
18851807         case 0x0002:
1886            state->m_st68k_sloop_bank = 1;
1808            m_st68k_sloop_bank = 1;
18871809            break;
18881810         case 0x0003:
1889            state->m_st68k_sloop_bank = 2;
1811            m_st68k_sloop_bank = 2;
18901812            break;
18911813         case 0x0004:
1892            state->m_st68k_sloop_bank = 3;
1814            m_st68k_sloop_bank = 3;
18931815            break;
18941816      }
18951817   }
18961818   last_offset = offset;
1897   return state->m_st68k_sloop_bank;
1819   return m_st68k_sloop_bank;
18981820}
18991821
19001822
1901WRITE16_HANDLER( st68k_protosloop_w )
1823WRITE16_MEMBER( harddriv_state::st68k_protosloop_w )
19021824{
1903   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1904   st68k_protosloop_tweak(state, offset & 0x3fff);
1825   st68k_protosloop_tweak(offset & 0x3fff);
19051826}
19061827
19071828
1908READ16_HANDLER( st68k_protosloop_r )
1829READ16_MEMBER( harddriv_state::st68k_protosloop_r )
19091830{
1910   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1911   int bank = st68k_protosloop_tweak(state, offset) * 0x4000;
1912   return state->m_m68k_slapstic_base[bank + (offset & 0x3fff)];
1831   int bank = st68k_protosloop_tweak(offset) * 0x4000;
1832   return m_m68k_slapstic_base[bank + (offset & 0x3fff)];
19131833}
19141834
19151835
r26010r26011
19281848 *
19291849 *************************************/
19301850
1931READ16_HANDLER( hdgsp_speedup_r )
1851READ16_MEMBER( harddriv_state::hdgsp_speedup_r )
19321852{
1933   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1934   int result = state->m_gsp_speedup_addr[0][offset];
1853   int result = m_gsp_speedup_addr[0][offset];
19351854
19361855   /* if both this address and the other important address are not $ffff */
19371856   /* then we can spin until something gets written */
1938   if (result != 0xffff && state->m_gsp_speedup_addr[1][0] != 0xffff &&
1939      &space.device() == state->m_gsp && space.device().safe_pc() == state->m_gsp_speedup_pc)
1857   if (result != 0xffff && m_gsp_speedup_addr[1][0] != 0xffff &&
1858      &space.device() == m_gsp && space.device().safe_pc() == m_gsp_speedup_pc)
19401859   {
1941      state->m_gsp_speedup_count[0]++;
1860      m_gsp_speedup_count[0]++;
19421861      space.device().execute().spin_until_interrupt();
19431862   }
19441863
r26010r26011
19461865}
19471866
19481867
1949WRITE16_HANDLER( hdgsp_speedup1_w )
1868WRITE16_MEMBER( harddriv_state::hdgsp_speedup1_w )
19501869{
1951   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1870   COMBINE_DATA(&m_gsp_speedup_addr[0][offset]);
19521871
1953   COMBINE_DATA(&state->m_gsp_speedup_addr[0][offset]);
1954
19551872   /* if $ffff is written, send an "interrupt" trigger to break us out of the spin loop */
1956   if (state->m_gsp_speedup_addr[0][offset] == 0xffff)
1957      state->m_gsp->signal_interrupt_trigger();
1873   if (m_gsp_speedup_addr[0][offset] == 0xffff)
1874      m_gsp->signal_interrupt_trigger();
19581875}
19591876
19601877
1961WRITE16_HANDLER( hdgsp_speedup2_w )
1878WRITE16_MEMBER( harddriv_state::hdgsp_speedup2_w )
19621879{
1963   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1880   COMBINE_DATA(&m_gsp_speedup_addr[1][offset]);
19641881
1965   COMBINE_DATA(&state->m_gsp_speedup_addr[1][offset]);
1966
19671882   /* if $ffff is written, send an "interrupt" trigger to break us out of the spin loop */
1968   if (state->m_gsp_speedup_addr[1][offset] == 0xffff)
1969      state->m_gsp->signal_interrupt_trigger();
1883   if (m_gsp_speedup_addr[1][offset] == 0xffff)
1884      m_gsp->signal_interrupt_trigger();
19701885}
19711886
19721887
r26010r26011
19791894 *
19801895 *************************************/
19811896
1982READ16_HANDLER( rdgsp_speedup1_r )
1897READ16_MEMBER( harddriv_state::rdgsp_speedup1_r )
19831898{
1984   harddriv_state *state = space.machine().driver_data<harddriv_state>();
1985   UINT16 result = state->m_gsp_speedup_addr[0][offset];
1899   UINT16 result = m_gsp_speedup_addr[0][offset];
19861900
19871901   /* if this address is equal to $f000, spin until something gets written */
1988   if (&space.device() == state->m_gsp && space.device().safe_pc() == state->m_gsp_speedup_pc &&
1902   if (&space.device() == m_gsp && space.device().safe_pc() == m_gsp_speedup_pc &&
19891903      (UINT8)result < space.device().state().state_int(TMS34010_A1))
19901904   {
1991      state->m_gsp_speedup_count[0]++;
1905      m_gsp_speedup_count[0]++;
19921906      space.device().execute().spin_until_interrupt();
19931907   }
19941908
r26010r26011
19961910}
19971911
19981912
1999WRITE16_HANDLER( rdgsp_speedup1_w )
1913WRITE16_MEMBER( harddriv_state::rdgsp_speedup1_w )
20001914{
2001   harddriv_state *state = space.machine().driver_data<harddriv_state>();
2002   COMBINE_DATA(&state->m_gsp_speedup_addr[0][offset]);
2003   if (&space.device() != state->m_gsp)
2004      state->m_gsp->signal_interrupt_trigger();
1915   COMBINE_DATA(&m_gsp_speedup_addr[0][offset]);
1916   if (&space.device() != m_gsp)
1917      m_gsp->signal_interrupt_trigger();
20051918}
20061919
20071920
r26010r26011
20171930 *
20181931 *************************************/
20191932
2020READ16_HANDLER( hdmsp_speedup_r )
1933READ16_MEMBER( harddriv_state::hdmsp_speedup_r )
20211934{
2022   harddriv_state *state = space.machine().driver_data<harddriv_state>();
2023   int data = state->m_msp_speedup_addr[offset];
1935   int data = m_msp_speedup_addr[offset];
20241936
2025   if (data == 0 && &space.device() == state->m_msp && space.device().safe_pc() == state->m_msp_speedup_pc)
1937   if (data == 0 && &space.device() == m_msp && space.device().safe_pc() == m_msp_speedup_pc)
20261938   {
2027      state->m_msp_speedup_count[0]++;
1939      m_msp_speedup_count[0]++;
20281940      space.device().execute().spin_until_interrupt();
20291941   }
20301942
r26010r26011
20321944}
20331945
20341946
2035WRITE16_HANDLER( hdmsp_speedup_w )
1947WRITE16_MEMBER( harddriv_state::hdmsp_speedup_w )
20361948{
2037   harddriv_state *state = space.machine().driver_data<harddriv_state>();
2038   COMBINE_DATA(&state->m_msp_speedup_addr[offset]);
2039   if (offset == 0 && state->m_msp_speedup_addr[offset] != 0)
2040      state->m_msp->signal_interrupt_trigger();
1949   COMBINE_DATA(&m_msp_speedup_addr[offset]);
1950   if (offset == 0 && m_msp_speedup_addr[offset] != 0)
1951      m_msp->signal_interrupt_trigger();
20411952}
20421953
20431954
r26010r26011
20521963 *
20531964 *************************************/
20541965
2055READ16_HANDLER( hdadsp_speedup_r )
1966READ16_MEMBER( harddriv_state::hdadsp_speedup_r )
20561967{
2057   harddriv_state *state = space.machine().driver_data<harddriv_state>();
2058   int data = state->m_adsp_data_memory[0x1fff];
1968   int data = m_adsp_data_memory[0x1fff];
20591969
2060   if (data == 0xffff && &space.device() == state->m_adsp && space.device().safe_pc() <= 0x3b)
1970   if (data == 0xffff && &space.device() == m_adsp && space.device().safe_pc() <= 0x3b)
20611971   {
2062      state->m_adsp_speedup_count[0]++;
1972      m_adsp_speedup_count[0]++;
20631973      space.device().execute().spin_until_interrupt();
20641974   }
20651975
r26010r26011
20671977}
20681978
20691979
2070READ16_HANDLER( hdds3_speedup_r )
1980READ16_MEMBER( harddriv_state::hdds3_speedup_r )
20711981{
2072   harddriv_state *state = space.machine().driver_data<harddriv_state>();
2073   int data = *state->m_ds3_speedup_addr;
1982   int data = *m_ds3_speedup_addr;
20741983
2075   if (data != 0 && &space.device() == state->m_adsp && space.device().safe_pc() == state->m_ds3_speedup_pc)
1984   if (data != 0 && &space.device() == m_adsp && space.device().safe_pc() == m_ds3_speedup_pc)
20761985   {
2077      state->m_adsp_speedup_count[2]++;
1986      m_adsp_speedup_count[2]++;
20781987      space.device().execute().spin_until_interrupt();
20791988   }
20801989
trunk/src/mame/includes/harddriv.h
r26010r26011
273273   optional_device<dac_device> m_dac;
274274   required_device<duartn68681_device> m_duart;
275275   DECLARE_WRITE_LINE_MEMBER(harddriv_duart_irq_handler);
276};
276   
277   /*----------- defined in machine/harddriv.c -----------*/
277278
279   /* Driver/Multisync board */
280   DECLARE_WRITE16_MEMBER( hd68k_irq_ack_w );
278281
279/*----------- defined in machine/harddriv.c -----------*/
282   DECLARE_READ16_MEMBER( hd68k_gsp_io_r );
283   DECLARE_WRITE16_MEMBER( hd68k_gsp_io_w );
280284
281/* Driver/Multisync board */
285   DECLARE_READ16_MEMBER( hd68k_msp_io_r );
286   DECLARE_WRITE16_MEMBER( hd68k_msp_io_w );
282287
283DECLARE_WRITE16_HANDLER( hd68k_irq_ack_w );
284void hdgsp_irq_gen(device_t *device, int state);
285void hdmsp_irq_gen(device_t *device, int state);
288   DECLARE_READ16_MEMBER( hd68k_port0_r );
289   DECLARE_READ16_MEMBER( hd68k_adc8_r );
290   DECLARE_READ16_MEMBER( hd68k_adc12_r );
291   DECLARE_READ16_MEMBER( hdc68k_port1_r );
292   DECLARE_READ16_MEMBER( hda68k_port1_r );
293   DECLARE_READ16_MEMBER( hdc68k_wheel_r );
294   DECLARE_READ16_MEMBER( hd68k_sound_reset_r );
286295
287DECLARE_READ16_HANDLER( hd68k_gsp_io_r );
288DECLARE_WRITE16_HANDLER( hd68k_gsp_io_w );
296   DECLARE_WRITE16_MEMBER( hd68k_adc_control_w );
297   DECLARE_WRITE16_MEMBER( hd68k_wr0_write );
298   DECLARE_WRITE16_MEMBER( hd68k_wr1_write );
299   DECLARE_WRITE16_MEMBER( hd68k_wr2_write );
300   DECLARE_WRITE16_MEMBER( hd68k_nwr_w );
301   DECLARE_WRITE16_MEMBER( hdc68k_wheel_edge_reset_w );
289302
290DECLARE_READ16_HANDLER( hd68k_msp_io_r );
291DECLARE_WRITE16_HANDLER( hd68k_msp_io_w );
303   DECLARE_READ16_MEMBER( hd68k_zram_r );
304   DECLARE_WRITE16_MEMBER( hd68k_zram_w );
292305
293DECLARE_READ16_HANDLER( hd68k_port0_r );
294DECLARE_READ16_HANDLER( hd68k_adc8_r );
295DECLARE_READ16_HANDLER( hd68k_adc12_r );
296DECLARE_READ16_HANDLER( hdc68k_port1_r );
297DECLARE_READ16_HANDLER( hda68k_port1_r );
298DECLARE_READ16_HANDLER( hdc68k_wheel_r );
299DECLARE_READ16_HANDLER( hd68k_sound_reset_r );
306   DECLARE_WRITE16_MEMBER( hdgsp_io_w );
300307
301DECLARE_WRITE16_HANDLER( hd68k_adc_control_w );
302DECLARE_WRITE16_HANDLER( hd68k_wr0_write );
303DECLARE_WRITE16_HANDLER( hd68k_wr1_write );
304DECLARE_WRITE16_HANDLER( hd68k_wr2_write );
305DECLARE_WRITE16_HANDLER( hd68k_nwr_w );
306DECLARE_WRITE16_HANDLER( hdc68k_wheel_edge_reset_w );
308   DECLARE_WRITE16_MEMBER( hdgsp_protection_w );
309   
310   /* ADSP board */
311   DECLARE_READ16_MEMBER( hd68k_adsp_program_r );
312   DECLARE_WRITE16_MEMBER( hd68k_adsp_program_w );
307313
308DECLARE_READ16_HANDLER( hd68k_zram_r );
309DECLARE_WRITE16_HANDLER( hd68k_zram_w );
314   DECLARE_READ16_MEMBER( hd68k_adsp_data_r );
315   DECLARE_WRITE16_MEMBER( hd68k_adsp_data_w );
310316
311DECLARE_WRITE16_HANDLER( hdgsp_io_w );
317   DECLARE_READ16_MEMBER( hd68k_adsp_buffer_r );
318   DECLARE_WRITE16_MEMBER( hd68k_adsp_buffer_w );
312319
313DECLARE_WRITE16_HANDLER( hdgsp_protection_w );
320   DECLARE_WRITE16_MEMBER( hd68k_adsp_control_w );
321   DECLARE_WRITE16_MEMBER( hd68k_adsp_irq_clear_w );
322   DECLARE_READ16_MEMBER( hd68k_adsp_irq_state_r );
314323
324   DECLARE_READ16_MEMBER( hdadsp_special_r );
325   DECLARE_WRITE16_MEMBER( hdadsp_special_w );
326   
327   /* DS III/IV board */
328   void update_ds3_irq();
329   void update_ds3_sirq();
330   
331   DECLARE_WRITE16_MEMBER( hd68k_ds3_control_w );
332   DECLARE_READ16_MEMBER( hd68k_ds3_girq_state_r );
315333
316/* ADSP board */
317DECLARE_READ16_HANDLER( hd68k_adsp_program_r );
318DECLARE_WRITE16_HANDLER( hd68k_adsp_program_w );
334   DECLARE_READ16_MEMBER( hd68k_ds3_gdata_r );
335   DECLARE_WRITE16_MEMBER( hd68k_ds3_gdata_w );
319336
320DECLARE_READ16_HANDLER( hd68k_adsp_data_r );
321DECLARE_WRITE16_HANDLER( hd68k_adsp_data_w );
337   DECLARE_READ16_MEMBER( hdds3_special_r );
338   DECLARE_WRITE16_MEMBER( hdds3_special_w );
339   DECLARE_READ16_MEMBER( hdds3_control_r );
340   DECLARE_WRITE16_MEMBER( hdds3_control_w );
322341
323DECLARE_READ16_HANDLER( hd68k_adsp_buffer_r );
324DECLARE_WRITE16_HANDLER( hd68k_adsp_buffer_w );
342   DECLARE_READ16_MEMBER( hd68k_ds3_program_r );
343   DECLARE_WRITE16_MEMBER( hd68k_ds3_program_w );
325344
326DECLARE_WRITE16_HANDLER( hd68k_adsp_control_w );
327DECLARE_WRITE16_HANDLER( hd68k_adsp_irq_clear_w );
328DECLARE_READ16_HANDLER( hd68k_adsp_irq_state_r );
345   DECLARE_READ16_MEMBER( hd68k_ds3_sdata_r );
346   DECLARE_WRITE16_MEMBER( hd68k_ds3_sdata_w );
347   DECLARE_WRITE16_MEMBER( hd68k_ds3_sirq_clear_w );
348   DECLARE_READ16_MEMBER( hd68k_ds3_sirq_state_r );
329349
330DECLARE_READ16_HANDLER( hdadsp_special_r );
331DECLARE_WRITE16_HANDLER( hdadsp_special_w );
350   DECLARE_READ16_MEMBER( hdds3_sdsp_special_r );
351   DECLARE_WRITE16_MEMBER( hdds3_sdsp_special_w );
332352
333/* DS III/IV board */
334TIMER_DEVICE_CALLBACK( ds3sdsp_internal_timer_callback );
335void hdds3sdsp_timer_enable_callback(adsp21xx_device &device, int enable);
353   DECLARE_READ16_MEMBER( hdds3_sdsp_control_r );
354   DECLARE_WRITE16_MEMBER( hdds3_sdsp_control_w );
355   DECLARE_READ16_MEMBER( hdds3_xdsp_control_r );
356   DECLARE_WRITE16_MEMBER( hdds3_xdsp_control_w );
357   
358   /* DSK board */
359   DECLARE_WRITE16_MEMBER( hd68k_dsk_control_w );
360   DECLARE_READ16_MEMBER( hd68k_dsk_ram_r );
361   DECLARE_WRITE16_MEMBER( hd68k_dsk_ram_w );
362   DECLARE_READ16_MEMBER( hd68k_dsk_zram_r );
363   DECLARE_WRITE16_MEMBER( hd68k_dsk_zram_w );
364   DECLARE_READ16_MEMBER( hd68k_dsk_small_rom_r );
365   DECLARE_READ16_MEMBER( hd68k_dsk_rom_r );
366   DECLARE_WRITE16_MEMBER( hd68k_dsk_dsp32_w );
367   DECLARE_READ16_MEMBER( hd68k_dsk_dsp32_r );
368   DECLARE_WRITE32_MEMBER( rddsp32_sync0_w );
369   DECLARE_WRITE32_MEMBER( rddsp32_sync1_w );
336370
337void hdds3sdsp_serial_tx_callback(adsp21xx_device &device, int port, INT32 data);
338INT32 hdds3sdsp_serial_rx_callback(adsp21xx_device &device, int port);
371   /* DSPCOM board */
372   DECLARE_WRITE16_MEMBER( hddspcom_control_w );
339373
340TIMER_DEVICE_CALLBACK( ds3xdsp_internal_timer_callback );
341void hdds3xdsp_timer_enable_callback(adsp21xx_device &device, int enable);
374   DECLARE_WRITE16_MEMBER( rd68k_slapstic_w );
375   DECLARE_READ16_MEMBER( rd68k_slapstic_r );
342376
343void hdds3xdsp_serial_tx_callback(adsp21xx_device &device, int port, INT32 data);
344INT32 hdds3xdsp_serial_rx_callback(adsp21xx_device &device, int port);
377   /* Game-specific protection */
378   int st68k_sloop_tweak(offs_t offset);
379   DECLARE_WRITE16_MEMBER( st68k_sloop_w );
380   DECLARE_READ16_MEMBER( st68k_sloop_r );
381   DECLARE_READ16_MEMBER( st68k_sloop_alt_r );
382   int st68k_protosloop_tweak(offs_t offset);
383   DECLARE_WRITE16_MEMBER( st68k_protosloop_w );
384   DECLARE_READ16_MEMBER( st68k_protosloop_r );
345385
346WRITE16_HANDLER( hd68k_ds3_control_w );
347READ16_HANDLER( hd68k_ds3_girq_state_r );
386   /* GSP optimizations */
387   DECLARE_READ16_MEMBER( hdgsp_speedup_r );
388   DECLARE_WRITE16_MEMBER( hdgsp_speedup1_w );
389   DECLARE_WRITE16_MEMBER( hdgsp_speedup2_w );
390   DECLARE_READ16_MEMBER( rdgsp_speedup1_r );
391   DECLARE_WRITE16_MEMBER( rdgsp_speedup1_w );
348392
349READ16_HANDLER( hd68k_ds3_gdata_r );
350WRITE16_HANDLER( hd68k_ds3_gdata_w );
393   /* MSP optimizations */
394   DECLARE_READ16_MEMBER( hdmsp_speedup_r );
395   DECLARE_WRITE16_MEMBER( hdmsp_speedup_w );
351396
352READ16_HANDLER( hdds3_special_r );
353WRITE16_HANDLER( hdds3_special_w );
354READ16_HANDLER( hdds3_control_r );
355WRITE16_HANDLER( hdds3_control_w );
397   /* ADSP optimizations */
398   DECLARE_READ16_MEMBER( hdadsp_speedup_r );
399   DECLARE_READ16_MEMBER( hdds3_speedup_r );
400   
401   /*----------- defined in video/harddriv.c -----------*/
402   DECLARE_READ16_MEMBER( hdgsp_control_lo_r );
403   DECLARE_WRITE16_MEMBER( hdgsp_control_lo_w );
404   DECLARE_READ16_MEMBER( hdgsp_control_hi_r );
405   DECLARE_WRITE16_MEMBER( hdgsp_control_hi_w );
356406
357READ16_HANDLER( hd68k_ds3_program_r );
358WRITE16_HANDLER( hd68k_ds3_program_w );
407   DECLARE_READ16_MEMBER( hdgsp_vram_2bpp_r );
408   DECLARE_WRITE16_MEMBER( hdgsp_vram_1bpp_w );
409   DECLARE_WRITE16_MEMBER( hdgsp_vram_2bpp_w );
359410
411   DECLARE_READ16_MEMBER( hdgsp_paletteram_lo_r );
412   DECLARE_WRITE16_MEMBER( hdgsp_paletteram_lo_w );
413   DECLARE_READ16_MEMBER( hdgsp_paletteram_hi_r );
414   DECLARE_WRITE16_MEMBER( hdgsp_paletteram_hi_w );
415};
360416
361READ16_HANDLER( hd68k_ds3_sdata_r );
362WRITE16_HANDLER( hd68k_ds3_sdata_w );
363WRITE16_HANDLER( hd68k_ds3_sirq_clear_w );
364READ16_HANDLER( hd68k_ds3_sirq_state_r );
365417
366READ16_HANDLER( hdds3_sdsp_special_r );
367WRITE16_HANDLER( hdds3_sdsp_special_w );
418/*----------- defined in machine/harddriv.c -----------*/
368419
369READ16_HANDLER( hdds3_sdsp_control_r );
370WRITE16_HANDLER( hdds3_sdsp_control_w );
371READ16_HANDLER( hdds3_xdsp_control_r );
372WRITE16_HANDLER( hdds3_xdsp_control_w );
420/* Driver/Multisync board */
421void hdgsp_irq_gen(device_t *device, int state);
422void hdmsp_irq_gen(device_t *device, int state);
373423
424/* DS III/IV board */
425TIMER_DEVICE_CALLBACK( ds3sdsp_internal_timer_callback );
426void hdds3sdsp_timer_enable_callback(adsp21xx_device &device, int enable);
374427
375/* DSK board */
376void hddsk_update_pif(dsp32c_device &device, UINT32 pins);
377DECLARE_WRITE16_HANDLER( hd68k_dsk_control_w );
378DECLARE_READ16_HANDLER( hd68k_dsk_ram_r );
379DECLARE_WRITE16_HANDLER( hd68k_dsk_ram_w );
380DECLARE_READ16_HANDLER( hd68k_dsk_zram_r );
381DECLARE_WRITE16_HANDLER( hd68k_dsk_zram_w );
382DECLARE_READ16_HANDLER( hd68k_dsk_small_rom_r );
383DECLARE_READ16_HANDLER( hd68k_dsk_rom_r );
384DECLARE_WRITE16_HANDLER( hd68k_dsk_dsp32_w );
385DECLARE_READ16_HANDLER( hd68k_dsk_dsp32_r );
386DECLARE_WRITE32_HANDLER( rddsp32_sync0_w );
387DECLARE_WRITE32_HANDLER( rddsp32_sync1_w );
428void hdds3sdsp_serial_tx_callback(adsp21xx_device &device, int port, INT32 data);
429INT32 hdds3sdsp_serial_rx_callback(adsp21xx_device &device, int port);
388430
389/* DSPCOM board */
390DECLARE_WRITE16_HANDLER( hddspcom_control_w );
431TIMER_DEVICE_CALLBACK( ds3xdsp_internal_timer_callback );
432void hdds3xdsp_timer_enable_callback(adsp21xx_device &device, int enable);
391433
392DECLARE_WRITE16_HANDLER( rd68k_slapstic_w );
393DECLARE_READ16_HANDLER( rd68k_slapstic_r );
434void hdds3xdsp_serial_tx_callback(adsp21xx_device &device, int port, INT32 data);
435INT32 hdds3xdsp_serial_rx_callback(adsp21xx_device &device, int port);
394436
395/* Game-specific protection */
396DECLARE_WRITE16_HANDLER( st68k_sloop_w );
397DECLARE_READ16_HANDLER( st68k_sloop_r );
398DECLARE_READ16_HANDLER( st68k_sloop_alt_r );
399DECLARE_WRITE16_HANDLER( st68k_protosloop_w );
400DECLARE_READ16_HANDLER( st68k_protosloop_r );
437/* DSK board */
438void hddsk_update_pif(dsp32c_device &device, UINT32 pins);
401439
402/* GSP optimizations */
403DECLARE_READ16_HANDLER( hdgsp_speedup_r );
404DECLARE_WRITE16_HANDLER( hdgsp_speedup1_w );
405DECLARE_WRITE16_HANDLER( hdgsp_speedup2_w );
406DECLARE_READ16_HANDLER( rdgsp_speedup1_r );
407DECLARE_WRITE16_HANDLER( rdgsp_speedup1_w );
408
409/* MSP optimizations */
410DECLARE_READ16_HANDLER( hdmsp_speedup_r );
411DECLARE_WRITE16_HANDLER( hdmsp_speedup_w );
412
413/* ADSP optimizations */
414DECLARE_READ16_HANDLER( hdadsp_speedup_r );
415DECLARE_READ16_HANDLER( hdds3_speedup_r );
416
417
418440/*----------- defined in audio/harddriv.c -----------*/
419441
420442void hdsnd_init(running_machine &machine);
421443
422444/*----------- defined in video/harddriv.c -----------*/
423445
424
425446void hdgsp_write_to_shiftreg(address_space &space, UINT32 address, UINT16 *shiftreg);
426447void hdgsp_read_from_shiftreg(address_space &space, UINT32 address, UINT16 *shiftreg);
427448
428DECLARE_READ16_HANDLER( hdgsp_control_lo_r );
429DECLARE_WRITE16_HANDLER( hdgsp_control_lo_w );
430DECLARE_READ16_HANDLER( hdgsp_control_hi_r );
431DECLARE_WRITE16_HANDLER( hdgsp_control_hi_w );
432
433DECLARE_READ16_HANDLER( hdgsp_vram_2bpp_r );
434DECLARE_WRITE16_HANDLER( hdgsp_vram_1bpp_w );
435DECLARE_WRITE16_HANDLER( hdgsp_vram_2bpp_w );
436
437DECLARE_READ16_HANDLER( hdgsp_paletteram_lo_r );
438DECLARE_WRITE16_HANDLER( hdgsp_paletteram_lo_w );
439DECLARE_READ16_HANDLER( hdgsp_paletteram_hi_r );
440DECLARE_WRITE16_HANDLER( hdgsp_paletteram_hi_w );
441
442449void harddriv_scanline_driver(screen_device &screen, bitmap_ind16 &bitmap, int scanline, const tms34010_display_params *params);
443450void harddriv_scanline_multisync(screen_device &screen, bitmap_ind16 &bitmap, int scanline, const tms34010_display_params *params);
trunk/src/mame/video/harddriv.c
r26010r26011
178178 *
179179 *************************************/
180180
181READ16_HANDLER( hdgsp_control_lo_r )
181READ16_MEMBER( harddriv_state::hdgsp_control_lo_r )
182182{
183   harddriv_state *state = space.machine().driver_data<harddriv_state>();
184   return state->m_gsp_control_lo[offset];
183   return m_gsp_control_lo[offset];
185184}
186185
187186
188WRITE16_HANDLER( hdgsp_control_lo_w )
187WRITE16_MEMBER( harddriv_state::hdgsp_control_lo_w )
189188{
190   harddriv_state *state = space.machine().driver_data<harddriv_state>();
191   int oldword = state->m_gsp_control_lo[offset];
189   int oldword = m_gsp_control_lo[offset];
192190   int newword;
193191
194   COMBINE_DATA(&state->m_gsp_control_lo[offset]);
195   newword = state->m_gsp_control_lo[offset];
192   COMBINE_DATA(&m_gsp_control_lo[offset]);
193   newword = m_gsp_control_lo[offset];
196194
197195   if (oldword != newword && offset != 0)
198196      logerror("GSP:gsp_control_lo(%X)=%04X\n", offset, newword);
r26010r26011
206204 *
207205 *************************************/
208206
209READ16_HANDLER( hdgsp_control_hi_r )
207READ16_MEMBER( harddriv_state::hdgsp_control_hi_r )
210208{
211   harddriv_state *state = space.machine().driver_data<harddriv_state>();
212   return state->m_gsp_control_hi[offset];
209   return m_gsp_control_hi[offset];
213210}
214211
215212
216WRITE16_HANDLER( hdgsp_control_hi_w )
213WRITE16_MEMBER( harddriv_state::hdgsp_control_hi_w )
217214{
218   harddriv_state *state = space.machine().driver_data<harddriv_state>();
219215   int val = (offset >> 3) & 1;
220216
221   int oldword = state->m_gsp_control_hi[offset];
217   int oldword = m_gsp_control_hi[offset];
222218   int newword;
223219
224   COMBINE_DATA(&state->m_gsp_control_hi[offset]);
225   newword = state->m_gsp_control_hi[offset];
220   COMBINE_DATA(&m_gsp_control_hi[offset]);
221   newword = m_gsp_control_hi[offset];
226222
227223   switch (offset & 7)
228224   {
229225      case 0x00:
230         state->m_shiftreg_enable = val;
226         m_shiftreg_enable = val;
231227         break;
232228
233229      case 0x01:
234         data = data & (15 >> state->m_gsp_multisync);
235         state->m_screen->update_partial(state->m_screen->vpos() - 1);
236         state->m_gfx_finescroll = data;
230         data = data & (15 >> m_gsp_multisync);
231         m_screen->update_partial(m_screen->vpos() - 1);
232         m_gfx_finescroll = data;
237233         break;
238234
239235      case 0x02:
240         update_palette_bank(space.machine(), (state->m_gfx_palettebank & ~1) | val);
236         update_palette_bank(space.machine(), (m_gfx_palettebank & ~1) | val);
241237         break;
242238
243239      case 0x03:
244         update_palette_bank(space.machine(), (state->m_gfx_palettebank & ~2) | (val << 1));
240         update_palette_bank(space.machine(), (m_gfx_palettebank & ~2) | (val << 1));
245241         break;
246242
247243      case 0x04:
248244         if (space.machine().total_colors() >= 256 * 8)
249            update_palette_bank(space.machine(), (state->m_gfx_palettebank & ~4) | (val << 2));
245            update_palette_bank(space.machine(), (m_gfx_palettebank & ~4) | (val << 2));
250246         break;
251247
252248      case 0x07:
r26010r26011
268264 *
269265 *************************************/
270266
271READ16_HANDLER( hdgsp_vram_2bpp_r )
267READ16_MEMBER( harddriv_state::hdgsp_vram_2bpp_r )
272268{
273269   return 0;
274270}
275271
276272
277WRITE16_HANDLER( hdgsp_vram_1bpp_w )
273WRITE16_MEMBER( harddriv_state::hdgsp_vram_1bpp_w )
278274{
279   harddriv_state *state = space.machine().driver_data<harddriv_state>();
280   UINT32 *dest = (UINT32 *)&state->m_gsp_vram[offset * 16];
281   UINT32 *mask = &state->m_mask_table[data * 4];
282   UINT32 color = state->m_gsp_control_lo[0] & 0xff;
275   UINT32 *dest = (UINT32 *)&m_gsp_vram[offset * 16];
276   UINT32 *mask = &m_mask_table[data * 4];
277   UINT32 color = m_gsp_control_lo[0] & 0xff;
283278   UINT32 curmask;
284279
285280   color |= color << 8;
r26010r26011
303298}
304299
305300
306WRITE16_HANDLER( hdgsp_vram_2bpp_w )
301WRITE16_MEMBER( harddriv_state::hdgsp_vram_2bpp_w )
307302{
308   harddriv_state *state = space.machine().driver_data<harddriv_state>();
309   UINT32 *dest = (UINT32 *)&state->m_gsp_vram[offset * 8];
310   UINT32 *mask = &state->m_mask_table[data * 2];
311   UINT32 color = state->m_gsp_control_lo[0];
303   UINT32 *dest = (UINT32 *)&m_gsp_vram[offset * 8];
304   UINT32 *mask = &m_mask_table[data * 2];
305   UINT32 color = m_gsp_control_lo[0];
312306   UINT32 curmask;
313307
314308   color |= color << 16;
r26010r26011
340334}
341335
342336
343READ16_HANDLER( hdgsp_paletteram_lo_r )
337READ16_MEMBER( harddriv_state::hdgsp_paletteram_lo_r )
344338{
345   harddriv_state *state = space.machine().driver_data<harddriv_state>();
346
347339   /* note that the palette is only accessed via the first 256 entries */
348340   /* others are selected via the palette bank */
349   offset = state->m_gfx_palettebank * 0x100 + (offset & 0xff);
341   offset = m_gfx_palettebank * 0x100 + (offset & 0xff);
350342
351   return state->m_gsp_paletteram_lo[offset];
343   return m_gsp_paletteram_lo[offset];
352344}
353345
354346
355WRITE16_HANDLER( hdgsp_paletteram_lo_w )
347WRITE16_MEMBER( harddriv_state::hdgsp_paletteram_lo_w )
356348{
357   harddriv_state *state = space.machine().driver_data<harddriv_state>();
358
359349   /* note that the palette is only accessed via the first 256 entries */
360350   /* others are selected via the palette bank */
361   offset = state->m_gfx_palettebank * 0x100 + (offset & 0xff);
351   offset = m_gfx_palettebank * 0x100 + (offset & 0xff);
362352
363   COMBINE_DATA(&state->m_gsp_paletteram_lo[offset]);
353   COMBINE_DATA(&m_gsp_paletteram_lo[offset]);
364354   gsp_palette_change(space.machine(), offset);
365355}
366356
r26010r26011
372362 *
373363 *************************************/
374364
375READ16_HANDLER( hdgsp_paletteram_hi_r )
365READ16_MEMBER( harddriv_state::hdgsp_paletteram_hi_r )
376366{
377   harddriv_state *state = space.machine().driver_data<harddriv_state>();
378
379367   /* note that the palette is only accessed via the first 256 entries */
380368   /* others are selected via the palette bank */
381   offset = state->m_gfx_palettebank * 0x100 + (offset & 0xff);
369   offset = m_gfx_palettebank * 0x100 + (offset & 0xff);
382370
383   return state->m_gsp_paletteram_hi[offset];
371   return m_gsp_paletteram_hi[offset];
384372}
385373
386374
387WRITE16_HANDLER( hdgsp_paletteram_hi_w )
375WRITE16_MEMBER( harddriv_state::hdgsp_paletteram_hi_w )
388376{
389   harddriv_state *state = space.machine().driver_data<harddriv_state>();
390
391377   /* note that the palette is only accessed via the first 256 entries */
392378   /* others are selected via the palette bank */
393   offset = state->m_gfx_palettebank * 0x100 + (offset & 0xff);
379   offset = m_gfx_palettebank * 0x100 + (offset & 0xff);
394380
395   COMBINE_DATA(&state->m_gsp_paletteram_hi[offset]);
381   COMBINE_DATA(&m_gsp_paletteram_hi[offset]);
396382   gsp_palette_change(space.machine(), offset);
397383}
398384

Previous 199869 Revisions Next


© 1997-2024 The MAME Team