Fix PCM data calculation

This commit is contained in:
Zachary Hall 2024-10-15 14:13:46 -07:00
parent 9268b4ef42
commit 7b2b050b34
2 changed files with 5 additions and 4 deletions

View file

@ -179,7 +179,7 @@ void ZsmBackend::tick(bool step) {
loop_rem |= bytes[8];
loop_rem <<= 8;
loop_rem |= bytes[7];
loop = loop_rem & 0xFFFF;
loop = loop_rem;
islooped = bytes[6];
remain = bytes[5];
remain <<= 8;
@ -191,8 +191,9 @@ void ZsmBackend::tick(bool step) {
cur |= bytes[1];
cur <<= 8;
cur |= bytes[0];
pcm_loop_point = cur + loop;
rem_point = remain - loop_rem;
cur += pcm_data_offs;
loop += cur;
loop_rem = remain - loop_rem;
file->seek(file_pos, SeekType::SET);
} break;
}

View file

@ -87,7 +87,7 @@ class ZsmBackend : public PlaybackBackend {
while (((pcm_read_ctrl() & 0x80) == 0 || pcm_fifo_avail() < samples) && remain > 0) {
remain--;
size_t oldpos = file->get_pos();
file->seek((cur++) + pcm_data_offs, SeekType::SET);
file->seek((cur++), SeekType::SET);
uint8_t sample;
file->read(&sample, 1, 1);
pcm_write_fifo(sample);