mirror of https://github.com/stella-emu/stella.git
added extra save state when starting time machine navigation
(some TODOs left, see EventHandler and TimeMachineDialog)
This commit is contained in:
parent
2c90aaa7c7
commit
d2177ea610
|
@ -138,7 +138,7 @@ bool RewindManager::addState(const string& message, bool timeMachine)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt32 RewindManager::rewindState(uInt32 numStates)
|
uInt32 RewindManager::rewindStates(uInt32 numStates)
|
||||||
{
|
{
|
||||||
uInt64 startCycles = myOSystem.console().tia().cycles();
|
uInt64 startCycles = myOSystem.console().tia().cycles();
|
||||||
uInt32 i;
|
uInt32 i;
|
||||||
|
@ -177,7 +177,7 @@ uInt32 RewindManager::rewindState(uInt32 numStates)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt32 RewindManager::unwindState(uInt32 numStates)
|
uInt32 RewindManager::unwindStates(uInt32 numStates)
|
||||||
{
|
{
|
||||||
uInt64 startCycles = myOSystem.console().tia().cycles();
|
uInt64 startCycles = myOSystem.console().tia().cycles();
|
||||||
uInt32 i;
|
uInt32 i;
|
||||||
|
@ -210,6 +210,16 @@ uInt32 RewindManager::unwindState(uInt32 numStates)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
uInt32 RewindManager::windStates(uInt32 numStates, bool unwind)
|
||||||
|
{
|
||||||
|
if(unwind)
|
||||||
|
return unwindStates(numStates);
|
||||||
|
else
|
||||||
|
return rewindStates(numStates);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void RewindManager::compressStates()
|
void RewindManager::compressStates()
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,22 +106,32 @@ class RewindManager
|
||||||
bool addState(const string& message, bool timeMachine = false);
|
bool addState(const string& message, bool timeMachine = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Rewind one level of the state list, and display the message associated
|
Rewind numStates levels of the state list, and display the message associated
|
||||||
with that state.
|
with that state.
|
||||||
|
|
||||||
@param numStates Number of states to rewind
|
@param numStates Number of states to rewind
|
||||||
@return Number of states to rewinded
|
@return Number of states to rewinded
|
||||||
*/
|
*/
|
||||||
uInt32 rewindState(uInt32 numStates = 1);
|
uInt32 rewindStates(uInt32 numStates = 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Unwind one level of the state list, and display the message associated
|
Unwind numStates levels of the state list, and display the message associated
|
||||||
with that state.
|
with that state.
|
||||||
|
|
||||||
@param numStates Number of states to unwind
|
@param numStates Number of states to unwind
|
||||||
@return Number of states to unwinded
|
@return Number of states to unwinded
|
||||||
*/
|
*/
|
||||||
uInt32 unwindState(uInt32 numStates = 1);
|
uInt32 unwindStates(uInt32 numStates = 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Rewind/unwind numStates levels of the state list, and display the message associated
|
||||||
|
with that state.
|
||||||
|
|
||||||
|
@param numStates Number of states to wind
|
||||||
|
@param unwind unwind or rewind
|
||||||
|
@return Number of states to winded
|
||||||
|
*/
|
||||||
|
uInt32 windStates(uInt32 numStates, bool unwind);
|
||||||
|
|
||||||
bool atFirst() const { return myStateList.atFirst(); }
|
bool atFirst() const { return myStateList.atFirst(); }
|
||||||
bool atLast() const { return myStateList.atLast(); }
|
bool atLast() const { return myStateList.atLast(); }
|
||||||
|
|
|
@ -142,17 +142,31 @@ void StateManager::toggleTimeMachine()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool StateManager::rewindState(uInt32 numStates)
|
bool StateManager::addState(const string& message, bool timeMachine)
|
||||||
{
|
{
|
||||||
RewindManager& r = myOSystem.state().rewindManager();
|
RewindManager& r = myOSystem.state().rewindManager();
|
||||||
return r.rewindState(numStates);
|
return r.addState(message, timeMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool StateManager::unwindState(uInt32 numStates)
|
bool StateManager::rewindStates(uInt32 numStates)
|
||||||
{
|
{
|
||||||
RewindManager& r = myOSystem.state().rewindManager();
|
RewindManager& r = myOSystem.state().rewindManager();
|
||||||
return r.unwindState(numStates);
|
return r.rewindStates(numStates);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool StateManager::unwindStates(uInt32 numStates)
|
||||||
|
{
|
||||||
|
RewindManager& r = myOSystem.state().rewindManager();
|
||||||
|
return r.unwindStates(numStates);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool StateManager::windStates(uInt32 numStates, bool unwind)
|
||||||
|
{
|
||||||
|
RewindManager& r = myOSystem.state().rewindManager();
|
||||||
|
return r.windStates(numStates, unwind);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -72,14 +72,24 @@ class StateManager
|
||||||
void setRewindMode(Mode mode) { myActiveMode = mode; }
|
void setRewindMode(Mode mode) { myActiveMode = mode; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Rewinds one state; this uses the RewindManager for its functionality.
|
Adds one state ; this uses the RewindManager for its functionality.
|
||||||
*/
|
*/
|
||||||
bool rewindState(uInt32 numStates = 1);
|
bool addState(const string& message, bool timeMachine = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Unwinds one state; this uses the RewindManager for its functionality.
|
Rewinds states; this uses the RewindManager for its functionality.
|
||||||
*/
|
*/
|
||||||
bool unwindState(uInt32 numStates = 1);
|
bool rewindStates(uInt32 numStates = 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Unwinds states; this uses the RewindManager for its functionality.
|
||||||
|
*/
|
||||||
|
bool unwindStates(uInt32 numStates = 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Rewinds/unwinds states; this uses the RewindManager for its functionality.
|
||||||
|
*/
|
||||||
|
bool windStates(uInt32 numStates, bool unwind);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Updates the state of the system based on the currently active mode.
|
Updates the state of the system based on the currently active mode.
|
||||||
|
|
|
@ -538,7 +538,7 @@ uInt16 Debugger::windStates(uInt16 numStates, bool unwind, string& message)
|
||||||
unlockBankswitchState();
|
unlockBankswitchState();
|
||||||
|
|
||||||
uInt64 startCycles = myOSystem.console().tia().cycles();
|
uInt64 startCycles = myOSystem.console().tia().cycles();
|
||||||
uInt16 winds = unwind ? r.unwindState(numStates) : r.rewindState(numStates);
|
uInt16 winds = r.windStates(numStates, unwind);
|
||||||
message = r.getUnitString(myOSystem.console().tia().cycles() - startCycles);
|
message = r.getUnitString(myOSystem.console().tia().cycles() - startCycles);
|
||||||
|
|
||||||
lockBankswitchState();
|
lockBankswitchState();
|
||||||
|
|
|
@ -300,27 +300,19 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
case KBDK_LEFT: // Alt-left(-shift) rewinds 1(10) states
|
case KBDK_LEFT: // Alt-left(-shift) rewinds 1(10) states
|
||||||
myOSystem.frameBuffer().setPauseDelay();
|
enterTimeMachineMenuMode((StellaModTest::isShift(mod) && state) ? 10 : 1, false);
|
||||||
setEventState(EventHandlerState::PAUSE);
|
|
||||||
myOSystem.state().rewindState((StellaModTest::isShift(mod) && state) ? 10 : 1);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KBDK_RIGHT: // Alt-right(-shift) unwinds 1(10) states
|
case KBDK_RIGHT: // Alt-right(-shift) unwinds 1(10) states
|
||||||
myOSystem.frameBuffer().setPauseDelay();
|
enterTimeMachineMenuMode((StellaModTest::isShift(mod) && state) ? 10 : 1, true);
|
||||||
setEventState(EventHandlerState::PAUSE);
|
|
||||||
myOSystem.state().unwindState((StellaModTest::isShift(mod) && state) ? 10 : 1);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KBDK_DOWN: // Alt-down rewinds to start of list
|
case KBDK_DOWN: // Alt-down rewinds to start of list
|
||||||
myOSystem.frameBuffer().setPauseDelay();
|
enterTimeMachineMenuMode(1000, false);
|
||||||
setEventState(EventHandlerState::PAUSE);
|
|
||||||
myOSystem.state().rewindState(1000);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KBDK_UP: // Alt-up rewinds to end of list
|
case KBDK_UP: // Alt-up rewinds to end of list
|
||||||
myOSystem.frameBuffer().setPauseDelay();
|
enterTimeMachineMenuMode(1000, true);
|
||||||
setEventState(EventHandlerState::PAUSE);
|
|
||||||
myOSystem.state().unwindState(1000);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1223,14 +1215,14 @@ bool EventHandler::eventStateChange(Event::Type type)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::OptionsMenuMode:
|
case Event::OptionsMenuMode:
|
||||||
if(myState == EventHandlerState::EMULATION)
|
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
|
||||||
enterMenuMode(EventHandlerState::OPTIONSMENU);
|
enterMenuMode(EventHandlerState::OPTIONSMENU);
|
||||||
else
|
else
|
||||||
handled = false;
|
handled = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::CmdMenuMode:
|
case Event::CmdMenuMode:
|
||||||
if(myState == EventHandlerState::EMULATION)
|
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
|
||||||
enterMenuMode(EventHandlerState::CMDMENU);
|
enterMenuMode(EventHandlerState::CMDMENU);
|
||||||
else if(myState == EventHandlerState::CMDMENU)
|
else if(myState == EventHandlerState::CMDMENU)
|
||||||
leaveMenuMode();
|
leaveMenuMode();
|
||||||
|
@ -1239,7 +1231,7 @@ bool EventHandler::eventStateChange(Event::Type type)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::TimeMachineMode:
|
case Event::TimeMachineMode:
|
||||||
if(myState == EventHandlerState::EMULATION)
|
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
|
||||||
enterMenuMode(EventHandlerState::TIMEMACHINE);
|
enterMenuMode(EventHandlerState::TIMEMACHINE);
|
||||||
else if(myState == EventHandlerState::TIMEMACHINE)
|
else if(myState == EventHandlerState::TIMEMACHINE)
|
||||||
leaveMenuMode();
|
leaveMenuMode();
|
||||||
|
@ -1248,8 +1240,7 @@ bool EventHandler::eventStateChange(Event::Type type)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::DebuggerMode:
|
case Event::DebuggerMode:
|
||||||
if(myState == EventHandlerState::EMULATION
|
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE
|
||||||
|| myState == EventHandlerState::PAUSE
|
|
||||||
|| myState == EventHandlerState::TIMEMACHINE)
|
|| myState == EventHandlerState::TIMEMACHINE)
|
||||||
enterDebugMode();
|
enterDebugMode();
|
||||||
else if(myState == EventHandlerState::DEBUGGER)
|
else if(myState == EventHandlerState::DEBUGGER)
|
||||||
|
@ -2141,6 +2132,19 @@ void EventHandler::leaveDebugMode()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void EventHandler::enterTimeMachineMenuMode(uInt32 numWinds, bool unwind)
|
||||||
|
{
|
||||||
|
// TODO: maybe remove this state if we leave the menu at the last state
|
||||||
|
myOSystem.state().addState("enter Time Machine menu", false); // force new state
|
||||||
|
myOSystem.state().windStates(numWinds, unwind);
|
||||||
|
|
||||||
|
// TODO: probably this check is not necessary
|
||||||
|
if(myState != EventHandlerState::TIMEMACHINE)
|
||||||
|
// TODO: display last wind message in time machine dialog
|
||||||
|
enterMenuMode(EventHandlerState::TIMEMACHINE);
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void EventHandler::setEventState(EventHandlerState state)
|
void EventHandler::setEventState(EventHandlerState state)
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,6 +137,7 @@ class EventHandler
|
||||||
void leaveMenuMode();
|
void leaveMenuMode();
|
||||||
bool enterDebugMode();
|
bool enterDebugMode();
|
||||||
void leaveDebugMode();
|
void leaveDebugMode();
|
||||||
|
void enterTimeMachineMenuMode(uInt32 numWinds, bool unwind);
|
||||||
void takeSnapshot(uInt32 number = 0);
|
void takeSnapshot(uInt32 number = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -383,10 +383,11 @@ void TimeMachineDialog::handleWinds(Int32 numWinds)
|
||||||
if(numWinds)
|
if(numWinds)
|
||||||
{
|
{
|
||||||
uInt64 startCycles = instance().console().tia().cycles();
|
uInt64 startCycles = instance().console().tia().cycles();
|
||||||
if(numWinds < 0) r.rewindState(-numWinds);
|
if(numWinds < 0) r.rewindStates(-numWinds);
|
||||||
else if(numWinds > 0) r.unwindState(numWinds);
|
else if(numWinds > 0) r.unwindStates(numWinds);
|
||||||
string message = r.getUnitString(instance().console().tia().cycles() - startCycles);
|
string message = r.getUnitString(instance().console().tia().cycles() - startCycles);
|
||||||
|
|
||||||
|
// TODO: add message text from addState()
|
||||||
myMessageWidget->setLabel((numWinds < 0 ? "(-" : "(+") + message + ")");
|
myMessageWidget->setLabel((numWinds < 0 ? "(-" : "(+") + message + ")");
|
||||||
}
|
}
|
||||||
// Update time
|
// Update time
|
||||||
|
|
Loading…
Reference in New Issue