diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index b14881186a..fce4ea9afe 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -243,6 +243,12 @@ set(pcsx2SPU2Sources SPU2/Timestretcher.cpp SPU2/Wavedump_wav.cpp SPU2/WavFile.cpp + SPU2/Linux/Alsa.cpp + SPU2/Linux/CfgHelpers.cpp + SPU2/Linux/Config.cpp + SPU2/Linux/ConfigDebug.cpp + SPU2/Linux/ConfigSoundTouch.cpp + SPU2/Linux/Dialogs.cpp ) # SPU2 headers @@ -260,6 +266,9 @@ set(pcsx2SPU2Headers SPU2/spdif.h SPU2/spu2replay.h SPU2/WavFile.h + SPU2/Linux/Alsa.h + SPU2/Linux/Config.h + SPU2/Linux/Dialogs.h ) # DebugTools sources diff --git a/pcsx2/IopCounters.cpp b/pcsx2/IopCounters.cpp index d38e9fb264..fe7ea665c4 100644 --- a/pcsx2/IopCounters.cpp +++ b/pcsx2/IopCounters.cpp @@ -139,12 +139,9 @@ void psxRcntInit() { psxCounters[4].interrupt = 0x08000; psxCounters[5].interrupt = 0x10000; - if (SPU2async != NULL) - { - psxCounters[6].rate = 768*12; - psxCounters[6].CycleT = psxCounters[6].rate; - psxCounters[6].mode = 0x8; - } + psxCounters[6].rate = 768*12; + psxCounters[6].CycleT = psxCounters[6].rate; + psxCounters[6].mode = 0x8; if (USBasync != NULL) { @@ -481,20 +478,17 @@ void psxRcntUpdate() } - if(SPU2async) - { - const s32 difference = psxRegs.cycle - psxCounters[6].sCycleT; - s32 c = psxCounters[6].CycleT; + const s32 difference = psxRegs.cycle - psxCounters[6].sCycleT; + s32 c = psxCounters[6].CycleT; - if(difference >= psxCounters[6].CycleT) - { - SPU2async(difference); - psxCounters[6].sCycleT = psxRegs.cycle; - psxCounters[6].CycleT = psxCounters[6].rate; - } - else c -= difference; - psxNextCounter = c; - } + if(difference >= psxCounters[6].CycleT) + { + SPU2async(difference); + psxCounters[6].sCycleT = psxRegs.cycle; + psxCounters[6].CycleT = psxCounters[6].rate; + } + else c -= difference; + psxNextCounter = c; if (DEV9async) { DEV9async(1); diff --git a/pcsx2/IopDma.cpp b/pcsx2/IopDma.cpp index 2aa3df70a4..9de249e41c 100644 --- a/pcsx2/IopDma.cpp +++ b/pcsx2/IopDma.cpp @@ -26,7 +26,7 @@ using namespace R3000A; // Dma8 in PsxSpd.c // Dma11/12 in PsxSio2.c -static void __fastcall psxDmaGeneric(u32 madr, u32 bcr, u32 chcr, u32 spuCore, _SPU2writeDMA4Mem spu2WriteFunc, _SPU2readDMA4Mem spu2ReadFunc) +static void __fastcall psxDmaGeneric(u32 madr, u32 bcr, u32 chcr, u32 spuCore) { const char dmaNum = spuCore ? '7' : '4'; @@ -38,36 +38,39 @@ static void __fastcall psxDmaGeneric(u32 madr, u32 bcr, u32 chcr, u32 spuCore, _ // Update the spu2 to the current cycle before initiating the DMA - if (SPU2async) - { - SPU2async(psxRegs.cycle - psxCounters[6].sCycleT); - //Console.Status("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT); + SPU2async(psxRegs.cycle - psxCounters[6].sCycleT); + //Console.Status("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT); - psxCounters[6].sCycleT = psxRegs.cycle; - psxCounters[6].CycleT = size * 3; + psxCounters[6].sCycleT = psxRegs.cycle; + psxCounters[6].CycleT = size * 3; - psxNextCounter -= (psxRegs.cycle - psxNextsCounter); - psxNextsCounter = psxRegs.cycle; - if (psxCounters[6].CycleT < psxNextCounter) - psxNextCounter = psxCounters[6].CycleT; + psxNextCounter -= (psxRegs.cycle - psxNextsCounter); + psxNextsCounter = psxRegs.cycle; + if (psxCounters[6].CycleT < psxNextCounter) + psxNextCounter = psxCounters[6].CycleT; - if((g_iopNextEventCycle - psxNextsCounter) > (u32)psxNextCounter) - { - //DevCon.Warning("SPU2async Setting new counter branch, old %x new %x ((%x - %x = %x) > %x delta)", g_iopNextEventCycle, psxNextsCounter + psxNextCounter, g_iopNextEventCycle, psxNextsCounter, (g_iopNextEventCycle - psxNextsCounter), psxNextCounter); - g_iopNextEventCycle = psxNextsCounter + psxNextCounter; - } - } + if((g_iopNextEventCycle - psxNextsCounter) > (u32)psxNextCounter) + { + //DevCon.Warning("SPU2async Setting new counter branch, old %x new %x ((%x - %x = %x) > %x delta)", g_iopNextEventCycle, psxNextsCounter + psxNextCounter, g_iopNextEventCycle, psxNextsCounter, (g_iopNextEventCycle - psxNextsCounter), psxNextCounter); + g_iopNextEventCycle = psxNextsCounter + psxNextCounter; + } switch (chcr) { case 0x01000201: //cpu to spu2 transfer PSXDMA_LOG("*** DMA %c - mem2spu *** %x addr = %x size = %x", dmaNum, chcr, madr, bcr); - spu2WriteFunc((u16 *)iopPhysMem(madr), size*2); + if(dmaNum==7) + SPU2writeDMA7Mem((u16 *)iopPhysMem(madr), size*2); + else if(dmaNum==4) + SPU2writeDMA4Mem((u16 *)iopPhysMem(madr), size*2); break; case 0x01000200: //spu2 to cpu transfer PSXDMA_LOG("*** DMA %c - spu2mem *** %x addr = %x size = %x", dmaNum, chcr, madr, bcr); - spu2ReadFunc((u16 *)iopPhysMem(madr), size*2); + if(dmaNum==7) + SPU2readDMA7Mem((u16 *)iopPhysMem(madr), size*2); + else if(dmaNum==4) + SPU2readDMA4Mem((u16 *)iopPhysMem(madr), size*2); psxCpu->Clear(spuCore ? HW_DMA7_MADR : HW_DMA4_MADR, size); break; @@ -79,7 +82,7 @@ static void __fastcall psxDmaGeneric(u32 madr, u32 bcr, u32 chcr, u32 spuCore, _ void psxDma4(u32 madr, u32 bcr, u32 chcr) // SPU2's Core 0 { - psxDmaGeneric(madr, bcr, chcr, 0, SPU2writeDMA4Mem, SPU2readDMA4Mem); + psxDmaGeneric(madr, bcr, chcr, 0); } int psxDma4Interrupt() @@ -105,7 +108,7 @@ void spu2DMA4Irq() void psxDma7(u32 madr, u32 bcr, u32 chcr) // SPU2's Core 1 { - psxDmaGeneric(madr, bcr, chcr, 1, SPU2writeDMA7Mem, SPU2readDMA7Mem); + psxDmaGeneric(madr, bcr, chcr, 1); } int psxDma7Interrupt() diff --git a/pcsx2/IopDma.h b/pcsx2/IopDma.h index 914b88dad2..8419156a12 100644 --- a/pcsx2/IopDma.h +++ b/pcsx2/IopDma.h @@ -13,8 +13,7 @@ * If not, see . */ -#ifndef __PSXDMA_H__ -#define __PSXDMA_H__ +#pragma once #include "PS2Edefs.h" @@ -43,5 +42,3 @@ extern void iopTestIntc(); extern DEV9handler dev9Handler; extern USBhandler usbHandler; - -#endif /* __PSXDMA_H__ */ diff --git a/pcsx2/SPU2/CMakeLists.txt b/pcsx2/SPU2/CMakeLists.txt deleted file mode 100644 index f2df085696..0000000000 --- a/pcsx2/SPU2/CMakeLists.txt +++ /dev/null @@ -1,158 +0,0 @@ -if (openSUSE) - # openSUSE don't install wx in a standard library system - # path. Let's bypass the dynamic linker and hardcode the path. - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) -endif() - -# Check that people use the good file -if(NOT TOP_CMAKE_WAS_SOURCED) - message(FATAL_ERROR " - You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir. - It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt") -endif() - - -set(CommonFlags --fvisibility=hidden --Wall --Wno-parentheses - ) - -# plugin name -set(Output spu2x-2.0.0) -if (UNIX) - if (SDL2_API) - set(spu2xFinalFlags "-DSPU2X_SDL2" ${CommonFlags}) - else() - set(spu2xFinalFlags "-DSPU2X_SDL" ${CommonFlags}) - endif() -else() - set(spu2xFinalFlags ${CommonFlags}) -endif() - -# spu2x sources -set(spu2xSources - ADSR.cpp - Debug.cpp - DplIIdecoder.cpp - Dma.cpp - Lowpass.cpp - Mixer.cpp - PrecompiledHeader.cpp - PS2E-spu2.cpp - ReadInput.cpp - RegLog.cpp - RegTable.cpp - Reverb.cpp - SndOut.cpp - SndOut_SDL.cpp - spu2freeze.cpp - Spu2replay.cpp - spu2sys.cpp - Timestretcher.cpp - Wavedump_wav.cpp - WavFile.cpp - ) - -# spu2x headers -set(spu2xHeaders - Config.h - Debug.h - defs.h - Dma.h - Global.h - Lowpass.h - Mixer.h - PS2E-spu2.h - regs.h - SndOut.h - spdif.h - Spu2replay.h - WavFile.h -) - -if(Windows) - LIST(APPEND spu2xSources - Windows/SndOut_waveOut.cpp - Windows/SndOut_DSound.cpp - Windows/SndOut_XAudio2.cpp - Windows/UIHelpers.cpp - Windows/RealtimeDebugger.cpp - Windows/dsp.cpp - Windows/ConfigSoundtouch.cpp - ) - - LIST(APPEND spu2xHeaders - Windows/resource.h - Windows/WinConfig.h - Windows/dsp.h - ) - - include_directories("Windows") -else() - LIST(APPEND spu2xSources - Linux/Alsa.cpp - Linux/CfgHelpers.cpp - Linux/Config.cpp - Linux/ConfigDebug.cpp - Linux/ConfigSoundTouch.cpp - Linux/Dialogs.cpp - wx/wxConfig.cpp - ) - - LIST(APPEND spu2xHeaders - Linux/Alsa.h - Linux/Config.h - Linux/Dialogs.h - wx/wxConfig.h - ) - - include_directories(Linux) -endif() - -set(spu2xFinalSources - ${spu2xSources} - ${spu2xHeaders} - ${spu2xLinuxHeaders} -) - -set(spu2xFinalLibs - Utilities_NO_TLS - ${ALSA_LIBRARIES} - ${GTK2_LIBRARIES} - ${SOUNDTOUCH_LIBRARIES} -) - -if (PORTAUDIO_FOUND) - set(spu2xFinalFlags - ${spu2xFinalFlags} - "-DSPU2X_PORTAUDIO" - ) - - LIST(APPEND spu2xFinalSources - SndOut_Portaudio.cpp - ) - - set(spu2xFinalLibs - ${spu2xFinalLibs} - ${PORTAUDIO_LIBRARIES} - ) -endif() - -if (SDL2_API) - set(spu2xFinalLibs - ${spu2xFinalLibs} - ${SDL2_LIBRARIES} - ) -else() - set(spu2xFinalLibs - ${spu2xFinalLibs} - ${SDL_LIBRARY} - ) -endif() - -if(BUILTIN_SPU2) - add_pcsx2_lib(${Output} "${spu2xFinalSources}" "${spu2xFinalLibs}" "${spu2xFinalFlags}") -else() - add_pcsx2_plugin(${Output} "${spu2xFinalSources}" "${spu2xFinalLibs}" "${spu2xFinalFlags}") -endif() diff --git a/pcsx2/SPU2/Dma.cpp b/pcsx2/SPU2/Dma.cpp index 97cfe2e051..87e7842a86 100644 --- a/pcsx2/SPU2/Dma.cpp +++ b/pcsx2/SPU2/Dma.cpp @@ -18,7 +18,7 @@ #include "Global.h" #include "Dma.h" -#include "PS2E-spu2.h" // temporary until I resolve cyclePtr/TimeUpdate dependencies. +#include "spu2.h" // temporary until I resolve cyclePtr/TimeUpdate dependencies. extern u8 callirq; diff --git a/pcsx2/SPU2/Global.h b/pcsx2/SPU2/Global.h index e5d1be7b87..bdb367b4bb 100644 --- a/pcsx2/SPU2/Global.h +++ b/pcsx2/SPU2/Global.h @@ -71,7 +71,6 @@ static __forceinline T GetClamped(T src, T min, T max) } #ifdef __WXMAC__ -#include "PS2Eext.h" #else extern void SysMessage(const char *fmt, ...); #endif diff --git a/pcsx2/SPU2/PS2E-spu2.cpp b/pcsx2/SPU2/PS2E-spu2.cpp deleted file mode 100644 index 9437ed9480..0000000000 --- a/pcsx2/SPU2/PS2E-spu2.cpp +++ /dev/null @@ -1,616 +0,0 @@ -/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2 - * Developed and maintained by the Pcsx2 Development Team. - * - * Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz] - * - * SPU2-X 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. - * - * SPU2-X 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with SPU2-X. If not, see . - */ - -#include "Global.h" -#include "PS2E-spu2.h" -#include "Dma.h" -#include "Dialogs.h" - -#ifdef __APPLE__ -#include "PS2Eext.h" -#endif - -#include "svnrev.h" - -#ifdef _MSC_VER -#define snprintf sprintf_s -#endif -// PCSX2 expects ASNI, not unicode, so this MUST always be char... -static char libraryName[256]; - -int SampleRate = 48000; - -static bool IsOpened = false; -static bool IsInitialized = false; - -static u32 pClocks = 0; - -u32 *cyclePtr = NULL; -u32 lClocks = 0; - - -//static bool cpu_detected = false; - -static bool CheckSSE() -{ - return true; - -#if 0 - if( !cpu_detected ) - { - cpudetectInit(); - cpu_detected = true; - } - if( !x86caps.hasStreamingSIMDExtensions || !x86caps.hasStreamingSIMD2Extensions ) - { - SysMessage( "Your CPU does not support SSE2 instructions.\nThe SPU2-X plugin requires SSE2 to run." ); - return false; - } - return true; -#endif -} - -void SPU2configure() -{ - if (!CheckSSE()) - return; - configure(); -} - -s32 SPU2test() -{ - if (!CheckSSE()) - return -1; - - ReadSettings(); - if (SndBuffer::Test() != 0) { - // TODO : Implement a proper dialog that allows the user to test different audio out drivers. - const wchar_t *wtf = mods[OutputModule]->GetIdent(); - SysMessage(L"The '%s' driver test failed. Please configure\na different SoundOut module and try again.", wtf); - return -1; - } - - return 0; -} - -// -------------------------------------------------------------------------------------- -// DMA 4/7 Callbacks from Core Emulator -// -------------------------------------------------------------------------------------- - -u16 *DMABaseAddr; -void (*_irqcallback)(); -void (*dma4callback)(); -void (*dma7callback)(); - -u32 CALLBACK SPU2ReadMemAddr(int core) -{ - return Cores[core].MADR; -} -void CALLBACK SPU2WriteMemAddr(int core, u32 value) -{ - Cores[core].MADR = value; -} - -void CALLBACK SPU2setDMABaseAddr(uptr baseaddr) -{ - DMABaseAddr = (u16 *)baseaddr; -} - -void CALLBACK SPU2setSettingsDir(const char *dir) -{ - CfgSetSettingsDir(dir); -} - -void CALLBACK SPU2setLogDir(const char *dir) -{ - CfgSetLogDir(dir); -} - -void SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)()) -{ - _irqcallback = SPU2callback; - dma4callback = DMA4callback; - dma7callback = DMA7callback; -} - -void CALLBACK SPU2readDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units -{ - if (cyclePtr != NULL) - TimeUpdate(*cyclePtr); - - FileLog("[%10d] SPU2 readDMA4Mem size %x\n", Cycles, size << 1); - Cores[0].DoDMAread(pMem, size); -} - -void CALLBACK SPU2writeDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units -{ - if (cyclePtr != NULL) - TimeUpdate(*cyclePtr); - - FileLog("[%10d] SPU2 writeDMA4Mem size %x at address %x\n", Cycles, size << 1, Cores[0].TSA); -#ifdef S2R_ENABLE - if (!replay_mode) - s2r_writedma4(Cycles, pMem, size); -#endif - Cores[0].DoDMAwrite(pMem, size); -} - -void CALLBACK SPU2interruptDMA4() -{ - FileLog("[%10d] SPU2 interruptDMA4\n", Cycles); - Cores[0].Regs.STATX |= 0x80; - //Cores[0].Regs.ATTR &= ~0x30; -} - -void CALLBACK SPU2interruptDMA7() -{ - FileLog("[%10d] SPU2 interruptDMA7\n", Cycles); - Cores[1].Regs.STATX |= 0x80; - //Cores[1].Regs.ATTR &= ~0x30; -} - -void CALLBACK SPU2readDMA7Mem(u16 *pMem, u32 size) -{ - if (cyclePtr != NULL) - TimeUpdate(*cyclePtr); - - FileLog("[%10d] SPU2 readDMA7Mem size %x\n", Cycles, size << 1); - Cores[1].DoDMAread(pMem, size); -} - -void CALLBACK SPU2writeDMA7Mem(u16 *pMem, u32 size) -{ - if (cyclePtr != NULL) - TimeUpdate(*cyclePtr); - - FileLog("[%10d] SPU2 writeDMA7Mem size %x at address %x\n", Cycles, size << 1, Cores[1].TSA); -#ifdef S2R_ENABLE - if (!replay_mode) - s2r_writedma7(Cycles, pMem, size); -#endif - Cores[1].DoDMAwrite(pMem, size); -} - -s32 SPU2reset() -{ - if (SndBuffer::Test() == 0 && SampleRate != 48000) - { - SampleRate = 48000; - SndBuffer::Cleanup(); - - try { - SndBuffer::Init(); - } - catch (std::exception& ex) { - fprintf(stderr, "SPU2-X Error: Could not initialize device, or something.\nReason: %s", ex.what()); - SPU2close(); - return -1; - } - } - else - SampleRate = 48000; - - memset(spu2regs, 0, 0x010000); - memset(_spu2mem, 0, 0x200000); - memset(_spu2mem + 0x2800, 7, 0x10); // from BIOS reversal. Locks the voices so they don't run free. - Cores[0].Init(0); - Cores[1].Init(1); - return 0; -} - -s32 SPU2ps1reset() -{ - printf("RESET PS1 \n"); - - if (SndBuffer::Test() == 0 && SampleRate != 44100) - { - SampleRate = 44100; - SndBuffer::Cleanup(); - - try { - SndBuffer::Init(); - } - catch (std::exception& ex) { - fprintf(stderr, "SPU2-X Error: Could not initialize device, or something.\nReason: %s", ex.what()); - SPU2close(); - return -1; - } - } - else - SampleRate = 44100; - - /* memset(spu2regs, 0, 0x010000); - memset(_spu2mem, 0, 0x200000); - memset(_spu2mem + 0x2800, 7, 0x10); // from BIOS reversal. Locks the voices so they don't run free. - Cores[0].Init(0); - Cores[1].Init(1);*/ - return 0; -} - -s32 SPU2init() -{ - assert(regtable[0x400] == NULL); - - if (IsInitialized) { - printf(" * SPU2-X: Already initialized - Ignoring SPU2init signal."); - return 0; - } - - IsInitialized = true; - - ReadSettings(); - -#ifdef SPU2_LOG - if (AccessLog()) { - spu2Log = OpenLog(AccessLogFileName); - setvbuf(spu2Log, NULL, _IONBF, 0); - FileLog("SPU2init\n"); - } -#endif - srand((unsigned)time(NULL)); - - spu2regs = (s16 *)malloc(0x010000); - _spu2mem = (s16 *)malloc(0x200000); - - // adpcm decoder cache: - // the cache data size is determined by taking the number of adpcm blocks - // (2MB / 16) and multiplying it by the decoded block size (28 samples). - // Thus: pcm_cache_data = 7,340,032 bytes (ouch!) - // Expanded: 16 bytes expands to 56 bytes [3.5:1 ratio] - // Resulting in 2MB * 3.5. - - pcm_cache_data = (PcmCacheEntry *)calloc(pcm_BlockCount, sizeof(PcmCacheEntry)); - - if ((spu2regs == NULL) || (_spu2mem == NULL) || (pcm_cache_data == NULL)) { - SysMessage("SPU2-X: Error allocating Memory\n"); - return -1; - } - - // Patch up a copy of regtable that directly maps "NULLs" to SPU2 memory. - - memcpy(regtable, regtable_original, sizeof(regtable)); - - for (uint mem = 0; mem < 0x800; mem++) { - u16 *ptr = regtable[mem >> 1]; - if (!ptr) { - regtable[mem >> 1] = &(spu2Ru16(mem)); - } - } - - SPU2reset(); - - DMALogOpen(); - InitADSR(); - -#ifdef S2R_ENABLE - if (!replay_mode) - s2r_open(Cycles, "replay_dump.s2r"); -#endif - return 0; -} - -#ifdef _MSC_VER -// Bit ugly to have this here instead of in RealttimeDebugger.cpp, but meh :p -extern bool debugDialogOpen; -extern HWND hDebugDialog; - -static INT_PTR CALLBACK DebugProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - int wmId; - - switch (uMsg) { - case WM_PAINT: - return FALSE; - case WM_INITDIALOG: { - debugDialogOpen = true; - } break; - - case WM_COMMAND: - wmId = LOWORD(wParam); - // Parse the menu selections: - switch (wmId) { - case IDOK: - case IDCANCEL: - debugDialogOpen = false; - EndDialog(hWnd, 0); - break; - default: - return FALSE; - } - break; - - default: - return FALSE; - } - return TRUE; -} -#endif -uptr gsWindowHandle = 0; - -s32 SPU2open(void *pDsp) -{ - if (IsOpened) - return 0; - - FileLog("[%10d] SPU2 Open\n", Cycles); - - if (pDsp != NULL) - gsWindowHandle = *(uptr *)pDsp; - else - gsWindowHandle = 0; - -#ifdef _MSC_VER -#ifdef PCSX2_DEVBUILD // Define may not be needed but not tested yet. Better make sure. - if (IsDevBuild && VisualDebug()) { - if (debugDialogOpen == 0) { - hDebugDialog = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_DEBUG), 0, DebugProc, 0); - ShowWindow(hDebugDialog, SW_SHOWNORMAL); - debugDialogOpen = 1; - } - } else if (debugDialogOpen) { - DestroyWindow(hDebugDialog); - debugDialogOpen = 0; - } -#endif -#endif - - IsOpened = true; - lClocks = (cyclePtr != NULL) ? *cyclePtr : 0; - - try { - SndBuffer::Init(); - -#ifndef __POSIX__ - DspLoadLibrary(dspPlugin, dspPluginModule); -#endif - WaveDump::Open(); - } catch (std::exception &ex) { - fprintf(stderr, "SPU2-X Error: Could not initialize device, or something.\nReason: %s", ex.what()); - SPU2close(); - return -1; - } - return 0; -} - -void SPU2close() -{ - if (!IsOpened) - return; - IsOpened = false; - - FileLog("[%10d] SPU2 Close\n", Cycles); - -#ifndef __POSIX__ - DspCloseLibrary(); -#endif - - SndBuffer::Cleanup(); -} - -void SPU2shutdown() -{ - if (!IsInitialized) - return; - IsInitialized = false; - - ConLog("* SPU2-X: Shutting down.\n"); - - SPU2close(); - -#ifdef S2R_ENABLE - if (!replay_mode) - s2r_close(); -#endif - - DoFullDump(); -#ifdef STREAM_DUMP - fclose(il0); - fclose(il1); -#endif -#ifdef EFFECTS_DUMP - fclose(el0); - fclose(el1); -#endif - WaveDump::Close(); - - DMALogClose(); - - safe_free(spu2regs); - safe_free(_spu2mem); - safe_free(pcm_cache_data); - - -#ifdef SPU2_LOG - if (!AccessLog()) - return; - FileLog("[%10d] SPU2shutdown\n", Cycles); - if (spu2Log) - fclose(spu2Log); -#endif -} - -void SPU2setClockPtr(u32 *ptr) -{ - cyclePtr = ptr; -} - -#ifdef DEBUG_KEYS -static u32 lastTicks; -static bool lState[6]; -#endif - -void SPU2async(u32 cycles) -{ - DspUpdate(); - - if (cyclePtr != NULL) { - TimeUpdate(*cyclePtr); - } else { - pClocks += cycles; - TimeUpdate(pClocks); - } - -#ifdef DEBUG_KEYS - u32 curTicks = GetTickCount(); - if ((curTicks - lastTicks) >= 50) { - int oldI = Interpolation; - bool cState[6]; - for (int i = 0; i < 6; i++) { - cState[i] = !!(GetAsyncKeyState(VK_NUMPAD0 + i) & 0x8000); - - if ((cState[i] && !lState[i]) && i != 5) - Interpolation = i; - - if ((cState[i] && !lState[i]) && i == 5) { - postprocess_filter_enabled = !postprocess_filter_enabled; - printf("Post process filters %s \n", postprocess_filter_enabled ? "enabled" : "disabled"); - } - - lState[i] = cState[i]; - } - - if (Interpolation != oldI) { - printf("Interpolation set to %d", Interpolation); - switch (Interpolation) { - case 0: - printf(" - Nearest.\n"); - break; - case 1: - printf(" - Linear.\n"); - break; - case 2: - printf(" - Cubic.\n"); - break; - case 3: - printf(" - Hermite.\n"); - break; - case 4: - printf(" - Catmull-Rom.\n"); - break; - default: - printf(" (unknown).\n"); - break; - } - } - - lastTicks = curTicks; - } -#endif -} - -u16 SPU2read(u32 rmem) -{ - // if(!replay_mode) - // s2r_readreg(Cycles,rmem); - - u16 ret = 0xDEAD; - u32 core = 0, mem = rmem & 0xFFFF, omem = mem; - if (mem & 0x400) { - omem ^= 0x400; - core = 1; - } - - if (omem == 0x1f9001AC) { - ret = Cores[core].DmaRead(); - } else { - if (cyclePtr != NULL) - TimeUpdate(*cyclePtr); - - if (rmem >> 16 == 0x1f80) { - ret = Cores[0].ReadRegPS1(rmem); - } else if (mem >= 0x800) { - ret = spu2Ru16(mem); - ConLog("* SPU2-X: Read from reg>=0x800: %x value %x\n", mem, ret); - } else { - ret = *(regtable[(mem >> 1)]); - //FileLog("[%10d] SPU2 read mem %x (core %d, register %x): %x\n",Cycles, mem, core, (omem & 0x7ff), ret); - SPU2writeLog("read", rmem, ret); - } - } - - return ret; -} - -void SPU2write(u32 rmem, u16 value) -{ -#ifdef S2R_ENABLE - if (!replay_mode) - s2r_writereg(Cycles, rmem, value); -#endif - - // Note: Reverb/Effects are very sensitive to having precise update timings. - // If the SPU2 isn't in in sync with the IOP, samples can end up playing at rather - // incorrect pitches and loop lengths. - - if (cyclePtr != NULL) - TimeUpdate(*cyclePtr); - - if (rmem >> 16 == 0x1f80) - Cores[0].WriteRegPS1(rmem, value); - else { - SPU2writeLog("write", rmem, value); - SPU2_FastWrite(rmem, value); - } -} - -// if start is 1, starts recording spu2 data, else stops -// returns a non zero value if successful -// for now, pData is not used -int SPU2setupRecording(int start, std::wstring* filename) -{ - if (start == 0) - RecordStop(); - else if (start == 1) - RecordStart(filename); - - return 0; -} - -s32 SPU2freeze(int mode, freezeData *data) -{ - pxAssume(data != NULL); - if (!data) { - printf("SPU2-X savestate null pointer!\n"); - return -1; - } - - if (mode == FREEZE_SIZE) { - data->size = Savestate::SizeIt(); - return 0; - } - - pxAssume(mode == FREEZE_LOAD || mode == FREEZE_SAVE); - - if (data->data == NULL) { - printf("SPU2-X savestate null pointer!\n"); - return -1; - } - - Savestate::DataBlock &spud = (Savestate::DataBlock &)*(data->data); - - switch (mode) { - case FREEZE_LOAD: - return Savestate::ThawIt(spud); - case FREEZE_SAVE: - return Savestate::FreezeIt(spud); - - jNO_DEFAULT; - } - - // technically unreachable, but kills a warning: - return 0; -} diff --git a/pcsx2/SPU2/PS2E-spu2.h b/pcsx2/SPU2/PS2E-spu2.h deleted file mode 100644 index 59e7618963..0000000000 --- a/pcsx2/SPU2/PS2E-spu2.h +++ /dev/null @@ -1,70 +0,0 @@ -/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2 - * Developed and maintained by the Pcsx2 Development Team. - * - * Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz] - * - * SPU2-X 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. - * - * SPU2-X 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with SPU2-X. If not, see . - */ - -#pragma once - -#include "Pcsx2Defs.h" -#include "PS2Edefs.h" - -s32 SPU2init(); -s32 SPU2reset(); -s32 SPU2ps1reset(); -s32 SPU2open(void *pDsp); -void SPU2close(); -void SPU2shutdown(); -void SPU2write(u32 mem, u16 value); -u16 SPU2read(u32 mem); - -// extended funcs -// if start is 1, starts recording spu2 data, else stops -// returns a non zero value if successful -// for now, pData is not used -int SPU2setupRecording(int start, std::wstring* filename); - -void SPU2setClockPtr(u32 *ptr); - -void SPU2async(u32 cycles); -s32 SPU2freeze(int mode, freezeData *data); -void SPU2configure(); -void SPU2about(); -s32 SPU2test(); - -#include "Spu2replay.h" - -extern u8 callirq; - -extern void (*_irqcallback)(); - -extern void (*dma4callback)(); -extern void (*dma7callback)(); - -extern s16 *input_data; -extern u32 input_data_ptr; - -extern double srate_pv; - -extern int recording; -extern u32 lClocks; -extern u32 *cyclePtr; - -extern void SPU2writeLog(const char *action, u32 rmem, u16 value); -extern void TimeUpdate(u32 cClocks); -extern void SPU2_FastWrite(u32 rmem, u16 value); - -extern void LowPassFilterInit(); - -//#define PCM24_S1_INTERLEAVE diff --git a/pcsx2/SPU2/ReadInput.cpp b/pcsx2/SPU2/ReadInput.cpp index d60e3f0b90..7398c151fc 100644 --- a/pcsx2/SPU2/ReadInput.cpp +++ b/pcsx2/SPU2/ReadInput.cpp @@ -18,7 +18,7 @@ #include "Global.h" #include "Dma.h" -#include "PS2E-spu2.h" // required for ENABLE_NEW_IOPDMA_SPU2 define +#include "spu2.h" // required for ENABLE_NEW_IOPDMA_SPU2 define // Core 0 Input is "SPDIF mode" - Source audio is AC3 compressed. diff --git a/pcsx2/SPU2/Windows/Spu2-X.def b/pcsx2/SPU2/Windows/Spu2-X.def deleted file mode 100644 index 0496050a7f..0000000000 --- a/pcsx2/SPU2/Windows/Spu2-X.def +++ /dev/null @@ -1,62 +0,0 @@ -; * SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2 -; * Developed and maintained by the Pcsx2 Development Team. -; * -; * Originally based on SPU2ghz v1.9 beta, by David Quintana. -; * -; * SPU2-X 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. -; * -; * SPU2-X 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 Lesser General Public License for more details. -; * -; * You should have received a copy of the GNU Lesser General Public License -; * along with SPU2-X. If not, see . - -; SPU2-X.def : Declares the module parameters for the DLL. - -;LIBRARY "SPU2-X" - -EXPORTS - ; Explicit exports can go here - PS2EgetLibType @2 - PS2EgetLibName @3 - PS2EgetLibVersion2 @4 - - SPU2init @5 - SPU2shutdown @6 - SPU2open @7 - SPU2close @8 - - SPU2configure @9 - SPU2test @10 - SPU2freeze @12 - - SPU2setSettingsDir @13 - SPU2setLogDir @14 - - SPU2write @15 - SPU2read @16 - SPU2async @17 - - SPU2readDMA4Mem @18 - SPU2writeDMA4Mem @19 - SPU2readDMA7Mem @20 - SPU2writeDMA7Mem @21 - SPU2interruptDMA4 @22 - SPU2interruptDMA7 @23 - - SPU2irqCallback @24 - SPU2setupRecording @25 - - SPU2ReadMemAddr @26 - SPU2WriteMemAddr @27 - - SPU2setClockPtr @28 - SPU2setDMABaseAddr @29 - - SPU2replay = s2r_replay @30 - - SPU2reset @31 - SPU2ps1reset @32 diff --git a/pcsx2/SPU2/Windows/Spu2-X.vcxproj b/pcsx2/SPU2/Windows/Spu2-X.vcxproj deleted file mode 100644 index 3f8c4c47f9..0000000000 --- a/pcsx2/SPU2/Windows/Spu2-X.vcxproj +++ /dev/null @@ -1,177 +0,0 @@ - - - - - DebugStrict - Win32 - - - DebugStrict - x64 - - - Debug - Win32 - - - Debug - x64 - - - Devel - Win32 - - - Devel - x64 - - - Release - Win32 - - - Release - x64 - - - - - {5307BBB7-EBB9-4AA4-8CB6-A94EC473C8C4} - - - - DynamicLibrary - $(DefaultPlatformToolset) - Unicode - true - true - false - - - - - - - - - - - - - - - - AllRules.ruleset - - - - DEBUG_FAST;%(PreprocessorDefinitions) - $(SolutionDir)3rdparty\portaudio\include\;%(AdditionalIncludeDirectories) - Async - StreamingSIMDExtensions2 - Use - Global.h - Default - - - rpcrt4.lib;winmm.lib;dsound.lib;comctl32.lib;%(AdditionalDependencies) - .\Spu2-X.def - MachineX86 - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - true - - - - - - - - - - - - - true - - - true - - - - - - - - - - - - - - - - - - - - - {0a18a071-125e-442f-aff7-a3f68abecf99} - false - - - {0fae817d-9a32-4830-857e-81da57246e16} - false - - - {e9b51944-7e6d-4bcd-83f2-7bbd5a46182d} - false - - - {3fcc50c2-81e9-5db2-b8d8-2129427568b1} - - - {4639972e-424e-4e13-8b07-ca403c481346} - false - - - - - \ No newline at end of file diff --git a/pcsx2/SPU2/Windows/Spu2-X.vcxproj.filters b/pcsx2/SPU2/Windows/Spu2-X.vcxproj.filters deleted file mode 100644 index 6d488786fe..0000000000 --- a/pcsx2/SPU2/Windows/Spu2-X.vcxproj.filters +++ /dev/null @@ -1,233 +0,0 @@ - - - - - {21596259-72f4-41c0-b499-40839e39f043} - h;hpp;cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {30e5b8dd-2015-4c3d-a663-992fb42627b5} - - - {ed4df93e-4e4b-4675-a181-c5084146df7c} - - - {1cb77247-dec9-4a0a-867f-7353b14decac} - - - {f87cf8e1-d654-4214-b7f4-6fb697f3941a} - - - {10ccccc1-642a-42ec-900c-801f707bd776} - - - {03be4765-f627-4c0a-9d40-f3c0f86f1e57} - - - {ea7e8889-2015-40b9-ac77-b4a3a58c41af} - - - {63ac2d88-b5c3-41a3-bd2c-a04c80acd35f} - - - {825046cd-874f-45f4-8622-14c146a97b46} - - - {3924e038-9ec9-4f1c-89b9-6d03c46566ac} - - - {efaf786c-f09d-49f7-b5f3-8bb7078e9c44} - - - {00c53f28-fde8-4f60-88d2-d223584f1db5} - - - {95111121-7e1f-4624-8765-a17e8f13827f} - - - {70e9653e-fba5-4c6e-ad9b-185006096d49} - - - {6fcf6c91-7afe-4ade-bb30-79d63901d590} - - - {381a6e5e-bdd5-48b0-81f8-e2775eff9585} - - - {d26e57df-a97e-4ba5-801a-c0c52b5d061f} - - - - - Source Files - - - Source Files - - - Source Files\debug - - - Source Files\Sound Output - - - Source Files\Sound Output - - - Source Files\Sound Output\Linux - - - Source Files\decoder - - - Source Files\SPU2 - - - Source Files\SPU2 - - - Source Files\SPU2 - - - Source Files\SPU2\Mixer - - - Source Files\Winamp DSP - - - Source Files\GUI\Linux\Include - - - Source Files\GUI\Linux\Include - - - Source Files\GUI\Windows - - - Source Files\GUI\Windows - - - Source Files\PluginInterface - - - Resources - - - - - Source Files - - - Source Files\debug - - - Source Files\debug - - - Source Files\debug - - - Source Files\debug - - - Source Files\Sound Output - - - Source Files\Sound Output - - - Source Files\Sound Output - - - Source Files\Sound Output\Windows - - - Source Files\Sound Output\Windows - - - Source Files\Sound Output\Linux - - - Source Files\Sound Output\Crossplatform - - - Source Files\SPU2 - - - Source Files\SPU2 - - - Source Files\SPU2 - - - Source Files\SPU2 - - - Source Files\SPU2\Mixer - - - Source Files\SPU2\Mixer - - - Source Files\SPU2\Mixer - - - Source Files\SPU2\Mixer - - - Source Files\Winamp DSP - - - Source Files\GUI\Linux - - - Source Files\GUI\Linux - - - Source Files\GUI\Windows - - - Source Files\GUI\Windows - - - Source Files\GUI\Windows - - - Source Files\GUI\Windows - - - Source Files\GUI\Windows - - - Source Files\GUI\Windows - - - Source Files\PluginInterface - - - Source Files\Sound Output - - - Source Files\Sound Output\Windows - - - - - Documents - - - Documents - - - Resources - - - Resources - - - - - Resources - - - \ No newline at end of file diff --git a/pcsx2/SPU2/defs.h b/pcsx2/SPU2/defs.h index 5881727024..ea099dd91d 100644 --- a/pcsx2/SPU2/defs.h +++ b/pcsx2/SPU2/defs.h @@ -553,7 +553,7 @@ extern void InitADSR(); extern void CalculateADSR(V_Voice &vc); extern void UpdateSpdifMode(); -namespace Savestate +namespace SPU2Savestate { struct DataBlock; diff --git a/pcsx2/SPU2/spu2.cpp b/pcsx2/SPU2/spu2.cpp index be6c54bb52..983a2be2e4 100644 --- a/pcsx2/SPU2/spu2.cpp +++ b/pcsx2/SPU2/spu2.cpp @@ -18,16 +18,19 @@ #include "Global.h" #include "spu2.h" #include "Dma.h" -#include "Dialogs.h" +#ifdef __linux__ +#include "Linux/Dialogs.h" +#elif defined(_WIN32) +#include "Windows/Dialogs.h" +#endif + +using namespace Threading; #include "svnrev.h" #ifdef _MSC_VER #define snprintf sprintf_s #endif -// PCSX2 expects ASNI, not unicode, so this MUST always be char... -static char libraryName[256]; - int SampleRate = 48000; static bool IsOpened = false; @@ -92,26 +95,26 @@ void (*_irqcallback)(); void (*dma4callback)(); void (*dma7callback)(); -u32 CALLBACK SPU2ReadMemAddr(int core) +u32 SPU2ReadMemAddr(int core) { return Cores[core].MADR; } -void CALLBACK SPU2WriteMemAddr(int core, u32 value) +void SPU2WriteMemAddr(int core, u32 value) { Cores[core].MADR = value; } -void CALLBACK SPU2setDMABaseAddr(uptr baseaddr) +void SPU2setDMABaseAddr(uptr baseaddr) { DMABaseAddr = (u16 *)baseaddr; } -void CALLBACK SPU2setSettingsDir(const char *dir) +void SPU2setSettingsDir(const char *dir) { CfgSetSettingsDir(dir); } -void CALLBACK SPU2setLogDir(const char *dir) +void SPU2setLogDir(const char *dir) { CfgSetLogDir(dir); } @@ -123,7 +126,7 @@ void SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7 dma7callback = DMA7callback; } -void CALLBACK SPU2readDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units +void SPU2readDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units { if (cyclePtr != NULL) TimeUpdate(*cyclePtr); @@ -132,7 +135,7 @@ void CALLBACK SPU2readDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units Cores[0].DoDMAread(pMem, size); } -void CALLBACK SPU2writeDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units +void SPU2writeDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units { if (cyclePtr != NULL) TimeUpdate(*cyclePtr); @@ -145,21 +148,21 @@ void CALLBACK SPU2writeDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units Cores[0].DoDMAwrite(pMem, size); } -void CALLBACK SPU2interruptDMA4() +void SPU2interruptDMA4() { FileLog("[%10d] SPU2 interruptDMA4\n", Cycles); Cores[0].Regs.STATX |= 0x80; //Cores[0].Regs.ATTR &= ~0x30; } -void CALLBACK SPU2interruptDMA7() +void SPU2interruptDMA7() { FileLog("[%10d] SPU2 interruptDMA7\n", Cycles); Cores[1].Regs.STATX |= 0x80; //Cores[1].Regs.ATTR &= ~0x30; } -void CALLBACK SPU2readDMA7Mem(u16 *pMem, u32 size) +void SPU2readDMA7Mem(u16 *pMem, u32 size) { if (cyclePtr != NULL) TimeUpdate(*cyclePtr); @@ -168,7 +171,7 @@ void CALLBACK SPU2readDMA7Mem(u16 *pMem, u32 size) Cores[1].DoDMAread(pMem, size); } -void CALLBACK SPU2writeDMA7Mem(u16 *pMem, u32 size) +void SPU2writeDMA7Mem(u16 *pMem, u32 size) { if (cyclePtr != NULL) TimeUpdate(*cyclePtr); @@ -339,6 +342,7 @@ uptr gsWindowHandle = 0; s32 SPU2open(void *pDsp) { + ScopedLock lock( mtx_SPU2Status ); if (IsOpened) return 0; @@ -384,6 +388,7 @@ s32 SPU2open(void *pDsp) void SPU2close() { + ScopedLock lock( mtx_SPU2Status ); if (!IsOpened) return; IsOpened = false; @@ -585,7 +590,7 @@ s32 SPU2freeze(int mode, freezeData *data) } if (mode == FREEZE_SIZE) { - data->size = Savestate::SizeIt(); + data->size = SPU2Savestate::SizeIt(); return 0; } @@ -596,13 +601,13 @@ s32 SPU2freeze(int mode, freezeData *data) return -1; } - Savestate::DataBlock &spud = (Savestate::DataBlock &)*(data->data); + SPU2Savestate::DataBlock &spud = (SPU2Savestate::DataBlock &)*(data->data); switch (mode) { case FREEZE_LOAD: - return Savestate::ThawIt(spud); + return SPU2Savestate::ThawIt(spud); case FREEZE_SAVE: - return Savestate::FreezeIt(spud); + return SPU2Savestate::FreezeIt(spud); jNO_DEFAULT; } @@ -610,3 +615,36 @@ s32 SPU2freeze(int mode, freezeData *data) // technically unreachable, but kills a warning: return 0; } + +void SPU2DoFreeze( SaveStateBase& state ) +{ + ScopedLock lock( mtx_SPU2Status ); + + freezeData fP = { 0, NULL }; + if( !SPU2freeze( FREEZE_SIZE, &fP ) ) + fP.size = 0; + + int fsize = fP.size; + state.Freeze( fsize ); + + Console.Indent().WriteLn( "%s SPU-2", state.IsSaving() ? "Saving" : "Loading"); + + fP.size = fsize; + if( fP.size == 0 ) return; + + state.PrepBlock( fP.size ); + fP.data = (s8*)state.GetBlockPtr(); + + if( state.IsSaving() ) + { + if( !SPU2freeze(FREEZE_SAVE, &fP) ) + throw std::runtime_error(" * SPU-2: Error saving state!\n"); + } + else + { + if( !SPU2freeze(FREEZE_LOAD, &fP) ) + throw std::runtime_error(" * SPU-2: Error loading state!\n"); + } + + state.CommitBlock( fP.size ); +} diff --git a/pcsx2/SPU2/spu2.h b/pcsx2/SPU2/spu2.h index 4eabc8a0e4..db3a9d4a3b 100644 --- a/pcsx2/SPU2/spu2.h +++ b/pcsx2/SPU2/spu2.h @@ -18,6 +18,10 @@ #pragma once #include "Pcsx2Defs.h" +#include "Utilities/Threading.h" +#include "SaveState.h" + +Threading::MutexRecursive mtx_SPU2Status; s32 SPU2init(); s32 SPU2reset(); @@ -38,11 +42,25 @@ void SPU2setClockPtr(u32 *ptr); void SPU2async(u32 cycles); s32 SPU2freeze(int mode, freezeData *data); +void SPU2DoFreeze( SaveStateBase& state ); void SPU2configure(); void SPU2about(); s32 SPU2test(); -#include "Spu2replay.h" + +u32 SPU2ReadMemAddr(int core); +void SPU2WriteMemAddr(int core, u32 value); +void SPU2setDMABaseAddr(uptr baseaddr); +void SPU2setSettingsDir(const char *dir); +void SPU2setLogDir(const char *dir); +void SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)()); +void SPU2readDMA4Mem(u16 *pMem, u32 size); +void SPU2writeDMA4Mem(u16 *pMem, u32 size); +void SPU2interruptDMA4(); +void SPU2interruptDMA7(); +void SPU2readDMA7Mem(u16 *pMem, u32 size); +void SPU2writeDMA7Mem(u16 *pMem, u32 size); +#include "spu2replay.h" extern u8 callirq; diff --git a/pcsx2/SPU2/spu2freeze.cpp b/pcsx2/SPU2/spu2freeze.cpp index 255940d2d3..92fd7abf71 100644 --- a/pcsx2/SPU2/spu2freeze.cpp +++ b/pcsx2/SPU2/spu2freeze.cpp @@ -16,9 +16,9 @@ */ #include "Global.h" -#include "PS2E-spu2.h" // hopefully temporary, until I resolve lClocks depdendency +#include "spu2.h" // hopefully temporary, until I resolve lClocks depdendency -namespace Savestate +namespace SPU2Savestate { // Arbitrary ID to identify SPU2-X saves. static const u32 SAVE_ID = 0x1227521; @@ -33,7 +33,7 @@ static void wipe_the_cache() } } -struct Savestate::DataBlock +struct SPU2Savestate::DataBlock { u32 spu2id; // SPU2-X state identifier lets ZeroGS/PeopsSPU2 know this isn't their state) u8 unkregs[0x10000]; // SPU2 raw register memory @@ -49,7 +49,7 @@ struct Savestate::DataBlock int PlayMode; }; -s32 __fastcall Savestate::FreezeIt(DataBlock &spud) +s32 __fastcall SPU2Savestate::FreezeIt(DataBlock &spud) { spud.spu2id = SAVE_ID; spud.version = SAVE_VERSION; @@ -78,7 +78,7 @@ s32 __fastcall Savestate::FreezeIt(DataBlock &spud) return 0; } -s32 __fastcall Savestate::ThawIt(DataBlock &spud) +s32 __fastcall SPU2Savestate::ThawIt(DataBlock &spud) { if (spud.spu2id != SAVE_ID || spud.version < SAVE_VERSION) { fprintf(stderr, "\n*** SPU2-X Warning:\n"); @@ -141,7 +141,7 @@ s32 __fastcall Savestate::ThawIt(DataBlock &spud) return 0; } -s32 __fastcall Savestate::SizeIt() +s32 __fastcall SPU2Savestate::SizeIt() { return sizeof(DataBlock); } diff --git a/pcsx2/SPU2/spu2replay.cpp b/pcsx2/SPU2/spu2replay.cpp index 2b5d62b61a..174a455cd1 100644 --- a/pcsx2/SPU2/spu2replay.cpp +++ b/pcsx2/SPU2/spu2replay.cpp @@ -17,7 +17,7 @@ // #include "Global.h" -#include "PS2E-spu2.h" +#include "spu2.h" #ifdef _MSC_VER #include "Windows.h" diff --git a/pcsx2/SPU2/spu2sys.cpp b/pcsx2/SPU2/spu2sys.cpp index 7a3c10830e..188e2ed4c8 100644 --- a/pcsx2/SPU2/spu2sys.cpp +++ b/pcsx2/SPU2/spu2sys.cpp @@ -25,7 +25,7 @@ #include "Global.h" #include "Dma.h" -#include "PS2E-spu2.h" // needed until I figure out a nice solution for irqcallback dependencies. +#include "spu2.h" // needed until I figure out a nice solution for irqcallback dependencies. s16 *spu2regs = NULL; s16 *_spu2mem = NULL; diff --git a/pcsx2/SaveState.cpp b/pcsx2/SaveState.cpp index 7aef11454c..ef5815cce0 100644 --- a/pcsx2/SaveState.cpp +++ b/pcsx2/SaveState.cpp @@ -29,6 +29,7 @@ #include "Counters.h" #include "Utilities/SafeArray.inl" +#include "SPU2/spu2.h" using namespace R5900; @@ -244,6 +245,8 @@ SaveStateBase& SaveStateBase::FreezePlugins() FreezeTag( FastFormatAscii().Write("Plugin:%s", tbl_PluginInfo[i].shortname) ); GetCorePlugins().Freeze( (PluginsEnum_t)i, *this ); } + // now with more core! + SPU2DoFreeze(*this); return *this; }