diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 308ec73a0..1f4a5c16a 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -270,7 +270,7 @@ void Debugger::loadState(int state) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int Debugger::step() { - mySystem.clearDirtyPages(); + saveOldState(); uInt64 startCycle = mySystem.cycles(); @@ -278,7 +278,7 @@ int Debugger::step() myOSystem.console().tia().updateScanlineByStep().flushLineCache(); lockBankswitchState(); - saveOldState("step"); + addState("step"); return int(mySystem.cycles() - startCycle); } @@ -297,7 +297,7 @@ int Debugger::trace() // 32 is the 6502 JSR instruction: if(mySystem.peek(myCpuDebug->pc()) == 32) { - mySystem.clearDirtyPages(); + saveOldState(); uInt64 startCycle = mySystem.cycles(); int targetPC = myCpuDebug->pc() + 3; // return address @@ -306,7 +306,7 @@ int Debugger::trace() myOSystem.console().tia().updateScanlineByTrace(targetPC).flushLineCache(); lockBankswitchState(); - saveOldState("trace"); + addState("trace"); return int(mySystem.cycles() - startCycle); } else @@ -485,7 +485,7 @@ void Debugger::nextScanline(int lines) ostringstream buf; buf << "scanline + " << lines; - mySystem.clearDirtyPages(); + saveOldState(); unlockBankswitchState(); while(lines) @@ -495,7 +495,7 @@ void Debugger::nextScanline(int lines) } lockBankswitchState(); - saveOldState(buf.str()); + addState(buf.str()); myOSystem.console().tia().flushLineCache(); } @@ -505,7 +505,7 @@ void Debugger::nextFrame(int frames) ostringstream buf; buf << "frame + " << frames; - mySystem.clearDirtyPages(); + saveOldState(); unlockBankswitchState(); while(frames) @@ -515,7 +515,7 @@ void Debugger::nextFrame(int frames) } lockBankswitchState(); - saveOldState(buf.str()); + addState(buf.str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -588,20 +588,24 @@ bool Debugger::patchROM(uInt16 addr, uInt8 value) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::saveOldState(string rewindMsg) +void Debugger::saveOldState(bool clearDirtyPages) { + if (clearDirtyPages) + mySystem.clearDirtyPages(); + myCartDebug->saveOldState(); myCpuDebug->saveOldState(); myRiotDebug->saveOldState(); myTiaDebug->saveOldState(); +} - // Add another rewind level to the Undo list - if(rewindMsg != "") - { - RewindManager& r = myOSystem.state().rewindManager(); - r.addState(rewindMsg); - updateRewindbuttons(r); - } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::addState(string rewindMsg) +{ + // Add another rewind level to the Time Machine buffer + RewindManager& r = myOSystem.state().rewindManager(); + r.addState(rewindMsg); + updateRewindbuttons(r); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -612,7 +616,9 @@ void Debugger::setStartState() // Save initial state and add it to the rewind list (except when in currently rewinding) RewindManager& r = myOSystem.state().rewindManager(); - saveOldState(r.atLast() ? "enter debugger" : ""); + saveOldState(false); + if (r.atLast()) + addState("enter debugger"); // Set the 're-disassemble' flag, but don't do it until the next scheduled time myDialog->rom().invalidate(false); diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 293063b22..900f064d8 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -241,12 +241,15 @@ class Debugger : public DialogContainer private: /** - Save state of each debugger subsystem. - - If a message is provided, we assume that a rewind state should - be saved with the given message. + Save state of each debugger subsystem and, by default, mark all + pages as clean (ie, turn off the dirty flag). */ - void saveOldState(string rewindMsg = ""); + void saveOldState(bool clearDirtyPages = true); + + /** + Saves a rewind state with the given message. + */ + void addState(string rewindMsg); /** Set initial state before entering the debugger. diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 21b49c3ed..ba0387944 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -233,7 +233,7 @@ bool M6502::execute(uInt32 number) cond = evalCondSaveStates(); if(cond > -1) { - myDebugger->saveOldState("conditional savestate"); + myDebugger->addState("conditional savestate"); } #endif // DEBUGGER_SUPPORT