keys for rewind/unwind from within emulator added (start pause mode and work in pause mode too)

entering debugger from pause mode allowed (TODO: allow more functions)
"Pause" displays always immediately
This commit is contained in:
thrust26 2017-10-14 12:22:21 +02:00
parent 474c9941d5
commit ff57f271ea
5 changed files with 66 additions and 9 deletions

View File

@ -134,6 +134,22 @@ void StateManager::toggleRewindMode()
myOSystem.frameBuffer().showMessage("Continuous rewind disabled");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::rewindState()
{
RewindManager& r = myOSystem.state().rewindManager();
// TODO: add parameter to indicate rewinding from within emulation
return r.rewindState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::unwindState()
{
RewindManager& r = myOSystem.state().rewindManager();
// TODO: add parameter to indicate unwinding from within emulation
return r.unwindState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StateManager::update()
{

View File

@ -64,6 +64,16 @@ class StateManager
*/
void toggleRewindMode();
/**
Rewinds one state; this uses the RewindManager for its functionality.
*/
bool rewindState();
/**
Unwinds one state; this uses the RewindManager for its functionality.
*/
bool unwindState();
/**
Updates the state of the system based on the currently active mode.
*/

View File

@ -273,9 +273,30 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
{
myOSystem.frameBuffer().toggleFullscreen();
}
// These only work when in emulation mode
else if(myState == S_EMULATE)
// state rewinding must work in pause mode too
else if(myState == S_EMULATE || myState == S_PAUSE)
{
switch(key)
{
case KBDK_LEFT: // Alt-left rewinds states
if(myOSystem.state().rewindState() && myState != S_PAUSE)
setEventState(S_PAUSE);
break;
case KBDK_RIGHT: // Alt-right unwinds states
if(myOSystem.state().unwindState() && myState != S_PAUSE)
setEventState(S_PAUSE);
break;
default:
handled = false;
break;
}
}
// These only work when in emulation mode
if(!handled && myState == S_EMULATE)
{
handled = true;
switch(key)
{
case KBDK_EQUALS:
@ -566,10 +587,19 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
case S_EMULATE:
handleEvent(myKeyTable[key][kEmulationMode], state);
break;
case S_PAUSE:
if(myKeyTable[key][kEmulationMode] == Event::TakeSnapshot)
handleEvent(myKeyTable[key][kEmulationMode], state);
switch(myKeyTable[key][kEmulationMode])
{
case Event::TakeSnapshot:
case Event::DebuggerMode:
handleEvent(myKeyTable[key][kEmulationMode], state);
default:
break;
}
break;
default:
if(myOverlay)
myOverlay->handleKeyEvent(key, mod, state);
@ -1174,7 +1204,7 @@ bool EventHandler::eventStateChange(Event::Type type)
break;
case Event::DebuggerMode:
if(myState == S_EMULATE)
if(myState == S_EMULATE || myState == S_PAUSE)
enterDebugMode();
else if(myState == S_DEBUGGER)
leaveDebugMode();

View File

@ -285,6 +285,7 @@ void FrameBuffer::update()
myStatsMsg.surface->setDstPos(myImageRect.x() + 1, myImageRect.y() + 1);
myStatsMsg.surface->render();
}
myPausedCount = 0;
break; // S_EMULATE
}
@ -292,10 +293,10 @@ void FrameBuffer::update()
{
myTIASurface->render();
// Show a pause message every 5 seconds
if(myPausedCount++ >= 7*myOSystem.frameRate())
// Show a pause message immediately and then every 7 seconds
if (myPausedCount-- <= 0)
{
myPausedCount = 0;
myPausedCount = uInt32(7 * myOSystem.frameRate());
showMessage("Paused", kMiddleCenter);
}
break; // S_PAUSE

View File

@ -475,7 +475,7 @@ class FrameBuffer
uInt32 myInitializedCount;
// Used to set intervals between messages while in pause mode
uInt32 myPausedCount;
Int32 myPausedCount;
// Dimensions of the actual image, after zooming, and taking into account
// any image 'centering'