diff --git a/src/common/mainSDL.cxx b/src/common/mainSDL.cxx index 08f5526d3..a129ab2c3 100644 --- a/src/common/mainSDL.cxx +++ b/src/common/mainSDL.cxx @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) // the ROM actually exists, use it to create a new console. // If not, use the built-in ROM launcher. In this case, we enter 'launcher' // mode and let the main event loop take care of opening a new console/ROM. - if(argc == 1 || romfile == "" || !romnode.exists()) + if(argc == 1 || romfile == "" || !romnode.exists() || romnode.isDirectory()) { if(!theOSystem->createLauncher()) { diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index c8ba9a5f2..159f61115 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -54,7 +54,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge* Cartridge::create(const uInt8* image, uInt32 size, - const Properties& properties, const Settings& settings) + const Properties& properties, Settings& settings) { Cartridge* cartridge = 0; @@ -72,6 +72,19 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size, // from the opposite bank compared to normal ones type = "F8 swapped"; } + else if(md5 == "291bcdb05f2b37cdf9452d2bf08e0321") + { + // The 32-in-1 ROM consists of 32 games of 2K each + // The current game is automatically automatically incremented on each + // power cycle; we emulate this by using saving the current game id + // on each run, and creating a 2K Cart of the appropriate part of + // the image + if(size == 32*2048) + { + type = "32in1"; + size = 2048; + } + } // Collect some info about the ROM ostringstream buf; @@ -88,16 +101,27 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size, type = detected; } - buf << type << autodetect << " ("; + buf << type << autodetect; + if(type == "32in1") + buf << " [G" << settings.getInt("romloadcount") << "]"; if(size < 1024) - buf << size << "B) "; + buf << " (" << size << "B) "; else - buf << (size/1024) << "K) "; + 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, size); + else if(type == "32in1") + { + // Get a 2K piece of the 64K image and create a normal 2K image + uInt32 i = settings.getInt("romloadcount"); + const uInt8* piece = image + i*2048; + // Move to the next game the next time this ROM is loaded + settings.setInt("romloadcount", (i+1)%32); + cartridge = new Cartridge2K(piece, 2048); + } else if(type == "3E") cartridge = new Cartridge3E(image, size); else if(type == "3F") diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 86fd16b9a..02c2934fc 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -51,7 +51,7 @@ class Cartridge : public Device @return Pointer to the new cartridge object allocated on the heap */ static Cartridge* create(const uInt8* image, uInt32 size, - const Properties& props, const Settings& settings); + const Properties& props, Settings& settings); /** Create a new cartridge diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 0ba8b76ee..84974caca 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -461,6 +461,11 @@ bool OSystem::createConsole(const string& romfile, const string& md5sum) { myRomFile = romfile; myRomMD5 = md5sum; + + // Each time a new console is loaded, we simulate a cart removal + // Some carts need knowledge of this, as they behave differently + // based on how many power-cycles they've been through since plugged in + mySettings->setInt("romloadcount", 0); } // Create an instance of the 2600 game console diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index e2c29337e..847f7f14e 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -118,6 +118,7 @@ Settings::Settings(OSystem* osystem) setInternal("stats", "false"); setInternal("audiofirst", "true"); setInternal("fastscbios", "false"); + setExternal("romloadcount", "0"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -