hrydgard/ppsspp — pull request #266 by unknownbrackets (2012-12-27 07:10:21+00:00)
Title: Initial progress on savestates (requesting review only)

Wanted to make sure I was following a reasonable path before going off into crazyville. More than happy to correct or change this to a better way as appropriate.

So far, this just implements saving/loading kernel objects, and not really very much tested yet either (unless you count "it hasn't crashed yet," which I don't.)

I basically just used a factory and the TMID enum, although it means adding kernel objects is a pain, I don't think there are all that many more to add. My usual approach is to change only what ought to be changed, so I used static funcs instead of e.g. moving all the classes to .h files and using a static method or forcing them to have no-args constructors.

But, I'd appreciate any feedback on this approach.

After this I have on my list:
* module state
* CPU state
* RAM (already done)
* Memstick state (just one var)
* GPU state (no idea how to do this)
* Timer state
* PPGe state

What I'm not sure on yet:
* I'm not sure where to put the savestate bootstrap code. Saw some declarations in HLE.h but feel that's the wrong place. Maybe a new file, or just sceKernel.cpp?

* Saving/restoring physical file handles sounds annoying, planning to leave fixing that for later since a good percentage of games will only have umd stuff open I hope.

* GPU state seems like it ought to be not-that-hard but I don't know where to start.
where to put

* Is it naive to assume I don't need to save anything about the jit? I think I don't.

* How much latency is acceptable for save states / how does one normally implement them in conjunction with jit (possible stupid question alert)? I was thinking of waiting for a Core::Advance() to actually execute the save / load operation to ensure nothing goes haywire.

* Can I safely ignore the DirectSound / etc. side of audio state? e.g. just save the module data and call it a day?

-[Unknown]