Added support for 6K Supercharger ROMs. Currently, the only one I know

of is the 6K version of 'Cubis'.  Thanks to Eckhard Stolberg for advice
on this.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1847 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-08-03 21:18:16 +00:00
parent 2537291ec8
commit d5bf1494da
4 changed files with 104 additions and 55 deletions

View File

@ -263,7 +263,7 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
// Guess type based on size
const char* type = 0;
if((size % 8448) == 0)
if((size % 8448) == 0 || size == 6144)
{
type = "AR";
}

View File

@ -30,10 +30,17 @@ CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size,
: my6502(0),
mySettings(settings)
{
// Minimum size supported internally is 8448 bytes
uInt32 minsize = BSPF_max(size, 8448u);
// Create a load image buffer and copy the given image
myLoadImages = new uInt8[size];
myNumberOfLoadImages = size / 8448;
myLoadImages = new uInt8[minsize];
myNumberOfLoadImages = minsize / 8448;
memcpy(myLoadImages, image, size);
// Add header if image doesn't include it
if(size < 8448)
memcpy(myLoadImages+8192, ourDefaultHeader, 256);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -283,68 +290,28 @@ void CartridgeAR::bankConfiguration(uInt8 configuration)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeAR::initializeROM()
{
static uInt8 dummyROMCode[] = {
0xa5, 0xfa, 0x85, 0x80, 0x4c, 0x18, 0xf8, 0xff,
0xff, 0xff, 0x78, 0xd8, 0xa0, 0x0, 0xa2, 0x0,
0x94, 0x0, 0xe8, 0xd0, 0xfb, 0x4c, 0x50, 0xf8,
0xa2, 0x0, 0xbd, 0x6, 0xf0, 0xad, 0xf8, 0xff,
0xa2, 0x0, 0xad, 0x0, 0xf0, 0xea, 0xbd, 0x0,
0xf7, 0xca, 0xd0, 0xf6, 0x4c, 0x50, 0xf8, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xa2, 0x3, 0xbc, 0x22, 0xf9, 0x94, 0xfa, 0xca,
0x10, 0xf8, 0xa0, 0x0, 0xa2, 0x28, 0x94, 0x4,
0xca, 0x10, 0xfb, 0xa2, 0x1c, 0x94, 0x81, 0xca,
0x10, 0xfb, 0xa9, 0xff, 0xc9, 0x0, 0xd0, 0x3,
0x4c, 0x13, 0xf9, 0xa9, 0x0, 0x85, 0x1b, 0x85,
0x1c, 0x85, 0x1d, 0x85, 0x1e, 0x85, 0x1f, 0x85,
0x19, 0x85, 0x1a, 0x85, 0x8, 0x85, 0x1, 0xa9,
0x10, 0x85, 0x21, 0x85, 0x2, 0xa2, 0x7, 0xca,
0xca, 0xd0, 0xfd, 0xa9, 0x0, 0x85, 0x20, 0x85,
0x10, 0x85, 0x11, 0x85, 0x2, 0x85, 0x2a, 0xa9,
0x5, 0x85, 0xa, 0xa9, 0xff, 0x85, 0xd, 0x85,
0xe, 0x85, 0xf, 0x85, 0x84, 0x85, 0x85, 0xa9,
0xf0, 0x85, 0x83, 0xa9, 0x74, 0x85, 0x9, 0xa9,
0xc, 0x85, 0x15, 0xa9, 0x1f, 0x85, 0x17, 0x85,
0x82, 0xa9, 0x7, 0x85, 0x19, 0xa2, 0x8, 0xa0,
0x0, 0x85, 0x2, 0x88, 0xd0, 0xfb, 0x85, 0x2,
0x85, 0x2, 0xa9, 0x2, 0x85, 0x2, 0x85, 0x0,
0x85, 0x2, 0x85, 0x2, 0x85, 0x2, 0xa9, 0x0,
0x85, 0x0, 0xca, 0x10, 0xe4, 0x6, 0x83, 0x66,
0x84, 0x26, 0x85, 0xa5, 0x83, 0x85, 0xd, 0xa5,
0x84, 0x85, 0xe, 0xa5, 0x85, 0x85, 0xf, 0xa6,
0x82, 0xca, 0x86, 0x82, 0x86, 0x17, 0xe0, 0xa,
0xd0, 0xc3, 0xa9, 0x2, 0x85, 0x1, 0xa2, 0x1c,
0xa0, 0x0, 0x84, 0x19, 0x84, 0x9, 0x94, 0x81,
0xca, 0x10, 0xfb, 0xa6, 0x80, 0xdd, 0x0, 0xf0,
0xa9, 0x9a, 0xa2, 0xff, 0xa0, 0x0, 0x9a, 0x4c,
0xfa, 0x0, 0xcd, 0xf8, 0xff, 0x4c
};
// Note that the following offsets depend on the 'scrom.asm' file
// in src/emucore/misc. If that file is ever recompiled (and its
// contents placed in the array above), the offsets will almost
// definitely change
// contents placed in the ourDummyROMCode array), the offsets will
// almost definitely change
// The scrom.asm code checks a value at offset 109 as follows:
// 0xff -> do a complete jump over the SC BIOS progress bars code
// 0x0 -> show SC BIOS progress bars as normal
dummyROMCode[109] = mySettings.getBool("fastscbios") ? 0xff : 0x0;
ourDummyROMCode[109] = mySettings.getBool("fastscbios") ? 0xff : 0x0;
// The accumulator should contain a random value after exiting the
// SC BIOS code - a value placed in offset 281 will be stored in A
class Random random;
dummyROMCode[281] = random.next();
ourDummyROMCode[281] = random.next();
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
for(uInt32 i = 0; i < 2048; ++i)
myImage[3 * 2048 + i] = 0x02;
myImage[3 * 2048 + i] = 0x02;
// Copy the "dummy" Supercharger BIOS code into the ROM area
for(uInt32 j = 0; j < sizeof(dummyROMCode); ++j)
myImage[3 * 2048 + j] = dummyROMCode[j];
for(uInt32 j = 0; j < sizeof(ourDummyROMCode); ++j)
myImage[3 * 2048 + j] = ourDummyROMCode[j];
// Finally set 6502 vectors to point to initial load code at 0xF80A of BIOS
myImage[3 * 2048 + 2044] = 0x0A;
@ -359,9 +326,7 @@ uInt8 CartridgeAR::checksum(uInt8* s, uInt16 length)
uInt8 sum = 0;
for(uInt32 i = 0; i < length; ++i)
{
sum += s[i];
}
return sum;
}
@ -591,3 +556,80 @@ bool CartridgeAR::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeAR::ourDummyROMCode[] = {
0xa5, 0xfa, 0x85, 0x80, 0x4c, 0x18, 0xf8, 0xff,
0xff, 0xff, 0x78, 0xd8, 0xa0, 0x00, 0xa2, 0x00,
0x94, 0x00, 0xe8, 0xd0, 0xfb, 0x4c, 0x50, 0xf8,
0xa2, 0x00, 0xbd, 0x06, 0xf0, 0xad, 0xf8, 0xff,
0xa2, 0x00, 0xad, 0x00, 0xf0, 0xea, 0xbd, 0x00,
0xf7, 0xca, 0xd0, 0xf6, 0x4c, 0x50, 0xf8, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xa2, 0x03, 0xbc, 0x22, 0xf9, 0x94, 0xfa, 0xca,
0x10, 0xf8, 0xa0, 0x00, 0xa2, 0x28, 0x94, 0x04,
0xca, 0x10, 0xfb, 0xa2, 0x1c, 0x94, 0x81, 0xca,
0x10, 0xfb, 0xa9, 0xff, 0xc9, 0x00, 0xd0, 0x03,
0x4c, 0x13, 0xf9, 0xa9, 0x00, 0x85, 0x1b, 0x85,
0x1c, 0x85, 0x1d, 0x85, 0x1e, 0x85, 0x1f, 0x85,
0x19, 0x85, 0x1a, 0x85, 0x08, 0x85, 0x01, 0xa9,
0x10, 0x85, 0x21, 0x85, 0x02, 0xa2, 0x07, 0xca,
0xca, 0xd0, 0xfd, 0xa9, 0x00, 0x85, 0x20, 0x85,
0x10, 0x85, 0x11, 0x85, 0x02, 0x85, 0x2a, 0xa9,
0x05, 0x85, 0x0a, 0xa9, 0xff, 0x85, 0x0d, 0x85,
0x0e, 0x85, 0x0f, 0x85, 0x84, 0x85, 0x85, 0xa9,
0xf0, 0x85, 0x83, 0xa9, 0x74, 0x85, 0x09, 0xa9,
0x0c, 0x85, 0x15, 0xa9, 0x1f, 0x85, 0x17, 0x85,
0x82, 0xa9, 0x07, 0x85, 0x19, 0xa2, 0x08, 0xa0,
0x00, 0x85, 0x02, 0x88, 0xd0, 0xfb, 0x85, 0x02,
0x85, 0x02, 0xa9, 0x02, 0x85, 0x02, 0x85, 0x00,
0x85, 0x02, 0x85, 0x02, 0x85, 0x02, 0xa9, 0x00,
0x85, 0x00, 0xca, 0x10, 0xe4, 0x06, 0x83, 0x66,
0x84, 0x26, 0x85, 0xa5, 0x83, 0x85, 0x0d, 0xa5,
0x84, 0x85, 0x0e, 0xa5, 0x85, 0x85, 0x0f, 0xa6,
0x82, 0xca, 0x86, 0x82, 0x86, 0x17, 0xe0, 0x0a,
0xd0, 0xc3, 0xa9, 0x02, 0x85, 0x01, 0xa2, 0x1c,
0xa0, 0x00, 0x84, 0x19, 0x84, 0x09, 0x94, 0x81,
0xca, 0x10, 0xfb, 0xa6, 0x80, 0xdd, 0x00, 0xf0,
0xa9, 0x9a, 0xa2, 0xff, 0xa0, 0x00, 0x9a, 0x4c,
0xfa, 0x00, 0xcd, 0xf8, 0xff, 0x4c
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeAR::ourDefaultHeader[256] = {
0xac, 0xfa, 0x0f, 0x18, 0x62, 0x00, 0x24, 0x02,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
0x01, 0x05, 0x09, 0x0d, 0x11, 0x15, 0x19, 0x1d,
0x02, 0x06, 0x0a, 0x0e, 0x12, 0x16, 0x1a, 0x1e,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
};

View File

@ -205,6 +205,13 @@ class CartridgeAR : public Cartridge
bool myWritePending;
uInt16 myCurrentBank;
// Fake SC-BIOS code to simulate the Supercharger load bars
static uInt8 ourDummyROMCode[294];
// Default 256-byte header to use if one isn't included in the ROM
// This data comes from z26
static uInt8 ourDefaultHeader[256];
};
#endif

View File

@ -24,16 +24,16 @@ int main(int ac, char* av[])
in.read((char*)data, len);
in.close();
cout << " ";
cout << "SIZE = " << (len - 2) << endl << " ";
// Skip first two bytes; they shouldn't be used
for(int t = 2; t < len; ++t)
{
cout << "0x" << hex << (int)data[t];
cout << "0x" << setw(2) << setfill('0') << hex << (int)data[t];
if(t < len - 1)
cout << ", ";
if(((t-2) % 8) == 7)
cout << endl << " ";
cout << endl << " ";
}
cout << endl;
delete[] data;