X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fsound.cpp;h=8010d8985667c04bae056bcfe51c6f5d42cfa0fb;hb=f9851983d3f21e480f2c03af10fa6ace79473d0c;hp=281aee286f8894a56175a9141a9cf26a8aa54085;hpb=f84e14d43ea0dff77d4b216b50e5de5b1d2efabc;p=stargem2 diff --git a/src/sound.cpp b/src/sound.cpp index 281aee2..8010d89 100755 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -10,6 +10,8 @@ // --- ---------- ------------------------------------------------------------ // JLH 06/15/2006 Added changelog ;-) // JLH 06/15/2006 Scrubbed all BYTE, WORD & DWORD references from the code +// JLH 02/10/2009 Fixed sound IRQ callback so that CPU samples are taken at +// cycle exact boundaries // // Notes: // The sound CPU (6808) runs at 894,750 (3,579,000 / 4) Hz. @@ -87,15 +89,15 @@ void SDLSoundCallback(void * userdata, Uint8 * buffer, int length) #define CYCLE_EXACT_SOUND #ifdef CYCLE_EXACT_SOUND - float overflow = 0.0; - uint32 time = 20; + static float overflow = 0.0; + static uint32 time = 20; #endif while (cnt != length) { // This is close, but not cycle exact (exact would be 20.289115646...) -//Need to figure out how to get that fraction to execute... !!! FIX !!! +//Need to figure out how to get that fraction to execute... !!! FIX !!! [DONE] /* One way would be to use a fractional accumulator, then subtract 1 every time it overflows. Like so: @@ -124,7 +126,7 @@ while (!done) #endif buffer[cnt++] = sram[0x0400]; // Fill the buffer with the PIA output value #ifdef CYCLE_EXACT_SOUND - overflow += 0.289115646; + overflow += 0.289115646; // Fractional part of CPU cycles... if (overflow > 1.0) {