SPU2: redesign the save state system

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2020-09-24 17:31:26 +02:00 committed by refractionpcsx2
parent 9c97092efd
commit 67738a57b7
20 changed files with 137 additions and 1392 deletions

View File

@ -243,6 +243,12 @@ set(pcsx2SPU2Sources
SPU2/Timestretcher.cpp SPU2/Timestretcher.cpp
SPU2/Wavedump_wav.cpp SPU2/Wavedump_wav.cpp
SPU2/WavFile.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 # SPU2 headers
@ -260,6 +266,9 @@ set(pcsx2SPU2Headers
SPU2/spdif.h SPU2/spdif.h
SPU2/spu2replay.h SPU2/spu2replay.h
SPU2/WavFile.h SPU2/WavFile.h
SPU2/Linux/Alsa.h
SPU2/Linux/Config.h
SPU2/Linux/Dialogs.h
) )
# DebugTools sources # DebugTools sources

View File

@ -139,12 +139,9 @@ void psxRcntInit() {
psxCounters[4].interrupt = 0x08000; psxCounters[4].interrupt = 0x08000;
psxCounters[5].interrupt = 0x10000; psxCounters[5].interrupt = 0x10000;
if (SPU2async != NULL)
{
psxCounters[6].rate = 768*12; psxCounters[6].rate = 768*12;
psxCounters[6].CycleT = psxCounters[6].rate; psxCounters[6].CycleT = psxCounters[6].rate;
psxCounters[6].mode = 0x8; psxCounters[6].mode = 0x8;
}
if (USBasync != NULL) if (USBasync != NULL)
{ {
@ -481,8 +478,6 @@ void psxRcntUpdate()
} }
if(SPU2async)
{
const s32 difference = psxRegs.cycle - psxCounters[6].sCycleT; const s32 difference = psxRegs.cycle - psxCounters[6].sCycleT;
s32 c = psxCounters[6].CycleT; s32 c = psxCounters[6].CycleT;
@ -494,7 +489,6 @@ void psxRcntUpdate()
} }
else c -= difference; else c -= difference;
psxNextCounter = c; psxNextCounter = c;
}
if (DEV9async) if (DEV9async)
{ {
DEV9async(1); DEV9async(1);

View File

@ -26,7 +26,7 @@ using namespace R3000A;
// Dma8 in PsxSpd.c // Dma8 in PsxSpd.c
// Dma11/12 in PsxSio2.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'; const char dmaNum = spuCore ? '7' : '4';
@ -38,8 +38,6 @@ static void __fastcall psxDmaGeneric(u32 madr, u32 bcr, u32 chcr, u32 spuCore, _
// Update the spu2 to the current cycle before initiating the DMA // Update the spu2 to the current cycle before initiating the DMA
if (SPU2async)
{
SPU2async(psxRegs.cycle - psxCounters[6].sCycleT); SPU2async(psxRegs.cycle - psxCounters[6].sCycleT);
//Console.Status("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT); //Console.Status("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT);
@ -56,18 +54,23 @@ static void __fastcall psxDmaGeneric(u32 madr, u32 bcr, u32 chcr, u32 spuCore, _
//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); //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; g_iopNextEventCycle = psxNextsCounter + psxNextCounter;
} }
}
switch (chcr) switch (chcr)
{ {
case 0x01000201: //cpu to spu2 transfer case 0x01000201: //cpu to spu2 transfer
PSXDMA_LOG("*** DMA %c - mem2spu *** %x addr = %x size = %x", dmaNum, chcr, madr, bcr); 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; break;
case 0x01000200: //spu2 to cpu transfer case 0x01000200: //spu2 to cpu transfer
PSXDMA_LOG("*** DMA %c - spu2mem *** %x addr = %x size = %x", dmaNum, chcr, madr, bcr); 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); psxCpu->Clear(spuCore ? HW_DMA7_MADR : HW_DMA4_MADR, size);
break; 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 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() int psxDma4Interrupt()
@ -105,7 +108,7 @@ void spu2DMA4Irq()
void psxDma7(u32 madr, u32 bcr, u32 chcr) // SPU2's Core 1 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() int psxDma7Interrupt()

View File

@ -13,8 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __PSXDMA_H__ #pragma once
#define __PSXDMA_H__
#include "PS2Edefs.h" #include "PS2Edefs.h"
@ -43,5 +42,3 @@ extern void iopTestIntc();
extern DEV9handler dev9Handler; extern DEV9handler dev9Handler;
extern USBhandler usbHandler; extern USBhandler usbHandler;
#endif /* __PSXDMA_H__ */

View File

@ -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()

View File

@ -18,7 +18,7 @@
#include "Global.h" #include "Global.h"
#include "Dma.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; extern u8 callirq;

View File

@ -71,7 +71,6 @@ static __forceinline T GetClamped(T src, T min, T max)
} }
#ifdef __WXMAC__ #ifdef __WXMAC__
#include "PS2Eext.h"
#else #else
extern void SysMessage(const char *fmt, ...); extern void SysMessage(const char *fmt, ...);
#endif #endif

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -18,7 +18,7 @@
#include "Global.h" #include "Global.h"
#include "Dma.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. // Core 0 Input is "SPDIF mode" - Source audio is AC3 compressed.

View File

@ -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 <http://www.gnu.org/licenses/>.
; 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

View File

@ -1,177 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugStrict|Win32">
<Configuration>DebugStrict</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="DebugStrict|x64">
<Configuration>DebugStrict</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Devel|Win32">
<Configuration>Devel</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Devel|x64">
<Configuration>Devel</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<Import Project="$(SolutionDir)common\vsprops\WinSDK.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{5307BBB7-EBB9-4AA4-8CB6-A94EC473C8C4}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="$(Configuration.Contains(Release))">true</WholeProgramOptimization>
<UseDebugLibraries Condition="$(Configuration.Contains(Debug))">true</UseDebugLibraries>
<UseDebugLibraries Condition="!$(Configuration.Contains(Debug))">false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="PropertySheets">
<Import Project="..\..\..\..\common\vsprops\plugin_svnroot.props" />
<Import Project="..\..\..\..\common\vsprops\BaseProperties.props" />
<Import Project="..\..\..\..\common\vsprops\3rdpartyDeps.props" />
<Import Project="..\..\..\..\common\vsprops\pthreads.props" />
<Import Condition="$(Configuration.Contains(Debug))" Project="..\..\..\..\common\vsprops\CodeGen_Debug.props" />
<Import Condition="$(Configuration.Contains(Devel))" Project="..\..\..\..\common\vsprops\CodeGen_Devel.props" />
<Import Condition="$(Configuration.Contains(Release))" Project="..\..\..\..\common\vsprops\CodeGen_Release.props" />
<Import Condition="!$(Configuration.Contains(Release))" Project="..\..\..\..\common\vsprops\IncrementalLinking.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions Condition="'$(Configuration)'=='Debug'">DEBUG_FAST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)3rdparty\portaudio\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ExceptionHandling>Async</ExceptionHandling>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>Global.h</PrecompiledHeaderFile>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>rpcrt4.lib;winmm.lib;dsound.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\Spu2-X.def</ModuleDefinitionFile>
<TargetMachine Condition="'$(Platform)'=='Win32'">MachineX86</TargetMachine>
<TargetMachine Condition="'$(Platform)'=='x64'">MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\Config.h" />
<ClInclude Include="..\Global.h" />
<ClInclude Include="..\spu2replay.h" />
<ClInclude Include="..\Lowpass.h" />
<ClInclude Include="..\SndOut.h" />
<ClInclude Include="..\Linux\Alsa.h" />
<ClInclude Include="..\spdif.h" />
<ClInclude Include="..\defs.h" />
<ClInclude Include="..\Dma.h" />
<ClInclude Include="..\regs.h" />
<ClInclude Include="..\Mixer.h" />
<ClInclude Include="dsp.h" />
<ClInclude Include="..\Linux\Config.h" />
<ClInclude Include="..\Linux\Dialogs.h" />
<ClInclude Include="Dialogs.h" />
<ClInclude Include="WinConfig.h" />
<ClInclude Include="..\PS2E-spu2.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\DplIIdecoder.cpp" />
<ClCompile Include="..\PrecompiledHeader.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\debug.cpp" />
<ClCompile Include="..\RegLog.cpp" />
<ClCompile Include="..\spu2replay.cpp" />
<ClCompile Include="..\wavedump_wav.cpp" />
<ClCompile Include="..\Lowpass.cpp" />
<ClCompile Include="..\SndOut.cpp" />
<ClCompile Include="..\Timestretcher.cpp" />
<ClCompile Include="SndOut_DSound.cpp" />
<ClCompile Include="SndOut_waveOut.cpp" />
<ClCompile Include="SndOut_XAudio2.cpp" />
<ClCompile Include="..\Linux\Alsa.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\SndOut_Portaudio.cpp" />
<ClCompile Include="..\dma.cpp" />
<ClCompile Include="..\RegTable.cpp" />
<ClCompile Include="..\spu2freeze.cpp" />
<ClCompile Include="..\spu2sys.cpp" />
<ClCompile Include="..\ADSR.cpp" />
<ClCompile Include="..\Mixer.cpp" />
<ClCompile Include="..\ReadInput.cpp" />
<ClCompile Include="..\Reverb.cpp" />
<ClCompile Include="dsp.cpp" />
<ClCompile Include="..\Linux\Config.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\Linux\Dialogs.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="CfgHelpers.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="ConfigDebug.cpp" />
<ClCompile Include="ConfigSoundtouch.cpp" />
<ClCompile Include="RealtimeDebugger.cpp" />
<ClCompile Include="UIHelpers.cpp" />
<ClCompile Include="..\PS2E-spu2.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LGPL.txt" />
<None Include="..\..\License.txt" />
<None Include="..\..\spu2-x-sm.bmp" />
<None Include="Spu2-X.def" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Spu2-X.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\3rdparty\portaudio\build\msvc\portaudio.vcxproj">
<Project>{0a18a071-125e-442f-aff7-a3f68abecf99}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\3rdparty\pthreads4w\build\pthreads4w.vcxproj">
<Project>{0fae817d-9a32-4830-857e-81da57246e16}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\3rdparty\soundtouch\SoundTouch.vcxproj">
<Project>{e9b51944-7e6d-4bcd-83f2-7bbd5a46182d}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\3rdparty\wxwidgets3.0\build\msw\wx30_base.vcxproj">
<Project>{3fcc50c2-81e9-5db2-b8d8-2129427568b1}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\common\build\Utilities\utilities.vcxproj">
<Project>{4639972e-424e-4e13-8b07-ca403c481346}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>

View File

@ -1,233 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{21596259-72f4-41c0-b499-40839e39f043}</UniqueIdentifier>
<Extensions>h;hpp;cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Source Files\debug">
<UniqueIdentifier>{30e5b8dd-2015-4c3d-a663-992fb42627b5}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Sound Output">
<UniqueIdentifier>{ed4df93e-4e4b-4675-a181-c5084146df7c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Sound Output\Windows">
<UniqueIdentifier>{1cb77247-dec9-4a0a-867f-7353b14decac}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Sound Output\Linux">
<UniqueIdentifier>{f87cf8e1-d654-4214-b7f4-6fb697f3941a}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Sound Output\Crossplatform">
<UniqueIdentifier>{10ccccc1-642a-42ec-900c-801f707bd776}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\decoder">
<UniqueIdentifier>{03be4765-f627-4c0a-9d40-f3c0f86f1e57}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\decoder\ac3%28a/52%29">
<UniqueIdentifier>{ea7e8889-2015-40b9-ac77-b4a3a58c41af}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\SPU2">
<UniqueIdentifier>{63ac2d88-b5c3-41a3-bd2c-a04c80acd35f}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\SPU2\Mixer">
<UniqueIdentifier>{825046cd-874f-45f4-8622-14c146a97b46}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Winamp DSP">
<UniqueIdentifier>{3924e038-9ec9-4f1c-89b9-6d03c46566ac}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\GUI">
<UniqueIdentifier>{efaf786c-f09d-49f7-b5f3-8bb7078e9c44}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\GUI\Linux">
<UniqueIdentifier>{00c53f28-fde8-4f60-88d2-d223584f1db5}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\GUI\Linux\Include">
<UniqueIdentifier>{95111121-7e1f-4624-8765-a17e8f13827f}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\GUI\Windows">
<UniqueIdentifier>{70e9653e-fba5-4c6e-ad9b-185006096d49}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\PluginInterface">
<UniqueIdentifier>{6fcf6c91-7afe-4ade-bb30-79d63901d590}</UniqueIdentifier>
</Filter>
<Filter Include="Documents">
<UniqueIdentifier>{381a6e5e-bdd5-48b0-81f8-e2775eff9585}</UniqueIdentifier>
</Filter>
<Filter Include="Resources">
<UniqueIdentifier>{d26e57df-a97e-4ba5-801a-c0c52b5d061f}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Config.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\Global.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\spu2replay.h">
<Filter>Source Files\debug</Filter>
</ClInclude>
<ClInclude Include="..\Lowpass.h">
<Filter>Source Files\Sound Output</Filter>
</ClInclude>
<ClInclude Include="..\SndOut.h">
<Filter>Source Files\Sound Output</Filter>
</ClInclude>
<ClInclude Include="..\Linux\Alsa.h">
<Filter>Source Files\Sound Output\Linux</Filter>
</ClInclude>
<ClInclude Include="..\spdif.h">
<Filter>Source Files\decoder</Filter>
</ClInclude>
<ClInclude Include="..\defs.h">
<Filter>Source Files\SPU2</Filter>
</ClInclude>
<ClInclude Include="..\Dma.h">
<Filter>Source Files\SPU2</Filter>
</ClInclude>
<ClInclude Include="..\regs.h">
<Filter>Source Files\SPU2</Filter>
</ClInclude>
<ClInclude Include="..\Mixer.h">
<Filter>Source Files\SPU2\Mixer</Filter>
</ClInclude>
<ClInclude Include="dsp.h">
<Filter>Source Files\Winamp DSP</Filter>
</ClInclude>
<ClInclude Include="..\Linux\Config.h">
<Filter>Source Files\GUI\Linux\Include</Filter>
</ClInclude>
<ClInclude Include="..\Linux\Dialogs.h">
<Filter>Source Files\GUI\Linux\Include</Filter>
</ClInclude>
<ClInclude Include="Dialogs.h">
<Filter>Source Files\GUI\Windows</Filter>
</ClInclude>
<ClInclude Include="WinConfig.h">
<Filter>Source Files\GUI\Windows</Filter>
</ClInclude>
<ClInclude Include="..\PS2E-spu2.h">
<Filter>Source Files\PluginInterface</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Resources</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\PrecompiledHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\debug.cpp">
<Filter>Source Files\debug</Filter>
</ClCompile>
<ClCompile Include="..\RegLog.cpp">
<Filter>Source Files\debug</Filter>
</ClCompile>
<ClCompile Include="..\spu2replay.cpp">
<Filter>Source Files\debug</Filter>
</ClCompile>
<ClCompile Include="..\wavedump_wav.cpp">
<Filter>Source Files\debug</Filter>
</ClCompile>
<ClCompile Include="..\Lowpass.cpp">
<Filter>Source Files\Sound Output</Filter>
</ClCompile>
<ClCompile Include="..\SndOut.cpp">
<Filter>Source Files\Sound Output</Filter>
</ClCompile>
<ClCompile Include="..\Timestretcher.cpp">
<Filter>Source Files\Sound Output</Filter>
</ClCompile>
<ClCompile Include="SndOut_DSound.cpp">
<Filter>Source Files\Sound Output\Windows</Filter>
</ClCompile>
<ClCompile Include="SndOut_waveOut.cpp">
<Filter>Source Files\Sound Output\Windows</Filter>
</ClCompile>
<ClCompile Include="..\Linux\Alsa.cpp">
<Filter>Source Files\Sound Output\Linux</Filter>
</ClCompile>
<ClCompile Include="..\SndOut_Portaudio.cpp">
<Filter>Source Files\Sound Output\Crossplatform</Filter>
</ClCompile>
<ClCompile Include="..\dma.cpp">
<Filter>Source Files\SPU2</Filter>
</ClCompile>
<ClCompile Include="..\RegTable.cpp">
<Filter>Source Files\SPU2</Filter>
</ClCompile>
<ClCompile Include="..\spu2freeze.cpp">
<Filter>Source Files\SPU2</Filter>
</ClCompile>
<ClCompile Include="..\spu2sys.cpp">
<Filter>Source Files\SPU2</Filter>
</ClCompile>
<ClCompile Include="..\ADSR.cpp">
<Filter>Source Files\SPU2\Mixer</Filter>
</ClCompile>
<ClCompile Include="..\Mixer.cpp">
<Filter>Source Files\SPU2\Mixer</Filter>
</ClCompile>
<ClCompile Include="..\ReadInput.cpp">
<Filter>Source Files\SPU2\Mixer</Filter>
</ClCompile>
<ClCompile Include="..\Reverb.cpp">
<Filter>Source Files\SPU2\Mixer</Filter>
</ClCompile>
<ClCompile Include="dsp.cpp">
<Filter>Source Files\Winamp DSP</Filter>
</ClCompile>
<ClCompile Include="..\Linux\Config.cpp">
<Filter>Source Files\GUI\Linux</Filter>
</ClCompile>
<ClCompile Include="..\Linux\Dialogs.cpp">
<Filter>Source Files\GUI\Linux</Filter>
</ClCompile>
<ClCompile Include="CfgHelpers.cpp">
<Filter>Source Files\GUI\Windows</Filter>
</ClCompile>
<ClCompile Include="Config.cpp">
<Filter>Source Files\GUI\Windows</Filter>
</ClCompile>
<ClCompile Include="ConfigDebug.cpp">
<Filter>Source Files\GUI\Windows</Filter>
</ClCompile>
<ClCompile Include="ConfigSoundtouch.cpp">
<Filter>Source Files\GUI\Windows</Filter>
</ClCompile>
<ClCompile Include="RealtimeDebugger.cpp">
<Filter>Source Files\GUI\Windows</Filter>
</ClCompile>
<ClCompile Include="UIHelpers.cpp">
<Filter>Source Files\GUI\Windows</Filter>
</ClCompile>
<ClCompile Include="..\PS2E-spu2.cpp">
<Filter>Source Files\PluginInterface</Filter>
</ClCompile>
<ClCompile Include="..\DplIIdecoder.cpp">
<Filter>Source Files\Sound Output</Filter>
</ClCompile>
<ClCompile Include="SndOut_XAudio2.cpp">
<Filter>Source Files\Sound Output\Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\LGPL.txt">
<Filter>Documents</Filter>
</None>
<None Include="..\..\License.txt">
<Filter>Documents</Filter>
</None>
<None Include="..\..\spu2-x-sm.bmp">
<Filter>Resources</Filter>
</None>
<None Include="Spu2-X.def">
<Filter>Resources</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Spu2-X.rc">
<Filter>Resources</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -553,7 +553,7 @@ extern void InitADSR();
extern void CalculateADSR(V_Voice &vc); extern void CalculateADSR(V_Voice &vc);
extern void UpdateSpdifMode(); extern void UpdateSpdifMode();
namespace Savestate namespace SPU2Savestate
{ {
struct DataBlock; struct DataBlock;

View File

@ -18,16 +18,19 @@
#include "Global.h" #include "Global.h"
#include "spu2.h" #include "spu2.h"
#include "Dma.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" #include "svnrev.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#define snprintf sprintf_s #define snprintf sprintf_s
#endif #endif
// PCSX2 expects ASNI, not unicode, so this MUST always be char...
static char libraryName[256];
int SampleRate = 48000; int SampleRate = 48000;
static bool IsOpened = false; static bool IsOpened = false;
@ -92,26 +95,26 @@ void (*_irqcallback)();
void (*dma4callback)(); void (*dma4callback)();
void (*dma7callback)(); void (*dma7callback)();
u32 CALLBACK SPU2ReadMemAddr(int core) u32 SPU2ReadMemAddr(int core)
{ {
return Cores[core].MADR; return Cores[core].MADR;
} }
void CALLBACK SPU2WriteMemAddr(int core, u32 value) void SPU2WriteMemAddr(int core, u32 value)
{ {
Cores[core].MADR = value; Cores[core].MADR = value;
} }
void CALLBACK SPU2setDMABaseAddr(uptr baseaddr) void SPU2setDMABaseAddr(uptr baseaddr)
{ {
DMABaseAddr = (u16 *)baseaddr; DMABaseAddr = (u16 *)baseaddr;
} }
void CALLBACK SPU2setSettingsDir(const char *dir) void SPU2setSettingsDir(const char *dir)
{ {
CfgSetSettingsDir(dir); CfgSetSettingsDir(dir);
} }
void CALLBACK SPU2setLogDir(const char *dir) void SPU2setLogDir(const char *dir)
{ {
CfgSetLogDir(dir); CfgSetLogDir(dir);
} }
@ -123,7 +126,7 @@ void SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7
dma7callback = DMA7callback; 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) if (cyclePtr != NULL)
TimeUpdate(*cyclePtr); TimeUpdate(*cyclePtr);
@ -132,7 +135,7 @@ void CALLBACK SPU2readDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units
Cores[0].DoDMAread(pMem, size); 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) if (cyclePtr != NULL)
TimeUpdate(*cyclePtr); TimeUpdate(*cyclePtr);
@ -145,21 +148,21 @@ void CALLBACK SPU2writeDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units
Cores[0].DoDMAwrite(pMem, size); Cores[0].DoDMAwrite(pMem, size);
} }
void CALLBACK SPU2interruptDMA4() void SPU2interruptDMA4()
{ {
FileLog("[%10d] SPU2 interruptDMA4\n", Cycles); FileLog("[%10d] SPU2 interruptDMA4\n", Cycles);
Cores[0].Regs.STATX |= 0x80; Cores[0].Regs.STATX |= 0x80;
//Cores[0].Regs.ATTR &= ~0x30; //Cores[0].Regs.ATTR &= ~0x30;
} }
void CALLBACK SPU2interruptDMA7() void SPU2interruptDMA7()
{ {
FileLog("[%10d] SPU2 interruptDMA7\n", Cycles); FileLog("[%10d] SPU2 interruptDMA7\n", Cycles);
Cores[1].Regs.STATX |= 0x80; Cores[1].Regs.STATX |= 0x80;
//Cores[1].Regs.ATTR &= ~0x30; //Cores[1].Regs.ATTR &= ~0x30;
} }
void CALLBACK SPU2readDMA7Mem(u16 *pMem, u32 size) void SPU2readDMA7Mem(u16 *pMem, u32 size)
{ {
if (cyclePtr != NULL) if (cyclePtr != NULL)
TimeUpdate(*cyclePtr); TimeUpdate(*cyclePtr);
@ -168,7 +171,7 @@ void CALLBACK SPU2readDMA7Mem(u16 *pMem, u32 size)
Cores[1].DoDMAread(pMem, size); Cores[1].DoDMAread(pMem, size);
} }
void CALLBACK SPU2writeDMA7Mem(u16 *pMem, u32 size) void SPU2writeDMA7Mem(u16 *pMem, u32 size)
{ {
if (cyclePtr != NULL) if (cyclePtr != NULL)
TimeUpdate(*cyclePtr); TimeUpdate(*cyclePtr);
@ -339,6 +342,7 @@ uptr gsWindowHandle = 0;
s32 SPU2open(void *pDsp) s32 SPU2open(void *pDsp)
{ {
ScopedLock lock( mtx_SPU2Status );
if (IsOpened) if (IsOpened)
return 0; return 0;
@ -384,6 +388,7 @@ s32 SPU2open(void *pDsp)
void SPU2close() void SPU2close()
{ {
ScopedLock lock( mtx_SPU2Status );
if (!IsOpened) if (!IsOpened)
return; return;
IsOpened = false; IsOpened = false;
@ -585,7 +590,7 @@ s32 SPU2freeze(int mode, freezeData *data)
} }
if (mode == FREEZE_SIZE) { if (mode == FREEZE_SIZE) {
data->size = Savestate::SizeIt(); data->size = SPU2Savestate::SizeIt();
return 0; return 0;
} }
@ -596,13 +601,13 @@ s32 SPU2freeze(int mode, freezeData *data)
return -1; return -1;
} }
Savestate::DataBlock &spud = (Savestate::DataBlock &)*(data->data); SPU2Savestate::DataBlock &spud = (SPU2Savestate::DataBlock &)*(data->data);
switch (mode) { switch (mode) {
case FREEZE_LOAD: case FREEZE_LOAD:
return Savestate::ThawIt(spud); return SPU2Savestate::ThawIt(spud);
case FREEZE_SAVE: case FREEZE_SAVE:
return Savestate::FreezeIt(spud); return SPU2Savestate::FreezeIt(spud);
jNO_DEFAULT; jNO_DEFAULT;
} }
@ -610,3 +615,36 @@ s32 SPU2freeze(int mode, freezeData *data)
// technically unreachable, but kills a warning: // technically unreachable, but kills a warning:
return 0; 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 );
}

