]> Shamusworld >> Repos - virtualjaguar/commitdiff
Added possibility to run DSP without host audio output, added configure options
authorShamus Hammons <jlhamm@acm.org>
Tue, 12 Jul 2011 04:02:54 +0000 (04:02 +0000)
committerShamus Hammons <jlhamm@acm.org>
Tue, 12 Jul 2011 04:02:54 +0000 (04:02 +0000)
for same, fixed log not to dump out when it reaches 10MB, instead it silently
ignores any further output. Also, attempting to run VJ with "use BIOS" checked
and no BIOS loaded no longer causes a virtual crash.

bios/readme.txt [deleted file]
src/dac.cpp
src/gui/configdialog.cpp
src/gui/generaltab.cpp
src/gui/generaltab.h
src/gui/mainwin.cpp
src/jaguar.cpp
src/log.cpp
src/settings.cpp
src/settings.h

diff --git a/bios/readme.txt b/bios/readme.txt
deleted file mode 100644 (file)
index 3b1d01a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Place the bios here
-
-jagboot.rom (128 Kb)
index f37dd843ba71093171b399dd204e85b7f0f950e1..990a7248b5a7c3fb4ec7152d94d0466d89e288a5 100644 (file)
@@ -57,7 +57,7 @@
 
 static uint32 LeftFIFOHeadPtr, LeftFIFOTailPtr, RightFIFOHeadPtr, RightFIFOTailPtr;
 static SDL_AudioSpec desired;
-static bool SDLSoundInitialized = false;
+static bool SDLSoundInitialized;
 
 // 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.
@@ -76,6 +76,14 @@ int GetCalculatedFrequency(void);
 //
 void DACInit(void)
 {
+       SDLSoundInitialized = false;
+
+       if (!vjs.audioEnabled)
+       {
+               WriteLog("DAC: Host audio playback disabled.\n");
+               return;
+       }
+
 //     memory_malloc_secure((void **)&DACBuffer, BUFFER_SIZE * sizeof(uint16), "DAC buffer");
 //     DACBuffer = (uint16 *)memory_malloc(BUFFER_SIZE * sizeof(uint16), "DAC buffer");
 
@@ -207,6 +215,8 @@ void DACWriteWord(uint32 offset, uint16 data, uint32 who/*= UNKNOWN*/)
 {
        if (offset == LTXD + 2)
        {
+               if (!SDLSoundInitialized)
+                       return;
                // Spin until buffer has been drained (for too fast processors!)...
 //Small problem--if Head == 0 and Tail == buffer end, then this will fail... !!! FIX !!!
 //[DONE]
@@ -246,6 +256,8 @@ WriteLog("Tail=%X, Head=%X", ltail, lhead);
        }
        else if (offset == RTXD + 2)
        {
+               if (!SDLSoundInitialized)
+                       return;
 /*
 Here's what's happening now:
 
index 886cb0548e1c791b26514c76b709e2f42f06aefc..f2cc06e708857d585252d1e96f20d991b1d53ebf 100644 (file)
@@ -55,6 +55,7 @@ void ConfigDialog::LoadDialogFromSettings(void)
 
        generalTab->useBIOS->setChecked(vjs.useJaguarBIOS);
        generalTab->useDSP->setChecked(vjs.DSPEnabled);
+       generalTab->useHostAudio->setChecked(vjs.audioEnabled);
 }
 
 void ConfigDialog::UpdateVJSettings(void)
@@ -66,4 +67,5 @@ void ConfigDialog::UpdateVJSettings(void)
 
        vjs.useJaguarBIOS = generalTab->useBIOS->isChecked();
        vjs.DSPEnabled    = generalTab->useDSP->isChecked();
+       vjs.audioEnabled  = generalTab->useHostAudio->isChecked();
 }
index 8574acba076e98d1863a428336cdf51434fe4d28..a583bbfa1348a6e011cc69c2327395515723f83a 100644 (file)
@@ -56,10 +56,12 @@ GeneralTab::GeneralTab(QWidget * parent/*= 0*/): QWidget(parent)
        // Checkboxes...
        useBIOS            = new QCheckBox(tr("Enable Jaguar BIOS"));
        useDSP             = new QCheckBox(tr("Enable DSP"));
+       useHostAudio       = new QCheckBox(tr("Enable audio playback"));
        useUnknownSoftware = new QCheckBox(tr("Allow unknown software in file chooser"));
 
        layout4->addWidget(useBIOS);
        layout4->addWidget(useDSP);
+       layout4->addWidget(useHostAudio);
        layout4->addWidget(useUnknownSoftware);
 
        setLayout(layout4);
index d10b10eb405eefc07a44cc3614f0725e8238fa50..2d3afb55a86738ce3b9a1fbee8e7aaca980a2ad9 100644 (file)
@@ -19,6 +19,7 @@ class GeneralTab: public QWidget
 
                QCheckBox * useBIOS;
                QCheckBox * useDSP;
+               QCheckBox * useHostAudio;
                QCheckBox * useUnknownSoftware;
 };
 
index 809b916eaa5c3f461dfc8e8ce4a3d6f2e50192bf..e61b369d8002b59edea9b066f84fef3573c16372 100644 (file)
@@ -41,6 +41,7 @@
 #include "generaltab.h"
 #include "version.h"
 
+#include "dac.h"
 #include "jaguar.h"
 #include "tom.h"
 #include "log.h"
@@ -307,8 +308,10 @@ void MainWin::Configure(void)
                return;
 
        QString before = vjs.ROMPath;
+       bool audioBefore = vjs.audioEnabled;
        dlg.UpdateVJSettings();
        QString after = vjs.ROMPath;
+       bool audioAfter = vjs.audioEnabled;
 
        bool allowOld = allowUnknownSoftware;
        //ick.
@@ -319,6 +322,13 @@ void MainWin::Configure(void)
        if ((before != after) || (allowOld != allowUnknownSoftware))
                filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
 
+       // If the "Enable audio" checkbox changed, then we have to re-init the DAC...
+       if (audioBefore != audioAfter)
+       {
+               DACDone();
+               DACInit();
+       }
+
        // Just in case we crash before a clean exit...
        WriteSettings();
 }
