mirror of https://github.com/PCSX2/pcsx2.git
Sio: Fix host pointer getting serialized
[SAVEVERSION+] It wasn't saving the FIFO anyway. Sorry for the save state bump, but it's unavoidable :(
This commit is contained in:
parent
4b4b82bd5f
commit
d0673f9133
|
@ -15,9 +15,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "System.h"
|
||||
#include "common/Assertions.h"
|
||||
#include "common/Exceptions.h"
|
||||
|
||||
enum class FreezeAction
|
||||
|
@ -33,7 +36,7 @@ enum class FreezeAction
|
|||
// [SAVEVERSION+]
|
||||
// This informs the auto updater that the users savestates will be invalidated.
|
||||
|
||||
static const u32 g_SaveVersion = (0x9A32 << 16) | 0x0000;
|
||||
static const u32 g_SaveVersion = (0x9A33 << 16) | 0x0000;
|
||||
|
||||
|
||||
// the freezing data between submodules and core
|
||||
|
@ -118,6 +121,36 @@ public:
|
|||
|
||||
void PrepBlock( int size );
|
||||
|
||||
template <typename T>
|
||||
void FreezeDeque(std::deque<T>& q)
|
||||
{
|
||||
// overwritten when loading
|
||||
u32 count = static_cast<u32>(q.size());
|
||||
Freeze(count);
|
||||
|
||||
// have to use a temp array, because deque doesn't have a contiguous block of memory
|
||||
std::unique_ptr<T[]> temp;
|
||||
if (count > 0)
|
||||
{
|
||||
temp = std::make_unique<T[]>(count);
|
||||
if (IsSaving())
|
||||
{
|
||||
u32 pos = 0;
|
||||
for (const T& it : q)
|
||||
temp[pos++] = it;
|
||||
}
|
||||
|
||||
FreezeMem(temp.get(), static_cast<int>(sizeof(T) * count));
|
||||
}
|
||||
|
||||
if (IsLoading())
|
||||
{
|
||||
q.clear();
|
||||
for (u32 i = 0; i < count; i++)
|
||||
q.push_back(temp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
uint GetCurrentPos() const
|
||||
{
|
||||
return m_idx;
|
||||
|
|
|
@ -868,53 +868,9 @@ void SaveStateBase::sio2Freeze()
|
|||
{
|
||||
FreezeTag("sio2");
|
||||
|
||||
if (IsSaving())
|
||||
{
|
||||
std::deque<u8>::iterator iter;
|
||||
size_t backupSize;
|
||||
|
||||
// Copy fifoIn
|
||||
if (fifoIn.size())
|
||||
{
|
||||
sio2.fifoInBackup = std::make_unique<u8[]>(fifoIn.size());
|
||||
iter = fifoIn.begin();
|
||||
backupSize = 0;
|
||||
|
||||
while (iter != fifoIn.end())
|
||||
{
|
||||
const u8 val = *iter++;
|
||||
sio2.fifoInBackup.get()[backupSize++] = val;
|
||||
}
|
||||
|
||||
sio2.fifoInBackupSize = backupSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
sio2.fifoInBackupSize = 0;
|
||||
}
|
||||
|
||||
// Copy fifoOut
|
||||
if (fifoOut.size())
|
||||
{
|
||||
sio2.fifoOutBackup = std::make_unique<u8[]>(fifoOut.size());
|
||||
iter = fifoOut.begin();
|
||||
backupSize = 0;
|
||||
|
||||
while (iter != fifoOut.end())
|
||||
{
|
||||
const u8 val = *iter++;
|
||||
sio2.fifoOutBackup.get()[backupSize++] = val;
|
||||
}
|
||||
|
||||
sio2.fifoOutBackupSize = backupSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
sio2.fifoOutBackupSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Freeze(sio2);
|
||||
FreezeDeque(fifoIn);
|
||||
FreezeDeque(fifoOut);
|
||||
|
||||
// CRCs for memory cards.
|
||||
// If the memory card hasn't changed when loading state, we can safely skip ejecting it.
|
||||
|
@ -944,28 +900,6 @@ void SaveStateBase::sio2Freeze()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restore fifoIn
|
||||
fifoIn.clear();
|
||||
|
||||
if (sio2.fifoInBackupSize)
|
||||
{
|
||||
for (size_t i = 0; i < sio2.fifoInBackupSize; i++)
|
||||
{
|
||||
fifoIn.push_back(sio2.fifoInBackup.get()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore fifoOut
|
||||
fifoOut.clear();
|
||||
|
||||
if (sio2.fifoOutBackupSize)
|
||||
{
|
||||
for (size_t j = 0; j < sio2.fifoOutBackupSize; j++)
|
||||
{
|
||||
fifoOut.push_back(sio2.fifoOutBackup.get()[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -198,11 +198,6 @@ public:
|
|||
size_t dmaBlockSize = 0;
|
||||
bool send3Complete = false;
|
||||
|
||||
std::unique_ptr<u8[]> fifoInBackup;
|
||||
size_t fifoInBackupSize;
|
||||
std::unique_ptr<u8[]> fifoOutBackup;
|
||||
size_t fifoOutBackupSize;
|
||||
|
||||
Sio2();
|
||||
~Sio2();
|
||||
|
||||
|
|
Loading…
Reference in New Issue