From 868fd551420e8b88e0bcf363c121e6e84a71b09a Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Tue, 12 Jul 2011 04:02:54 +0000 Subject: [PATCH] Added possibility to run DSP without host audio output, added configure options 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 | 3 --- src/dac.cpp | 14 +++++++++++++- src/gui/configdialog.cpp | 2 ++ src/gui/generaltab.cpp | 2 ++ src/gui/generaltab.h | 1 + src/gui/mainwin.cpp | 12 ++++++++++++ src/jaguar.cpp | 10 +++++++--- src/log.cpp | 18 +++++++++++++++--- src/settings.cpp | 2 +- src/settings.h | 1 + 10 files changed, 54 insertions(+), 11 deletions(-) delete mode 100644 bios/readme.txt diff --git a/bios/readme.txt b/bios/readme.txt deleted file mode 100644 index 3b1d01a..0000000 --- a/bios/readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -Place the bios here - -jagboot.rom (128 Kb) diff --git a/src/dac.cpp b/src/dac.cpp index f37dd84..990a724 100644 --- a/src/dac.cpp +++ b/src/dac.cpp @@ -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: diff --git a/src/gui/configdialog.cpp b/src/gui/configdialog.cpp index 886cb05..f2cc06e 100644 --- a/src/gui/configdialog.cpp +++ b/src/gui/configdialog.cpp @@ -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(); } diff --git a/src/gui/generaltab.cpp b/src/gui/generaltab.cpp index 8574acb..a583bbf 100644 --- a/src/gui/generaltab.cpp +++ b/src/gui/generaltab.cpp @@ -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); diff --git a/src/gui/generaltab.h b/src/gui/generaltab.h index d10b10e..2d3afb5 100644 --- a/src/gui/generaltab.h +++ b/src/gui/generaltab.h @@ -19,6 +19,7 @@ class GeneralTab: public QWidget QCheckBox * useBIOS; QCheckBox * useDSP; + QCheckBox * useHostAudio; QCheckBox * useUnknownSoftware; }; diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 809b916..e61b369 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -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); diff --git a/src/jaguar.cpp b/src/jaguar.cpp index f893964..3ae824c 100644 --- a/src/jaguar.cpp +++ b/src/jaguar.cpp @@ -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); diff --git a/src/log.cpp b/src/log.cpp index 76c0aa9..15b2384 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -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); diff --git a/src/settings.cpp b/src/settings.cpp index b647d5e..977e925 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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 diff --git a/src/settings.h b/src/settings.h index ccb9e2f..6869325 100644 --- a/src/settings.h +++ b/src/settings.h @@ -28,6 +28,7 @@ struct VJSettings bool useOpenGL; uint32 glFilter; bool hardwareTypeAlpine; + bool audioEnabled; uint32 frameSkip; uint32 renderType; -- 2.37.2