diff options
Diffstat (limited to 'src/mame/drivers/taitosj.cpp')
-rw-r--r-- | src/mame/drivers/taitosj.cpp | 123 |
1 files changed, 74 insertions, 49 deletions
diff --git a/src/mame/drivers/taitosj.cpp b/src/mame/drivers/taitosj.cpp index b29e3dd5d3c..d3db46e4a63 100644 --- a/src/mame/drivers/taitosj.cpp +++ b/src/mame/drivers/taitosj.cpp @@ -175,21 +175,13 @@ TODO: WRITE8_MEMBER(taitosj_state::taitosj_sndnmi_msk_w) { - m_sndnmi_disable = (data & 1); - if ((m_sound_cmd_written && (!m_sndnmi_disable)) || m_sound_semaphore) - m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); - else - m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + /* B0 is the sound nmi enable, active low */ + m_soundnmi->in_w<0>((~data)&1); } -WRITE8_MEMBER(taitosj_state::sound_command_w) +WRITE8_MEMBER(taitosj_state::soundlatch_w) { - m_sound_cmd_written = true; - m_soundlatch->write(space,0,data); - if ((m_sound_cmd_written && (!m_sndnmi_disable)) || m_sound_semaphore) - m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); - else - m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(taitosj_state::soundlatch_w_cb), this), data); } @@ -199,13 +191,9 @@ WRITE8_MEMBER(taitosj_state::input_port_4_f0_w) } // EPORT2 -WRITE8_MEMBER(taitosj_state::sound_semaphore_w) +WRITE8_MEMBER(taitosj_state::sound_semaphore2_w) { - m_sound_semaphore = (data & 1); - if ((m_sound_cmd_written && (!m_sndnmi_disable)) || m_sound_semaphore) - m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); - else - m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(taitosj_state::sound_semaphore2_w_cb), this), data); } CUSTOM_INPUT_MEMBER(taitosj_state::input_port_4_f0_r) @@ -243,8 +231,8 @@ static ADDRESS_MAP_START( taitosj_main_nomcu_map, AS_PROGRAM, 8, taitosj_state ) AM_RANGE(0xd506, 0xd507) AM_MIRROR(0x00f0) AM_WRITEONLY AM_SHARE("colorbank") AM_RANGE(0xd508, 0xd508) AM_MIRROR(0x00f0) AM_WRITE(taitosj_collision_reg_clear_w) AM_RANGE(0xd509, 0xd50a) AM_MIRROR(0x00f0) AM_WRITEONLY AM_SHARE("gfxpointer") - AM_RANGE(0xd50b, 0xd50b) AM_MIRROR(0x00f0) AM_WRITE(sound_command_w) - AM_RANGE(0xd50c, 0xd50c) AM_MIRROR(0x00f0) AM_WRITE(sound_semaphore_w) + AM_RANGE(0xd50b, 0xd50b) AM_MIRROR(0x00f0) AM_WRITE(soundlatch_w) + AM_RANGE(0xd50c, 0xd50c) AM_MIRROR(0x00f0) AM_WRITE(sound_semaphore2_w) AM_RANGE(0xd50d, 0xd50d) AM_MIRROR(0x00f0) AM_DEVWRITE("watchdog", watchdog_timer_device, reset_w) AM_RANGE(0xd50e, 0xd50e) AM_MIRROR(0x00f0) AM_WRITE(taitosj_bankswitch_w) AM_RANGE(0xd50f, 0xd50f) AM_MIRROR(0x00f0) AM_WRITENOP @@ -313,8 +301,8 @@ static ADDRESS_MAP_START( kikstart_main_map, AS_PROGRAM, 8, taitosj_state ) AM_RANGE(0xd40f, 0xd40f) AM_DEVREAD("ay1", ay8910_device, data_r) /* DSW2 and DSW3 */ AM_RANGE(0xd508, 0xd508) AM_WRITE(taitosj_collision_reg_clear_w) AM_RANGE(0xd509, 0xd50a) AM_WRITEONLY AM_SHARE("gfxpointer") - AM_RANGE(0xd50b, 0xd50b) AM_WRITE(sound_command_w) - AM_RANGE(0xd50c, 0xd50c) AM_WRITE(sound_semaphore_w) + AM_RANGE(0xd50b, 0xd50b) AM_WRITE(soundlatch_w) + AM_RANGE(0xd50c, 0xd50c) AM_WRITE(sound_semaphore2_w) AM_RANGE(0xd50d, 0xd50d) AM_DEVWRITE("watchdog", watchdog_timer_device, reset_w) AM_RANGE(0xd50e, 0xd50e) AM_WRITE(taitosj_bankswitch_w) AM_RANGE(0xd600, 0xd600) AM_WRITEONLY AM_SHARE("video_mode") @@ -322,47 +310,75 @@ static ADDRESS_MAP_START( kikstart_main_map, AS_PROGRAM, 8, taitosj_state ) AM_RANGE(0xe000, 0xefff) AM_ROM ADDRESS_MAP_END +TIMER_CALLBACK_MEMBER(taitosj_state::soundlatch_w_cb) +{ + if (m_soundlatch_flag && (m_soundlatch_data != param)) + logerror("Warning: soundlatch written before being read. Previous: %02x, new: %02x\n", m_soundlatch_data, param); + m_soundlatch_data = param; + m_soundlatch_flag = true; + m_soundnmi->in_w<1>(1); +} + +TIMER_CALLBACK_MEMBER(taitosj_state::soundlatch_clear7_w_cb) +{ + if (m_soundlatch_flag) + logerror("Warning: soundlatch bit 7 cleared before being read. Previous: %02x, new: %02x\n", m_soundlatch_data, m_soundlatch_data&0x7f); + m_soundlatch_data &= 0x7F; +} + +TIMER_CALLBACK_MEMBER(taitosj_state::sound_semaphore2_w_cb) +{ + m_sound_semaphore2 = (param&1); + m_soundnmi2->in_w<1>((param&1)); +} + +TIMER_CALLBACK_MEMBER(taitosj_state::sound_semaphore2_clear_w_cb) +{ + m_sound_semaphore2 = false; + m_soundnmi2->in_w<1>(0); +} + // RD5000 -READ8_MEMBER(taitosj_state::sound_command_r) +READ8_MEMBER(taitosj_state::soundlatch_r) { - m_sound_cmd_written = false; - return m_soundlatch->read(space,0); + if (!machine().side_effect_disabled()) + { + m_soundlatch_flag = false; + m_soundnmi->in_w<1>(0); + } + return m_soundlatch_data; } // RD5001 -READ8_MEMBER(taitosj_state::sound_status_r) +READ8_MEMBER(taitosj_state::soundlatch_flags_r) { - return (m_sound_cmd_written == true ? 8 : 0) | (m_sound_semaphore == true ? 4 : 0) | 3; + return (m_soundlatch_flag?8:0) | (m_sound_semaphore2?4:0) | 3; } // WR5000 -WRITE8_MEMBER(taitosj_state::sound_command_ack_w) +WRITE8_MEMBER(taitosj_state::soundlatch_clear7_w) { - m_soundlatch->write(space,0, m_soundlatch->read(space,0) & 0x7f); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(taitosj_state::soundlatch_clear7_w_cb), this), data); } // WR5001 -WRITE8_MEMBER(taitosj_state::sound_semaphore_clear_w) +WRITE8_MEMBER(taitosj_state::sound_semaphore2_clear_w) { - m_sound_semaphore = false; - if ((m_sound_cmd_written && (!m_sndnmi_disable)) || m_sound_semaphore) - m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); - else - m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(taitosj_state::sound_semaphore2_clear_w_cb), this), data); } static ADDRESS_MAP_START( taitosj_audio_map, AS_PROGRAM, 8, taitosj_state ) AM_RANGE(0x0000, 0x3fff) AM_ROM AM_RANGE(0x4000, 0x43ff) AM_RAM - AM_RANGE(0x4800, 0x4801) AM_DEVWRITE("ay2", ay8910_device, address_data_w) - AM_RANGE(0x4801, 0x4801) AM_DEVREAD("ay2", ay8910_device, data_r) - AM_RANGE(0x4802, 0x4803) AM_DEVWRITE("ay3", ay8910_device, address_data_w) - AM_RANGE(0x4803, 0x4803) AM_DEVREAD("ay3", ay8910_device, data_r) - AM_RANGE(0x4804, 0x4805) AM_DEVWRITE("ay4", ay8910_device, address_data_w) - AM_RANGE(0x4805, 0x4805) AM_DEVREAD("ay4", ay8910_device, data_r) - AM_RANGE(0x5000, 0x5000) AM_READWRITE(sound_command_r, sound_command_ack_w) - AM_RANGE(0x5001, 0x5001) AM_READWRITE(sound_status_r, sound_semaphore_clear_w) + AM_RANGE(0x4800, 0x4801) AM_MIRROR(0x07f8) AM_DEVWRITE("ay2", ay8910_device, address_data_w) + AM_RANGE(0x4801, 0x4801) AM_MIRROR(0x07f8) AM_DEVREAD("ay2", ay8910_device, data_r) + AM_RANGE(0x4802, 0x4803) AM_MIRROR(0x07f8) AM_DEVWRITE("ay3", ay8910_device, address_data_w) + AM_RANGE(0x4803, 0x4803) AM_MIRROR(0x07f8) AM_DEVREAD("ay3", ay8910_device, data_r) + AM_RANGE(0x4804, 0x4805) AM_MIRROR(0x07fa) AM_DEVWRITE("ay4", ay8910_device, address_data_w) + AM_RANGE(0x4805, 0x4805) AM_MIRROR(0x07fa) AM_DEVREAD("ay4", ay8910_device, data_r) + AM_RANGE(0x5000, 0x5000) AM_MIRROR(0x07fc) AM_READWRITE(soundlatch_r, soundlatch_clear7_w) + AM_RANGE(0x5001, 0x5001) AM_MIRROR(0x07fc) AM_READWRITE(soundlatch_flags_r, sound_semaphore2_clear_w) AM_RANGE(0xe000, 0xefff) AM_ROM /* space for diagnostic ROM */ ADDRESS_MAP_END @@ -1768,7 +1784,11 @@ static MACHINE_CONFIG_START( nomcu ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("speaker") - MCFG_GENERIC_LATCH_8_ADD("soundlatch") + MCFG_INPUT_MERGER_ALL_HIGH("soundnmi") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(DEVWRITELINE("soundnmi2", input_merger_device, in_w<0>)) + + MCFG_INPUT_MERGER_ANY_HIGH("soundnmi2") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("audiocpu", INPUT_LINE_NMI)) MCFG_SOUND_ADD("ay1", AY8910, XTAL_6MHz/4) // 6mhz/4 on GAME board, AY-3-8910 @ IC53 (this is the only AY which uses proper mixing resistors, the 3 below have outputs tied together) MCFG_AY8910_PORT_A_READ_CB(IOPORT("DSW2")) @@ -2758,8 +2778,13 @@ ROM_END void taitosj_state::reset_common() { - m_sndnmi_disable = false; // ay-3-8910 resets all registers to 0 on reset - m_sound_semaphore = false; + m_sound_semaphore2 = false; + m_soundnmi2->in_w<1>(0); + m_soundlatch_data = 0xff; + m_soundlatch_flag = false; + m_soundnmi->in_w<1>(0); + m_soundnmi->in_w<0>(0); + m_sound_semaphore2 = false; m_ay1->set_output_gain(0, 0.0); // 3 outputs for Ay1 since it doesn't use tied together outs m_ay1->set_output_gain(1, 0.0); m_ay1->set_output_gain(2, 0.0); @@ -2775,9 +2800,9 @@ void taitosj_state::reset_common() void taitosj_state::init_common() { - save_item(NAME(m_sndnmi_disable)); - save_item(NAME(m_sound_cmd_written)); - save_item(NAME(m_sound_semaphore)); + save_item(NAME(m_soundlatch_data)); + save_item(NAME(m_soundlatch_flag)); + save_item(NAME(m_sound_semaphore2)); save_item(NAME(m_input_port_4_f0)); save_item(NAME(m_kikstart_gears)); |