@@ -651,6 +661,7 @@ void MainWin::ReadSettings(void)
        vjs.frameSkip        = settings.value("frameSkip", 0).toInt();
        vjs.useJaguarBIOS    = settings.value("useJaguarBIOS", false).toBool();
        vjs.DSPEnabled       = settings.value("DSPEnabled", false).toBool();
+       vjs.audioEnabled     = settings.value("audioEnabled", true).toBool();
        vjs.usePipelinedDSP  = settings.value("usePipelinedDSP", false).toBool();
        vjs.fullscreen       = settings.value("fullscreen", false).toBool();
        vjs.useOpenGL        = settings.value("useOpenGL", true).toBool();
@@ -728,6 +739,7 @@ void MainWin::WriteSettings(void)
        settings.setValue("frameSkip", vjs.frameSkip);
        settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
        settings.setValue("DSPEnabled", vjs.DSPEnabled);
+       settings.setValue("audioEnabled", vjs.audioEnabled);
        settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
        settings.setValue("fullscreen", vjs.fullscreen);
        settings.setValue("useOpenGL", vjs.useOpenGL);
index f893964f6e730ebe98ce772337ae5e7132613b5f..3ae824cbd7ad331fb61e83138e8acd51c78cf472 100644 (file)
@@ -41,6 +41,7 @@
 #define ABORT_ON_ILLEGAL_INSTRUCTIONS
 //#define ABORT_ON_OFFICIAL_ILLEGAL_INSTRUCTION
 #define CPU_DEBUG_MEMORY
+//#define LOG_CD_BIOS_CALLS
 
 // Private function prototypes
 
