The TIA windowed zooming modes now work (using Alt-minus and Alt-equals).

Rearranged some of the desktop size code, to be more consistent with the
new API.

Beginning to remove the old assumptions that a smaller screen than 640x480
could be used.  In the 4.0 release, the smallest (internal) screen
supported will actually be 640x480, and if the real desktop can't display
it, then it will be scaled down.  This is one of the nice benefits of
killing pure software rendering support, and letting the hardware just
draw the screen as it likes.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2877 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-04-29 14:52:35 +00:00
parent 0c3b9f1443
commit 61689a9563
9 changed files with 84 additions and 146 deletions

View File

@ -524,11 +524,12 @@ void Console::changeYStart(int direction)
void Console::changeHeight(int direction)
{
uInt32 height = myTIA->height();
uInt32 dheight = myOSystem->frameBuffer().desktopSize().h;
if(direction == +1) // increase Height
{
height++;
if(height > 256 || height > myOSystem->desktopHeight())
if(height > 256 || height > dheight)
{
myOSystem->frameBuffer().showMessage("Height at maximum");
return;
@ -585,11 +586,12 @@ void Console::setTIAProperties()
// Make sure these values fit within the bounds of the desktop
// If not, attempt to center vertically
if(height > myOSystem->desktopHeight())
uInt32 dheight = myOSystem->frameBuffer().desktopSize().h;
if(height > dheight)
{
ystart += height - myOSystem->desktopHeight();
ystart += height - dheight;
ystart = BSPF_min(ystart, 64u);
height = myOSystem->desktopHeight();
height = dheight;
}
myTIA->setYStart(ystart);
myTIA->setHeight(height);

View File

@ -367,11 +367,11 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, char ascii, bool
switch(key)
{
case KBDK_EQUALS:
myOSystem->frameBuffer().changeVidMode(+1);
myOSystem->frameBuffer().changeWindowedVidMode(+1);
break;
case KBDK_MINUS:
myOSystem->frameBuffer().changeVidMode(-1);
myOSystem->frameBuffer().changeWindowedVidMode(-1);
break;
case KBDK_LEFTBRACKET:

View File

@ -79,19 +79,20 @@ FrameBuffer::~FrameBuffer(void)
bool FrameBuffer::initialize()
{
// Get desktop resolution and supported renderers
queryHardware(myDesktopWidth, myDesktopHeight, myRenderers);
uInt32 query_w, query_h;
queryHardware(query_w, query_h, myRenderers);
// Check the 'maxres' setting, which is an undocumented developer feature
// that specifies the desktop size (not normally set)
const GUI::Size& s = myOSystem->settings().getSize("maxres");
if(s.w > 0 && s.h > 0)
{
myDesktopWidth = s.w;
myDesktopHeight = s.h;
query_w = s.w;
query_h = s.h;
}
// Various parts of the codebase assume a minimum screen size
myDesktopWidth = BSPF_max(myDesktopWidth, (uInt32)kFBMinW);
myDesktopHeight = BSPF_max(myDesktopHeight, (uInt32)kFBMinH);
myDesktopSize.w = BSPF_max(query_w, (uInt32)kFBMinW);
myDesktopSize.h = BSPF_max(query_h, (uInt32)kFBMinH);
////////////////////////////////////////////////////////////////////
// Create fonts to draw text
@ -103,8 +104,8 @@ bool FrameBuffer::initialize()
// We can probably add ifdefs to take care of corner cases,
// but that means we've failed to abstract it enough ...
////////////////////////////////////////////////////////////////////
bool smallScreen = myDesktopWidth < (uInt32)kFBMinW ||
myDesktopHeight < (uInt32)kFBMinH;
bool smallScreen = myDesktopSize.w < (uInt32)kFBMinW ||
myDesktopSize.h < (uInt32)kFBMinH;
// This font is used in a variety of situations when a really small
// font is needed; we let the specific widget/dialog decide when to
@ -137,7 +138,7 @@ bool FrameBuffer::initialize()
// Determine possible TIA windowed zoom levels
uInt32 maxZoom = maxWindowSizeForScreen((uInt32)kTIAMinW, (uInt32)kTIAMinH,
myDesktopWidth, myDesktopHeight);
myDesktopSize.w, myDesktopSize.h);
// Figure our the smallest zoom level we can use
uInt32 firstZoom = smallScreen ? 1 : 2;
@ -156,6 +157,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
uInt32 width, uInt32 height)
{
myInitializedCount++;
myScreenTitle = title;
// A 'windowed' system is defined as one where the window size can be
// larger than the screen size, as there's some sort of window manager
@ -173,14 +175,15 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
// we're running on a 'large' system, and the window size requirements
// can be relaxed
// Otherwise, we treat the system as if WINDOWED_SUPPORT is not defined
if(myOSystem->desktopWidth() < (uInt32)kFBMinW &&
myOSystem->desktopHeight() < (uInt32)kFBMinH &&
(myOSystem->desktopWidth() < width || myOSystem->desktopHeight() < height))
if(myDesktopSize.w < (uInt32)kFBMinW &&
myDesktopSize.h < (uInt32)kFBMinH &&
(myDesktopSize.w < width || myDesktopSize.h < height))
return kFailTooLarge;
// FIXSDL - remove size limitations here?
if(myOSystem->settings().getString("fullscreen") == "1")
{
if(myOSystem->desktopWidth() < width || myOSystem->desktopHeight() < height)
if(myDesktopSize.w < width || myDesktopSize.h < height)
return kFailTooLarge;
useFullscreen = true;
@ -191,7 +194,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
// Make sure this mode is even possible
// We only really need to worry about it in non-windowed environments,
// where requesting a window that's too large will probably cause a crash
if(myOSystem->desktopWidth() < width || myOSystem->desktopHeight() < height)
if(myDesktopSize.w < width || myDesktopSize.h < height)
return kFailTooLarge;
#endif
@ -205,7 +208,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
myScreenSize = mode.screen;
if(width <= myScreenSize.w && height <= myScreenSize.h)
{
if(setVideoMode(title, mode, useFullscreen))
if(setVideoMode(myScreenTitle, mode, useFullscreen))
{
// Did we get the requested fullscreen state?
myOSystem->settings().setValue("fullscreen", fullScreen());
@ -776,68 +779,36 @@ void FrameBuffer::toggleFullscreen()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBuffer::changeVidMode(int direction)
bool FrameBuffer::changeWindowedVidMode(int direction)
{
cerr << "changeVidMode: " << direction << endl;
#if 0 //FIXSDL
#ifdef WINDOWED_SUPPORT
EventHandler::State state = myOSystem->eventHandler().state();
bool inUIMode = (state == EventHandler::S_DEBUGGER ||
state == EventHandler::S_LAUNCHER);
bool tiaMode = (state != EventHandler::S_DEBUGGER &&
state != EventHandler::S_LAUNCHER);
// Ignore any attempts to change video size while in UI mode
if(inUIMode && direction != 0)
// Ignore any attempts to change video size while in invalid modes
if(!tiaMode || fullScreen())
return false;
// Only save mode changes in TIA mode with a valid selector
bool saveModeChange = !inUIMode && (direction == -1 || direction == +1);
if(direction == +1)
myCurrentModeList->next();
else if(direction == -1)
myCurrentModeList->previous();
VideoMode vidmode = myCurrentModeList->current(myOSystem->settings(), fullScreen());
if(setVidMode(vidmode))
{
myImageRect.setWidth(vidmode.image_w);
myImageRect.setHeight(vidmode.image_h);
myImageRect.moveTo(vidmode.image_x, vidmode.image_y);
myScreenRect.setWidth(vidmode.screen_w);
myScreenRect.setHeight(vidmode.screen_h);
// Did we get the requested fullscreen state?
const string& fullscreen = myOSystem->settings().getString("fullscreen");
if(fullscreen != "-1")
myOSystem->settings().setValue("fullscreen", fullScreen() ? "1" : "0");
setCursorState();
if(!inUIMode)
{
if(direction != 0) // only show message when mode actually changes
showMessage(vidmode.gfxmode.description);
}
if(saveModeChange)
myOSystem->settings().setValue("tia.filter", vidmode.gfxmode.name);
refresh();
}
else
return false;
const VideoMode& mode = myCurrentModeList->current();
myImageRect = mode.image;
myScreenSize = mode.screen;
if(setVideoMode(myScreenTitle, mode, false))
{
showMessage(mode.description);
myOSystem->settings().setValue("tia.zoom", mode.zoom);
refresh();
return true;
}
#endif
return true;
/*
cerr << "New mode:" << endl
<< " screen w = " << newmode.screen_w << endl
<< " screen h = " << newmode.screen_h << endl
<< " image x = " << newmode.image_x << endl
<< " image y = " << newmode.image_y << endl
<< " image w = " << newmode.image_w << endl
<< " image h = " << newmode.image_h << endl
<< " zoom = " << newmode.zoom << endl
<< " name = " << newmode.name << endl
<< endl;
*/
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -906,7 +877,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
{
// TIA windowed modes
uInt32 maxZoom = maxWindowSizeForScreen(baseWidth, baseHeight,
myDesktopWidth, myDesktopHeight);
myDesktopSize.w, myDesktopSize.h);
// Aspect ratio
bool ntsc = myOSystem->console().about().InitialFrameRate == "60";
@ -915,7 +886,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
// Figure our the smallest zoom level we can use
uInt32 firstZoom = 2;
if(myDesktopWidth < 640 || myDesktopHeight < 480)
if(myDesktopSize.w < 640 || myDesktopSize.h < 480)
firstZoom = 1;
for(uInt32 zoom = firstZoom; zoom <= maxZoom; ++zoom)
{
@ -931,7 +902,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
// TIA fullscreen mode
// GUI::Size screen(myDesktopWidth, myDesktopHeight);
myFullscreenModeList.add(
VideoMode(baseWidth, baseHeight, myDesktopWidth, myDesktopHeight, true)
VideoMode(baseWidth, baseHeight, myDesktopSize.w, myDesktopSize.h, true)
);
}
@ -942,7 +913,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
VideoMode(baseWidth, baseHeight, baseWidth, baseHeight, false)
);
myFullscreenModeList.add(
VideoMode(baseWidth, baseHeight, myDesktopWidth, myDesktopHeight, true)
VideoMode(baseWidth, baseHeight, myDesktopSize.w, myDesktopSize.h, true)
);
}
@ -955,7 +926,6 @@ cerr << "Windowed modes:\n" << myWindowedModeList << endl
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FrameBuffer::VideoMode& FrameBuffer::getSavedVidMode(bool fullscreen)
{
cerr << "getSavedVidMode(full=" << fullscreen << ")\n";
EventHandler::State state = myOSystem->eventHandler().state();
if(fullscreen)

View File

@ -200,10 +200,9 @@ class FrameBuffer
const GUI::Size& screenSize() const { return myScreenSize; }
/**
Get the maximum dimensions of a window for the framebuffer hardware.
Returns the current dimensions of the users' desktop.
*/
uInt32 desktopWidth() const { return myDesktopWidth; }
uInt32 desktopHeight() const { return myDesktopHeight; }
const GUI::Size& desktopSize() const { return myDesktopSize; }
/**
Get the supported renderers for the video hardware.
@ -238,14 +237,13 @@ class FrameBuffer
/**
This method is called when the user wants to switch to the next available
video mode (functionality depends on fullscreen or windowed mode).
direction = -1 means go to the next lower video mode
direction = 0 means to reload the current video mode
direction = +1 means go to the next higher video mode
windowed video mode.
direction = -1 means go to the next lower windowed video mode
direction = +1 means go to the next higher windowed video mode
@param direction Described above
*/
bool changeVidMode(int direction);
bool changeWindowedVidMode(int direction);
/**
Sets the state of the cursor (hidden or grabbed) based on the
@ -601,8 +599,11 @@ class FrameBuffer
// Dimensions of the main window (not always the same as the image)
GUI::Size myScreenSize;
// Title of the main window/screen
string myScreenTitle;
// Maximum dimensions of the desktop area
uInt32 myDesktopWidth, myDesktopHeight;
GUI::Size myDesktopSize;
// Supported renderers
VariantList myRenderers;

View File

@ -232,13 +232,6 @@ class OSystem
*/
float frameRate() const { return myDisplayFrameRate; }
//FIXME - remove this code
/**
Get the maximum dimensions of a window for the video hardware.
*/
uInt32 desktopWidth() const { return myFrameBuffer->desktopWidth(); }
uInt32 desktopHeight() const { return myFrameBuffer->desktopHeight(); }
/////////////////////////////////////////////////
/**
Return the default full/complete directory name for storing data.
*/

View File

@ -32,14 +32,15 @@ Launcher::Launcher(OSystem* osystem)
: DialogContainer(osystem)
{
const GUI::Size& s = myOSystem->settings().getSize("launcherres");
const GUI::Size& d = myOSystem->frameBuffer().desktopSize();
myWidth = s.w; myHeight = s.h;
// The launcher dialog is resizable, within certain bounds
// We check those bounds now
myWidth = BSPF_max(myWidth, osystem->desktopWidth() >= 640 ? 640u : 320u);
myHeight = BSPF_max(myHeight, osystem->desktopHeight() >= 480 ? 480u : 240u);
myWidth = BSPF_min(myWidth, osystem->desktopWidth());
myHeight = BSPF_min(myHeight, osystem->desktopHeight());
myWidth = BSPF_max(myWidth, (uInt32)FrameBuffer::kFBMinW);
myHeight = BSPF_max(myHeight, (uInt32)FrameBuffer::kFBMinH);
myWidth = BSPF_min(myWidth, (uInt32)d.w);
myHeight = BSPF_min(myHeight, (uInt32)d.h);
myOSystem->settings().setValue("launcherres",
GUI::Size(myWidth, myHeight));

View File

@ -18,6 +18,7 @@
//============================================================================
#include "Dialog.hxx"
#include "FrameBuffer.hxx"
#include "OptionsDialog.hxx"
#include "bspf.hxx"
#include "Menu.hxx"
@ -28,20 +29,7 @@ class Properties;
Menu::Menu(OSystem* osystem)
: DialogContainer(osystem)
{
// This dialog is overlaid on the main TIA screen; we make sure it will fit
// If the TIA can use 1x mode, it implies that the overlay can be no larger
// than 320x240
// Otherwise we can use 2x mode, in which 640x420 is the minimum TIA size
int dw = osystem->desktopWidth(), dh = osystem->desktopHeight();
if(dw < 640 || dh < 480)
{
dw = 320; dh = 240;
}
else
{
dw = 480; dh = 380;
}
myBaseDialog = new OptionsDialog(myOSystem, this, 0, dw, dh, false); // in game mode
myBaseDialog = new OptionsDialog(myOSystem, this, 0, 480, 380, false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -53,6 +53,7 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
WidgetArray wid;
VariantList items;
ButtonWidget* b;
const GUI::Size& ds = instance().frameBuffer().desktopSize();
// Set real dimensions
_w = 37 * fontWidth + 10;
@ -73,16 +74,8 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
myLauncherWidthSlider = new SliderWidget(myTab, font, xpos, ypos, pwidth,
lineHeight, "Launcher Width: ",
lwidth, kLWidthChanged);
if(instance().desktopWidth() < 640)
{
myLauncherWidthSlider->setMinValue(320);
myLauncherWidthSlider->setMaxValue(instance().desktopWidth());
}
else
{
myLauncherWidthSlider->setMinValue(640);
myLauncherWidthSlider->setMaxValue(1920);
}
myLauncherWidthSlider->setMinValue(FrameBuffer::kFBMinW);
myLauncherWidthSlider->setMaxValue(ds.w);
myLauncherWidthSlider->setStepValue(10);
wid.push_back(myLauncherWidthSlider);
myLauncherWidthLabel =
@ -95,16 +88,8 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
myLauncherHeightSlider = new SliderWidget(myTab, font, xpos, ypos, pwidth,
lineHeight, "Launcher Height: ",
lwidth, kLHeightChanged);
if(instance().desktopHeight() < 480)
{
myLauncherHeightSlider->setMinValue(240);
myLauncherHeightSlider->setMaxValue(instance().desktopHeight());
}
else
{
myLauncherHeightSlider->setMinValue(480);
myLauncherHeightSlider->setMaxValue(1200);
}
myLauncherHeightSlider->setMinValue(FrameBuffer::kFBMinH);
myLauncherHeightSlider->setMaxValue(ds.h);
myLauncherHeightSlider->setStepValue(10);
wid.push_back(myLauncherHeightSlider);
myLauncherHeightLabel =
@ -171,7 +156,7 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
lineHeight, "Debugger Width: ",
lwidth, kDWidthChanged);
myDebuggerWidthSlider->setMinValue(DebuggerDialog::kSmallFontMinW);
myDebuggerWidthSlider->setMaxValue(osystem->desktopWidth());
myDebuggerWidthSlider->setMaxValue(ds.w);
myDebuggerWidthSlider->setStepValue(10);
wid.push_back(myDebuggerWidthSlider);
myDebuggerWidthLabel =
@ -185,7 +170,7 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
lineHeight, "Debugger Height: ",
lwidth, kDHeightChanged);
myDebuggerHeightSlider->setMinValue(DebuggerDialog::kSmallFontMinH);
myDebuggerHeightSlider->setMaxValue(osystem->desktopHeight());
myDebuggerHeightSlider->setMaxValue(ds.h);
myDebuggerHeightSlider->setStepValue(10);
wid.push_back(myDebuggerHeightSlider);
myDebuggerHeightLabel =
@ -228,7 +213,7 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
// (and when it's actually been compiled into the app)
bool debuggerAvailable =
#if defined(DEBUGGER_SUPPORT) && defined(WINDOWED_SUPPORT)
(instance().desktopWidth() >= 800 && instance().desktopHeight() >= 600);
(ds.w >= 800 && ds.h >= 600); // TODO - maybe this logic can disappear?
#else
false;
#endif
@ -315,10 +300,10 @@ void UIDialog::loadConfig()
const GUI::Size& ls = instance().settings().getSize("launcherres");
int w = ls.w, h = ls.h;
w = BSPF_max(w, 320);
h = BSPF_max(h, 240);
w = BSPF_min(w, 1920);
h = BSPF_min(h, 1200);
w = BSPF_max(w, (int)FrameBuffer::kFBMinW);
h = BSPF_max(h, (int)FrameBuffer::kFBMinH);
w = BSPF_min(w, instance().frameBuffer().desktopSize().w);
h = BSPF_min(h, instance().frameBuffer().desktopSize().h);
myLauncherWidthSlider->setValue(w);
myLauncherWidthLabel->setValue(w);
@ -343,8 +328,8 @@ void UIDialog::loadConfig()
w = ds.w, h = ds.h;
w = BSPF_max(w, (int)DebuggerDialog::kSmallFontMinW);
h = BSPF_max(h, (int)DebuggerDialog::kSmallFontMinH);
w = BSPF_min(w, (int)instance().desktopWidth());
h = BSPF_min(h, (int)instance().desktopHeight());
w = BSPF_min(w, (int)ds.w);
h = BSPF_min(h, (int)ds.h);
myDebuggerWidthSlider->setValue(w);
myDebuggerWidthLabel->setValue(w);
@ -414,8 +399,8 @@ void UIDialog::setDefaults()
{
case 0: // Launcher options
{
int w = BSPF_min(instance().desktopWidth(), 640u);
int h = BSPF_min(instance().desktopHeight(), 480u);
int w = BSPF_min(instance().frameBuffer().desktopSize().w, (int)FrameBuffer::kFBMinW);
int h = BSPF_min(instance().frameBuffer().desktopSize().h, (int)FrameBuffer::kFBMinH);
myLauncherWidthSlider->setValue(w);
myLauncherWidthLabel->setValue(w);
myLauncherHeightSlider->setValue(h);
@ -429,8 +414,8 @@ void UIDialog::setDefaults()
case 1: // Debugger options
{
#ifdef DEBUGGER_SUPPORT
int w = BSPF_min(instance().desktopWidth(), (uInt32)DebuggerDialog::kMediumFontMinW);
int h = BSPF_min(instance().desktopHeight(), (uInt32)DebuggerDialog::kMediumFontMinH);
int w = BSPF_min(instance().frameBuffer().desktopSize().w, (int)DebuggerDialog::kMediumFontMinW);
int h = BSPF_min(instance().frameBuffer().desktopSize().h, (int)DebuggerDialog::kMediumFontMinH);
myDebuggerWidthSlider->setValue(w);
myDebuggerWidthLabel->setValue(w);
myDebuggerHeightSlider->setValue(h);

View File

@ -322,8 +322,7 @@ void VideoDialog::loadConfig()
// the desktop and which renderer we're using
const VariantList& items = instance().frameBuffer().supportedTIAZoomLevels();
myTIAZoom->addItems(items);
myTIAZoom->setSelected(instance().settings().getString("tia.zoom"),
instance().desktopWidth() < 640 ? "1" : "2");
myTIAZoom->setSelected(instance().settings().getString("tia.zoom"), "2");
// TIA Palette
myTIAPalette->setSelected(
@ -482,8 +481,7 @@ void VideoDialog::setDefaults()
case 0: // General
{
myRenderer->setSelected("soft", "");
myTIAZoom->setSelected(
instance().desktopWidth() < 640 ? "1" : "2", "");
myTIAZoom->setSelected("2", "");
myTIAPalette->setSelected("standard", "");
myFrameTiming->setSelected("sleep", "");
myTIAInterpolate->setSelected("nearest", "");