From: Steve A. <ste...@us...> - 2005-12-23 20:49:00
|
Update of /cvsroot/stella/stella/src/emucore In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5670/src/emucore Modified Files: Cart.cxx CartAR.cxx Console.cxx Console.hxx OSystem.cxx Log Message: Fixed segfault/false assert when the cartridge type is undefined. Stella will now either exit gracefully (when launching a ROM from the commandline), or continue running (when in ROM launcher mode) when attempting to use an undefined cartridge type. Index: Cart.cxx =================================================================== RCS file: /cvsroot/stella/stella/src/emucore/Cart.cxx,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Cart.cxx 13 Oct 2005 02:05:36 -0000 1.17 --- Cart.cxx 23 Dec 2005 20:48:50 -0000 1.18 *************** *** 18,22 **** #include <assert.h> ! #include <string.h> #include "Cart.hxx" #include "Cart2K.hxx" --- 18,23 ---- #include <assert.h> ! ! #include "bspf.hxx" #include "Cart.hxx" #include "Cart2K.hxx" *************** *** 98,105 **** cartridge = new CartridgeUA(image); else ! { ! // TODO: At some point this should be handled in a better way... ! assert(false); ! } return cartridge; --- 99,103 ---- cartridge = new CartridgeUA(image); else ! cerr << "ERROR: Invalid cartridge type " << type << " ..." << endl; return cartridge; Index: CartAR.cxx =================================================================== RCS file: /cvsroot/stella/stella/src/emucore/CartAR.cxx,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CartAR.cxx 17 Dec 2005 01:23:07 -0000 1.13 --- CartAR.cxx 23 Dec 2005 20:48:50 -0000 1.14 *************** *** 201,206 **** bool CartridgeAR::patch(uInt16 address, uInt8 value) { ! // myImage[address & 0x0FFF] = value; ! return false; } --- 201,206 ---- bool CartridgeAR::patch(uInt16 address, uInt8 value) { ! // myImage[address & 0x0FFF] = value; ! return false; } *************** *** 299,304 **** // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! void CartridgeAR::bank(uInt16 b) { ! if(bankLocked) return; bankConfiguration(b); --- 299,306 ---- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! void CartridgeAR::bank(uInt16 b) ! { ! if(bankLocked) ! return; bankConfiguration(b); *************** *** 306,315 **** // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! int CartridgeAR::bank() { return myCurrentBank; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! int CartridgeAR::bankCount() { return 32; } --- 308,319 ---- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! int CartridgeAR::bank() ! { return myCurrentBank; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! int CartridgeAR::bankCount() ! { return 32; } *************** *** 585,589 **** // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! uInt8* CartridgeAR::getImage(int& size) { size = myNumberOfLoadImages * 8448; return &myLoadImages[0]; --- 589,594 ---- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! uInt8* CartridgeAR::getImage(int& size) ! { size = myNumberOfLoadImages * 8448; return &myLoadImages[0]; Index: Console.cxx =================================================================== RCS file: /cvsroot/stella/stella/src/emucore/Console.cxx,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** Console.cxx 27 Nov 2005 22:37:24 -0000 1.77 --- Console.cxx 23 Dec 2005 20:48:50 -0000 1.78 *************** *** 63,67 **** Console::Console(const uInt8* image, uInt32 size, const string& md5, OSystem* osystem) ! : myOSystem(osystem) { myControllers[0] = 0; --- 63,68 ---- Console::Console(const uInt8* image, uInt32 size, const string& md5, OSystem* osystem) ! : myOSystem(osystem), ! myIsInitializedFlag(false) { myControllers[0] = 0; *************** *** 152,155 **** --- 153,158 ---- tia->setSound(myOSystem->sound()); Cartridge* cartridge = Cartridge::create(image, size, myProperties); + if(!cartridge) + return; mySystem->attach(m6502); *************** *** 216,219 **** --- 219,225 ---- myOSystem->debugger().initialize(); #endif + + // If we get this far, the console must be valid + myIsInitializedFlag = true; } Index: Console.hxx =================================================================== RCS file: /cvsroot/stella/stella/src/emucore/Console.hxx,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Console.hxx 19 Oct 2005 00:59:51 -0000 1.40 --- Console.hxx 23 Dec 2005 20:48:50 -0000 1.41 *************** *** 120,123 **** --- 120,128 ---- M6532& riot() const { return *myRiot; } + /** + Determine whether the console was successfully created + */ + bool isInitialized() { return myIsInitializedFlag; } + public: /** *************** *** 258,261 **** --- 263,270 ---- // A RIOT of my own! (...with apologies to The Clash...) M6532 *myRiot; + + // Indicates whether the console was correctly initialized + // We don't really care why it wasn't initialized ... + bool myIsInitializedFlag; }; Index: OSystem.cxx =================================================================== RCS file: /cvsroot/stella/stella/src/emucore/OSystem.cxx,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** OSystem.cxx 18 Dec 2005 18:37:03 -0000 1.50 --- OSystem.cxx 23 Dec 2005 20:48:50 -0000 1.51 *************** *** 297,317 **** // The Console c'tor takes care of updating the eventhandler state myConsole = new Console(image, size, md5, this); ! #ifdef CHEATCODE_SUPPORT ! myCheatManager->loadCheats(md5); ! #endif ! ! if(showmessage) ! myFrameBuffer->showMessage("New console created"); ! if(mySettings->getBool("showinfo")) ! cout << "Game console created: " << myRomFile << endl; ! retval = true; ! myEventHandler->reset(EventHandler::S_EMULATE); ! myFrameBuffer->setCursorState(); } else { ! cerr << "ERROR: Couldn't open " << myRomFile << "..." << endl; ! // myEventHandler->quit(); retval = false; } --- 297,323 ---- // The Console c'tor takes care of updating the eventhandler state myConsole = new Console(image, size, md5, this); ! if(myConsole->isInitialized()) ! { ! #ifdef CHEATCODE_SUPPORT ! myCheatManager->loadCheats(md5); ! #endif ! if(showmessage) ! myFrameBuffer->showMessage("New console created"); ! if(mySettings->getBool("showinfo")) ! cout << "Game console created: " << myRomFile << endl; ! myEventHandler->reset(EventHandler::S_EMULATE); ! myFrameBuffer->setCursorState(); ! retval = true; ! } ! else ! { ! cerr << "ERROR: Couldn't create console for " << myRomFile << " ..." << endl; ! retval = false; ! } } else { ! cerr << "ERROR: Couldn't open " << myRomFile << " ..." << endl; retval = false; } |