Fixed crash in software mode when switching the ROM launcher to a

fullscreen mode smaller than it was initially created for.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1326 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2007-07-11 15:08:13 +00:00
parent 7e5d519234
commit 80296e2bed
3 changed files with 31 additions and 13 deletions

View File

@ -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: VideoModeList.hxx,v 1.1 2007-06-20 16:33:22 stephena Exp $
// $Id: VideoModeList.hxx,v 1.2 2007-07-11 15:08:04 stephena Exp $
//============================================================================
#ifndef VIDMODE_LIST_HXX
@ -33,7 +33,7 @@ struct VideoMode {
This class implements an iterator around an array of VideoMode objects.
@author Stephen Anthony
@version $Id: VideoModeList.hxx,v 1.1 2007-06-20 16:33:22 stephena Exp $
@version $Id: VideoModeList.hxx,v 1.2 2007-07-11 15:08:04 stephena Exp $
*/
class VideoModeList
{
@ -68,11 +68,11 @@ class VideoModeList
void setByResolution(uInt32 width, uInt32 height)
{
// Find the largest resolution within the given bounds
// Find the largest resolution able to hold the given bounds
myIdx = 0;
for(unsigned int i = myModeList.size() - 1; i; --i)
{
if(myModeList[i].screen_w <= width && myModeList[i].screen_h <= height)
if(width <= myModeList[i].screen_w && height <= myModeList[i].screen_h)
{
myIdx = i;
break;

View File

@ -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.118 2007-06-20 16:33:22 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.119 2007-07-11 15:08:10 stephena Exp $
//============================================================================
#include <sstream>
@ -758,6 +758,8 @@ cerr << "Fullscreen modes:" << endl
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VideoMode FrameBuffer::getSavedVidMode()
{
EventHandler::State state = myOSystem->eventHandler().state();
if(myOSystem->settings().getBool("fullscreen"))
{
// Point the modelist to fullscreen modes, and set the iterator to
@ -769,6 +771,22 @@ VideoMode FrameBuffer::getSavedVidMode()
w = myOSystem->desktopWidth();
h = myOSystem->desktopHeight();
}
// The launcher and debugger modes are different, in that their size is
// set at program launch and can't be changed
// In these cases, the resolution must accommodate their size
if(state == EventHandler::S_LAUNCHER)
{
int lw, lh;
myOSystem->settings().getSize("launcherres", lw, lh);
w = MAX(w, lw);
h = MAX(h, lh);
}
#ifdef DEBUGGER_SUPPORT
else if(state == EventHandler::S_DEBUGGER)
cerr << "TODO: check debugger size\n";
#endif
myCurrentModeList = &myFullscreenModeList;
myCurrentModeList->setByResolution(w, h);
}
@ -776,7 +794,6 @@ VideoMode FrameBuffer::getSavedVidMode()
{
// Point the modelist to windowed modes, and set the iterator to
// the mode closest to the given zoom level
EventHandler::State state = myOSystem->eventHandler().state();
bool inTIAMode = (state == EventHandler::S_EMULATE ||
state == EventHandler::S_PAUSE ||
state == EventHandler::S_MENU ||

View File

@ -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: Launcher.cxx,v 1.15 2007-06-20 16:33:23 stephena Exp $
// $Id: Launcher.cxx,v 1.16 2007-07-11 15:08:13 stephena Exp $
//============================================================================
#include <sstream>
@ -34,14 +34,15 @@ Launcher::Launcher(OSystem* osystem)
{
int w, h;
myOSystem->settings().getSize("launcherres", w, h);
myWidth = w >= 0 ? w : 0;
myHeight = h >= 0 ? h : 0;
myWidth = MAX(w, 0);
myHeight = MAX(h, 0);
// Error check the resolution
if(myWidth < 320) myWidth = 320;
if(myWidth > osystem->desktopWidth()) myWidth = osystem->desktopWidth();
if(myHeight < 240) myHeight = 240;
if(myHeight > osystem->desktopHeight()) myHeight = osystem->desktopHeight();
myWidth = MAX(myWidth, 320u);
myWidth = MIN(myWidth, osystem->desktopWidth());
myHeight = MAX(myHeight, 240u);
myHeight = MIN(myHeight, osystem->desktopHeight());
myOSystem->settings().setSize("launcherres", myWidth, myHeight);
myBaseDialog = new LauncherDialog(myOSystem, this, 0, 0, myWidth, myHeight);
}