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"); 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() void StateManager::update()
{ {

View File

@ -64,6 +64,16 @@ class StateManager
*/ */
void toggleRewindMode(); 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. 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(); myOSystem.frameBuffer().toggleFullscreen();
} }
// These only work when in emulation mode // state rewinding must work in pause mode too
else if(myState == S_EMULATE) 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) switch(key)
{ {
case KBDK_EQUALS: case KBDK_EQUALS:
@ -566,10 +587,19 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
case S_EMULATE: case S_EMULATE:
handleEvent(myKeyTable[key][kEmulationMode], state); handleEvent(myKeyTable[key][kEmulationMode], state);
break; break;
case S_PAUSE: case S_PAUSE:
if(myKeyTable[key][kEmulationMode] == Event::TakeSnapshot) switch(myKeyTable[key][kEmulationMode])
handleEvent(myKeyTable[key][kEmulationMode], state); {
case Event::TakeSnapshot:
case Event::DebuggerMode:
handleEvent(myKeyTable[key][kEmulationMode], state);
default:
break;
}
break; break;
default: default:
if(myOverlay) if(myOverlay)
myOverlay->handleKeyEvent(key, mod, state); myOverlay->handleKeyEvent(key, mod, state);
@ -1174,7 +1204,7 @@ bool EventHandler::eventStateChange(Event::Type type)
break; break;
case Event::DebuggerMode: case Event::DebuggerMode:
if(myState == S_EMULATE) if(myState == S_EMULATE || myState == S_PAUSE)
enterDebugMode(); enterDebugMode();
else if(myState == S_DEBUGGER) else if(myState == S_DEBUGGER)
leaveDebugMode(); leaveDebugMode();

View File

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

View File

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