From 8925bf8b366137fd6b27ec669a5f1563b2a7e885 Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 14 Oct 2006 22:17:27 +0000 Subject: [PATCH] Fixed long-standing crash when switching zoom/scaler levels in the software framebuffer. Fixed getScaler() logic to only use scalers that are actually available in a particular mode. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1134 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/common/FrameBufferSoft.cxx | 6 ++--- stella/src/emucore/FrameBuffer.cxx | 34 +++++++++++++++------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index f380d18e5..e558947d0 100644 --- a/stella/src/common/FrameBufferSoft.cxx +++ b/stella/src/common/FrameBufferSoft.cxx @@ -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: FrameBufferSoft.cxx,v 1.53 2006-10-14 20:08:29 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.54 2006-10-14 22:17:26 stephena Exp $ //============================================================================ #include @@ -33,9 +33,9 @@ FrameBufferSoft::FrameBufferSoft(OSystem* osystem) : FrameBuffer(osystem), myZoomLevel(1), + myRenderType(kSoftZoom), myRectList(NULL), - myOverlayRectList(NULL), - myRenderType(kSoftZoom) + myOverlayRectList(NULL) { } diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index d4af3155c..0619a0cf7 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.cxx @@ -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.91 2006-10-14 20:08:29 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.92 2006-10-14 22:17:27 stephena Exp $ //============================================================================ #include @@ -306,8 +306,13 @@ inline void FrameBuffer::drawMessage() // Force an immediate update myOSystem->eventHandler().refreshDisplay(true); } +/* FIXME ?? - this sometimes causes a crash when switching from + bigger to smaller launcher windows and showing a message + I'm sure there's a bug somewhere, but this code no longer + seems to be needed, so I may just delete it at some point ... else addDirtyRect(myMessage.x, myMessage.y, myMessage.w, myMessage.h); +*/ } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -402,14 +407,14 @@ bool FrameBuffer::scale(int direction, const string& type) if(!createScreen()) return false; - myOSystem->eventHandler().refreshDisplay(); - showMessage(newScaler.name); - EventHandler::State state = myOSystem->eventHandler().state(); bool inTIAMode = (state == EventHandler::S_EMULATE || state == EventHandler::S_MENU || state == EventHandler::S_CMDMENU); + myOSystem->eventHandler().refreshDisplay(); + showMessage(newScaler.name); + if(inTIAMode) myOSystem->settings().setString("scale_tia", newScaler.name); else @@ -721,12 +726,11 @@ void FrameBuffer::setAvailableScalers() state == EventHandler::S_MENU || state == EventHandler::S_CMDMENU); -/* - cerr << "TIA mode: " << (inTIAMode ? "yes" : "no") << ", state: " << state << endl + cerr << " ====> setAvailableScalers() <====" << endl << endl + << "TIA mode: " << (inTIAMode ? "yes" : "no") << ", state: " << state << endl << "maxsize: " << maxsize << endl << "type: " << (type() == kSoftBuffer ? "soft buffer" : "GL buffer") << endl << endl; -*/ // Next, determine which mode we're in and update the appropriate scaler list if(type() == kSoftBuffer) @@ -759,16 +763,15 @@ void FrameBuffer::setAvailableScalers() ourUIScalers[i].available = true; } } -/* + cerr << "UI Scalers available:\n"; - for(int i = 0; i < 6; ++i) + for(int i = 0; i < kUIScalerListSize; ++i) if(ourUIScalers[i].available) cerr << ourUIScalers[i].name << endl; - for(int i = 0; i < kNumScalers; ++i) + for(int i = 0; i < kTIAScalerListSize; ++i) if(ourTIAScalers[i].available) cerr << ourTIAScalers[i].name << endl; - cerr << endl << endl; -*/ + cerr << " =================================" << endl << endl; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -786,9 +789,10 @@ void FrameBuffer::getScaler(Scaler& scaler, int direction, const string& name) switch(direction) { case 0: // search for the actual scaler specified in 'name' +cerr << "get scaler = " << name << endl; for(int i = 0; i < size; ++i) { - if(list[i].name == name) + if(list[i].name == name && list[i].available) { scaler = list[i]; found = true; @@ -804,7 +808,7 @@ void FrameBuffer::getScaler(Scaler& scaler, int direction, const string& name) // First find the current scaler for(i = 0; i < size; ++i) { - if(list[i].name == name) + if(list[i].name == name && list[i].available) { pos = i; break; @@ -838,7 +842,7 @@ void FrameBuffer::getScaler(Scaler& scaler, int direction, const string& name) // First find the current scaler for(i = 0; i < size; ++i) { - if(list[i].name == name) + if(list[i].name == name && list[i].available) { pos = i; break;