thefox wrote:
...would be cool to see a proof-of-concept implementation of this, even if it's not the most optimal.
I've managed to get it working - only took a couple of hours or so. Surprisingly ended up being pretty simple to add.
It has some limitations (in order to keep the code simple), but I think it's probably good enough for what you would typically need it for.
Essentially, whenever you do "step back", it reloads the last save state, and keeps running (replaying previous input) to the previous instruction's PC.
So it can't rewind past the last save state (so if the save state was taken 5 cycles ago, you'll only be able to rewind that far - but that's a pretty low probability, and I doubt anybody is going to start rewinding thousands of instructions).
Performance wasn't that great depending on how far the execution was to the last save state, so I added a save state cache for the last 100 cycles (e.g ~25-50 instructions) before the first step. On the first step back it makes a save state every instruction for the last 100 cycles before the target instruction, then it uses that cache until its empty and repeats the process. With this, stepping back is more or less as fast as stepping forward.
I made a preview build (windows-only, the code is on GitHub if you're using Linux) if anyone feels like giving it a try:
linkIf you've ever used Mesen before, the emulator will most likely crash unless you remove the settings.xml file in the Documents\Mesen folder (because of other changes I've recently done to the settings.xml format that won't be upgraded properly since the build isn't marked as version 0.9.1)
I didn't test this all that much, so if you test it and see anything odd, let me know.