@@ -243,6 +244,8 @@ if (m68kPC == 0x802058) start = true;
                WriteLog("--> [Calling BusWrite2] D2: %08X\n", m68k_get_reg(NULL, M68K_REG_D2));
 //             m68k_set_reg(M68K_REG_D2, 0x12345678);
        }//*/
+
+#ifdef LOG_CD_BIOS_CALLS
 /*
 CD_init::      -> $3000
 BIOS_VER::     -> $3004
@@ -308,7 +311,8 @@ CD_switch:: -> $306C
                WriteLog("\t\tA0=%08X, A1=%08X, D0=%08X, D1=%08X, D2=%08X\n",
                        m68k_get_reg(NULL, M68K_REG_A0), m68k_get_reg(NULL, M68K_REG_A1),
                        m68k_get_reg(NULL, M68K_REG_D0), m68k_get_reg(NULL, M68K_REG_D1), m68k_get_reg(NULL, M68K_REG_D2));
-//*/
+#endif
+
 #ifdef ABORT_ON_ILLEGAL_INSTRUCTIONS
        if (!m68k_is_valid_instruction(m68k_read_memory_16(m68kPC), M68K_CPU_TYPE_68000))
        {
@@ -1511,8 +1515,8 @@ void RenderCallback(void);
 //extern uint32 * backbuffer;
 void JaguarReset(void)
 {
-//NOTE: This causes a (virtual) crash if this is set in the config but not found... !!! FIX !!!
-       if (vjs.useJaguarBIOS)
+       // Only use the system BIOS if it's available...!
+       if (vjs.useJaguarBIOS && (biosAvailable & (BIOS_NORMAL | BIOS_STUB1 | BIOS_STUB2)))
                memcpy(jaguarMainRAM, jaguarBootROM, 8);
        else
                SET32(jaguarMainRAM, 4, jaguarRunAddress);
index 76c0aa98cd83ca5d900d0113a0e8a83e2d1c3165..15b2384d0099f7e9b2770734ce8ce60a1835b5a3 100644 (file)
@@ -11,6 +11,9 @@
 // Who  When        What
 // ---  ----------  -------------------------------------------------------------
 // JLH  01/16/2010  Created this log ;-)
+// JLH  07/11/2011  Instead of dumping out on max log file size being reached, we
+//                  now just silently ignore any more output. 10 megs ought to be
+//                  enough for anybody. ;-)
 //
 
 #include "log.h"
@@ -41,7 +44,8 @@ FILE * LogGet(void)
 
 void LogDone(void)
 {
-       fclose(log_stream);
+       if (log_stream != NULL)
+               fclose(log_stream);
 }
 
 //
@@ -51,15 +55,23 @@ void LogDone(void)
 void WriteLog(const char * text, ...)
 {
        va_list arg;
-
        va_start(arg, text);
+
+       if (log_stream == NULL)
+       {
+               va_end(arg);
+               return;
+       }
+
        logSize += vfprintf(log_stream, text, arg);
 
        if (logSize > MAX_LOG_SIZE)
        {
                fflush(log_stream);
                fclose(log_stream);
-               exit(1);
+               // Instead of dumping out, we just close the file and ignore any more output.
+               log_stream = NULL;
+//             exit(1);
        }//*/
 
        va_end(arg);
index b647d5eb123230e34b826ced52cf6f6f30f2f33b..977e925320897801e9ce18f23d02eeb8aa55e787 100644 (file)
@@ -124,4 +124,4 @@ void CheckForTrailingSlash(char * path)
                if (path[strlen(path) - 1] != '/')
                        strcat(path, "/");      // NOTE: Possible buffer overflow
 }
-#endif
\ No newline at end of file
+#endif
index ccb9e2f1f22655d7b35c907909ca3248105ebcee..68693255d765a30af01a4fffc703ff13bb09b8fb 100644 (file)
@@ -28,6 +28,7 @@ struct VJSettings
        bool useOpenGL;
        uint32 glFilter;
        bool hardwareTypeAlpine;
+       bool audioEnabled;
        uint32 frameSkip;
        uint32 renderType;