]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/dac.cpp
Fixed fullscreen<-->windowed mode swith in OpenGL mode, phase one of
[virtualjaguar] / src / dac.cpp
index 0ad2b9f7114da3d59120bebe04edb06ea50cf477..59019f8d14d5fd25d83c717ee415a5246eefd575 100644 (file)
 // work correctly...! Perhaps just need to set up SSI stuff so BUTCH doesn't get
 // confused...
 
+// ALSO: Need to implement some form of proper locking to replace the clusterfuck
+//       that is the current spinlock implementation. Since the DSP is a separate
+//       entity, could we get away with running it in the sound IRQ?
+
+// ALSO: It may be a good idea to physically separate the left and right buffers
+//       to prevent things like the DSP filling only one side and such. Do such
+//       mono modes exist on the Jag? Seems to according to Super Burnout.
+
+#include "dac.h"
+
 #include "SDL.h"
 #include "m68k.h"
 #include "jaguar.h"
 #include "settings.h"
-#include "dac.h"
+#include "log.h"
 
 //#define DEBUG_DAC
 
@@ -43,7 +53,7 @@ static bool SDLSoundInitialized = false;
 // We can get away with using native endian here because we can tell SDL to use the native
 // endian when looking at the sample buffer, i.e., no need to worry about it.
 
-static uint16 * DACBuffer;
+static uint16 DACBuffer[BUFFER_SIZE];
 static uint8 SCLKFrequencyDivider = 19;                                // Default is roughly 22 KHz (20774 Hz in NTSC mode)
 /*static*/ uint16 serialMode = 0;
 
@@ -57,7 +67,8 @@ int GetCalculatedFrequency(void);
 //
 void DACInit(void)
 {
-       memory_malloc_secure((void **)&DACBuffer, BUFFER_SIZE * sizeof(uint16), "DAC buffer");
+//     memory_malloc_secure((void **)&DACBuffer, BUFFER_SIZE * sizeof(uint16), "DAC buffer");
+//     DACBuffer = (uint16 *)memory_malloc(BUFFER_SIZE * sizeof(uint16), "DAC buffer");
 
        desired.freq = GetCalculatedFrequency();                // SDL will do conversion on the fly, if it can't get the exact rate. Nice!
        desired.format = AUDIO_S16SYS;                                  // This uses the native endian (for portability)...
@@ -96,7 +107,7 @@ void DACDone(void)
                SDL_CloseAudio();
        }
 
-       memory_free(DACBuffer);
+//     memory_free(DACBuffer);
        WriteLog("DAC: Done.\n");
 }
 
@@ -328,6 +339,8 @@ WriteLog("Tail=%X, Head=%X", rtail, rhead);
                                {
                                        if (SDL_OpenAudio(&desired, NULL) < 0)  // NULL means SDL guarantees what we want
                                        {
+// This is bad, Bad, BAD !!! DON'T ABORT BECAUSE WE DIDN'T GET OUR FREQ! !!! FIX !!!
+#warning !!! FIX !!! Aborting because of SDL audio problem is bad!
                                                WriteLog("DAC: Failed to initialize SDL sound: %s.\nDesired freq: %u\nShutting down!\n", SDL_GetError(), desired.freq);
                                                log_done();
                                                exit(1);
@@ -379,5 +392,5 @@ uint16 DACReadWord(uint32 offset, uint32 who/*= UNKNOWN*/)
        else if (offset == RRXD + 2)
                return rrxd;
 
-       return 0xFFFF;  // May need SSTAT as well... (but may be a Jaguar II only feature)              
+       return 0xFFFF;  // May need SSTAT as well... (but may be a Jaguar II only feature)
 }