Added native support for the 32-in-1 cart. Loading this ROM will always

start with game 0 (as if it's been unplugged for some time), but reloading
the ROM with Ctrl-r will cycle through each game (emulating a power-cycle).

Fixed crash when specifying a directory on the commandline; only files
are supported as ROMs.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1770 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-06-12 18:44:32 +00:00
parent 5d29bc0e2d
commit 465dc36476
5 changed files with 36 additions and 6 deletions

View File

@ -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())
{

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -118,6 +118,7 @@ Settings::Settings(OSystem* osystem)
setInternal("stats", "false");
setInternal("audiofirst", "true");
setInternal("fastscbios", "false");
setExternal("romloadcount", "0");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -