Some changes to VideoMode handling. Fullscreen mode isn't working yet,

and OpenGL mode (windowed and fullscreen) isn't working at all.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1542 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-07-04 14:27:17 +00:00
parent 31447d9a6e
commit 04d8449398
4 changed files with 310 additions and 156 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBufferSoft.cxx,v 1.80 2008-06-19 12:01:30 stephena Exp $ // $Id: FrameBufferSoft.cxx,v 1.81 2008-07-04 14:27:17 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -105,7 +105,9 @@ bool FrameBufferSoft::setVidMode(VideoMode& mode)
// is successfully created // is successfully created
mode.screen_w = myScreen->w; mode.screen_w = myScreen->w;
mode.screen_h = myScreen->h; mode.screen_h = myScreen->h;
myZoomLevel = mode.zoom; myZoomLevel = mode.gfxmode.zoom;
// FIXME - look at gfxmode directly
// Make sure drawMediaSource() knows which renderer to use // Make sure drawMediaSource() knows which renderer to use
stateChanged(myOSystem->eventHandler().state()); stateChanged(myOSystem->eventHandler().state());

View File

@ -1,119 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
//
// 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.5 2008-06-19 12:01:30 stephena Exp $
//============================================================================
#ifndef VIDMODE_LIST_HXX
#define VIDMODE_LIST_HXX
#include "Array.hxx"
#include "bspf.hxx"
struct VideoMode {
uInt32 image_x, image_y, image_w, image_h;
uInt32 screen_w, screen_h;
uInt32 zoom;
string name;
};
/**
This class implements an iterator around an array of VideoMode objects.
@author Stephen Anthony
@version $Id: VideoModeList.hxx,v 1.5 2008-06-19 12:01:30 stephena Exp $
*/
class VideoModeList
{
public:
VideoModeList() : myIdx(-1) { }
void add(VideoMode mode) { myModeList.push_back(mode); }
void clear() { myModeList.clear(); }
bool isEmpty() const { return myModeList.isEmpty(); }
uInt32 size() const { return myModeList.size(); }
const VideoMode& previous()
{
--myIdx;
if(myIdx < 0) myIdx = myModeList.size() - 1;
return current();
}
const VideoMode& current() const
{
return myModeList[myIdx];
}
const VideoMode& next()
{
myIdx = (myIdx + 1) % myModeList.size();
return current();
}
void setByResolution(uInt32 width, uInt32 height)
{
// Find the largest resolution able to hold the given bounds
myIdx = myModeList.size() - 1;
for(unsigned int i = 0; i < myModeList.size(); ++i)
{
if(width <= myModeList[i].screen_w && height <= myModeList[i].screen_h)
{
myIdx = i;
break;
}
}
}
void setByZoom(uInt32 zoom)
{
// Find the largest zoom within the given bounds
myIdx = 0;
for(unsigned int i = myModeList.size() - 1; i; --i)
{
if(myModeList[i].zoom <= zoom)
{
myIdx = i;
break;
}
}
}
void print()
{
for(Common::Array<VideoMode>::const_iterator i = myModeList.begin(); i != myModeList.end(); ++i)
{
cerr << " Mode " << i << endl
<< " screen w = " << i->screen_w << endl
<< " screen h = " << i->screen_h << endl
<< " image x = " << i->image_x << endl
<< " image y = " << i->image_y << endl
<< " image w = " << i->image_w << endl
<< " image h = " << i->image_h << endl
<< " zoom = " << i->zoom << endl
<< " name = " << i->name << endl
<< endl;
}
}
private:
Common::Array<VideoMode> myModeList;
int myIdx;
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.cxx,v 1.134 2008-06-19 12:01:30 stephena Exp $ // $Id: FrameBuffer.cxx,v 1.135 2008-07-04 14:27:17 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -457,7 +457,6 @@ bool FrameBuffer::changeVidMode(int direction)
// Only save mode changes in TIA mode with a valid selector // Only save mode changes in TIA mode with a valid selector
bool saveModeChange = !inUIMode && (direction == -1 || direction == +1); bool saveModeChange = !inUIMode && (direction == -1 || direction == +1);
VideoMode oldmode = myCurrentModeList->current();
if(!inUIMode) if(!inUIMode)
{ {
if(direction == +1) if(direction == +1)
@ -466,15 +465,15 @@ bool FrameBuffer::changeVidMode(int direction)
myCurrentModeList->previous(); myCurrentModeList->previous();
} }
VideoMode newmode = myCurrentModeList->current(); VideoMode video = myCurrentModeList->current();
if(setVidMode(newmode)) if(setVidMode(video))
{ {
myImageRect.setWidth(newmode.image_w); myImageRect.setWidth(video.image_w);
myImageRect.setHeight(newmode.image_h); myImageRect.setHeight(video.image_h);
myImageRect.moveTo(newmode.image_x, newmode.image_y); myImageRect.moveTo(video.image_x, video.image_y);
myScreenRect.setWidth(newmode.screen_w); myScreenRect.setWidth(video.screen_w);
myScreenRect.setHeight(newmode.screen_h); myScreenRect.setHeight(video.screen_h);
} }
else else
return false; return false;
@ -482,12 +481,12 @@ bool FrameBuffer::changeVidMode(int direction)
myOSystem->eventHandler().handleResizeEvent(); myOSystem->eventHandler().handleResizeEvent();
myOSystem->eventHandler().refreshDisplay(true); myOSystem->eventHandler().refreshDisplay(true);
setCursorState(); setCursorState();
showMessage(newmode.name); showMessage(video.gfxmode.description);
if(!inUIMode && saveModeChange) if(!inUIMode && saveModeChange)
{ {
// FIXME - adapt to scaler infrastructure // FIXME - adapt to scaler infrastructure
myOSystem->settings().setInt("zoom_tia", newmode.zoom); // myOSystem->settings().setInt("zoom_tia", newmode.zoom);
} }
return true; return true;
/* /*
@ -662,31 +661,33 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
m.image_x = m.image_y = 0; m.image_x = m.image_y = 0;
m.image_w = m.screen_w = baseWidth; m.image_w = m.screen_w = baseWidth;
m.image_h = m.screen_h = baseHeight; m.image_h = m.screen_h = baseHeight;
m.zoom = 1; m.gfxmode = ourGraphicsModes[0]; // this should be zoom1x
myWindowedModeList.add(m); myWindowedModeList.add(m);
} }
else else
{ {
// FIXME - scan list of scalers, see which ones are appropriate // Scan list of filters, adding only those which are appropriate
// for the given dimensions // for the given dimensions
int max_zoom = maxWindowSizeForScreen(baseWidth, baseHeight, uInt32 max_zoom = maxWindowSizeForScreen(baseWidth, baseHeight,
myOSystem->desktopWidth(), myOSystem->desktopHeight()); myOSystem->desktopWidth(), myOSystem->desktopHeight());
for(int i = 1; i <= max_zoom; ++i) for(unsigned int i = 0; i < GFX_NumModes; ++i)
{ {
VideoMode m; uInt32 zoom = ourGraphicsModes[i].zoom;
m.image_x = m.image_y = 0; if(zoom <= max_zoom)
m.image_w = m.screen_w = baseWidth * i; {
m.image_h = m.screen_h = baseHeight * i; VideoMode m;
m.zoom = i; m.image_x = m.image_y = 0;
ostringstream buf; m.image_w = m.screen_w = baseWidth * zoom;
buf << "Zoom " << i << "x"; m.image_h = m.screen_h = baseHeight * zoom;
m.name = buf.str(); m.gfxmode = ourGraphicsModes[i];
myWindowedModeList.add(m); myWindowedModeList.add(m);
}
} }
} }
#if 0
// Now consider the fullscreen modes // Now consider the fullscreen modes
// There are often stricter requirements on these, and they're normally // There are often stricter requirements on these, and they're normally
// different depending on the OSystem in use // different depending on the OSystem in use
@ -751,10 +752,11 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
myFullscreenModeList.add(m); myFullscreenModeList.add(m);
} }
} }
#endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VideoMode FrameBuffer::getSavedVidMode() FrameBuffer::VideoMode FrameBuffer::getSavedVidMode()
{ {
EventHandler::State state = myOSystem->eventHandler().state(); EventHandler::State state = myOSystem->eventHandler().state();
@ -763,21 +765,206 @@ VideoMode FrameBuffer::getSavedVidMode()
else else
myCurrentModeList = &myWindowedModeList; myCurrentModeList = &myWindowedModeList;
myCurrentModeList->print();
// Now select the best resolution depending on the state // Now select the best resolution depending on the state
// UI modes (launcher and debugger) have only one supported resolution // UI modes (launcher and debugger) have only one supported resolution
// so the 'current' one is the only valid one // so the 'current' one is the only valid one
if(state == EventHandler::S_DEBUGGER || state == EventHandler::S_LAUNCHER) if(state == EventHandler::S_DEBUGGER || state == EventHandler::S_LAUNCHER)
{ {
myCurrentModeList->setByZoom(1); myCurrentModeList->setByGfxMode(GFX_Zoom1x);
} }
else else
{ {
// FIXME - get dimensions from scaler const string& name = myOSystem->settings().getString("tia_filter");
int zoom = myOSystem->settings().getInt("zoom_tia"); myCurrentModeList->setByGfxMode(name);
myCurrentModeList->setByZoom(zoom);
} }
return myCurrentModeList->current(); // Check if 'auto-size' is enabled for fullscreen modes
if(myOSystem->settings().getBool("fullscreen"))
{
VideoMode mode = myCurrentModeList->current();
// FIXME - add centering
return mode;
}
else
return myCurrentModeList->current();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::VideoModeList::VideoModeList()
{
myIdx = -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::VideoModeList::~VideoModeList()
{
clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::add(VideoMode mode)
{
myModeList.push_back(mode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::clear()
{
myModeList.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBuffer::VideoModeList::isEmpty() const
{
return myModeList.isEmpty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 FrameBuffer::VideoModeList::size() const
{
return myModeList.size();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FrameBuffer::VideoMode& FrameBuffer::VideoModeList::previous()
{
--myIdx;
if(myIdx < 0) myIdx = myModeList.size() - 1;
return current();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FrameBuffer::VideoMode& FrameBuffer::VideoModeList::current() const
{
return myModeList[myIdx];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FrameBuffer::VideoMode& FrameBuffer::VideoModeList::next()
{
myIdx = (myIdx + 1) % myModeList.size();
return current();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::setByGfxMode(GfxID id)
{
// First we determine which graphics mode is being requested
bool found = false;
GraphicsMode gfxmode;
for(uInt32 i = 0; i < GFX_NumModes; ++i)
{
if(ourGraphicsModes[i].type == id)
{
gfxmode = ourGraphicsModes[i];
found = true;
break;
}
}
if(!found) gfxmode = ourGraphicsModes[0];
// Now we scan the list for the applicable video mode
set(gfxmode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::setByGfxMode(const string& name)
{
// First we determine which graphics mode is being requested
bool found = false;
GraphicsMode gfxmode;
for(uInt32 i = 0; i < GFX_NumModes; ++i)
{
if(ourGraphicsModes[i].name == name)
{
gfxmode = ourGraphicsModes[i];
found = true;
break;
}
}
if(!found) gfxmode = ourGraphicsModes[0];
// Now we scan the list for the applicable video mode
set(gfxmode);
}
#if 0
// Find the largest resolution able to hold the given bounds
myIdx = myModeList.size() - 1;
for(unsigned int i = 0; i < myModeList.size(); ++i)
{
if(width <= myModeList[i].screen_w && height <= myModeList[i].screen_h)
{
myIdx = i;
break;
}
}
// Find the largest zoom within the given bounds
myIdx = 0;
for(unsigned int i = myModeList.size() - 1; i; --i)
{
if(myModeList[i].zoom <= zoom)
{
myIdx = i;
break;
}
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::set(const GraphicsMode& gfxmode)
{
// Attempt to point the current mode to the one given
myIdx = -1;
// First search for the given gfx id
for(unsigned int i = 0; i < myModeList.size(); ++i)
{
if(myModeList[i].gfxmode.type == gfxmode.type)
{
myIdx = i;
return;
}
}
// If we get here, then the gfx type couldn't be found, so we search
// for the first mode with the same zoomlevel
for(unsigned int i = 0; i < myModeList.size(); ++i)
{
if(myModeList[i].gfxmode.zoom == gfxmode.zoom)
{
myIdx = i;
return;
}
}
// Finally, just pick the lowes video mode
myIdx = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::print()
{
cerr << "VideoModeList: " << endl << endl;
for(Common::Array<VideoMode>::const_iterator i = myModeList.begin();
i != myModeList.end(); ++i)
{
cerr << " Mode " << i << endl
<< " screen w = " << i->screen_w << endl
<< " screen h = " << i->screen_h << endl
<< " image x = " << i->image_x << endl
<< " image y = " << i->image_y << endl
<< " image w = " << i->image_w << endl
<< " image h = " << i->image_h << endl
<< " gfx id = " << i->gfxmode.type << endl
<< " gfx name = " << i->gfxmode.name << endl
<< " gfx desc = " << i->gfxmode.description << endl
<< " gfx zoom = " << i->gfxmode.zoom << endl
<< endl;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -906,3 +1093,17 @@ void FBSurface::drawString(const GUI::Font* font, const string& s,
x += w; x += w;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::GraphicsMode FrameBuffer::ourGraphicsModes[GFX_NumModes] = {
{ GFX_Zoom1x, "zoom1x", "Zoom 1x", 1 },
{ GFX_Zoom2x, "zoom2x", "Zoom 2x", 2 },
{ GFX_Zoom3x, "zoom3x", "Zoom 3x", 3 },
{ GFX_Zoom4x, "zoom4x", "Zoom 4x", 4 },
{ GFX_Zoom5x, "zoom5x", "Zoom 5x", 5 },
{ GFX_Zoom6x, "zoom6x", "Zoom 6x", 6 },
{ GFX_Zoom7x, "zoom7x", "Zoom 7x", 7 },
{ GFX_Zoom8x, "zoom8x", "Zoom 8x", 8 },
{ GFX_Zoom9x, "zoom9x", "Zoom 9x", 9 },
{ GFX_Zoom10x, "zoom10x", "Zoom 10x", 10 }
};

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.hxx,v 1.99 2008-06-20 12:19:42 stephena Exp $ // $Id: FrameBuffer.hxx,v 1.100 2008-07-04 14:27:17 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_HXX #ifndef FRAMEBUFFER_HXX
@ -31,7 +31,7 @@ namespace GUI {
} }
#include "EventHandler.hxx" #include "EventHandler.hxx"
#include "VideoModeList.hxx" //#include "VideoModeList.hxx"
#include "Rect.hxx" #include "Rect.hxx"
#include "bspf.hxx" #include "bspf.hxx"
@ -90,7 +90,7 @@ enum {
turn drawn here as well. turn drawn here as well.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.99 2008-06-20 12:19:42 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.100 2008-07-04 14:27:17 stephena Exp $
*/ */
class FrameBuffer class FrameBuffer
{ {
@ -282,6 +282,41 @@ class FrameBuffer
virtual void scanline(uInt32 row, uInt8* data) const = 0; virtual void scanline(uInt32 row, uInt8* data) const = 0;
protected: protected:
// Different types of graphic filters to apply to the TIA image
enum GfxID {
GFX_Zoom1x,
GFX_Zoom2x,
GFX_Zoom3x,
GFX_Zoom4x,
GFX_Zoom5x,
GFX_Zoom6x,
GFX_Zoom7x,
GFX_Zoom8x,
GFX_Zoom9x,
GFX_Zoom10x,
GFX_NumModes
};
struct GraphicsMode {
GfxID type;
const char* name;
const char* description;
uInt32 zoom;
};
// Contains all relevant info for the dimensions of an SDL screen
// Also takes care of the case when the SDL image should be 'centered'
// within the given screen
// image_XXX are the image offsets into the SDL screen
// screen_XXX are the dimensions of the SDL screen itself
// Also contains relevant info for the graphics mode/filter to use
// when rendering the image
struct VideoMode {
uInt32 image_x, image_y, image_w, image_h;
uInt32 screen_w, screen_h;
GraphicsMode gfxmode;
};
/** /**
This method is called to initialize the video subsystem This method is called to initialize the video subsystem
with the given video mode. Normally, it will also call setVidMode(). with the given video mode. Normally, it will also call setVidMode().
@ -383,6 +418,38 @@ class FrameBuffer
*/ */
VideoMode getSavedVidMode(); VideoMode getSavedVidMode();
private:
/**
This class implements an iterator around an array of VideoMode objects.
*/
class VideoModeList
{
public:
VideoModeList();
~VideoModeList();
void add(VideoMode mode);
void clear();
bool isEmpty() const;
uInt32 size() const;
const FrameBuffer::VideoMode& previous();
const FrameBuffer::VideoMode& current() const;
const FrameBuffer::VideoMode& next();
void setByGfxMode(GfxID id);
void setByGfxMode(const string& name);
void print();
private:
void set(const GraphicsMode& gfxmode);
private:
Common::Array<VideoMode> myModeList;
int myIdx;
};
private: private:
// Indicates the number of times the framebuffer was initialized // Indicates the number of times the framebuffer was initialized
uInt32 myInitializedCount; uInt32 myInitializedCount;
@ -414,6 +481,9 @@ class FrameBuffer
VideoModeList myWindowedModeList; VideoModeList myWindowedModeList;
VideoModeList myFullscreenModeList; VideoModeList myFullscreenModeList;
VideoModeList* myCurrentModeList; VideoModeList* myCurrentModeList;
// Holds static strings for the remap menu (emulation and menu events)
static GraphicsMode ourGraphicsModes[GFX_NumModes];
}; };
@ -426,7 +496,7 @@ class FrameBuffer
FrameBuffer type. FrameBuffer type.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.99 2008-06-20 12:19:42 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.100 2008-07-04 14:27:17 stephena Exp $
*/ */
// Text alignment modes for drawString() // Text alignment modes for drawString()
enum TextAlignment { enum TextAlignment {