diff --git a/src/devices/sound/upd1771.cpp b/src/devices/sound/upd1771.cpp index 6b0ef06b884..b08ced8779f 100644 --- a/src/devices/sound/upd1771.cpp +++ b/src/devices/sound/upd1771.cpp @@ -432,15 +432,30 @@ void upd1771c_device::write(uint8_t data) //6Khz(ish) DIGI playback //end capture - if (m_index >= 2 && m_packet[m_index - 2] == 0xfe && m_packet[m_index - 1] == 0x00) { - //TODO play capture! - m_index = 0; - m_packet[0] = 0; - m_state = STATE_ADPCM; + bool have_all_data = false; + if (m_index >= 2 && m_packet[m_index - 2] == 0xfe && m_packet[m_index - 1] == 0x00) + { + //TODO play capture! + if (m_index >= 6) + { + // offsets 2 and 3 in the transferred pcm data seem to contain the number of samples + uint16_t count = (m_packet[4] << 8) | m_packet[3]; + count--; + m_packet[3] = count & 0xff; + m_packet[4] = (count >> 8); + if (count == 0) + { + m_index = 0; + m_packet[0] = 0; + m_state = STATE_ADPCM; + have_all_data = true; + } + } + } + if (!have_all_data) + m_timer->adjust(attotime::from_ticks(512, clock())); } - else - m_timer->adjust(attotime::from_ticks(512, clock())); break; //garbage: wipe stack