From a66cb36cc79dc9ecefd9e78441b321153ed4ac95 Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Tue, 10 Oct 2017 21:31:01 +0300 Subject: Rewind feature and RAM savestates. This starts the work requested in #2398. How RAM states work. Implemented using util::vectorstream. Instead of dumping m_save.m_entry_list to file, it writes them as binary to vectorstream. Compression is not used, as it would slow down the process. The header is written as usual, also in binary. When a state is loaded, the savestate data gets binary-read from vectorstream. How rewind works. Rewind is optional, it can be turned off through MAME GUI while not running. Rewind capacity is available there too. Rewind step hotkey is available from the standard hotkey menu. In the debugger you have the "rewind" command ("rw" shortcut) that works the same as the hotkey. Every time you advance a frame (pause step), rewinder captures a RAM savestate of the frame you were at. It does the same when you do step into/over/out in the debugger. Every time it captures a new state (and when you unpause), it marks as invalid all its states that go after the current machine time, because input might change, so they are not relevant anymore. It keeps their buffers allocated though, for future use. When rewinder runs out of allowed amount of savestates it can have, it invalidates the first state in the list and tosses its unique_ptr to the end of the list, then it uses its buffer to capture a new state. When you hit the rewind step key, or use "rewind" command in the debugger, it loads a state that is immediately before the current machine time. Invalid states between valid ones are not allowed to appear, as that breaks rewinder integrity and causes problems. Rewinder keeps its own set of ram states as a vector of unique_ptr's. All rewinder operations and errors get reported using machine().popmessage(). --- src/emu/emuopts.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/emu/emuopts.cpp') diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index 11e369f0aca..12e674718d9 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -62,6 +62,8 @@ const options_entry emu_options::s_option_entries[] = { nullptr, nullptr, OPTION_HEADER, "CORE STATE/PLAYBACK OPTIONS" }, { OPTION_STATE, nullptr, OPTION_STRING, "saved state to load" }, { OPTION_AUTOSAVE, "0", OPTION_BOOLEAN, "enable automatic restore at startup, and automatic save at exit time" }, + { OPTION_REWIND, "1", OPTION_BOOLEAN, "enable rewind savestates" }, + { OPTION_REWIND_CAPACITY "(1-500)", "100", OPTION_INTEGER, "quantity of states rewind buffer can contain" }, { OPTION_PLAYBACK ";pb", nullptr, OPTION_STRING, "playback an input file" }, { OPTION_RECORD ";rec", nullptr, OPTION_STRING, "record an input file" }, { OPTION_RECORD_TIMECODE, "0", OPTION_BOOLEAN, "record an input timecode file (requires -record option)" }, -- cgit v1.2.3-70-g09d2 From 6bec01265d403bac70c740e0c3a69c51b3073ba9 Mon Sep 17 00:00:00 2001 From: Robbbert Date: Fri, 8 Dec 2017 00:42:01 +1100 Subject: (nw) fixed typo, and rewind off by default. --- src/emu/debug/debughlp.cpp | 2 +- src/emu/emuopts.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/emu/emuopts.cpp') diff --git a/src/emu/debug/debughlp.cpp b/src/emu/debug/debughlp.cpp index 3a34030a59f..f25d52b3ae7 100644 --- a/src/emu/debug/debughlp.cpp +++ b/src/emu/debug/debughlp.cpp @@ -462,7 +462,7 @@ static const help_item static_help_list[] = "\n" "The rewind command loads the most recent RAM-based state. Rewind states, when enabled, are " "saved when \"step\", \"over\", or \"out\" command gets executed, storing the machine state as " - "of the moment before actually steping. Consecutively loading rewind states can work like " + "of the moment before actually stepping. Consecutively loading rewind states can work like " "reverse execution. Depending on which steps forward were taken previously, the bahavior can " "be similar to GDB's \"reverse-stepi\" or \"reverse-next\". All output for this command is " "currently echoed into the running machine window. Previous memory and PC tracking statistics " diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index 12e674718d9..4fd91155fd2 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -62,7 +62,7 @@ const options_entry emu_options::s_option_entries[] = { nullptr, nullptr, OPTION_HEADER, "CORE STATE/PLAYBACK OPTIONS" }, { OPTION_STATE, nullptr, OPTION_STRING, "saved state to load" }, { OPTION_AUTOSAVE, "0", OPTION_BOOLEAN, "enable automatic restore at startup, and automatic save at exit time" }, - { OPTION_REWIND, "1", OPTION_BOOLEAN, "enable rewind savestates" }, + { OPTION_REWIND, "0", OPTION_BOOLEAN, "enable rewind savestates" }, { OPTION_REWIND_CAPACITY "(1-500)", "100", OPTION_INTEGER, "quantity of states rewind buffer can contain" }, { OPTION_PLAYBACK ";pb", nullptr, OPTION_STRING, "playback an input file" }, { OPTION_RECORD ";rec", nullptr, OPTION_STRING, "record an input file" }, -- cgit v1.2.3-70-g09d2