sound/upd1771.cpp: Improve check for end of adpcm stream when the stream contains multiple samples. (#12913)

* Fixes SCV Star Speeder.
This commit is contained in:
wilbertpol 2024-10-28 15:29:47 +00:00 committed by GitHub
parent b5ee6d82d2
commit 2ba3fe29c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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