From 9d758a41b6c3f15384fb3e2290bcccf8e8907a56 Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 5 Oct 2002 12:49:49 +0000 Subject: [PATCH] Changed some text messages involving state loading/saving in the X11 and SDL ports. Added 'Shift-F10' key combo to X11 port to cycle downwards through state slots. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@113 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/ui/sdl/mainSDL.cxx | 4 +-- stella/src/ui/x11/mainX11.cxx | 65 +++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/stella/src/ui/sdl/mainSDL.cxx b/stella/src/ui/sdl/mainSDL.cxx index a570a98e3..8bc42415a 100644 --- a/stella/src/ui/sdl/mainSDL.cxx +++ b/stella/src/ui/sdl/mainSDL.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: mainSDL.cxx,v 1.28 2002-09-29 14:11:11 stephena Exp $ +// $Id: mainSDL.cxx,v 1.29 2002-10-05 12:49:49 stephena Exp $ //============================================================================ #include @@ -674,7 +674,7 @@ void changeState(int direction) // Print appropriate message char buf[40]; - snprintf(buf, 39, "Changed to state slot %d", currentState); + snprintf(buf, 39, "Changed to slot %d", currentState); string message = buf; theConsole->mediaSource().showMessage(message, MESSAGE_INTERVAL * settings->theDesiredFrameRate); diff --git a/stella/src/ui/x11/mainX11.cxx b/stella/src/ui/x11/mainX11.cxx index 49c417377..e41b12be8 100644 --- a/stella/src/ui/x11/mainX11.cxx +++ b/stella/src/ui/x11/mainX11.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: mainX11.cxx,v 1.26 2002-09-29 14:11:11 stephena Exp $ +// $Id: mainX11.cxx,v 1.27 2002-10-05 12:49:49 stephena Exp $ //============================================================================ #include @@ -86,7 +86,7 @@ static void usage(); static void loadState(); static void saveState(); -static void changeState(); +static void changeState(int direction); // Globals for X windows stuff static Display* theDisplay = (Display*) NULL; @@ -590,7 +590,10 @@ void handleEvents() } else if((key == XK_F10) && (event.type == KeyPress)) { - changeState(); + if(event.xkey.state & ShiftMask) + changeState(0); + else + changeState(1); } else if((key == XK_F11) && (event.type == KeyPress)) { @@ -973,16 +976,26 @@ void saveState() /** Changes the current state slot. */ -void changeState() +void changeState(int direction) { - if(currentState == 9) - currentState = 0; - else - ++currentState; + if(direction == 1) // increase current state slot + { + if(currentState == 9) + currentState = 0; + else + ++currentState; + } + else // decrease current state slot + { + if(currentState == 0) + currentState = 9; + else + --currentState; + } // Print appropriate message char buf[40]; - snprintf(buf, 39, "Changed to state slot %d", currentState); + snprintf(buf, 39, "Changed to slot %d", currentState); string message = buf; theConsole->mediaSource().showMessage(message, MESSAGE_INTERVAL * settings->theDesiredFrameRate); @@ -1339,23 +1352,6 @@ void cleanup() #endif } -/** - Returns number of ticks in microseconds -*/ -#ifdef HAVE_GETTIMEOFDAY -inline uInt32 getTicks() -{ - timeval now; - gettimeofday(&now, 0); - - uInt32 ticks = now.tv_sec * 1000000 + now.tv_usec; - - return ticks; -} -#else -#error We need gettimeofday for the X11 version!!! -#endif - /** Creates some directories under $HOME. Required directories are $HOME/.stella and $HOME/.stella/state @@ -1575,3 +1571,20 @@ int main(int argc, char* argv[]) cleanup(); return 0; } + +/** + Returns number of ticks in microseconds +*/ +#ifdef HAVE_GETTIMEOFDAY +inline uInt32 getTicks() +{ + timeval now; + gettimeofday(&now, 0); + + uInt32 ticks = now.tv_sec * 1000000 + now.tv_usec; + + return ticks; +} +#else +#error We need gettimeofday for the X11 version!!! +#endif