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

View file

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