View File

@ -18,6 +18,10 @@
#pragma once #pragma once
#include "Pcsx2Defs.h" #include "Pcsx2Defs.h"
#include "Utilities/Threading.h"
#include "SaveState.h"
Threading::MutexRecursive mtx_SPU2Status;
s32 SPU2init(); s32 SPU2init();
s32 SPU2reset(); s32 SPU2reset();
@ -38,11 +42,25 @@ void SPU2setClockPtr(u32 *ptr);
void SPU2async(u32 cycles); void SPU2async(u32 cycles);
s32 SPU2freeze(int mode, freezeData *data); s32 SPU2freeze(int mode, freezeData *data);
void SPU2DoFreeze( SaveStateBase& state );
void SPU2configure(); void SPU2configure();
void SPU2about(); void SPU2about();
s32 SPU2test(); 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; extern u8 callirq;

View File

@ -16,9 +16,9 @@
*/ */
#include "Global.h" #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. // Arbitrary ID to identify SPU2-X saves.
static const u32 SAVE_ID = 0x1227521; 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) u32 spu2id; // SPU2-X state identifier lets ZeroGS/PeopsSPU2 know this isn't their state)
u8 unkregs[0x10000]; // SPU2 raw register memory u8 unkregs[0x10000]; // SPU2 raw register memory
@ -49,7 +49,7 @@ struct Savestate::DataBlock
int PlayMode; int PlayMode;
}; };
s32 __fastcall Savestate::FreezeIt(DataBlock &spud) s32 __fastcall SPU2Savestate::FreezeIt(DataBlock &spud)
{ {
spud.spu2id = SAVE_ID; spud.spu2id = SAVE_ID;
spud.version = SAVE_VERSION; spud.version = SAVE_VERSION;
@ -78,7 +78,7 @@ s32 __fastcall Savestate::FreezeIt(DataBlock &spud)
return 0; return 0;
} }
s32 __fastcall Savestate::ThawIt(DataBlock &spud) s32 __fastcall SPU2Savestate::ThawIt(DataBlock &spud)
{ {
if (spud.spu2id != SAVE_ID || spud.version < SAVE_VERSION) { if (spud.spu2id != SAVE_ID || spud.version < SAVE_VERSION) {
fprintf(stderr, "\n*** SPU2-X Warning:\n"); fprintf(stderr, "\n*** SPU2-X Warning:\n");
@ -141,7 +141,7 @@ s32 __fastcall Savestate::ThawIt(DataBlock &spud)
return 0; return 0;
} }
s32 __fastcall Savestate::SizeIt() s32 __fastcall SPU2Savestate::SizeIt()
{ {
return sizeof(DataBlock); return sizeof(DataBlock);
} }

View File

@ -17,7 +17,7 @@
// //
#include "Global.h" #include "Global.h"
#include "PS2E-spu2.h" #include "spu2.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#include "Windows.h" #include "Windows.h"

View File

@ -25,7 +25,7 @@
#include "Global.h" #include "Global.h"
#include "Dma.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 *spu2regs = NULL;
s16 *_spu2mem = NULL; s16 *_spu2mem = NULL;

View File

@ -29,6 +29,7 @@
#include "Counters.h" #include "Counters.h"
#include "Utilities/SafeArray.inl" #include "Utilities/SafeArray.inl"
#include "SPU2/spu2.h"
using namespace R5900; using namespace R5900;
@ -244,6 +245,8 @@ SaveStateBase& SaveStateBase::FreezePlugins()
FreezeTag( FastFormatAscii().Write("Plugin:%s", tbl_PluginInfo[i].shortname) ); FreezeTag( FastFormatAscii().Write("Plugin:%s", tbl_PluginInfo[i].shortname) );
GetCorePlugins().Freeze( (PluginsEnum_t)i, *this ); GetCorePlugins().Freeze( (PluginsEnum_t)i, *this );
} }
// now with more core!
SPU2DoFreeze(*this);
return *this; return *this;
} }