From 4305e17cbebd1f44182ddd6af7a735a469d7d961 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 19 Dec 2021 00:31:08 +1000 Subject: [PATCH] SPU2: Prepare for Qt (add Host wrapper) --- pcsx2/SPU2/Config.h | 2 +- pcsx2/SPU2/Host/CfgHelpers.cpp | 75 ++++++++++++++++ pcsx2/SPU2/Host/Config.cpp | 118 ++++++++++++++++++++++++++ pcsx2/SPU2/Host/Config.h | 106 +++++++++++++++++++++++ pcsx2/SPU2/Host/ConfigDebug.cpp | 108 +++++++++++++++++++++++ pcsx2/SPU2/Host/ConfigSoundTouch.cpp | 63 ++++++++++++++ pcsx2/SPU2/Host/Dialogs.cpp | 85 +++++++++++++++++++ pcsx2/SPU2/Host/Dialogs.h | 42 +++++++++ pcsx2/SPU2/Windows/SndOut_XAudio2.cpp | 4 + pcsx2/SPU2/spu2.cpp | 18 ++-- pcsx2/SPU2/spu2.h | 3 + pcsx2/SPU2/spu2sys.cpp | 2 +- 12 files changed, 619 insertions(+), 7 deletions(-) create mode 100644 pcsx2/SPU2/Host/CfgHelpers.cpp create mode 100644 pcsx2/SPU2/Host/Config.cpp create mode 100644 pcsx2/SPU2/Host/Config.h create mode 100644 pcsx2/SPU2/Host/ConfigDebug.cpp create mode 100644 pcsx2/SPU2/Host/ConfigSoundTouch.cpp create mode 100644 pcsx2/SPU2/Host/Dialogs.cpp create mode 100644 pcsx2/SPU2/Host/Dialogs.h diff --git a/pcsx2/SPU2/Config.h b/pcsx2/SPU2/Config.h index 1175109c5a..123eed250f 100644 --- a/pcsx2/SPU2/Config.h +++ b/pcsx2/SPU2/Config.h @@ -83,7 +83,7 @@ extern u32 OutputModule; extern int SndOutLatencyMS; extern int SynchMode; -#ifndef __POSIX__ +#if defined(_WIN32) && !defined(PCSX2_CORE) extern wchar_t dspPlugin[]; extern int dspPluginModule; diff --git a/pcsx2/SPU2/Host/CfgHelpers.cpp b/pcsx2/SPU2/Host/CfgHelpers.cpp new file mode 100644 index 0000000000..21ecb9eb1d --- /dev/null +++ b/pcsx2/SPU2/Host/CfgHelpers.cpp @@ -0,0 +1,75 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2020 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#include "PrecompiledHeader.h" +#include "common/StringUtil.h" +#include "SPU2/Host/Config.h" +#include "SPU2/Host/Dialogs.h" +#include "HostSettings.h" + +bool CfgReadBool(const wchar_t* Section, const wchar_t* Name, bool Default) +{ + return Host::GetBoolSettingValue(StringUtil::WideStringToUTF8String(Section).c_str(), + StringUtil::WideStringToUTF8String(Name).c_str(), Default); +} + +int CfgReadInt(const wchar_t* Section, const wchar_t* Name, int Default) +{ + return Host::GetIntSettingValue(StringUtil::WideStringToUTF8String(Section).c_str(), + StringUtil::WideStringToUTF8String(Name).c_str(), Default); +} + +float CfgReadFloat(const wchar_t* Section, const wchar_t* Name, float Default) +{ + return Host::GetFloatSettingValue(StringUtil::WideStringToUTF8String(Section).c_str(), + StringUtil::WideStringToUTF8String(Name).c_str(), Default); +} + +void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wchar_t* Data, int DataSize, const wchar_t* Default) +{ + const std::wstring res(StringUtil::UTF8StringToWideString( + Host::GetStringSettingValue( + StringUtil::WideStringToUTF8String(Section).c_str(), + StringUtil::WideStringToUTF8String(Name).c_str(), + StringUtil::WideStringToUTF8String(Default).c_str()))); + + std::wcsncpy(Data, res.c_str(), DataSize); + Data[DataSize - 1] = 0; +} + +void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, const wchar_t* Default) +{ + Data = StringUtil::UTF8StringToWxString( + Host::GetStringSettingValue( + StringUtil::WideStringToUTF8String(Section).c_str(), + StringUtil::WideStringToUTF8String(Name).c_str(), + StringUtil::WideStringToUTF8String(Default).c_str())); +} + +void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value) +{ +} + +void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value) +{ +} + +void CfgWriteFloat(const wchar_t* Section, const wchar_t* Name, float Value) +{ +} + +void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wxString& Data) +{ +} \ No newline at end of file diff --git a/pcsx2/SPU2/Host/Config.cpp b/pcsx2/SPU2/Host/Config.cpp new file mode 100644 index 0000000000..a7f09e64e3 --- /dev/null +++ b/pcsx2/SPU2/Host/Config.cpp @@ -0,0 +1,118 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2021 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#include "PrecompiledHeader.h" + +#include "common/StringUtil.h" + +#include "SPU2/Global.h" +#include "SPU2/Host/Config.h" +#include "SPU2/Host/Dialogs.h" +#include "HostSettings.h" + +int AutoDMAPlayRate[2] = {0, 0}; + +// Default settings. + +// MIXING +int Interpolation = 5; +/* values: + 0: No interpolation (uses nearest) + 1. Linear interpolation + 2. Cubic interpolation + 3. Hermite interpolation + 4. Catmull-Rom interpolation + 5. Gaussian interpolation +*/ + +float FinalVolume; // global +bool AdvancedVolumeControl; +float VolumeAdjustFLdb; // Decibels settings, because audiophiles love that. +float VolumeAdjustCdb; +float VolumeAdjustFRdb; +float VolumeAdjustBLdb; +float VolumeAdjustBRdb; +float VolumeAdjustSLdb; +float VolumeAdjustSRdb; +float VolumeAdjustLFEdb; +float VolumeAdjustFL; // Linear coefficients calculated from decibels, +float VolumeAdjustC; +float VolumeAdjustFR; +float VolumeAdjustBL; +float VolumeAdjustBR; +float VolumeAdjustSL; +float VolumeAdjustSR; +float VolumeAdjustLFE; + +bool _visual_debug_enabled = false; // Windows-only feature + +// OUTPUT +u32 OutputModule = 0; +int SndOutLatencyMS = 100; +int SynchMode = 0; // Time Stretch, Async or Disabled. + +int numSpeakers = 0; +int dplLevel = 0; +bool temp_debug_state; + +/*****************************************************************************/ + +void ReadSettings() +{ + Interpolation = Host::GetIntSettingValue("SPU2/Mixing", "Interpolation", 5); + FinalVolume = ((float)Host::GetIntSettingValue("SPU2/Mixing", "FinalVolume", 100)) / 100; + if (FinalVolume > 1.0f) + FinalVolume = 1.0f; + + AdvancedVolumeControl = Host::GetBoolSettingValue("SPU2/Mixing", "AdvancedVolumeControl", false); + VolumeAdjustCdb = Host::GetFloatSettingValue("SPU2/Mixing", "VolumeAdjustC", 0); + VolumeAdjustFLdb = Host::GetFloatSettingValue("SPU2/Mixing", "VolumeAdjustFL", 0); + VolumeAdjustFRdb = Host::GetFloatSettingValue("SPU2/Mixing", "VolumeAdjustFR", 0); + VolumeAdjustBLdb = Host::GetFloatSettingValue("SPU2/Mixing", "VolumeAdjustBL", 0); + VolumeAdjustBRdb = Host::GetFloatSettingValue("SPU2/Mixing", "VolumeAdjustBR", 0); + VolumeAdjustSLdb = Host::GetFloatSettingValue("SPU2/Mixing", "VolumeAdjustSL", 0); + VolumeAdjustSRdb = Host::GetFloatSettingValue("SPU2/Mixing", "VolumeAdjustSR", 0); + VolumeAdjustLFEdb = Host::GetFloatSettingValue("SPU2/Mixing", "VolumeAdjustLFE", 0); + VolumeAdjustC = powf(10, VolumeAdjustCdb / 10); + VolumeAdjustFL = powf(10, VolumeAdjustFLdb / 10); + VolumeAdjustFR = powf(10, VolumeAdjustFRdb / 10); + VolumeAdjustBL = powf(10, VolumeAdjustBLdb / 10); + VolumeAdjustBR = powf(10, VolumeAdjustBRdb / 10); + VolumeAdjustSL = powf(10, VolumeAdjustSLdb / 10); + VolumeAdjustSR = powf(10, VolumeAdjustSRdb / 10); + VolumeAdjustLFE = powf(10, VolumeAdjustLFEdb / 10); + + const std::string modname(Host::GetStringSettingValue("SPU2/Output", "OutputModule", "cubeb")); + OutputModule = FindOutputModuleById(StringUtil::UTF8StringToWideString(modname).c_str()); // Find the driver index of this module... + + SndOutLatencyMS = Host::GetIntSettingValue("SPU2/Output", "Latency", 100); + SynchMode = Host::GetIntSettingValue("SPU2/Output", "SynchMode", 0); + numSpeakers = Host::GetIntSettingValue("SPU2/Output", "SpeakerConfiguration", 0); + + SoundtouchCfg::ReadSettings(); + DebugConfig::ReadSettings(); + + // Sanity Checks + // ------------- + + Clampify(SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX); + + if (mods[OutputModule] == nullptr) + { + Console.Warning("* SPU2: Unknown output module '%s' specified in configuration file.", modname.c_str()); + Console.Warning("* SPU2: Defaulting to Cubeb (%s).", CubebOut->GetIdent()); + OutputModule = FindOutputModuleById(CubebOut->GetIdent()); + } +} diff --git a/pcsx2/SPU2/Host/Config.h b/pcsx2/SPU2/Host/Config.h new file mode 100644 index 0000000000..7bcea7c6e2 --- /dev/null +++ b/pcsx2/SPU2/Host/Config.h @@ -0,0 +1,106 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2020 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#ifndef CONFIG_H_INCLUDED +#define CONFIG_H_INCLUDED + +#include +#include + +extern bool DebugEnabled; + +extern bool _MsgToConsole; +extern bool _MsgKeyOnOff; +extern bool _MsgVoiceOff; +extern bool _MsgDMA; +extern bool _MsgAutoDMA; +extern bool _MsgOverruns; +extern bool _MsgCache; + +extern bool _AccessLog; +extern bool _DMALog; +extern bool _WaveLog; + +extern bool _CoresDump; +extern bool _MemDump; +extern bool _RegDump; +extern bool _visual_debug_enabled; + +/*static __forceinline bool MsgToConsole() { return _MsgToConsole & DebugEnabled; } + +static __forceinline bool MsgKeyOnOff() { return _MsgKeyOnOff & MsgToConsole(); } +static __forceinline bool MsgVoiceOff() { return _MsgVoiceOff & MsgToConsole(); } +static __forceinline bool MsgDMA() { return _MsgDMA & MsgToConsole(); } +static __forceinline bool MsgAutoDMA() { return _MsgAutoDMA & MsgDMA(); } +static __forceinline bool MsgOverruns() { return _MsgOverruns & MsgToConsole(); } +static __forceinline bool MsgCache() { return _MsgCache & MsgToConsole(); } + +static __forceinline bool AccessLog() { return _AccessLog & DebugEnabled; } +static __forceinline bool DMALog() { return _DMALog & DebugEnabled; } +static __forceinline bool WaveLog() { return _WaveLog & DebugEnabled; } + +static __forceinline bool CoresDump() { return _CoresDump & DebugEnabled; } +static __forceinline bool MemDump() { return _MemDump & DebugEnabled; } +static __forceinline bool RegDump() { return _RegDump & DebugEnabled; }*/ + + +//extern wchar_t AccessLogFileName[255]; +//extern wchar_t WaveLogFileName[255]; +//extern wchar_t DMA4LogFileName[255]; +//extern wchar_t DMA7LogFileName[255]; +//extern wchar_t CoresDumpFileName[255]; +//extern wchar_t MemDumpFileName[255]; +//extern wchar_t RegDumpFileName[255]; + +extern int Interpolation; +extern float FinalVolume; + +extern int AutoDMAPlayRate[2]; + +extern u32 OutputModule; +extern int SndOutLatencyMS; + +extern int SynchMode; + +#ifdef PCSX2_DEVBUILD +const int LATENCY_MAX = 3000; +#else +const int LATENCY_MAX = 750; +#endif + +const int LATENCY_MIN = 3; +const int LATENCY_MIN_TIMESTRETCH = 15; + +namespace SoundtouchCfg +{ + extern const int SequenceLen_Min; + extern const int SequenceLen_Max; + + extern const int SeekWindow_Min; + extern const int SeekWindow_Max; + + extern const int Overlap_Min; + extern const int Overlap_Max; + + extern int SequenceLenMS; + extern int SeekWindowMS; + extern int OverlapMS; + + void ReadSettings(); +}; // namespace SoundtouchCfg + +void ReadSettings(); + +#endif // CONFIG_H_INCLUDED diff --git a/pcsx2/SPU2/Host/ConfigDebug.cpp b/pcsx2/SPU2/Host/ConfigDebug.cpp new file mode 100644 index 0000000000..171593cfcc --- /dev/null +++ b/pcsx2/SPU2/Host/ConfigDebug.cpp @@ -0,0 +1,108 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2020 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#include "PrecompiledHeader.h" + +#include "Config.h" + +#include "SPU2/Global.h" +#include "SPU2/Host/Dialogs.h" +#include "SPU2/Host/Config.h" +#include "common/Path.h" +#include "common/StringUtil.h" +#include "HostSettings.h" + +bool DebugEnabled = false; +bool _MsgToConsole = false; +bool _MsgKeyOnOff = false; +bool _MsgVoiceOff = false; +bool _MsgDMA = false; +bool _MsgAutoDMA = false; +bool _MsgOverruns = false; +bool _MsgCache = false; + +bool _AccessLog = false; +bool _DMALog = false; +bool _WaveLog = false; + +bool _CoresDump = false; +bool _MemDump = false; +bool _RegDump = false; + +wxString AccessLogFileName; +wxString WaveLogFileName; +wxString DMA4LogFileName; +wxString DMA7LogFileName; + +wxString CoresDumpFileName; +wxString MemDumpFileName; +wxString RegDumpFileName; + +void CfgSetSettingsDir(const char* dir) +{ +} + +void CfgSetLogDir(const char* dir) +{ +} + +FILE* OpenBinaryLog(const wxString& logfile) +{ + return wxFopen(Path::Combine(EmuFolders::Logs, logfile), L"wb"); +} + +FILE* OpenLog(const wxString& logfile) +{ + return wxFopen(Path::Combine(EmuFolders::Logs, logfile), L"w"); +} + +FILE* OpenDump(const wxString& logfile) +{ + return wxFopen(Path::Combine(EmuFolders::Logs, logfile), L"w"); +} + +namespace DebugConfig +{ + static const char* Section = "SPU/Debug"; + + void ReadSettings() + { + DebugEnabled = Host::GetBoolSettingValue(Section, "Global_Enable", 0); + _MsgToConsole = Host::GetBoolSettingValue(Section, "Show_Messages", 0); + _MsgKeyOnOff = Host::GetBoolSettingValue(Section, "Show_Messages_Key_On_Off", 0); + _MsgVoiceOff = Host::GetBoolSettingValue(Section, "Show_Messages_Voice_Off", 0); + _MsgDMA = Host::GetBoolSettingValue(Section, "Show_Messages_DMA_Transfer", 0); + _MsgAutoDMA = Host::GetBoolSettingValue(Section, "Show_Messages_AutoDMA", 0); + _MsgOverruns = Host::GetBoolSettingValue(Section, "Show_Messages_Overruns", 0); + _MsgCache = Host::GetBoolSettingValue(Section, "Show_Messages_CacheStats", 0); + + _AccessLog = Host::GetBoolSettingValue(Section, "Log_Register_Access", 0); + _DMALog = Host::GetBoolSettingValue(Section, "Log_DMA_Transfers", 0); + _WaveLog = Host::GetBoolSettingValue(Section, "Log_WAVE_Output", 0); + + _CoresDump = Host::GetBoolSettingValue(Section, "Dump_Info", 0); + _MemDump = Host::GetBoolSettingValue(Section, "Dump_Memory", 0); + _RegDump = Host::GetBoolSettingValue(Section, "Dump_Regs", 0); + + AccessLogFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "Access_Log_Filename", "SPU2Log.txt")); + WaveLogFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "WaveLog_Filename", "SPU2log.wav")); + DMA4LogFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "DMA4Log_Filename", "SPU2dma4.dat")); + DMA7LogFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "DMA7Log_Filename", "SPU2dma7.dat")); + + CoresDumpFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "Info_Dump_Filename", "SPU2Cores.txt")); + MemDumpFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "Mem_Dump_Filename", "SPU2mem.dat")); + RegDumpFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "Reg_Dump_Filename", "SPU2regs.dat")); + } +} // namespace DebugConfig diff --git a/pcsx2/SPU2/Host/ConfigSoundTouch.cpp b/pcsx2/SPU2/Host/ConfigSoundTouch.cpp new file mode 100644 index 0000000000..5ad4d52ece --- /dev/null +++ b/pcsx2/SPU2/Host/ConfigSoundTouch.cpp @@ -0,0 +1,63 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2020 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#include "PrecompiledHeader.h" + +#include "SPU2/Global.h" +#include "SPU2/Host/Dialogs.h" +#include "SPU2/Config.h" +#include "SoundTouch.h" +#include "HostSettings.h" + +namespace SoundtouchCfg +{ + // Timestretch Slider Bounds, Min/Max + const int SequenceLen_Min = 20; + const int SequenceLen_Max = 100; + + const int SeekWindow_Min = 10; + const int SeekWindow_Max = 30; + + const int Overlap_Min = 5; + const int Overlap_Max = 15; + + int SequenceLenMS = 30; + int SeekWindowMS = 20; + int OverlapMS = 10; + + static void ClampValues() + { + Clampify(SequenceLenMS, SequenceLen_Min, SequenceLen_Max); + Clampify(SeekWindowMS, SeekWindow_Min, SeekWindow_Max); + Clampify(OverlapMS, Overlap_Min, Overlap_Max); + } + + void ApplySettings(soundtouch::SoundTouch& sndtouch) + { + sndtouch.setSetting(SETTING_SEQUENCE_MS, SequenceLenMS); + sndtouch.setSetting(SETTING_SEEKWINDOW_MS, SeekWindowMS); + sndtouch.setSetting(SETTING_OVERLAP_MS, OverlapMS); + } + + void ReadSettings() + { + SequenceLenMS = Host::GetIntSettingValue("Soundtouch", "SequenceLengthMS", 30); + SeekWindowMS = Host::GetIntSettingValue("Soundtouch", "SeekWindowMS", 20); + OverlapMS = Host::GetIntSettingValue("Soundtouch", "OverlapMS", 10); + + ClampValues(); + } + +} // namespace SoundtouchCfg diff --git a/pcsx2/SPU2/Host/Dialogs.cpp b/pcsx2/SPU2/Host/Dialogs.cpp new file mode 100644 index 0000000000..92bf825765 --- /dev/null +++ b/pcsx2/SPU2/Host/Dialogs.cpp @@ -0,0 +1,85 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2020 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +// To be continued... + +#include "PrecompiledHeader.h" +#include "Dialogs.h" +#include + +#if !defined(PCSX2_CORE) && (defined(__unix__) || defined(__APPLE__)) +#include + +void SysMessage(const char* fmt, ...) +{ + va_list list; + char msg[512]; + + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); + + if (msg[strlen(msg) - 1] == '\n') + msg[strlen(msg) - 1] = 0; + + wxMessageDialog dialog(nullptr, msg, "Info", wxOK); + dialog.ShowModal(); +} + +void SysMessage(const wchar_t* fmt, ...) +{ + va_list list; + va_start(list, fmt); + wxString msg; + msg.PrintfV(fmt, list); + va_end(list); + + wxMessageDialog dialog(nullptr, msg, "Info", wxOK); + dialog.ShowModal(); +} + +#else + +#include + +void SysMessage(const char* fmt, ...) +{ + va_list list; + va_start(list, fmt); + vfprintf(stderr, fmt, list); + va_end(list); +} + +void SysMessage(const wchar_t* fmt, ...) +{ + va_list list; + va_start(list, fmt); + wxString msg; + msg.PrintfV(fmt, list); + va_end(list); + + fprintf(stderr, "%s\n", msg.ToStdString().c_str()); +} + +#endif + +void DspUpdate() +{ +} + +s32 DspLoadLibrary(wchar_t* fileName, int modnum) +{ + return 0; +} diff --git a/pcsx2/SPU2/Host/Dialogs.h b/pcsx2/SPU2/Host/Dialogs.h new file mode 100644 index 0000000000..35691a7396 --- /dev/null +++ b/pcsx2/SPU2/Host/Dialogs.h @@ -0,0 +1,42 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2020 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#ifndef DIALOG_H_INCLUDED +#define DIALOG_H_INCLUDED + +#include "SPU2/Global.h" +#include "SPU2/Config.h" + +#include + +namespace DebugConfig +{ + extern void ReadSettings(); +} // namespace DebugConfig + +extern void CfgSetSettingsDir(const char* dir); +extern void CfgSetLogDir(const char* dir); + +extern bool CfgReadBool(const wchar_t* Section, const wchar_t* Name, bool Default); +extern void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, const wchar_t* Default); +extern int CfgReadInt(const wchar_t* Section, const wchar_t* Name, int Default); +extern float CfgReadFloat(const wchar_t* Section, const wchar_t* Name, float Default); + +extern void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value); +extern void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value); +extern void CfgWriteFloat(const wchar_t* Section, const wchar_t* Name, float Value); +extern void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wxString& Data); + +#endif diff --git a/pcsx2/SPU2/Windows/SndOut_XAudio2.cpp b/pcsx2/SPU2/Windows/SndOut_XAudio2.cpp index faa09873cf..4f59c3bff3 100644 --- a/pcsx2/SPU2/Windows/SndOut_XAudio2.cpp +++ b/pcsx2/SPU2/Windows/SndOut_XAudio2.cpp @@ -58,7 +58,11 @@ private: } BaseStreamingVoice(uint numChannels) +#ifndef PCSX2_CORE : m_nBuffers(Config_XAudio2.NumBuffers) +#else + : m_nBuffers(2) +#endif , m_nChannels(numChannels) , m_BufferSize(SndOutPacketSize * m_nChannels * PacketsPerBuffer) , m_BufferSizeBytes(m_BufferSize * sizeof(s16)) diff --git a/pcsx2/SPU2/spu2.cpp b/pcsx2/SPU2/spu2.cpp index 68e2f19b37..c927d8b1f2 100644 --- a/pcsx2/SPU2/spu2.cpp +++ b/pcsx2/SPU2/spu2.cpp @@ -17,15 +17,18 @@ #include "Global.h" #include "spu2.h" #include "Dma.h" +#ifndef PCSX2_CORE #if defined(_WIN32) #include "Windows/Dialogs.h" #else // BSD, Macos #include "Linux/Dialogs.h" #include "Linux/Config.h" #endif +#else +#include "Host/Dialogs.h" +#endif #include "R3000A.h" #include "common/pxStreams.h" -#include "gui/AppCoreThread.h" using namespace Threading; @@ -38,6 +41,9 @@ static bool IsInitialized = false; u32 lClocks = 0; +#ifndef PCSX2_CORE +#include "gui/AppCoreThread.h" + void SPU2configure() { ScopedCoreThreadPause paused_core(SystemsMask::System_SPU2); @@ -46,6 +52,8 @@ void SPU2configure() paused_core.AllowResume(); } +#endif + // -------------------------------------------------------------------------------------- // DMA 4/7 Callbacks from Core Emulator // -------------------------------------------------------------------------------------- @@ -208,7 +216,7 @@ s32 SPU2init() return 0; } -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(PCSX2_CORE) // Bit ugly to have this here instead of in RealttimeDebugger.cpp, but meh :p extern bool debugDialogOpen; extern HWND hDebugDialog; @@ -258,7 +266,7 @@ s32 SPU2open() FileLog("[%10d] SPU2 Open\n", Cycles); -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(PCSX2_CORE) #ifdef PCSX2_DEVBUILD // Define may not be needed but not tested yet. Better make sure. if (IsDevBuild && VisualDebug()) { @@ -284,7 +292,7 @@ s32 SPU2open() { SndBuffer::Init(); -#ifndef __POSIX__ +#if defined(_WIN32) && !defined(PCSX2_CORE) DspLoadLibrary(dspPlugin, dspPluginModule); #endif WaveDump::Open(); @@ -307,7 +315,7 @@ void SPU2close() FileLog("[%10d] SPU2 Close\n", Cycles); -#ifndef __POSIX__ +#if defined(_WIN32) && !defined(PCSX2_CORE) DspCloseLibrary(); #endif diff --git a/pcsx2/SPU2/spu2.h b/pcsx2/SPU2/spu2.h index f0213ea51e..2539e15fb3 100644 --- a/pcsx2/SPU2/spu2.h +++ b/pcsx2/SPU2/spu2.h @@ -42,7 +42,10 @@ void SPU2endRecording(); void SPU2async(u32 cycles); s32 SPU2freeze(FreezeAction mode, freezeData* data); + +#ifndef PCSX2_CORE void SPU2configure(); +#endif void SPU2setSettingsDir(const char* dir); void SPU2setLogDir(const char* dir); diff --git a/pcsx2/SPU2/spu2sys.cpp b/pcsx2/SPU2/spu2sys.cpp index 700d88f3df..027e1f3196 100644 --- a/pcsx2/SPU2/spu2sys.cpp +++ b/pcsx2/SPU2/spu2sys.cpp @@ -415,7 +415,7 @@ __forceinline void TimeUpdate(u32 cClocks) } // Visual debug display showing all core's activity! Disabled via #define on release builds. -#ifdef _WIN32 +#if defined(_WIN32) && !defined(PCSX2_CORE) UpdateDebugDialog(); #endif