2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2009-01-01 18:13:40 +00:00
|
|
|
// Copyright (c) 1995-2009 by Bradford W. Mott and the Stella team
|
2001-12-27 19:54:36 +00:00
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
|
2007-01-14 16:17:57 +00:00
|
|
|
#include <cassert>
|
2008-05-30 12:06:17 +00:00
|
|
|
#include <cstring>
|
2007-01-14 16:17:57 +00:00
|
|
|
|
2009-05-17 19:30:10 +00:00
|
|
|
#include "M6502.hxx"
|
2001-12-27 19:54:36 +00:00
|
|
|
#include "Random.hxx"
|
|
|
|
#include "System.hxx"
|
2007-01-14 16:17:57 +00:00
|
|
|
#include "CartAR.hxx"
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2009-06-09 14:27:21 +00:00
|
|
|
CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size,
|
|
|
|
const Settings& settings)
|
|
|
|
: my6502(0),
|
|
|
|
mySettings(settings)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
|
|
|
// Create a load image buffer and copy the given image
|
|
|
|
myLoadImages = new uInt8[size];
|
|
|
|
myNumberOfLoadImages = size / 8448;
|
|
|
|
memcpy(myLoadImages, image, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
CartridgeAR::~CartridgeAR()
|
|
|
|
{
|
|
|
|
delete[] myLoadImages;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeAR::reset()
|
|
|
|
{
|
2008-08-01 12:16:00 +00:00
|
|
|
// Initialize RAM with random values
|
|
|
|
class Random random;
|
|
|
|
for(uInt32 i = 0; i < 6 * 1024; ++i)
|
|
|
|
myImage[i] = random.next();
|
|
|
|
|
2009-06-09 14:27:21 +00:00
|
|
|
// Initialize SC BIOS ROM
|
|
|
|
initializeROM();
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
myPower = true;
|
2002-04-05 02:18:23 +00:00
|
|
|
myPowerRomCycle = mySystem->cycles();
|
2001-12-27 19:54:36 +00:00
|
|
|
myWriteEnabled = false;
|
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
myDataHoldRegister = 0;
|
2001-12-27 19:54:36 +00:00
|
|
|
myNumberOfDistinctAccesses = 0;
|
|
|
|
myWritePending = false;
|
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
// Set bank configuration upon reset so ROM is selected and powered up
|
|
|
|
bankConfiguration(0);
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeAR::systemCyclesReset()
|
|
|
|
{
|
|
|
|
// Get the current system cycle
|
|
|
|
uInt32 cycles = mySystem->cycles();
|
|
|
|
|
|
|
|
// Adjust cycle values
|
|
|
|
myPowerRomCycle -= cycles;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeAR::install(System& system)
|
|
|
|
{
|
|
|
|
mySystem = &system;
|
|
|
|
uInt16 shift = mySystem->pageShift();
|
|
|
|
uInt16 mask = mySystem->pageMask();
|
|
|
|
|
2009-05-17 19:30:10 +00:00
|
|
|
my6502 = &(mySystem->m6502());
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
// Make sure the system we're being installed in has a page size that'll work
|
|
|
|
assert((0x1000 & mask) == 0);
|
|
|
|
|
|
|
|
System::PageAccess access;
|
|
|
|
for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift))
|
|
|
|
{
|
|
|
|
access.directPeekBase = 0;
|
|
|
|
access.directPokeBase = 0;
|
|
|
|
access.device = this;
|
|
|
|
mySystem->setPageAccess(i >> shift, access);
|
|
|
|
}
|
|
|
|
|
|
|
|
bankConfiguration(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
uInt8 CartridgeAR::peek(uInt16 addr)
|
|
|
|
{
|
2002-04-05 02:18:23 +00:00
|
|
|
// Is the "dummy" SC BIOS hotspot for reading a load being accessed?
|
|
|
|
if(((addr & 0x1FFF) == 0x1850) && (myImageOffset[1] == (3 * 2048)))
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2002-04-05 02:18:23 +00:00
|
|
|
// Get load that's being accessed (BIOS places load number at 0x80)
|
|
|
|
uInt8 load = mySystem->peek(0x0080);
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
// Read the specified load into RAM
|
|
|
|
loadIntoRAM(load);
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
return myImage[(addr & 0x07FF) + myImageOffset[1]];
|
|
|
|
}
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
// Cancel any pending write if more than 5 distinct accesses have occurred
|
|
|
|
// TODO: Modify to handle when the distinct counter wraps around...
|
|
|
|
if(myWritePending &&
|
|
|
|
(my6502->distinctAccesses() > myNumberOfDistinctAccesses + 5))
|
|
|
|
{
|
|
|
|
myWritePending = false;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
// Is the data hold register being set?
|
2001-12-27 19:54:36 +00:00
|
|
|
if(!(addr & 0x0F00) && (!myWriteEnabled || !myWritePending))
|
|
|
|
{
|
2002-04-05 02:18:23 +00:00
|
|
|
myDataHoldRegister = addr;
|
2001-12-27 19:54:36 +00:00
|
|
|
myNumberOfDistinctAccesses = my6502->distinctAccesses();
|
|
|
|
myWritePending = true;
|
|
|
|
}
|
|
|
|
// Is the bank configuration hotspot being accessed?
|
|
|
|
else if((addr & 0x1FFF) == 0x1FF8)
|
|
|
|
{
|
|
|
|
// Yes, so handle bank configuration
|
|
|
|
myWritePending = false;
|
2002-04-05 02:18:23 +00:00
|
|
|
bankConfiguration(myDataHoldRegister);
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
// Handle poke if writing enabled
|
2002-04-05 02:18:23 +00:00
|
|
|
else if(myWriteEnabled && myWritePending &&
|
|
|
|
(my6502->distinctAccesses() == (myNumberOfDistinctAccesses + 5)))
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2002-04-05 02:18:23 +00:00
|
|
|
if((addr & 0x0800) == 0)
|
|
|
|
myImage[(addr & 0x07FF) + myImageOffset[0]] = myDataHoldRegister;
|
|
|
|
else if(myImageOffset[1] != 3 * 2048) // Can't poke to ROM :-)
|
|
|
|
myImage[(addr & 0x07FF) + myImageOffset[1]] = myDataHoldRegister;
|
|
|
|
myWritePending = false;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return myImage[(addr & 0x07FF) + myImageOffset[(addr & 0x0800) ? 1 : 0]];
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeAR::poke(uInt16 addr, uInt8)
|
|
|
|
{
|
2002-04-05 02:18:23 +00:00
|
|
|
// Cancel any pending write if more than 5 distinct accesses have occurred
|
|
|
|
// TODO: Modify to handle when the distinct counter wraps around...
|
|
|
|
if(myWritePending &&
|
|
|
|
(my6502->distinctAccesses() > myNumberOfDistinctAccesses + 5))
|
|
|
|
{
|
|
|
|
myWritePending = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is the data hold register being set?
|
2001-12-27 19:54:36 +00:00
|
|
|
if(!(addr & 0x0F00) && (!myWriteEnabled || !myWritePending))
|
|
|
|
{
|
2002-04-05 02:18:23 +00:00
|
|
|
myDataHoldRegister = addr;
|
2001-12-27 19:54:36 +00:00
|
|
|
myNumberOfDistinctAccesses = my6502->distinctAccesses();
|
|
|
|
myWritePending = true;
|
|
|
|
}
|
|
|
|
// Is the bank configuration hotspot being accessed?
|
|
|
|
else if((addr & 0x1FFF) == 0x1FF8)
|
|
|
|
{
|
|
|
|
// Yes, so handle bank configuration
|
|
|
|
myWritePending = false;
|
2002-04-05 02:18:23 +00:00
|
|
|
bankConfiguration(myDataHoldRegister);
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
// Handle poke if writing enabled
|
2002-04-05 02:18:23 +00:00
|
|
|
else if(myWriteEnabled && myWritePending &&
|
|
|
|
(my6502->distinctAccesses() == (myNumberOfDistinctAccesses + 5)))
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2002-04-05 02:18:23 +00:00
|
|
|
if((addr & 0x0800) == 0)
|
|
|
|
myImage[(addr & 0x07FF) + myImageOffset[0]] = myDataHoldRegister;
|
|
|
|
else if(myImageOffset[1] != 3 * 2048) // Can't poke to ROM :-)
|
|
|
|
myImage[(addr & 0x07FF) + myImageOffset[1]] = myDataHoldRegister;
|
|
|
|
myWritePending = false;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeAR::bankConfiguration(uInt8 configuration)
|
|
|
|
{
|
|
|
|
// D7-D5 of this byte: Write Pulse Delay (n/a for emulator)
|
|
|
|
//
|
|
|
|
// D4-D0: RAM/ROM configuration:
|
|
|
|
// $F000-F7FF $F800-FFFF Address range that banks map into
|
|
|
|
// 000wp 2 ROM
|
|
|
|
// 001wp 0 ROM
|
|
|
|
// 010wp 2 0 as used in Commie Mutants and many others
|
|
|
|
// 011wp 0 2 as used in Suicide Mission
|
|
|
|
// 100wp 2 ROM
|
|
|
|
// 101wp 1 ROM
|
|
|
|
// 110wp 2 1 as used in Killer Satellites
|
|
|
|
// 111wp 1 2 as we use for 2k/4k ROM cloning
|
|
|
|
//
|
|
|
|
// w = Write Enable (1 = enabled; accesses to $F000-$F0FF cause writes
|
|
|
|
// to happen. 0 = disabled, and the cart acts like ROM.)
|
|
|
|
// p = ROM Power (0 = enabled, 1 = off.) Only power the ROM if you're
|
|
|
|
// wanting to access the ROM for multiloads. Otherwise set to 1.
|
|
|
|
|
2005-06-27 12:43:49 +00:00
|
|
|
myCurrentBank = configuration & 0x1f; // remember for the bank() method
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
// Handle ROM power configuration
|
|
|
|
myPower = !(configuration & 0x01);
|
|
|
|
|
|
|
|
if(myPower)
|
|
|
|
{
|
|
|
|
myPowerRomCycle = mySystem->cycles();
|
|
|
|
}
|
|
|
|
|
|
|
|
myWriteEnabled = configuration & 0x02;
|
|
|
|
|
|
|
|
switch((configuration >> 2) & 0x07)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
myImageOffset[0] = 2 * 2048;
|
|
|
|
myImageOffset[1] = 3 * 2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
myImageOffset[0] = 0 * 2048;
|
|
|
|
myImageOffset[1] = 3 * 2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
myImageOffset[0] = 2 * 2048;
|
|
|
|
myImageOffset[1] = 0 * 2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
myImageOffset[0] = 0 * 2048;
|
|
|
|
myImageOffset[1] = 2 * 2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
myImageOffset[0] = 2 * 2048;
|
|
|
|
myImageOffset[1] = 3 * 2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
myImageOffset[0] = 1 * 2048;
|
|
|
|
myImageOffset[1] = 3 * 2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
myImageOffset[0] = 2 * 2048;
|
|
|
|
myImageOffset[1] = 1 * 2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
myImageOffset[0] = 1 * 2048;
|
|
|
|
myImageOffset[1] = 2 * 2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2009-06-09 14:27:21 +00:00
|
|
|
void CartridgeAR::initializeROM()
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
|
|
|
static uInt8 dummyROMCode[] = {
|
2009-06-09 14:27:21 +00:00
|
|
|
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
|
2001-12-27 19:54:36 +00:00
|
|
|
};
|
|
|
|
|
2009-06-09 14:27:21 +00:00
|
|
|
// 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
|
|
|
|
|
|
|
|
// 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;
|
2006-11-08 00:09:53 +00:00
|
|
|
|
2009-06-09 14:27:21 +00:00
|
|
|
// 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();
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
// 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;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
// Copy the "dummy" Supercharger BIOS code into the ROM area
|
2009-06-09 14:27:21 +00:00
|
|
|
for(uInt32 j = 0; j < sizeof(dummyROMCode); ++j)
|
2002-04-05 02:18:23 +00:00
|
|
|
myImage[3 * 2048 + j] = dummyROMCode[j];
|
|
|
|
|
|
|
|
// Finally set 6502 vectors to point to initial load code at 0xF80A of BIOS
|
|
|
|
myImage[3 * 2048 + 2044] = 0x0A;
|
|
|
|
myImage[3 * 2048 + 2045] = 0xF8;
|
|
|
|
myImage[3 * 2048 + 2046] = 0x0A;
|
|
|
|
myImage[3 * 2048 + 2047] = 0xF8;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
uInt8 CartridgeAR::checksum(uInt8* s, uInt16 length)
|
|
|
|
{
|
|
|
|
uInt8 sum = 0;
|
|
|
|
|
|
|
|
for(uInt32 i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
sum += s[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeAR::loadIntoRAM(uInt8 load)
|
|
|
|
{
|
|
|
|
uInt16 image;
|
|
|
|
|
|
|
|
// Scan through all of the loads to see if we find the one we're looking for
|
|
|
|
for(image = 0; image < myNumberOfLoadImages; ++image)
|
|
|
|
{
|
|
|
|
// Is this the correct load?
|
|
|
|
if(myLoadImages[(image * 8448) + 8192 + 5] == load)
|
|
|
|
{
|
|
|
|
// Copy the load's header
|
|
|
|
memcpy(myHeader, myLoadImages + (image * 8448) + 8192, 256);
|
|
|
|
|
|
|
|
// Verify the load's header
|
|
|
|
if(checksum(myHeader, 8) != 0x55)
|
|
|
|
{
|
|
|
|
cerr << "WARNING: The Supercharger header checksum is invalid...\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load all of the pages from the load
|
|
|
|
bool invalidPageChecksumSeen = false;
|
|
|
|
for(uInt32 j = 0; j < myHeader[3]; ++j)
|
|
|
|
{
|
|
|
|
uInt32 bank = myHeader[16 + j] & 0x03;
|
|
|
|
uInt32 page = (myHeader[16 + j] >> 2) & 0x07;
|
|
|
|
uInt8* src = myLoadImages + (image * 8448) + (j * 256);
|
|
|
|
uInt8 sum = checksum(src, 256) + myHeader[16 + j] + myHeader[64 + j];
|
|
|
|
|
|
|
|
if(!invalidPageChecksumSeen && (sum != 0x55))
|
|
|
|
{
|
|
|
|
cerr << "WARNING: Some Supercharger page checksums are invalid...\n";
|
|
|
|
invalidPageChecksumSeen = true;
|
|
|
|
}
|
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
// Copy page to Supercharger RAM (don't allow a copy into ROM area)
|
|
|
|
if(bank < 3)
|
|
|
|
{
|
|
|
|
memcpy(myImage + (bank * 2048) + (page * 256), src, 256);
|
|
|
|
}
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
2002-04-05 02:18:23 +00:00
|
|
|
// Copy the bank switching byte and starting address into the 2600's
|
|
|
|
// RAM for the "dummy" SC BIOS to access it
|
|
|
|
mySystem->poke(0xfe, myHeader[0]);
|
|
|
|
mySystem->poke(0xff, myHeader[1]);
|
|
|
|
mySystem->poke(0x80, myHeader[2]);
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Should probably switch to an internal ROM routine to display
|
|
|
|
// this message to the user...
|
|
|
|
cerr << "ERROR: Supercharger load is missing from ROM image...\n";
|
|
|
|
}
|
|
|
|
|
2002-05-13 19:17:32 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
void CartridgeAR::bank(uInt16 bank)
|
|
|
|
{
|
2008-03-28 23:29:14 +00:00
|
|
|
if(myBankLocked) return;
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
|
|
|
|
bankConfiguration(bank);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
int CartridgeAR::bank()
|
|
|
|
{
|
|
|
|
return myCurrentBank;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
int CartridgeAR::bankCount()
|
|
|
|
{
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool CartridgeAR::patch(uInt16 address, uInt8 value)
|
|
|
|
{
|
2009-05-25 17:51:52 +00:00
|
|
|
// TODO - add support for debugger
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
uInt8* CartridgeAR::getImage(int& size)
|
|
|
|
{
|
|
|
|
size = myNumberOfLoadImages * 8448;
|
|
|
|
return &myLoadImages[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool CartridgeAR::save(Serializer& out) const
|
2002-05-13 19:17:32 +00:00
|
|
|
{
|
2002-05-14 15:22:28 +00:00
|
|
|
string cart = name();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uInt32 i;
|
|
|
|
|
|
|
|
out.putString(cart);
|
|
|
|
|
|
|
|
// Indicates the offest within the image for the corresponding bank
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(2);
|
2002-05-14 15:22:28 +00:00
|
|
|
for(i = 0; i < 2; ++i)
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(myImageOffset[i]);
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// The 6K of RAM and 2K of ROM contained in the Supercharger
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(8192);
|
2002-05-14 15:22:28 +00:00
|
|
|
for(i = 0; i < 8192; ++i)
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
out.putByte((char)myImage[i]);
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// The 256 byte header for the current 8448 byte load
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(256);
|
2002-05-14 15:22:28 +00:00
|
|
|
for(i = 0; i < 256; ++i)
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
out.putByte((char)myHeader[i]);
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// All of the 8448 byte loads associated with the game
|
|
|
|
// Note that the size of this array is myNumberOfLoadImages * 8448
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(myNumberOfLoadImages * 8448);
|
2002-05-14 18:29:45 +00:00
|
|
|
for(i = 0; i < (uInt32) myNumberOfLoadImages * 8448; ++i)
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(myLoadImages[i]);
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Indicates how many 8448 loads there are
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
out.putByte((char)myNumberOfLoadImages);
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Indicates if the RAM is write enabled
|
|
|
|
out.putBool(myWriteEnabled);
|
|
|
|
|
|
|
|
// Indicates if the ROM's power is on or off
|
|
|
|
out.putBool(myPower);
|
|
|
|
|
|
|
|
// Indicates when the power was last turned on
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(myPowerRomCycle);
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Data hold register used for writing
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
out.putByte((char)myDataHoldRegister);
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Indicates number of distinct accesses when data hold register was set
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(myNumberOfDistinctAccesses);
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Indicates if a write is pending or not
|
|
|
|
out.putBool(myWritePending);
|
|
|
|
}
|
2007-01-14 16:17:57 +00:00
|
|
|
catch(const char* msg)
|
2002-05-14 15:22:28 +00:00
|
|
|
{
|
|
|
|
cerr << msg << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
cerr << "Unknown error in save state for " << cart << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-05-13 19:17:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool CartridgeAR::load(Deserializer& in)
|
|
|
|
{
|
2002-05-14 15:22:28 +00:00
|
|
|
string cart = name();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(in.getString() != cart)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
uInt32 i, limit;
|
|
|
|
|
|
|
|
// Indicates the offest within the image for the corresponding bank
|
2005-12-17 01:23:07 +00:00
|
|
|
limit = (uInt32) in.getInt();
|
2002-05-14 15:22:28 +00:00
|
|
|
for(i = 0; i < limit; ++i)
|
2005-12-17 01:23:07 +00:00
|
|
|
myImageOffset[i] = (uInt32) in.getInt();
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// The 6K of RAM and 2K of ROM contained in the Supercharger
|
2005-12-17 01:23:07 +00:00
|
|
|
limit = (uInt32) in.getInt();
|
2002-05-14 15:22:28 +00:00
|
|
|
for(i = 0; i < limit; ++i)
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
myImage[i] = (uInt8) in.getByte();
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// The 256 byte header for the current 8448 byte load
|
2005-12-17 01:23:07 +00:00
|
|
|
limit = (uInt32) in.getInt();
|
2002-05-14 15:22:28 +00:00
|
|
|
for(i = 0; i < limit; ++i)
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
myHeader[i] = (uInt8) in.getByte();
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// All of the 8448 byte loads associated with the game
|
|
|
|
// Note that the size of this array is myNumberOfLoadImages * 8448
|
2005-12-17 01:23:07 +00:00
|
|
|
limit = (uInt32) in.getInt();
|
2002-05-14 15:22:28 +00:00
|
|
|
for(i = 0; i < limit; ++i)
|
2005-12-17 01:23:07 +00:00
|
|
|
myLoadImages[i] = (uInt8) in.getInt();
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Indicates how many 8448 loads there are
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
myNumberOfLoadImages = (uInt8) in.getByte();
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Indicates if the RAM is write enabled
|
|
|
|
myWriteEnabled = in.getBool();
|
|
|
|
|
|
|
|
// Indicates if the ROM's power is on or off
|
|
|
|
myPower = in.getBool();
|
|
|
|
|
|
|
|
// Indicates when the power was last turned on
|
2005-12-17 01:23:07 +00:00
|
|
|
myPowerRomCycle = (Int32) in.getInt();
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Data hold register used for writing
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
myDataHoldRegister = (uInt8) in.getByte();
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Indicates number of distinct accesses when data hold register was set
|
2005-12-17 01:23:07 +00:00
|
|
|
myNumberOfDistinctAccesses = (uInt32) in.getInt();
|
2002-05-14 15:22:28 +00:00
|
|
|
|
|
|
|
// Indicates if a write is pending or not
|
|
|
|
myWritePending = in.getBool();
|
|
|
|
}
|
2007-01-14 16:17:57 +00:00
|
|
|
catch(const char* msg)
|
2002-05-14 15:22:28 +00:00
|
|
|
{
|
|
|
|
cerr << msg << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
cerr << "Unknown error in load state for " << cart << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-05-13 19:17:32 +00:00
|
|
|
return true;
|
|
|
|
}
|