save state handling for entering and leaving the debugger modified.

This commit is contained in:
thrust26 2017-10-13 15:29:20 +02:00
parent 44f7029573
commit cdb2e18324
3 changed files with 11 additions and 7 deletions

View File

@ -29,6 +29,7 @@ RewindManager::RewindManager(OSystem& system, StateManager& statemgr)
: myOSystem(system), : myOSystem(system),
myStateManager(statemgr), myStateManager(statemgr),
myIsNTSC(true) // TODO myIsNTSC(true) // TODO
// TODO: current is not valid
{ {
} }
@ -42,6 +43,7 @@ bool RewindManager::addState(const string& message)
compressStates(); compressStates();
RewindState& state = myStateList.addFirst(); RewindState& state = myStateList.addFirst();
// TODO: addFirst() must set current() to the just added element
Serializer& s = state.data; Serializer& s = state.data;
s.reset(); // rewind Serializer internal buffers s.reset(); // rewind Serializer internal buffers
@ -60,7 +62,9 @@ bool RewindManager::rewindState()
if(!myStateList.empty()) if(!myStateList.empty())
{ {
// TODO: get state previous to the current state instead of first() // TODO: get state previous to the current state instead of first()
RewindState& state = myStateList.first(); // RewindState& state = myStateList.current();
// myStateList.prev(); // moves current to the previous (older) element
RewindState& state = myStateList.first(); // TOOD: remove
Serializer& s = state.data; Serializer& s = state.data;
string message = getMessage(state); string message = getMessage(state);
@ -72,7 +76,7 @@ bool RewindManager::rewindState()
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showMessage(message);
// TODO: Do NOT remove state (TODO later somewhere else: stop emulation) // TODO: Do NOT remove state (TODO later somewhere else: stop emulation)
myStateList.removeFirst(); myStateList.removeFirst(); // TODO: delete this
return true; return true;
} }

View File

@ -528,10 +528,7 @@ void Debugger::setStartState()
// Lock the bus each time the debugger is entered, so we don't disturb anything // Lock the bus each time the debugger is entered, so we don't disturb anything
lockBankswitchState(); lockBankswitchState();
// If rewinding is not enabled, always start the debugger with a clean list
RewindManager& r = myOSystem.state().rewindManager(); RewindManager& r = myOSystem.state().rewindManager();
if(myOSystem.state().mode() == StateManager::Mode::Off)
r.clear();
myDialog->rewindButton().setEnabled(!r.atLast()); myDialog->rewindButton().setEnabled(!r.atLast());
myDialog->unwindButton().setEnabled(!r.atFirst()); myDialog->unwindButton().setEnabled(!r.atFirst());
@ -548,6 +545,9 @@ void Debugger::setQuitState()
// Bus must be unlocked for normal operation when leaving debugger mode // Bus must be unlocked for normal operation when leaving debugger mode
unlockBankswitchState(); unlockBankswitchState();
// Save state when leaving the debugger
saveOldState("exit debugger");
// execute one instruction on quit. If we're // execute one instruction on quit. If we're
// sitting at a breakpoint/trap, this will get us past it. // sitting at a breakpoint/trap, this will get us past it.
// Somehow this feels like a hack to me, but I don't know why // Somehow this feels like a hack to me, but I don't know why