]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/dac.cpp
Yet more switches!
[virtualjaguar] / src / dac.cpp
index 2ae3e69595f8f4708fb8caef3a106b895ad9aed4..54bc50be0e8bd968e802e75ecbaa7bb4e46d4b76 100644 (file)
@@ -9,6 +9,9 @@
 #include <SDL.h>
 #include "jaguar.h"
 #include "dac.h"
+#include "settings.h"
+
+//#define DEBUG_DAC
 
 #define BUFFER_SIZE            0x8000                                          // Make the DAC buffers 32K x 16 bits
 
@@ -138,8 +141,8 @@ void SDLSoundCallback(void * userdata, Uint8 * buffer, int length)
 //
 int GetCalculatedFrequency(void)
 {
-       extern bool hardwareTypeNTSC;
-       int systemClockFrequency = (hardwareTypeNTSC ? RISC_CLOCK_RATE_NTSC : RISC_CLOCK_RATE_PAL);
+//     extern bool hardwareTypeNTSC;
+       int systemClockFrequency = (vjs.hardwareTypeNTSC ? RISC_CLOCK_RATE_NTSC : RISC_CLOCK_RATE_PAL);
 
        // We divide by 32 here in order to find the frequency of 32 SCLKs in a row (transferring
        // 16 bits of left data + 16 bits of right data = 32 bits, 1 SCLK = 1 bit transferred).
@@ -175,8 +178,10 @@ void DACWriteWord(uint32 offset, uint16 data)
 //                     DACBuffer[LeftFIFOTailPtr] = data ^ 0x8000;
                        SDL_UnlockAudio();
                }
+#ifdef DEBUG_DAC
                else
                        WriteLog("DAC: Ran into FIFO's left tail pointer!\n");
+#endif
        }
        else if (offset == RTXD + 2)
        {
@@ -189,8 +194,10 @@ void DACWriteWord(uint32 offset, uint16 data)
 //                     DACBuffer[RightFIFOTailPtr] = data ^ 0x8000;
                        SDL_UnlockAudio();
                }
+#ifdef DEBUG_DAC
                else
                        WriteLog("DAC: Ran into FIFO's right tail pointer!\n");
+#endif
        }
        else if (offset == SCLK + 2)                                    // Sample rate
        {
@@ -199,7 +206,7 @@ void DACWriteWord(uint32 offset, uint16 data)
                {
                        SCLKFrequencyDivider = (uint8)data;
 //Of course a better way would be to query the hardware to find the upper limit...
-                       if (data > 7)   // Anything less is too high!
+                       if (data > 7)   // Anything less than 8 is too high!
                        {
                                SDL_CloseAudio();
                                desired.freq = GetCalculatedFrequency();// SDL will do conversion on the fly, if it can't get the exact rate. Nice!