Modified the autodetect routine to include a search for 3F style

bankswitching as suggested by Adam Wozniak.  This allows most of
the demos/homebrew games being created using this method to work
without a stella.pro file entry.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@164 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
bwmott 2003-02-17 04:59:54 +00:00
parent 8d530f38a2
commit 28572bbff3
2 changed files with 30 additions and 10 deletions

View File

@ -8,12 +8,12 @@
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2002 by Bradford W. Mott
// Copyright (c) 1995-2003 by Bradford W. Mott
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart.cxx,v 1.5 2002-12-15 05:49:04 bwmott Exp $
// $Id: Cart.cxx,v 1.6 2003-02-17 04:59:54 bwmott Exp $
//============================================================================
#include <assert.h>
@ -178,7 +178,7 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
}
else if((size == 8192) || (memcmp(image, image + 8192, 8192) == 0))
{
type = "F8";
type = isProbably3F(image, size) ? "3F" : "F8";
}
else if((size == 10495) || (size == 10240))
{
@ -199,18 +199,18 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
if(image[i] != first)
{
// It's not a super cart (probably)
type = "F4";
type = isProbably3F(image, size) ? "3F" : "F4";
break;
}
}
}
else if(size == 65536)
{
type = "MB";
type = isProbably3F(image, size) ? "3F" : "MB";
}
else if(size == 131072)
{
type = "MC";
type = isProbably3F(image, size) ? "3F" : "MC";
}
else
{
@ -223,7 +223,7 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
if(image[i] != first)
{
// It's not a super cart (probably)
type = "F6";
type = isProbably3F(image, size) ? "3F" : "F6";
break;
}
}
@ -233,6 +233,21 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
return type;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge::isProbably3F(const uInt8* image, uInt32 size)
{
uInt32 count = 0;
for(uInt32 i = 0; i < size - 1; ++i)
{
if((image[i] == 0x85) && (image[i + 1] == 0x3F))
{
++count;
}
}
return (count > 2);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge::Cartridge(const Cartridge&)
{

View File

@ -8,12 +8,12 @@
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-1998 by Bradford W. Mott
// Copyright (c) 1995-2003 by Bradford W. Mott
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart.hxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $
// $Id: Cart.hxx,v 1.2 2003-02-17 04:59:54 bwmott Exp $
//============================================================================
#ifndef CARTRIDGE_HXX
@ -31,7 +31,7 @@ class System;
game and handles any bankswitching performed by the cartridge.
@author Bradford W. Mott
@version $Id: Cart.hxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $
@version $Id: Cart.hxx,v 1.2 2003-02-17 04:59:54 bwmott Exp $
*/
class Cartridge : public Device
{
@ -69,6 +69,11 @@ class Cartridge : public Device
*/
static string autodetectType(const uInt8* image, uInt32 size);
/**
Returns true iff the image is probably a 3F bankswitching cartridge
*/
static bool isProbably3F(const uInt8* image, uInt32 size);
private:
// Copy constructor isn't supported by cartridges so make it private
Cartridge(const Cartridge&);