mirror of https://github.com/PCSX2/pcsx2.git
SPU2: Purge SPU2Replay
This commit is contained in:
parent
20e2a4055c
commit
993af8c19e
|
@ -254,7 +254,6 @@ set(pcsx2SPU2Sources
|
|||
SPU2/SndOut.cpp
|
||||
SPU2/SndOut_SDL.cpp
|
||||
SPU2/spu2freeze.cpp
|
||||
SPU2/spu2replay.cpp
|
||||
SPU2/spu2sys.cpp
|
||||
SPU2/Timestretcher.cpp
|
||||
SPU2/Wavedump_wav.cpp
|
||||
|
@ -286,7 +285,6 @@ set(pcsx2SPU2Headers
|
|||
SPU2/regs.h
|
||||
SPU2/SndOut.h
|
||||
SPU2/spdif.h
|
||||
SPU2/spu2replay.h
|
||||
SPU2/WavFile.h
|
||||
SPU2/Linux/Alsa.h
|
||||
SPU2/Linux/Config.h
|
||||
|
|
|
@ -118,19 +118,9 @@ StereoOut32 V_Core::ReadInput()
|
|||
if (!InputDataTransferred && !InputDataLeft)
|
||||
{
|
||||
if (Index == 0)
|
||||
{
|
||||
if (!SPU2_dummy_callback)
|
||||
spu2DMA4Irq();
|
||||
else
|
||||
SPU2interruptDMA4();
|
||||
}
|
||||
spu2DMA4Irq();
|
||||
else
|
||||
{
|
||||
if (!SPU2_dummy_callback)
|
||||
spu2DMA7Irq();
|
||||
else
|
||||
SPU2interruptDMA7();
|
||||
}
|
||||
spu2DMA7Irq();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
using namespace Threading;
|
||||
|
||||
MutexRecursive mtx_SPU2Status;
|
||||
bool SPU2_dummy_callback = false;
|
||||
|
||||
#include "svnrev.h"
|
||||
|
||||
|
@ -122,10 +121,7 @@ void SPU2writeDMA4Mem(u16* pMem, u32 size) // size now in 16bit units
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -162,10 +158,7 @@ void SPU2writeDMA7Mem(u16* pMem, u32 size)
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -240,7 +233,6 @@ s32 SPU2init()
|
|||
return 0;
|
||||
|
||||
IsInitialized = true;
|
||||
SPU2_dummy_callback = false;
|
||||
|
||||
ReadSettings();
|
||||
|
||||
|
@ -290,10 +282,6 @@ s32 SPU2init()
|
|||
DMALogOpen();
|
||||
InitADSR();
|
||||
|
||||
#ifdef S2R_ENABLE
|
||||
if (!replay_mode)
|
||||
s2r_open(Cycles, "replay_dump.s2r");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -415,17 +403,11 @@ void SPU2shutdown()
|
|||
if (!IsInitialized)
|
||||
return;
|
||||
IsInitialized = false;
|
||||
SPU2_dummy_callback = false;
|
||||
|
||||
ConLog("* SPU2: Shutting down.\n");
|
||||
|
||||
SPU2close();
|
||||
|
||||
#ifdef S2R_ENABLE
|
||||
if (!replay_mode)
|
||||
s2r_close();
|
||||
#endif
|
||||
|
||||
DoFullDump();
|
||||
#ifdef STREAM_DUMP
|
||||
fclose(il0);
|
||||
|
@ -532,11 +514,9 @@ void SPU2async(u32 cycles)
|
|||
|
||||
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;
|
||||
|
@ -582,11 +562,6 @@ u16 SPU2read(u32 rmem)
|
|||
|
||||
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.
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
extern Threading::MutexRecursive mtx_SPU2Status;
|
||||
|
||||
extern bool SPU2_dummy_callback;
|
||||
|
||||
s32 SPU2init();
|
||||
s32 SPU2reset();
|
||||
s32 SPU2ps1reset();
|
||||
|
@ -58,16 +56,9 @@ void SPU2interruptDMA4();
|
|||
void SPU2interruptDMA7();
|
||||
void SPU2readDMA7Mem(u16* pMem, u32 size);
|
||||
void SPU2writeDMA7Mem(u16* pMem, u32 size);
|
||||
#include "spu2replay.h"
|
||||
|
||||
extern u8 callirq;
|
||||
|
||||
extern s16* input_data;
|
||||
extern u32 input_data_ptr;
|
||||
|
||||
extern double srate_pv;
|
||||
|
||||
extern int recording;
|
||||
extern u32 lClocks;
|
||||
extern u32* cyclePtr;
|
||||
|
||||
|
|
|
@ -1,309 +0,0 @@
|
|||
/* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Global.h"
|
||||
#include "spu2.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "Windows.h"
|
||||
#endif
|
||||
|
||||
FILE* s2rfile;
|
||||
|
||||
void s2r_write16(s16 data)
|
||||
{
|
||||
fwrite(&data, 2, 1, s2rfile);
|
||||
}
|
||||
|
||||
void s2r_write32(u32 data)
|
||||
{
|
||||
fwrite(&data, 4, 1, s2rfile);
|
||||
}
|
||||
|
||||
static void EMITC(u32 i, u32 a)
|
||||
{
|
||||
s2r_write32(((i & 0x7u) << 29u) | (a & 0x1FFFFFFFu));
|
||||
}
|
||||
|
||||
int s2r_open(u32 ticks, char* filename)
|
||||
{
|
||||
s2rfile = fopen(filename, "wb");
|
||||
if (s2rfile)
|
||||
s2r_write32(ticks);
|
||||
return s2rfile ? 0 : -1;
|
||||
}
|
||||
|
||||
void s2r_readreg(u32 ticks, u32 addr)
|
||||
{
|
||||
if (!s2rfile)
|
||||
return;
|
||||
s2r_write32(ticks);
|
||||
EMITC(0, addr);
|
||||
}
|
||||
|
||||
void s2r_writereg(u32 ticks, u32 addr, s16 value)
|
||||
{
|
||||
if (!s2rfile)
|
||||
return;
|
||||
s2r_write32(ticks);
|
||||
EMITC(1, addr);
|
||||
s2r_write16(value);
|
||||
}
|
||||
|
||||
void s2r_writedma4(u32 ticks, u16* data, u32 len)
|
||||
{
|
||||
u32 i;
|
||||
if (!s2rfile)
|
||||
return;
|
||||
s2r_write32(ticks);
|
||||
EMITC(2, len);
|
||||
for (i = 0; i < len; i++, data++)
|
||||
s2r_write16(*data);
|
||||
}
|
||||
|
||||
void s2r_writedma7(u32 ticks, u16* data, u32 len)
|
||||
{
|
||||
u32 i;
|
||||
if (!s2rfile)
|
||||
return;
|
||||
s2r_write32(ticks);
|
||||
EMITC(3, len);
|
||||
for (i = 0; i < len; i++, data++)
|
||||
s2r_write16(*data);
|
||||
}
|
||||
|
||||
void s2r_close()
|
||||
{
|
||||
if (!s2rfile)
|
||||
return;
|
||||
fclose(s2rfile);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////
|
||||
// replay code
|
||||
|
||||
bool replay_mode = false;
|
||||
|
||||
u16 dmabuffer[0xFFFFF];
|
||||
|
||||
[[maybe_unused]]const u32 IOP_CLK = 768 * 48000;
|
||||
[[maybe_unused]]const u32 IOPCiclesPerMS = 768 * 48;
|
||||
u32 CurrentIOPCycle = 0;
|
||||
|
||||
u64 HighResFreq;
|
||||
u64 HighResPrev;
|
||||
double HighResScale;
|
||||
|
||||
bool Running = false;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
int conprintf(const char* fmt, ...)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char s[1024];
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
vsprintf(s, fmt, list);
|
||||
va_end(list);
|
||||
|
||||
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
|
||||
DWORD written = 0;
|
||||
WriteConsoleA(handle, s, strlen(s), &written, 0);
|
||||
FlushFileBuffers(handle);
|
||||
|
||||
return written;
|
||||
#else
|
||||
va_list list;
|
||||
va_start(list, fmt);
|
||||
int ret = vsprintf(stderr, fmt, list);
|
||||
va_end(list);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
u64 HighResFrequency()
|
||||
{
|
||||
u64 freq;
|
||||
#ifdef _WIN32
|
||||
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
return freq;
|
||||
}
|
||||
|
||||
u64 HighResCounter()
|
||||
{
|
||||
u64 time;
|
||||
#ifdef _WIN32
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&time);
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
return time;
|
||||
}
|
||||
|
||||
void InitWaitSync() // not extremely accurate but enough.
|
||||
{
|
||||
HighResFreq = HighResFrequency();
|
||||
HighResPrev = HighResCounter();
|
||||
HighResScale = (double)HighResFreq / (double)IOP_CLK;
|
||||
}
|
||||
|
||||
u32 WaitSync(u32 TargetCycle)
|
||||
{
|
||||
u32 WaitCycles = (TargetCycle - CurrentIOPCycle);
|
||||
u32 WaitTime = WaitCycles / IOPCiclesPerMS;
|
||||
if (WaitTime > 10)
|
||||
WaitTime = 10;
|
||||
if (WaitTime == 0)
|
||||
WaitTime = 1;
|
||||
SleepEx(WaitTime, TRUE);
|
||||
|
||||
// Refresh current time after sleeping
|
||||
u64 Current = HighResCounter();
|
||||
u32 delta = (u32)floor((Current - HighResPrev) / HighResScale + 0.5); // We lose some precision here, cycles might drift away over long periods of time ;P
|
||||
|
||||
// Calculate time delta
|
||||
CurrentIOPCycle += delta;
|
||||
HighResPrev += (u64)floor(delta * HighResScale + 0.5); // Trying to compensate drifting mentioned above, not necessarily useful.
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
|
||||
{
|
||||
Running = false;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "Windows/Dialogs.h"
|
||||
void s2r_replay(HWND hwnd, HINSTANCE hinst, LPSTR filename, int nCmdShow)
|
||||
{
|
||||
int events = 0;
|
||||
|
||||
Running = true;
|
||||
|
||||
#ifdef _WIN32
|
||||
AllocConsole();
|
||||
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
||||
|
||||
conprintf("Playing %s file on %x...", filename, hwnd);
|
||||
#endif
|
||||
|
||||
// load file
|
||||
FILE* file = fopen(filename, "rb");
|
||||
|
||||
if (!file)
|
||||
{
|
||||
conprintf("Could not open the replay file.");
|
||||
return;
|
||||
}
|
||||
// if successful, init the plugin
|
||||
|
||||
#define TryRead(dest, size, count, file) \
|
||||
if (fread(dest, size, count, file) < count) \
|
||||
{ \
|
||||
conprintf("Error reading from file."); \
|
||||
goto Finish; /* Need to exit the while() loop and maybe also the switch */ \
|
||||
}
|
||||
|
||||
TryRead(&CurrentIOPCycle, 4, 1, file);
|
||||
|
||||
replay_mode = true;
|
||||
|
||||
InitWaitSync(); // Initialize the WaitSync stuff
|
||||
|
||||
SPU2init();
|
||||
SPU2_dummy_callback = true;
|
||||
SPU2setClockPtr(&CurrentIOPCycle);
|
||||
SPU2open(&hwnd);
|
||||
|
||||
CurrentIOPCycle = 0;
|
||||
|
||||
SPU2async(0);
|
||||
|
||||
while (!feof(file) && Running)
|
||||
{
|
||||
u32 ccycle = 0;
|
||||
u32 evid = 0;
|
||||
u32 sval = 0;
|
||||
u32 tval = 0;
|
||||
|
||||
TryRead(&ccycle, 4, 1, file);
|
||||
TryRead(&sval, 4, 1, file);
|
||||
|
||||
evid = sval >> 29;
|
||||
sval &= 0x1FFFFFFF;
|
||||
|
||||
u32 TargetCycle = ccycle * 768;
|
||||
|
||||
while (TargetCycle > CurrentIOPCycle)
|
||||
{
|
||||
u32 delta = WaitSync(TargetCycle);
|
||||
SPU2async(delta);
|
||||
}
|
||||
|
||||
switch (evid)
|
||||
{
|
||||
case 0:
|
||||
SPU2read(sval);
|
||||
break;
|
||||
case 1:
|
||||
TryRead(&tval, 2, 1, file);
|
||||
SPU2write(sval, tval);
|
||||
break;
|
||||
case 2:
|
||||
TryRead(dmabuffer, sval, 2, file);
|
||||
SPU2writeDMA4Mem(dmabuffer, sval);
|
||||
break;
|
||||
case 3:
|
||||
TryRead(dmabuffer, sval, 2, file);
|
||||
SPU2writeDMA7Mem(dmabuffer, sval);
|
||||
break;
|
||||
default:
|
||||
// not implemented
|
||||
return;
|
||||
break;
|
||||
}
|
||||
events++;
|
||||
}
|
||||
|
||||
Finish:
|
||||
|
||||
//shutdown
|
||||
SPU2close();
|
||||
SPU2shutdown();
|
||||
fclose(file);
|
||||
|
||||
conprintf("Finished playing %s file (%d cycles, %d events).", filename, CurrentIOPCycle, events);
|
||||
|
||||
#ifdef _WIN32
|
||||
FreeConsole();
|
||||
#endif
|
||||
|
||||
replay_mode = false;
|
||||
}
|
||||
#endif
|
|
@ -1,28 +0,0 @@
|
|||
/* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//#define S2R_ENABLE
|
||||
|
||||
// s2r dumping
|
||||
int s2r_open(u32 ticks, char* filename);
|
||||
void s2r_readreg(u32 ticks, u32 addr);
|
||||
void s2r_writereg(u32 ticks, u32 addr, s16 value);
|
||||
void s2r_writedma4(u32 ticks, u16* data, u32 len);
|
||||
void s2r_writedma7(u32 ticks, u16* data, u32 len);
|
||||
void s2r_close();
|
||||
|
||||
extern bool replay_mode;
|
|
@ -429,8 +429,7 @@ __forceinline void TimeUpdate(u32 cClocks)
|
|||
if (!(Spdif.Info & (4 << i)) && Cores[i].IRQEnable)
|
||||
{
|
||||
Spdif.Info |= (4 << i);
|
||||
if (!SPU2_dummy_callback)
|
||||
spu2Irq();
|
||||
spu2Irq();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -479,18 +478,14 @@ __forceinline void TimeUpdate(u32 cClocks)
|
|||
if (!(Spdif.Info & (4 << i)) && Cores[i].IRQEnable)
|
||||
{
|
||||
Spdif.Info |= (4 << i);
|
||||
if (!SPU2_dummy_callback)
|
||||
spu2Irq();
|
||||
spu2Irq();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Cores[0].DMAICounter <= 0)
|
||||
{
|
||||
Cores[0].MADR = Cores[0].TADR;
|
||||
if (!SPU2_dummy_callback)
|
||||
spu2DMA4Irq();
|
||||
else
|
||||
SPU2interruptDMA4();
|
||||
spu2DMA4Irq();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -535,8 +530,7 @@ __forceinline void TimeUpdate(u32 cClocks)
|
|||
if (!(Spdif.Info & (4 << i)) && Cores[i].IRQEnable)
|
||||
{
|
||||
Spdif.Info |= (4 << i);
|
||||
if (!SPU2_dummy_callback)
|
||||
spu2Irq();
|
||||
spu2Irq();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -544,10 +538,7 @@ __forceinline void TimeUpdate(u32 cClocks)
|
|||
if (Cores[1].DMAICounter <= 0)
|
||||
{
|
||||
Cores[1].MADR = Cores[1].TADR;
|
||||
if (!SPU2_dummy_callback)
|
||||
spu2DMA7Irq();
|
||||
else
|
||||
SPU2interruptDMA7();
|
||||
spu2DMA7Irq();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -815,8 +806,7 @@ void V_Core::WriteRegPS1(u32 mem, u16 value)
|
|||
if (Cores[0].IRQEnable && (Cores[0].IRQA <= Cores[0].ActiveTSA))
|
||||
{
|
||||
SetIrqCall(0);
|
||||
if (!SPU2_dummy_callback)
|
||||
spu2Irq();
|
||||
spu2Irq();
|
||||
}
|
||||
DmaWrite(value);
|
||||
show = false;
|
||||
|
|
|
@ -327,7 +327,6 @@
|
|||
<ClCompile Include="..\..\SPU2\debug.cpp" />
|
||||
<ClCompile Include="..\..\SPU2\RegLog.cpp" />
|
||||
<ClCompile Include="..\..\SPU2\SndOut_Portaudio.cpp" />
|
||||
<ClCompile Include="..\..\SPU2\spu2replay.cpp" />
|
||||
<ClCompile Include="..\..\SPU2\wavedump_wav.cpp" />
|
||||
<ClCompile Include="..\..\SPU2\Lowpass.cpp" />
|
||||
<ClCompile Include="..\..\SPU2\SndOut.cpp" />
|
||||
|
@ -688,7 +687,6 @@
|
|||
<ClInclude Include="..\..\PAD\Windows\XInputEnum.h" />
|
||||
<ClInclude Include="..\..\SPU2\Config.h" />
|
||||
<ClInclude Include="..\..\SPU2\Global.h" />
|
||||
<ClInclude Include="..\..\SPU2\spu2replay.h" />
|
||||
<ClInclude Include="..\..\SPU2\interpolate_table.h" />
|
||||
<ClInclude Include="..\..\SPU2\Lowpass.h" />
|
||||
<ClInclude Include="..\..\SPU2\SndOut.h" />
|
||||
|
@ -967,4 +965,4 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
||||
</Project>
|
|
@ -979,9 +979,6 @@
|
|||
<ClCompile Include="..\..\SPU2\spu2freeze.cpp">
|
||||
<Filter>System\Ps2\SPU2</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\SPU2\spu2replay.cpp">
|
||||
<Filter>System\Ps2\SPU2</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\SPU2\spu2sys.cpp">
|
||||
<Filter>System\Ps2\SPU2</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1779,9 +1776,6 @@
|
|||
<ClInclude Include="..\..\SPU2\spu2.h">
|
||||
<Filter>System\Ps2\SPU2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\SPU2\spu2replay.h">
|
||||
<Filter>System\Ps2\SPU2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\SPU2\Mixer.h">
|
||||
<Filter>System\Ps2\SPU2</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Reference in New Issue