Simplify savestate code so it's all automagical.
If you can't beat 'em, join 'em?
This commit is contained in:
parent
8f10c7f161
commit
a4032c5170
9 changed files with 108 additions and 165 deletions
|
@ -103,6 +103,8 @@ typedef std::map<int, PsmfStream *> PsmfStreamMap;
|
|||
|
||||
class Psmf {
|
||||
public:
|
||||
// For savestates only.
|
||||
Psmf() {}
|
||||
Psmf(u32 data);
|
||||
~Psmf();
|
||||
void DoState(PointerWrap &p);
|
||||
|
@ -142,6 +144,8 @@ public:
|
|||
|
||||
class PsmfPlayer {
|
||||
public:
|
||||
// For savestates only.
|
||||
PsmfPlayer() {}
|
||||
PsmfPlayer(u32 data);
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
|
@ -164,6 +168,10 @@ public:
|
|||
|
||||
class PsmfStream {
|
||||
public:
|
||||
// Used for save states.
|
||||
PsmfStream() {
|
||||
}
|
||||
|
||||
PsmfStream(int type, int channel) {
|
||||
this->type = type;
|
||||
this->channel = channel;
|
||||
|
@ -245,10 +253,6 @@ Psmf::~Psmf() {
|
|||
}
|
||||
|
||||
PsmfPlayer::PsmfPlayer(u32 data) {
|
||||
// Used for savestates.
|
||||
if (data == 0) {
|
||||
return;
|
||||
}
|
||||
videoCodec = Memory::Read_U32(data);
|
||||
videoStreamNum = Memory::Read_U32(data + 4);
|
||||
audioCodec = Memory::Read_U32(data + 8);
|
||||
|
@ -282,23 +286,7 @@ void Psmf::DoState(PointerWrap &p) {
|
|||
p.Do(audioChannels);
|
||||
p.Do(audioFrequency);
|
||||
|
||||
int n = (int) streamMap.size();
|
||||
p.Do(n);
|
||||
if (p.mode == p.MODE_READ) {
|
||||
// Already empty, if we're reading this is brand new.
|
||||
for (int i = 0; i < n; ++i) {
|
||||
int key;
|
||||
p.Do(key);
|
||||
PsmfStream *stream = new PsmfStream(0, 0);
|
||||
stream->DoState(p);
|
||||
streamMap[key] = stream;
|
||||
}
|
||||
} else {
|
||||
for (auto it = streamMap.begin(), end = streamMap.end(); it != end; ++it) {
|
||||
p.Do(it->first);
|
||||
it->second->DoState(p);
|
||||
}
|
||||
}
|
||||
p.Do(streamMap);
|
||||
|
||||
p.DoMarker("Psmf");
|
||||
}
|
||||
|
@ -350,58 +338,28 @@ void __PsmfInit()
|
|||
|
||||
void __PsmfDoState(PointerWrap &p)
|
||||
{
|
||||
int n = (int) psmfMap.size();
|
||||
p.Do(n);
|
||||
if (p.mode == p.MODE_READ) {
|
||||
std::map<u32, Psmf *>::iterator it, end;
|
||||
for (it = psmfMap.begin(), end = psmfMap.end(); it != end; ++it) {
|
||||
delete it->second;
|
||||
}
|
||||
psmfMap.clear();
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
u32 key;
|
||||
p.Do(key);
|
||||
Psmf *psmf = new Psmf(0);
|
||||
psmf->DoState(p);
|
||||
psmfMap[key] = psmf;
|
||||
}
|
||||
} else {
|
||||
std::map<u32, Psmf *>::iterator it, end;
|
||||
for (it = psmfMap.begin(), end = psmfMap.end(); it != end; ++it) {
|
||||
p.Do(it->first);
|
||||
it->second->DoState(p);
|
||||
}
|
||||
}
|
||||
p.Do(psmfMap);
|
||||
|
||||
p.DoMarker("scePsmf");
|
||||
}
|
||||
|
||||
void __PsmfPlayerDoState(PointerWrap &p)
|
||||
{
|
||||
int n = (int) psmfPlayerMap.size();
|
||||
p.Do(n);
|
||||
if (p.mode == p.MODE_READ) {
|
||||
std::map<u32, PsmfPlayer *>::iterator it, end;
|
||||
for (it = psmfPlayerMap.begin(), end = psmfPlayerMap.end(); it != end; ++it) {
|
||||
delete it->second;
|
||||
}
|
||||
psmfMap.clear();
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
u32 key;
|
||||
p.Do(key);
|
||||
PsmfPlayer *psmfplayer = new PsmfPlayer(0);
|
||||
psmfplayer->DoState(p);
|
||||
psmfPlayerMap[key] = psmfplayer;
|
||||
}
|
||||
} else {
|
||||
std::map<u32, PsmfPlayer *>::iterator it, end;
|
||||
for (it = psmfPlayerMap.begin(), end = psmfPlayerMap.end(); it != end; ++it) {
|
||||
p.Do(it->first);
|
||||
it->second->DoState(p);
|
||||
}
|
||||
}
|
||||
p.Do(psmfPlayerMap);
|
||||
|
||||
// TODO: Actually load this from a map.
|
||||
psmfPlayerStatus = PSMF_PLAYER_STATUS_NONE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue