diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index dbefb9dc8..8a38a5417 100644 --- a/stella/src/common/FrameBufferSoft.cxx +++ b/stella/src/common/FrameBufferSoft.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferSoft.cxx,v 1.69 2007-01-15 00:07:51 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.70 2007-01-30 17:13:07 stephena Exp $ //============================================================================ #include @@ -859,7 +859,8 @@ void FrameBufferSoft::stateChanged(EventHandler::State state) // When in a UI mode, always use dirty rects // Otherwise, check the 'dirtyrects' setting // Phosphor mode implies a full update, so turn off dirty rects - bool emulation = state == EventHandler::S_EMULATE; + bool emulation = (state == EventHandler::S_EMULATE || + state == EventHandler::S_PAUSE); if(emulation) { if(myUsePhosphor) diff --git a/stella/src/emucore/Event.hxx b/stella/src/emucore/Event.hxx index 2473e567d..1385767cc 100644 --- a/stella/src/emucore/Event.hxx +++ b/stella/src/emucore/Event.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Event.hxx,v 1.27 2007-01-24 21:36:38 stephena Exp $ +// $Id: Event.hxx,v 1.28 2007-01-30 17:13:07 stephena Exp $ //============================================================================ #ifndef EVENT_HXX @@ -26,7 +26,7 @@ class EventStreamer; /** @author Bradford W. Mott - @version $Id: Event.hxx,v 1.27 2007-01-24 21:36:38 stephena Exp $ + @version $Id: Event.hxx,v 1.28 2007-01-30 17:13:07 stephena Exp $ */ class Event { @@ -77,8 +77,8 @@ class Event DrivingOneFire, ChangeState, LoadState, SaveState, TakeSnapshot, Quit, - MenuMode, CmdMenuMode, DebuggerMode, LauncherMode, Fry, - VolumeDecrease, VolumeIncrease, + PauseMode, MenuMode, CmdMenuMode, DebuggerMode, LauncherMode, + Fry, VolumeDecrease, VolumeIncrease, UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown, UISelect, UINavPrev, UINavNext, UIOK, UICancel, diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 1606480e4..931d18266 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -14,7 +14,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.cxx,v 1.199 2007-01-24 21:36:38 stephena Exp $ +// $Id: EventHandler.cxx,v 1.200 2007-01-30 17:13:07 stephena Exp $ //============================================================================ #include @@ -190,15 +190,19 @@ void EventHandler::refreshDisplay(bool forceUpdate) switch(myState) { case S_EMULATE: - myOSystem->frameBuffer().refresh(); + case S_PAUSE: + if(&myOSystem->frameBuffer()) + myOSystem->frameBuffer().refresh(); break; - case S_MENU: + case S_MENU: // fall through to next case case S_CMDMENU: - myOSystem->frameBuffer().refresh(); + if(&myOSystem->frameBuffer()) + myOSystem->frameBuffer().refresh(); case S_LAUNCHER: case S_DEBUGGER: - myOverlay->refresh(); + if(myOverlay) + myOverlay->refresh(); break; default: @@ -206,7 +210,7 @@ void EventHandler::refreshDisplay(bool forceUpdate) break; } - if(forceUpdate) + if(forceUpdate && &myOSystem->frameBuffer()) myOSystem->frameBuffer().update(); } @@ -1224,6 +1228,21 @@ bool EventHandler::eventStateChange(Event::Type type) switch(type) { + case Event::PauseMode: + if(myState == S_EMULATE) + { + myState = S_PAUSE; + myOSystem->sound().mute(true); + } + else if(myState == S_PAUSE) + { + myState = S_EMULATE; + myOSystem->sound().mute(false); + } + else + handled = false; + break; + case Event::MenuMode: if(myState == S_EMULATE) enterMenuMode(S_MENU); @@ -1751,6 +1770,7 @@ void EventHandler::setDefaultKeymap(EventMode mode) myKeyTable[ SDLK_F11 ][mode] = Event::LoadState; myKeyTable[ SDLK_F12 ][mode] = Event::TakeSnapshot; myKeyTable[ SDLK_BACKSPACE ][mode] = Event::Fry; + myKeyTable[ SDLK_PAUSE ][mode] = Event::PauseMode; myKeyTable[ SDLK_TAB ][mode] = Event::MenuMode; myKeyTable[ SDLK_BACKSLASH ][mode] = Event::CmdMenuMode; myKeyTable[ SDLK_BACKQUOTE ][mode] = Event::DebuggerMode; @@ -2203,7 +2223,6 @@ void EventHandler::enterMenuMode(State state) setEventState(state); myOverlay->reStack(); - refreshDisplay(); myOSystem->frameBuffer().setCursorState(); myOSystem->sound().mute(true); @@ -2215,7 +2234,6 @@ void EventHandler::leaveMenuMode() { setEventState(S_EMULATE); - refreshDisplay(); myOSystem->frameBuffer().setCursorState(); myOSystem->sound().mute(false); @@ -2238,10 +2256,6 @@ bool EventHandler::enterDebugMode() // Make sure debugger starts in a consistent state myOSystem->debugger().setStartState(); - - // Make sure screen is always refreshed when entering debug mode - // (sometimes entering on a breakpoint doesn't draw contents) - refreshDisplay(); #else myOSystem->frameBuffer().showMessage("Debugger unsupported"); #endif @@ -2262,7 +2276,6 @@ void EventHandler::leaveDebugMode() setEventState(S_EMULATE); myOSystem->createFrameBuffer(); - refreshDisplay(); myOSystem->frameBuffer().setCursorState(); myOSystem->sound().mute(false); myEvent->clear(); @@ -2277,12 +2290,17 @@ void EventHandler::setEventState(State state) { case S_EMULATE: myOverlay = NULL; + myOSystem->sound().mute(false); // Controller types only make sense in Emulate mode myController[0] = myOSystem->console().controller(Controller::Left).type(); myController[1] = myOSystem->console().controller(Controller::Right).type(); break; + case S_PAUSE: + myOSystem->sound().mute(true); + break; + case S_MENU: myOverlay = &myOSystem->menu(); break; @@ -2310,6 +2328,8 @@ void EventHandler::setEventState(State state) myOSystem->stateChanged(myState); if(&myOSystem->frameBuffer()) myOSystem->frameBuffer().stateChanged(myState); + + refreshDisplay(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2565,6 +2585,7 @@ EventHandler::ActionList EventHandler::ourEmulActionList[kEmulActionListSize] = { Event::Fry, "Fry cartridge", 0 }, { Event::VolumeDecrease, "Decrease volume", 0 }, { Event::VolumeIncrease, "Increase volume", 0 }, + { Event::PauseMode, "Pause", 0 }, { Event::MenuMode, "Enter options menu mode", 0 }, { Event::CmdMenuMode, "Toggle command menu mode", 0 }, { Event::DebuggerMode, "Toggle debugger mode", 0 }, diff --git a/stella/src/emucore/EventHandler.hxx b/stella/src/emucore/EventHandler.hxx index 7622392f3..f03b719d9 100644 --- a/stella/src/emucore/EventHandler.hxx +++ b/stella/src/emucore/EventHandler.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.hxx,v 1.100 2007-01-24 21:36:38 stephena Exp $ +// $Id: EventHandler.hxx,v 1.101 2007-01-30 17:13:10 stephena Exp $ //============================================================================ #ifndef EVENTHANDLER_HXX @@ -62,7 +62,7 @@ enum EventMode { mapping can take place. @author Stephen Anthony - @version $Id: EventHandler.hxx,v 1.100 2007-01-24 21:36:38 stephena Exp $ + @version $Id: EventHandler.hxx,v 1.101 2007-01-30 17:13:10 stephena Exp $ */ class EventHandler { @@ -78,7 +78,15 @@ class EventHandler virtual ~EventHandler(); // Enumeration representing the different states of operation - enum State { S_NONE, S_EMULATE, S_LAUNCHER, S_MENU, S_CMDMENU, S_DEBUGGER }; + enum State { + S_NONE, + S_EMULATE, + S_PAUSE, + S_LAUNCHER, + S_MENU, + S_CMDMENU, + S_DEBUGGER + }; /** Returns the event object associated with this handler class. @@ -465,7 +473,7 @@ class EventHandler private: enum { - kEmulActionListSize = 80, + kEmulActionListSize = 81, kMenuActionListSize = 13 }; diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 5e66aceb1..5b417f0f7 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.cxx,v 1.116 2007-01-06 16:28:38 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.117 2007-01-30 17:13:10 stephena Exp $ //============================================================================ #include @@ -44,7 +44,8 @@ FrameBuffer::FrameBuffer(OSystem* osystem) theRedrawTIAIndicator(true), myUsePhosphor(false), myPhosphorBlend(77), - myInitializedCount(0) + myInitializedCount(0), + myPausedCount(0) { } @@ -141,6 +142,21 @@ void FrameBuffer::update() break; // S_EMULATE } + case EventHandler::S_PAUSE: + { + // Only update the screen if it's been invalidated + if(theRedrawTIAIndicator) + drawMediaSource(); + + // Show a pause message every 5 seconds + if(myPausedCount++ >= 7*myOSystem->frameRate()) + { + myPausedCount = 0; + showMessage("Paused", kMiddleCenter); + } + break; // S_PAUSE + } + case EventHandler::S_MENU: { // Only update the screen if it's been invalidated @@ -386,6 +402,7 @@ bool FrameBuffer::scale(int direction, const string& type) EventHandler::State state = myOSystem->eventHandler().state(); bool inTIAMode = (state == EventHandler::S_EMULATE || + state == EventHandler::S_PAUSE || state == EventHandler::S_MENU || state == EventHandler::S_CMDMENU); @@ -413,6 +430,7 @@ void FrameBuffer::setCursorState() switch(myOSystem->eventHandler().state()) { case EventHandler::S_EMULATE: + case EventHandler::S_PAUSE: showCursor(false); break; default: @@ -735,6 +753,7 @@ const string& FrameBuffer::currentScalerName() { EventHandler::State state = myOSystem->eventHandler().state(); bool inTIAMode = (state == EventHandler::S_EMULATE || + state == EventHandler::S_PAUSE || state == EventHandler::S_MENU || state == EventHandler::S_CMDMENU); diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index 5f5d11e2f..947315687 100644 --- a/stella/src/emucore/FrameBuffer.hxx +++ b/stella/src/emucore/FrameBuffer.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.hxx,v 1.85 2007-01-06 16:28:38 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.86 2007-01-30 17:13:10 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -93,7 +93,7 @@ struct Scaler { All GUI elements (ala ScummVM) are drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.85 2007-01-06 16:28:38 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.86 2007-01-30 17:13:10 stephena Exp $ */ class FrameBuffer { @@ -548,6 +548,9 @@ class FrameBuffer // Indicates the number of times the framebuffer was initialized uInt32 myInitializedCount; + // Used to set intervals between messages while in pause mode + uInt32 myPausedCount; + // Used for onscreen messages struct Message { string text; diff --git a/stella/src/emucore/OSystem.cxx b/stella/src/emucore/OSystem.cxx index 5d3180376..693fd3a2a 100644 --- a/stella/src/emucore/OSystem.cxx +++ b/stella/src/emucore/OSystem.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OSystem.cxx,v 1.94 2007-01-19 21:53:26 stephena Exp $ +// $Id: OSystem.cxx,v 1.95 2007-01-30 17:13:10 stephena Exp $ //============================================================================ #include @@ -240,10 +240,11 @@ bool OSystem::createFrameBuffer(bool showmessage) switch(myEventHandler->state()) { case EventHandler::S_EMULATE: + case EventHandler::S_PAUSE: case EventHandler::S_MENU: case EventHandler::S_CMDMENU: myConsole->initializeVideo(); - break; // S_EMULATE, S_MENU, S_CMDMENU + break; // S_EMULATE, S_PAUSE, S_MENU, S_CMDMENU case EventHandler::S_LAUNCHER: myLauncher->initializeVideo();