Fixed issue with incorrect reporting of OpenGL version number for Windows.

Because the version was always being returned as 0, the TV effects were
always disabled, even on hardware that could support them.

Creation of OpenGL video mode is now more robust.  If it fails for any
reason, fallback to software mode is now done (and a message stating
that it happened).  This still won't protect against the operating
system lying to Stella and saying OpenGL support is really available
when it isn't, though.

Added support for ROMs smaller than 2K.  These are still treated as
2K ROMs, but have their contents mirrored appropriately.

Bumped version number.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1768 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-06-12 13:29:26 +00:00
parent cfba3449b4
commit 664d4e5d1a
9 changed files with 64 additions and 27 deletions

View File

@ -31,6 +31,8 @@ Stephen Anthony at stephena@users.sourceforge.net.
* Improve debugger support for remaining cartridges with dedicated RAM,
and add source-level debugging
* Make the prompt tab in the debugger accept case-insensitive commands.
* Fix bank going over 255 (when accessing RAM) for 3E in the debugger
RomWidget view.

View File

@ -188,10 +188,6 @@ bool FrameBufferGL::loadFuncs()
else
return false;
// Grab OpenGL version number
string version((const char *)p_glGetString(GL_VERSION));
myGLVersion = atof(version.substr(0, 3).c_str());
return true;
}
@ -345,6 +341,10 @@ bool FrameBufferGL::setVidMode(VideoMode& mode)
if(!loadFuncs())
return false;
// Grab OpenGL version number
string version((const char *)p_glGetString(GL_VERSION));
myGLVersion = atof(version.substr(0, 3).c_str());
// Check for some extensions that can potentially speed up operation
// Don't use it if we've been instructed not to
if(myOSystem->settings().getBool("gl_texrect"))

View File

@ -64,6 +64,8 @@ class FrameBufferGL : public FrameBuffer
/**
Return version of the OpenGL library found by the OSystem
(0 indicates that the libary was not loaded successfully).
This will not return a valid version number until setVidMode()
has been called at least once.
*/
static float glVersion() { return myGLVersion; }

View File

@ -19,7 +19,7 @@
#ifndef VERSION_HXX
#define VERSION_HXX
#define STELLA_BASE_VERSION "2.8"
#define STELLA_BASE_VERSION "2.8.1_svn"
#ifdef NIGHTLY_BUILD
#define STELLA_VERSION STELLA_BASE_VERSION "pre-" NIGHTLY_BUILD

View File

@ -88,12 +88,16 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size,
type = detected;
}
buf << type << autodetect << " (" << (size/1024) << "K) ";
buf << type << autodetect << " (";
if(size < 1024)
buf << size << "B) ";
else
buf << (size/1024) << "K) ";
myAboutString = buf.str();
// We should know the cart's type by now so let's create it
if(type == "2K")
cartridge = new Cartridge2K(image);
cartridge = new Cartridge2K(image, size);
else if(type == "3E")
cartridge = new Cartridge3E(image, size);
else if(type == "3F")
@ -203,6 +207,10 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
{
type = "AR";
}
else if(size < 2048) // Sub2K images
{
type = "2K";
}
else if((size == 2048) ||
(size == 4096 && memcmp(image, image + 2048, 2048) == 0))
{

View File

@ -23,10 +23,25 @@
#include "Cart2K.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge2K::Cartridge2K(const uInt8* image)
Cartridge2K::Cartridge2K(const uInt8* image, uInt32 size)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, 2048);
// Size can be a maximum of 2K
if(size > 2048) size = 2048;
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
memset(myImage, 0x02, 2048);
// Mirror each power-of-two slice in the 2K address space
uInt32 slice = 1, numslices = 2048;
while(slice < size)
{
slice <<= 1;
numslices >>= 1;
}
// Copy the ROM image slices into my buffer
for(uInt32 i = 0; i < numslices; ++i)
memcpy(myImage + i*slice, image, slice);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -41,8 +41,9 @@ class Cartridge2K : public Cartridge
Create a new cartridge using the specified image
@param image Pointer to the ROM image
@param size The size of the ROM image (<= 2048 bytes)
*/
Cartridge2K(const uInt8* image);
Cartridge2K(const uInt8* image, uInt32 size);
/**
Destructor

View File

@ -60,8 +60,6 @@ FrameBuffer* MediaFactory::createVideo(OSystem* osystem)
const string& gl_lib = osystem->settings().getString("gl_lib");
if(FrameBufferGL::loadLibrary(gl_lib))
fb = new FrameBufferGL(osystem);
else
cerr << "ERROR: Couldn't dynamically load OpenGL library ...\n";
}
#endif
@ -80,16 +78,6 @@ FrameBuffer* MediaFactory::createVideo(OSystem* osystem)
// This should never happen
assert(fb != NULL);
switch(fb->type())
{
case kSoftBuffer:
osystem->settings().setString("video", "soft");
break;
case kGLBuffer:
osystem->settings().setString("video", "gl");
break;
}
return fb;
}

View File

@ -376,22 +376,23 @@ bool OSystem::createFrameBuffer()
case EventHandler::S_MENU:
case EventHandler::S_CMDMENU:
if(!myConsole->initializeVideo())
return false;
goto fallback;
break; // S_EMULATE, S_PAUSE, S_MENU, S_CMDMENU
case EventHandler::S_LAUNCHER:
if(!myLauncher->initializeVideo())
return false;
goto fallback;
break; // S_LAUNCHER
#ifdef DEBUGGER_SUPPORT
case EventHandler::S_DEBUGGER:
if(!myDebugger->initializeVideo())
return false;
goto fallback;
break; // S_DEBUGGER
#endif
default:
default: // Should never happen
cerr << "ERROR: Unknown emulation state in createFrameBuffer()" << endl;
break;
}
@ -406,6 +407,26 @@ bool OSystem::createFrameBuffer()
}
return true;
// GOTO are normally considered evil, unless well documented :)
// If initialization of video system fails while in OpenGL mode,
// attempt to fallback to software mode
fallback:
if(myFrameBuffer && myFrameBuffer->type() == kGLBuffer)
{
cerr << "ERROR: OpenGL mode failed, fallback to software" << endl;
delete myFrameBuffer; myFrameBuffer = NULL;
mySettings->setString("video", "soft");
bool ret = createFrameBuffer();
if(ret)
{
setFramerate(60);
myFrameBuffer->showMessage("OpenGL mode failed, fallback to software", kMiddleCenter);
}
return ret;
}
else
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -