in atari_py/ale_interface/src/emucore/Cart.cxx [174:284]
string Cartridge::autodetectType(const uInt8* image, uInt32 size)
{
// Guess type based on size
const char* type = 0;
if((size % 8448) == 0)
{
type = "AR";
}
else if((size == 2048) ||
(size == 4096 && memcmp(image, image + 2048, 2048) == 0))
{
if(isProbablyCV(image, size))
type = "CV";
else
type = "2K";
}
else if(size == 4096)
{
if(isProbablyCV(image, size))
type = "CV";
else
type = "4K";
}
else if(size == 8192) // 8K
{
if(isProbablySC(image, size))
type = "F8SC";
else if(memcmp(image, image + 4096, 4096) == 0)
type = "4K";
else if(isProbablyE0(image, size))
type = "E0";
else if(isProbably3E(image, size))
type = "3E";
else if(isProbably3F(image, size))
type = "3F";
else if(isProbablyUA(image, size))
type = "UA";
else if(isProbablyFE(image, size))
type = "FE";
else
type = "F8";
}
else if((size == 10495) || (size == 10496) || (size == 10240)) // 10K - Pitfall2
{
type = "DPC";
}
else if(size == 12288) // 12K
{
// TODO - this should really be in a method that checks the first
// 512 bytes of ROM and finds if either the lower 256 bytes or
// higher 256 bytes are all the same. For now, we assume that
// all carts of 12K are CBS RAM Plus/FASC.
type = "FASC";
}
else if(size == 16384) // 16K
{
if(isProbablySC(image, size))
type = "F6SC";
else if(isProbablyE7(image, size))
type = "E7";
else if(isProbably3E(image, size))
type = "3E";
else if(isProbably3F(image, size))
type = "3F";
else
type = "F6";
}
else if(size == 32768) // 32K
{
if(isProbablySC(image, size))
type = "F4SC";
else if(isProbably3E(image, size))
type = "3E";
else if(isProbably3F(image, size))
type = "3F";
else
type = "F4";
}
else if(size == 65536) // 64K
{
// TODO - autodetect 4A50
if(isProbably3E(image, size))
type = "3E";
else if(isProbably3F(image, size))
type = "3F";
else
type = "MB";
}
else if(size == 131072) // 128K
{
// TODO - autodetect 4A50
if(isProbably3E(image, size))
type = "3E";
else if(isProbably3F(image, size))
type = "3F";
else
type = "MC";
}
else // what else can we do?
{
if(isProbably3E(image, size))
type = "3E";
else if(isProbably3F(image, size))
type = "3F";
else
type = "4K"; // Most common bankswitching type
}
return type;
}