Implement reset FIFO for ZSM commands

This commit is contained in:
Zachary Hall 2024-10-15 16:17:23 -07:00
parent 27dbe46ac7
commit b695192f34
2 changed files with 7 additions and 3 deletions

View file

@ -155,7 +155,11 @@ void ZsmBackend::tick(bool step) {
for (size_t i = 0; i < cmd.extcmd.bytes; i += 2) { for (size_t i = 0; i < cmd.extcmd.bytes; i += 2) {
switch (cmd.extcmd.pcm[i]) { switch (cmd.extcmd.pcm[i]) {
case 0: { // ctrl case 0: { // ctrl
pcm_write_ctrl(cmd.extcmd.pcm[i + 1]); uint8_t ctrl = cmd.extcmd.pcm[i + 1];
if (ctrl & 0x80) {
remain = 0;
}
pcm_write_ctrl(ctrl);
} break; } break;
case 1: { // rate case 1: { // rate
pcm_write_rate(cmd.extcmd.pcm[i + 1]); pcm_write_rate(cmd.extcmd.pcm[i + 1]);

View file

@ -85,12 +85,12 @@ class ZsmBackend : public PlaybackBackend {
} }
void audio_step(size_t samples) { void audio_step(size_t samples) {
if (samples == 0) return; if (samples == 0) return;
while (pcm_fifo_avail() < samples && remain > 0) { while (pcm_fifo_avail() < samples) {
if (pcm_read_rate() == 0) break; if (pcm_read_rate() == 0) break;
if ((--remain) == 0) { if ((--remain) == 0) {
if (islooped) { if (islooped) {
cur = loop; cur = loop;
remain = loop_rem - 1; remain = loop_rem;
} else { } else {
break; break;
} }