fragglet / sdl-sopwith

Classic bi-plane shoot-'em up
https://fragglet.github.io/sdl-sopwith
GNU General Public License v2.0
66 stars 13 forks source link

Improve sound/music playback timing #24

Open NY00123 opened 11 months ago

NY00123 commented 11 months ago

Right now, the title music plays slower than the original matching DOS version.

This experimental change partially resolves the differences, but there may still be precision errors (especially right after starting the program):

diff --git a/src/swsound.c b/src/swsound.c
index 1da8869..d3d68b9 100644
--- a/src/swsound.c
+++ b/src/swsound.c
@@ -607,7 +607,7 @@ void swsndupdate(void)
        int thisclock = Timer_GetMS();

        if (thisclock > lastclock + 1000 / 18.2) {
-               lastclock = thisclock;
+               lastclock += 1000 / 18.2;
                soundadj();
        }
 }
NY00123 commented 5 months ago

Reopening this, because my patch has a problem that I recall observing and is still reproduced here: A part of the track is skipped upon starting the program, but not later (after "game over").