From 3ef83843b52886af2b6ebee2e79f97935a288acc Mon Sep 17 00:00:00 2001 From: stephena Date: Fri, 12 Jun 2009 21:47:03 +0000 Subject: [PATCH] Added autodetection for X07 bankswitching scheme. Added OpenGL info to the TV effect tab of the VideoDialog, so users can see why the effects aren't available if OpenGL is not sufficient. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1772 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/emucore/Cart.cxx | 19 +++++++++++++++++++ src/emucore/Cart.hxx | 5 +++++ src/gui/VideoDialog.cxx | 20 ++++++++++++++++++++ src/gui/VideoDialog.hxx | 3 +++ 4 files changed, 47 insertions(+) diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index b97b73113..9f0e5c6f8 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -321,6 +321,8 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size) if(isProbablySC(image, size)) type = "EFSC"; } + else if(isProbablyX07(image, size)) + type = "X07"; else type = "MB"; } @@ -583,6 +585,23 @@ bool Cartridge::isProbablyFE(const uInt8* image, uInt32 size) return false; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::isProbablyX07(const uInt8* image, uInt32 size) +{ + // X07 bankswitching switches to bank 0, 1, 2, etc by accessing address 0x08xd + uInt8 signature[3][3] = { + { 0xAD, 0x0D, 0x08 }, // LDA $080D + { 0xAD, 0x1D, 0x08 }, // LDA $081D + { 0xAD, 0x2D, 0x08 } // LDA $082D + }; + for(uInt32 i = 0; i < 3; ++i) + { + if(searchForBytes(image, size, signature[i], 3, 1)) + return true; + } + return false; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge::Cartridge(const Cartridge&) { diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 02c2934fc..0368ead08 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -254,6 +254,11 @@ class Cartridge : public Device */ static bool isProbablyFE(const uInt8* image, uInt32 size); + /** + Returns true if the image is probably an X07 bankswitching cartridge + */ + static bool isProbablyX07(const uInt8* image, uInt32 size); + protected: // If myBankLocked is true, ignore attempts at bankswitching. This is used // by the debugger, when disassembling/dumping ROM. diff --git a/src/gui/VideoDialog.cxx b/src/gui/VideoDialog.cxx index 2f8870647..a1ac1e62a 100644 --- a/src/gui/VideoDialog.cxx +++ b/src/gui/VideoDialog.cxx @@ -275,6 +275,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, wid.push_back(myPhosphorCheckbox); ypos += lineHeight + 4; + // OpenGL information // Add message concerning GLSL requirement ypos += lineHeight + 4; lwidth = font.getStringWidth("(*) TV effects require OpenGL 2.0+ & GLSL"); @@ -285,6 +286,15 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, new StaticTextWidget(myTab, font, 10+font.getStringWidth("(*) "), ypos, lwidth, fontHeight, "\'gl_texrect\' must be disabled", kTextAlignLeft); + ypos += lineHeight + 10; + + myGLVersionInfo = + new StaticTextWidget(myTab, font, 10+font.getStringWidth("(*) "), ypos, + lwidth, fontHeight, "", kTextAlignLeft); + ypos += lineHeight + 4; + myGLTexRectInfo = + new StaticTextWidget(myTab, font, 10+font.getStringWidth("(*) "), ypos, + lwidth, fontHeight, "", kTextAlignLeft); // Add items for tab 2 addToFocusList(wid, tabID); @@ -427,6 +437,16 @@ void VideoDialog::loadConfig() // TV phosphor burn-off effect myPhosphorCheckbox->setState(instance().settings().getBool("tv_phos")); myPhosphorCheckbox->setEnabled(tv); + + char buf[30]; + if(gl) sprintf(buf, "OpenGL version detected: %3.1f", FrameBufferGL::glVersion()); + else sprintf(buf, "OpenGL version detected: None"); + myGLVersionInfo->setLabel(buf); + sprintf(buf, "OpenGL texrect enabled: %s", + instance().settings().getBool("gl_texrect") ? "Yes" : "No"); + myGLTexRectInfo->setLabel(buf); +#else + myGLVersionInfo->setLabel("OpenGL mode not supported"); #endif myTab->loadConfig(); diff --git a/src/gui/VideoDialog.hxx b/src/gui/VideoDialog.hxx index ab93b75fe..140766182 100644 --- a/src/gui/VideoDialog.hxx +++ b/src/gui/VideoDialog.hxx @@ -81,6 +81,9 @@ class VideoDialog : public Dialog PopUpWidget* myNoisePopup; CheckboxWidget* myPhosphorCheckbox; + StaticTextWidget* myGLVersionInfo; + StaticTextWidget* myGLTexRectInfo; + enum { kNAspectRatioChanged = 'VDan', kPAspectRatioChanged = 'VDap',