Fix loop position

This commit is contained in:
Zachary Hall 2024-10-15 09:44:56 -07:00
parent 3799b1a166
commit c188aafb22
3 changed files with 3 additions and 1 deletions

Binary file not shown.

1
.gitignore vendored
View file

@ -19,3 +19,4 @@ wasm-rt/wasmer
cmake-build-*/ cmake-build-*/
.ctagsd .ctagsd
*.rej *.rej
.codelite/*.tags

View file

@ -52,6 +52,7 @@ void ZsmBackend::load(const char *filename) {
while (true) { while (true) {
tmpDelayTicks -= get_delay_per_frame(); tmpDelayTicks -= get_delay_per_frame();
if (tmpDelayTicks < 0.0) { if (tmpDelayTicks < 0.0) {
if (file->get_pos() == (size_t)loop_point) loop_pos = time;
ZsmCommand cmd = get_command(); ZsmCommand cmd = get_command();
if (cmd.id == ZsmEOF) { if (cmd.id == ZsmEOF) {
break; break;
@ -65,7 +66,7 @@ void ZsmBackend::load(const char *filename) {
music_data_len = file->get_pos(); music_data_len = file->get_pos();
switch_stream(0); switch_stream(0);
loop_end = length; loop_end = length;
loop_start = ((double)this->loop_point) / ((double)tick_rate); loop_start = this->loop_pos;
fm_stream = SDL_NewAudioStream(AUDIO_S16SYS, 2, YM_FREQ, AUDIO_S16SYS, 2, PSG_FREQ); fm_stream = SDL_NewAudioStream(AUDIO_S16SYS, 2, YM_FREQ, AUDIO_S16SYS, 2, PSG_FREQ);
DEBUG.writefln("fm_stream: %ld -> %ld", YM_FREQ, PSG_FREQ); DEBUG.writefln("fm_stream: %ld -> %ld", YM_FREQ, PSG_FREQ);
} }