]> Shamusworld >> Repos - apple2/blobdiff - src/apple2.cpp
More work on sound.cpp, especially definition of time constants
[apple2] / src / apple2.cpp
index 729dc23cc80206dbeee31fad906e592e3b5bcd70..f50454d35678757cf8495c3b84bb2bd60ccb21d2 100755 (executable)
@@ -163,6 +163,23 @@ if (addr >= 0xC080 && addr <= 0xC08F)
        }
        else if ((addr & 0xFFF0) == 0xC030)
        {
+/*
+This is problematic, mainly because the v65C02 removes actual cycles run after each call.
+Therefore, we don't really have a reliable method of sending a timestamp to the sound routine.
+How to fix?
+
+What we need to send is a delta T value but related to the IRQ buffer routine. E.g., if the buffer
+hasn't had any changes in it then we just fill it with the last sample value and are done. Then
+we need to adjust our delta T accordingly. What we could do is keep a running total of time since the
+last change and adjust it accordingly, i.e., whenever a sound IRQ happens.
+How to keep track?
+
+Have deltaT somewhere. Then, whenever there's a toggle, backfill buffer with last spkr state and reset
+deltaT to zero. In the sound IRQ, if deltaT > buffer size, then subtract buffer size from deltaT. (?)
+
+
+
+*/
                ToggleSpeaker(GetCurrentV65C02Clock());
 //should it return something else here???
                return 0x00;
@@ -797,6 +814,8 @@ else if (event.key.keysym.sym == SDLK_F10)
        SetCallbackTime(FrameCallback, 16666.66666667);
 
 //Instead of this, we should yield remaining time to other processes... !!! FIX !!!
+//lessee...
+//nope. SDL_Delay(10);
        while (SDL_GetTicks() - startTicks < 16);       // Wait for next frame...
        startTicks = SDL_GetTicks();
 }