mirror of https://github.com/PCSX2/pcsx2.git
USB: savestate bump + initial sstate implem for usb
This commit is contained in:
parent
0c43fa92e5
commit
90c9686684
|
@ -24,7 +24,7 @@
|
|||
// the lower 16 bit value. IF the change is breaking of all compatibility with old
|
||||
// states, increment the upper 16 bit value, and clear the lower 16 bits to 0.
|
||||
|
||||
static const u32 g_SaveVersion = (0x9A0F << 16) | 0x0000;
|
||||
static const u32 g_SaveVersion = (0x9A10 << 16) | 0x0000;
|
||||
|
||||
// this function is meant to be used in the place of GSfreeze, and provides a safe layer
|
||||
// between the GS saving function and the MTGS's needs. :)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <cerrno>
|
||||
#include <cassert>
|
||||
|
||||
#include "Utilities/pxStreams.h"
|
||||
#include "USB.h"
|
||||
#include "osdebugout.h"
|
||||
#include "qemu-usb/USBinternal.h"
|
||||
|
@ -649,3 +650,49 @@ s64 get_clock()
|
|||
{
|
||||
return clocks;
|
||||
}
|
||||
|
||||
void USBDoFreezeOut(void* dest)
|
||||
{
|
||||
freezeData fP = {0, (s8*)dest};
|
||||
if (USBfreeze(FREEZE_SIZE, &fP) != 0)
|
||||
return;
|
||||
if (!fP.size)
|
||||
return;
|
||||
|
||||
Console.Indent().WriteLn("Saving USB");
|
||||
|
||||
if (USBfreeze(FREEZE_SAVE, &fP) != 0)
|
||||
throw std::runtime_error(" * USB: Error saving state!\n");
|
||||
}
|
||||
|
||||
|
||||
void USBDoFreezeIn(pxInputStream& infp)
|
||||
{
|
||||
freezeData fP = {0, nullptr};
|
||||
if (USBfreeze(FREEZE_SIZE, &fP) != 0)
|
||||
fP.size = 0;
|
||||
|
||||
Console.Indent().WriteLn("Loading USB");
|
||||
|
||||
if (!infp.IsOk() || !infp.Length())
|
||||
{
|
||||
// no state data to read, but SPU2 expects some state data?
|
||||
// Issue a warning to console...
|
||||
if (fP.size != 0)
|
||||
Console.Indent().Warning("Warning: No data for USB found. Status may be unpredictable.");
|
||||
|
||||
return;
|
||||
|
||||
// Note: Size mismatch check could also be done here on loading, but
|
||||
// some plugins may have built-in version support for non-native formats or
|
||||
// older versions of a different size... or could give different sizes depending
|
||||
// on the status of the plugin when loading, so let's ignore it.
|
||||
}
|
||||
|
||||
ScopedAlloc<s8> data(fP.size);
|
||||
fP.data = data.GetPtr();
|
||||
|
||||
infp.Read(fP.data, fP.size);
|
||||
if (USBfreeze(FREEZE_LOAD, &fP) != 0)
|
||||
throw std::runtime_error(" * USB: Error loading state!\n");
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@ void USBwrite8(u32 addr, u8 value);
|
|||
void USBwrite16(u32 addr, u16 value);
|
||||
void USBwrite32(u32 addr, u32 value);
|
||||
|
||||
void USBDoFreezeOut(void* dest);
|
||||
void USBDoFreezeIn(pxInputStream& infp);
|
||||
|
||||
|
||||
void USBsetRAM(void* mem);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "ZipTools/ThreadedZipTools.h"
|
||||
#include "Utilities/pxStreams.h"
|
||||
#include "SPU2/spu2.h"
|
||||
#include "USB/USB.h"
|
||||
|
||||
#include "ConsoleLogger.h"
|
||||
|
||||
|
@ -264,6 +265,30 @@ public:
|
|||
bool IsRequired() const { return true; }
|
||||
};
|
||||
|
||||
class SavestateEntry_USB : public BaseSavestateEntry
|
||||
{
|
||||
public:
|
||||
virtual ~SavestateEntry_USB() = default;
|
||||
|
||||
wxString GetFilename() const { return L"USB.bin"; }
|
||||
void FreezeIn(pxInputStream& reader) const { return USBDoFreezeIn(reader); }
|
||||
void FreezeOut(SaveStateBase& writer) const
|
||||
{
|
||||
int size = 0;
|
||||
freezeData fP = {0, NULL};
|
||||
if (USBfreeze(FREEZE_SIZE, &fP) == 0)
|
||||
{
|
||||
size = fP.size;
|
||||
writer.PrepBlock(size);
|
||||
USBDoFreezeOut(writer.GetBlockPtr());
|
||||
writer.CommitBlock(size);
|
||||
}
|
||||
return;
|
||||
}
|
||||
bool IsRequired() const { return true; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// [TODO] : Add other components as files to the savestate gzip?
|
||||
|
@ -286,6 +311,7 @@ static const std::unique_ptr<BaseSavestateEntry> SavestateEntries[] = {
|
|||
std::unique_ptr<BaseSavestateEntry>(new SavestateEntry_VU0prog),
|
||||
std::unique_ptr<BaseSavestateEntry>(new SavestateEntry_VU1prog),
|
||||
std::unique_ptr<BaseSavestateEntry>(new SavestateEntry_SPU2),
|
||||
std::unique_ptr<BaseSavestateEntry>(new SavestateEntry_USB),
|
||||
|
||||
std::unique_ptr<BaseSavestateEntry>(new PluginSavestateEntry(PluginId_GS)),
|
||||
std::unique_ptr<BaseSavestateEntry>(new PluginSavestateEntry(PluginId_PAD)),
|
||||
|
|
Loading…
Reference in New Issue