From 7606af4b3aa26a3d867ae1c94760c5ef080cde35 Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 15 Mar 2006 23:14:01 +0000 Subject: [PATCH] Fixed bug/crash with attempting to create a Console if the ROM image dimensions are larger than the current screen. In the process, this restructuring will allow messages to be shown in states other than emulation mode. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1047 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/Console.cxx | 13 ++++++++++++- stella/src/emucore/EventHandler.cxx | 6 ++++-- stella/src/emucore/FrameBuffer.cxx | 18 ++++++++++-------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index ba5d78569..b5543812c 100644 --- a/stella/src/emucore/Console.cxx +++ b/stella/src/emucore/Console.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: Console.cxx,v 1.84 2006-03-05 01:18:41 stephena Exp $ +// $Id: Console.cxx,v 1.85 2006-03-15 23:14:01 stephena Exp $ //============================================================================ #include @@ -87,6 +87,17 @@ Console::Console(const uInt8* image, uInt32 size, const string& md5, if(myProperties.get(Display_Height) == "210") myProperties.set(Display_Height, "250"); + // Make sure this ROM can fit in the screen dimensions + int sWidth, sHeight, iWidth, iHeight; + myOSystem->getScreenDimensions(sWidth, sHeight); + iWidth = atoi(myProperties.get(Display_Width).c_str()) << 1; + iHeight = atoi(myProperties.get(Display_Height).c_str()); + if(iWidth > sWidth || iHeight > sHeight) + { + myOSystem->frameBuffer().showMessage("ROM image dimensions larger than screen"); + return; + } + // Setup the controllers based on properties string left = myProperties.get(Controller_Left); string right = myProperties.get(Controller_Right); diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 2beac244a..a91345cd1 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.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: EventHandler.cxx,v 1.152 2006-03-05 01:18:42 stephena Exp $ +// $Id: EventHandler.cxx,v 1.153 2006-03-15 23:14:01 stephena Exp $ //============================================================================ #include @@ -194,7 +194,7 @@ void EventHandler::refreshDisplay() switch(myState) { case S_EMULATE: - myOSystem->frameBuffer().refresh(); + myOSystem->frameBuffer().refresh(true); break; case S_MENU: @@ -208,6 +208,8 @@ void EventHandler::refreshDisplay() default: break; } + +// cerr << " ==> State change = " << myState << endl; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 5d973e1d8..274d263c3 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.79 2006-03-06 15:42:26 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.80 2006-03-15 23:14:01 stephena Exp $ //============================================================================ #include @@ -176,6 +176,7 @@ void FrameBuffer::update() // Draw any pending messages if(myMessageTime > 0 && !myPauseStatus) drawMessage(); + break; // S_EMULATE } @@ -206,6 +207,11 @@ void FrameBuffer::update() case EventHandler::S_LAUNCHER: { myOSystem->launcher().draw(); + + // Draw any pending messages + if(myMessageTime > 0) + drawMessage(); + break; // S_LAUNCHER } @@ -232,7 +238,6 @@ void FrameBuffer::update() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::refresh(bool now) { -// cerr << "refreshTIA() " << myNumRedraws++ << endl; theRedrawTIAIndicator = true; if(now) { @@ -248,7 +253,7 @@ void FrameBuffer::showMessage(const string& message) if(myMessageTime > 0) { theRedrawTIAIndicator = true; - drawMediaSource(); + myOSystem->eventHandler().refreshDisplay(); } myMessageText = message; @@ -260,7 +265,7 @@ void FrameBuffer::hideMessage() { // Erase old messages on the screen if(myMessageTime > 0) - refresh(true); + myOSystem->eventHandler().refreshDisplay(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -533,10 +538,7 @@ inline void FrameBuffer::drawMessage() // Either erase the entire message (when time is reached), // or show again this frame if(myMessageTime == 0) - { - theRedrawTIAIndicator = true; - drawMediaSource(); - } + myOSystem->eventHandler().refreshDisplay(); else addDirtyRect(x, y, w, h); }